Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
ea071f25
Commit
ea071f25
authored
Oct 31, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factor out redundancy in std::string -> Python object helper code
parent
76254d22
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
23 deletions
+7
-23
Cython/Utility/CppConvert.pyx
Cython/Utility/CppConvert.pyx
+7
-23
No files found.
Cython/Utility/CppConvert.pyx
View file @
ea071f25
...
@@ -24,31 +24,15 @@ cdef extern from *:
...
@@ -24,31 +24,15 @@ cdef extern from *:
cdef
cppclass
string
"{{type}}"
:
cdef
cppclass
string
"{{type}}"
:
char
*
data
()
char
*
data
()
size_t
size
()
size_t
size
()
cdef
object
__Pyx_PyObject_FromStringAndSize
(
char
*
,
size_t
)
cdef
object
__Pyx_PyBytes_FromStringAndSize
(
char
*
,
size_t
)
cdef
object
__Pyx_PyByteArray_FromStringAndSize
(
char
*
,
size_t
)
cdef
object
__Pyx_PyStr_FromStringAndSize
(
char
*
,
size_t
)
cdef
object
__Pyx_PyUnicode_FromStringAndSize
(
char
*
,
size_t
)
@
cname
(
"{{cname}}"
)
{{
for
py_type
in
[
'PyObject'
,
'PyUnicode'
,
'PyStr'
,
'PyBytes'
,
'PyByteArray'
]}}
cdef
inline
object
{{
cname
}}(
const
string
&
s
):
cdef
extern
from
*
:
return
__Pyx_PyObject_FromStringAndSize
(
s
.
data
(),
s
.
size
())
cdef
object
__Pyx_
{{
py_type
}}
_FromStringAndSize
(
char
*
,
size_t
)
@
cname
(
"{{cname.replace("
PyObject
", "
PyUnicode
", 1)}}"
)
cdef
inline
object
{{
cname
.
replace
(
"PyObject"
,
"PyUnicode"
,
1
)}}(
const
string
&
s
):
return
__Pyx_PyUnicode_FromStringAndSize
(
s
.
data
(),
s
.
size
())
@
cname
(
"{{cname.replace("
PyObject
", "
PyStr
", 1)}}"
)
cdef
inline
object
{{
cname
.
replace
(
"PyObject"
,
"PyStr"
,
1
)}}(
const
string
&
s
):
return
__Pyx_PyStr_FromStringAndSize
(
s
.
data
(),
s
.
size
())
@
cname
(
"{{cname.replace("
PyObject
", "
PyBytes
", 1)}}"
)
cdef
inline
object
{{
cname
.
replace
(
"PyObject"
,
"PyBytes"
,
1
)}}(
const
string
&
s
):
return
__Pyx_PyBytes_FromStringAndSize
(
s
.
data
(),
s
.
size
())
@
cname
(
"{{cname.replace("
PyObject
", "
PyByteArray
", 1)}}"
)
@
cname
(
"{{cname.replace("
PyObject
", py_type, 1)}}"
)
cdef
inline
object
{{
cname
.
replace
(
"PyObject"
,
"PyByteArray"
,
1
)}}(
const
string
&
s
):
cdef
inline
object
{{
cname
.
replace
(
"PyObject"
,
py_type
,
1
)}}(
const
string
&
s
):
return
__Pyx_PyByteArray_FromStringAndSize
(
s
.
data
(),
s
.
size
())
return
__Pyx_
{{
py_type
}}
_FromStringAndSize
(
s
.
data
(),
s
.
size
())
{{
endfor
}}
#################### vector.from_py ####################
#################### vector.from_py ####################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment