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
Gwenaël Samain
cython
Commits
2adf9051
Commit
2adf9051
authored
Jun 29, 2012
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nesting for all stl containers.
parent
e00ee0a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
20 deletions
+65
-20
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+0
-1
Cython/Utility/CppConvert.pyx
Cython/Utility/CppConvert.pyx
+65
-19
No files found.
Cython/Compiler/PyrexTypes.py
View file @
2adf9051
...
...
@@ -3030,7 +3030,6 @@ class CppClassType(CType):
context
[
"T%s_from_py"
%
ix
]
=
T
.
from_py_function
cls
=
self
.
cname
[
5
:]
cname
=
"__pyx_convert_%s_from_py_%s"
%
(
cls
,
"____"
.
join
(
tags
))
print
cls
,
"->"
,
cname
context
[
'cname'
]
=
cname
from
UtilityCode
import
CythonUtilityCode
env
.
use_utility_code
(
CythonUtilityCode
.
load
(
cls
+
".from_py"
,
"CppConvert.pyx"
,
context
=
context
))
...
...
Cython/Utility/CppConvert.pyx
View file @
2adf9051
...
...
@@ -28,32 +28,47 @@ cdef object {{cname}}(string& s):
#################### vector.from_py ####################
cdef
extern
from
*
:
ctypedef
struct
X
"{{T0}}"
:
pass
cdef
X
X_from_py
"{{T0_from_py}}"
(
object
)
except
*
cdef
extern
from
*
:
cdef
cppclass
vector
"std::vector"
[
T
]:
void
push_back
(
T
&
)
@
cname
(
"{{cname}}"
)
cdef
vector
[
{{
T0
}}
]
{{
cname
}}(
object
o
)
except
*
:
cdef
vector
[
{{
T0
}}
]
v
cdef
vector
[
X
]
{{
cname
}}(
object
o
)
except
*
:
cdef
vector
[
X
]
v
for
item
in
o
:
v
.
push_back
(
item
)
v
.
push_back
(
X_from_py
(
item
)
)
return
v
#################### vector.to_py ####################
cdef
extern
from
*
:
ctypedef
struct
X
"{{T0}}"
:
pass
cdef
object
X_to_py
"{{T0_to_py}}"
(
X
)
cdef
extern
from
*
:
cdef
cppclass
vector
"const std::vector"
[
T
]:
size_t
size
()
T
&
operator
[](
size_t
)
@
cname
(
"{{cname}}"
)
cdef
object
{{
cname
}}(
vector
[
{{
T0
}}
]
&
v
):
return
[
v
[
i
]
for
i
in
range
(
v
.
size
())]
cdef
object
{{
cname
}}(
vector
[
X
]
&
v
):
return
[
X_to_py
(
v
[
i
])
for
i
in
range
(
v
.
size
())]
#################### list.from_py ####################
cdef
extern
from
*
:
ctypedef
struct
X
"{{T0}}"
:
pass
cdef
X
X_from_py
"{{T0_from_py}}"
(
object
)
except
*
cdef
extern
from
*
:
cdef
cppclass
cpp_list
"std::list"
[
T
]:
void
push_back
(
T
&
)
...
...
@@ -62,12 +77,17 @@ cdef extern from *:
cdef
cpp_list
[{{
T0
}}]
{{
cname
}}(
object
o
)
except
*
:
cdef
cpp_list
[{{
T0
}}]
l
for
item
in
o
:
l
.
push_back
(
item
)
l
.
push_back
(
X_from_py
(
item
)
)
return
l
#################### list.to_py ####################
cdef
extern
from
*
:
ctypedef
struct
X
"{{T0}}"
:
pass
cdef
object
X_to_py
"{{T0_to_py}}"
(
X
)
cdef
extern
from
*
:
cdef
cppclass
cpp_list
"std::list"
[
T
]:
cppclass
const_iterator
:
...
...
@@ -79,26 +99,31 @@ cdef extern from *:
cdef
cppclass
const_cpp_list
"const std::list"
[
T
]
(
cpp_list
)
@
cname
(
"{{cname}}"
)
cdef
object
{{
cname
}}(
const_cpp_list
[
{{
T0
}}
]
&
v
):
cdef
object
{{
cname
}}(
const_cpp_list
[
X
]
&
v
):
o
=
[]
cdef
cpp_list
[
{{
T0
}}
].
const_iterator
iter
=
s
.
begin
()
cdef
cpp_list
[
X
].
const_iterator
iter
=
s
.
begin
()
while
iter
!=
s
.
end
():
o
.
append
(
cython
.
operator
.
dereference
(
iter
))
o
.
append
(
X_to_py
(
cython
.
operator
.
dereference
(
iter
)
))
cython
.
operator
.
preincrement
(
iter
)
return
o
#################### set.from_py ####################
cdef
extern
from
*
:
ctypedef
struct
X
"{{T0}}"
:
pass
cdef
X
X_from_py
"{{T0_from_py}}"
(
object
)
except
*
cdef
extern
from
*
:
cdef
cppclass
set
"std::set"
[
T
]:
void
insert
(
T
&
)
@
cname
(
"{{cname}}"
)
cdef
set
[
{{
T0
}}
]
{{
cname
}}(
object
o
)
except
*
:
cdef
set
[
{{
T0
}}
]
s
cdef
set
[
X
]
{{
cname
}}(
object
o
)
except
*
:
cdef
set
[
X
]
s
for
item
in
o
:
s
.
insert
(
item
)
s
.
insert
(
X_from_py
(
item
)
)
return
s
...
...
@@ -106,6 +131,11 @@ cdef set[{{T0}}] {{cname}}(object o) except *:
cimport
cython
cdef
extern
from
*
:
ctypedef
struct
X
"{{T0}}"
:
pass
cdef
object
X_to_py
"{{T0_to_py}}"
(
X
)
cdef
extern
from
*
:
cdef
cppclass
cpp_set
"std::set"
[
T
]:
cppclass
const_iterator
:
...
...
@@ -118,36 +148,52 @@ cdef extern from *:
pass
@
cname
(
"{{cname}}"
)
cdef
object
{{
cname
}}(
const_cpp_set
[
{{
T0
}}
]
&
s
):
cdef
object
{{
cname
}}(
const_cpp_set
[
X
]
&
s
):
o
=
set
()
cdef
cpp_set
[
{{
T0
}}
].
const_iterator
iter
=
s
.
begin
()
cdef
cpp_set
[
X
].
const_iterator
iter
=
s
.
begin
()
while
iter
!=
s
.
end
():
o
.
add
(
cython
.
operator
.
dereference
(
iter
))
o
.
add
(
X_to_py
(
cython
.
operator
.
dereference
(
iter
)
))
cython
.
operator
.
preincrement
(
iter
)
return
o
#################### pair.from_py ####################
cdef
extern
from
*
:
ctypedef
struct
X
"{{T0}}"
:
pass
ctypedef
struct
Y
"{{T1}}"
:
pass
cdef
X
X_from_py
"{{T0_from_py}}"
(
object
)
except
*
cdef
Y
Y_from_py
"{{T1_from_py}}"
(
object
)
except
*
cdef
extern
from
*
:
cdef
cppclass
pair
"std::pair"
[
T
,
U
]:
pair
(
T
&
,
U
&
)
@
cname
(
"{{cname}}"
)
cdef
pair
[
{{
T0
}},{{
T1
}}
]
{{
cname
}}(
object
o
)
except
*
:
cdef
pair
[
X
,
Y
]
{{
cname
}}(
object
o
)
except
*
:
x
,
y
=
o
return
pair
[
{{
T0
}},{{
T1
}}](
x
,
y
)
return
pair
[
X
,
Y
](
X_from_py
(
x
),
Y_from_py
(
y
)
)
#################### pair.to_py ####################
cdef
extern
from
*
:
ctypedef
struct
X
"{{T0}}"
:
pass
ctypedef
struct
Y
"{{T1}}"
:
pass
cdef
object
X_to_py
"{{T0_to_py}}"
(
X
)
cdef
object
Y_to_py
"{{T1_to_py}}"
(
Y
)
cdef
extern
from
*
:
cdef
cppclass
pair
"const std::pair"
[
T
,
U
]:
T
first
U
second
@
cname
(
"{{cname}}"
)
cdef
object
{{
cname
}}(
pair
[
{{
T0
}},{{
T1
}}
]
&
p
):
return
p
.
first
,
p
.
second
cdef
object
{{
cname
}}(
pair
[
X
,
Y
]
&
p
):
return
X_to_py
(
p
.
first
),
Y_to_py
(
p
.
second
)
#################### map.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