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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
2e216822
Commit
2e216822
authored
Jan 01, 2015
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow coercion of C literal lists to stl types.
parent
9d9657fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-0
tests/run/cpp_stl_conversion.pyx
tests/run/cpp_stl_conversion.pyx
+8
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
2e216822
...
...
@@ -6687,6 +6687,9 @@ class ListNode(SequenceNode):
if
isinstance
(
arg
,
CoerceToPyTypeNode
):
arg
=
arg
.
arg
self
.
args
[
i
]
=
arg
.
coerce_to
(
base_type
,
env
)
elif
dst_type
.
is_cpp_class
:
# TODO(robertwb): Avoid object conversion for vector/list/set.
return
TypecastNode
(
self
.
pos
,
operand
=
self
,
type
=
PyrexTypes
.
py_object_type
).
coerce_to
(
dst_type
,
env
)
elif
self
.
mult_factor
:
error
(
self
.
pos
,
"Cannot coerce multiplied list to '%s'"
%
dst_type
)
elif
dst_type
.
is_struct
:
...
...
tests/run/cpp_stl_conversion.pyx
View file @
2e216822
...
...
@@ -116,6 +116,14 @@ def test_double_vector(o):
cdef
vector
[
double
]
v
=
o
return
v
def
test_repeated_double_vector
(
a
,
b
,
int
n
):
"""
>>> test_repeated_double_vector(1, 1.5, 3)
[1.0, 1.5, 1.0, 1.5, 1.0, 1.5]
"""
cdef
vector
[
double
]
v
=
[
a
,
b
]
*
n
return
v
ctypedef
int
my_int
def
test_typedef_vector
(
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