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
Kirill Smelkov
cython
Commits
e00ee0a2
Commit
e00ee0a2
authored
Jun 29, 2012
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow nesting.
parent
1aa49b25
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
10 deletions
+31
-10
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+6
-3
Cython/Includes/libcpp/string.pxd
Cython/Includes/libcpp/string.pxd
+3
-0
Cython/Utility/CppConvert.pyx
Cython/Utility/CppConvert.pyx
+22
-7
No files found.
Cython/Compiler/PyrexTypes.py
View file @
e00ee0a2
...
...
@@ -30,7 +30,6 @@ class BaseType(object):
all
.
append
(
c
)
else
:
all
.
append
(
'_%x_'
%
ord
(
c
))
print
self
.
declaration_code
(
""
),
''
.
join
(
all
)
return
''
.
join
(
all
)
def
base_declaration_code
(
self
,
base_code
,
entity_code
):
...
...
@@ -3026,9 +3025,12 @@ class CppClassType(CType):
if
not
T
.
create_from_py_utility_code
(
env
):
return
False
tags
.
append
(
T
.
specialization_name
())
context
[
"T%s"
%
ix
]
=
T
.
declaration_code
(
""
,
for_display
=
True
)
# TODO: exception values
context
[
"T%s"
%
ix
]
=
T
.
declaration_code
(
""
)
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
))
...
...
@@ -3045,7 +3047,8 @@ class CppClassType(CType):
if
not
T
.
create_to_py_utility_code
(
env
):
return
False
tags
.
append
(
T
.
specialization_name
())
context
[
"T%s"
%
ix
]
=
T
.
declaration_code
(
""
,
for_display
=
True
)
context
[
"T%s"
%
ix
]
=
T
.
declaration_code
(
""
)
context
[
"T%s_to_py"
%
ix
]
=
T
.
to_py_function
cls
=
self
.
cname
[
5
:]
cname
=
"__pyx_convert_%s_to_py_%s"
%
(
cls
,
"____"
.
join
(
tags
))
context
[
'cname'
]
=
cname
...
...
Cython/Includes/libcpp/string.pxd
View file @
e00ee0a2
...
...
@@ -94,6 +94,9 @@ cdef extern from "<string>" namespace "std":
#string& operator= (char*)
#string& operator= (char)
string
operator
+
(
string
&
rhs
)
nogil
string
operator
+
(
char
*
rhs
)
nogil
bint
operator
==
(
string
&
)
nogil
bint
operator
==
(
char
*
)
nogil
...
...
Cython/Utility/CppConvert.pyx
View file @
e00ee0a2
...
...
@@ -152,6 +152,14 @@ cdef object {{cname}}(pair[{{T0}},{{T1}}]& p):
#################### map.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
&
)
...
...
@@ -165,11 +173,11 @@ cdef extern from *:
@
cname
(
"{{cname}}"
)
cdef
map
[
{{
T0
}},{{
T1
}}
]
{{
cname
}}(
object
o
)
except
*
:
cdef
map
[
X
,
Y
]
{{
cname
}}(
object
o
)
except
*
:
cdef
dict
d
=
o
cdef
map
[
{{
T0
}},{{
T1
}}
]
m
cdef
map
[
X
,
Y
]
m
for
key
,
value
in
d
.
iteritems
():
m
.
insert
(
pair
[
{{
T0
}},{{
T1
}}](
<
{{
T0
}}
>
key
,
<
{{
T1
}}
>
value
))
m
.
insert
(
pair
[
X
,
Y
](
X_from_py
(
key
),
Y_from_py
(
value
)
))
return
m
...
...
@@ -179,6 +187,13 @@ cdef map[{{T0}},{{T1}}] {{cname}}(object o) except *:
cimport
cython
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
map
"std::map"
[
T
,
U
]:
...
...
@@ -193,12 +208,12 @@ cdef extern from *:
iterator
end
()
@
cname
(
"{{cname}}"
)
cdef
object
{{
cname
}}(
map
[
{{
T0
}},{{
T1
}}
]
s
):
cdef
object
{{
cname
}}(
map
[
X
,
Y
]
s
):
o
=
{}
cdef
map
[
{{
T0
}},{{
T1
}}
].
value_type
*
key_value
cdef
map
[
{{
T0
}},{{
T1
}}
].
iterator
iter
=
s
.
begin
()
cdef
map
[
X
,
Y
].
value_type
*
key_value
cdef
map
[
X
,
Y
].
iterator
iter
=
s
.
begin
()
while
iter
!=
s
.
end
():
key_value
=
&
cython
.
operator
.
dereference
(
iter
)
o
[
key_value
.
first
]
=
key_value
.
second
o
[
X_to_py
(
key_value
.
first
)]
=
Y_to_py
(
key_value
.
second
)
cython
.
operator
.
preincrement
(
iter
)
return
o
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