FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cefpython/cefpython/stream.pyx at v31.2 · pythonthings/cefpython · GitHub
pythonthings
cefpython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cefpython
/
cefpython
/
stream.pyx
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (30 loc) · 1.38 KB
Breadcrumbs
cefpython
/
cefpython
/
stream.pyx
Copy path
File metadata and controls
35 lines (30 loc) · 1.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
Copyright (c) 2012-2014 The CEF Python authors. All rights reserved.
#
License: New BSD License.
#
Website: http://code.google.com/p/cefpython/
cdef
class
PyStreamReader:
cdef CefRefPtr[CefStreamReader] cefStreamReader
cdef cpp_bool HasCefStreamReader(
self
)
except
*
:
if
<
void
*
>
self
.cefStreamReader !
=
NULL
and
self
.cefStreamReader.get():
return
True
return
False
cdef CefRefPtr[CefStreamReader] GetCefStreamReader(
self
)
except
*
:
if
self
.HasCefStreamReader():
return
self
.cefStreamReader
return
<
CefRefPtr[CefStreamReader]
>
NULL
cpdef py_void SetFile(
self
, py_string
file
):
if
os.path.exists(
file
):
self
.cefStreamReader
=
cef_stream_static.CreateForFile(
PyToCefStringValue(
file
))
else
:
raise
Exception
(
"
File does not exist:
%s
"
%
file
)
cpdef py_void SetData(
self
, py_string data):
cdef cpp_string cppString
=
data
#
CreateForData() requires "void* data", we can't just pass
#
cppString.c_str() as it is const, we need to copy all data.
cdef
void
*
voidData
cdef
int
dataLength
=
cppString.length()
voidData
=
<
void
*
>
malloc(dataLength)
memcpy(voidData, cppString.c_str(), dataLength)
self
.cefStreamReader
=
cef_stream_static.CreateForData(
voidData, dataLength)
free(voidData)
Back
|
FazBrowse Home
|
New Git URL