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
2b335420
Commit
2b335420
authored
Feb 07, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix C array assignments from lists of C arrays
parent
60490a4c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
+32
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+12
-5
tests/run/carray_coercion.pyx
tests/run/carray_coercion.pyx
+20
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
2b335420
...
@@ -6767,6 +6767,13 @@ class ListNode(SequenceNode):
...
@@ -6767,6 +6767,13 @@ class ListNode(SequenceNode):
else
:
else
:
offset
=
''
offset
=
''
for
i
,
arg
in
enumerate
(
self
.
args
):
for
i
,
arg
in
enumerate
(
self
.
args
):
if
arg
.
type
.
is_array
:
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"IncludeStringH"
,
"StringTools.c"
))
code
.
putln
(
"memcpy(&(%s[%s%s]), %s, sizeof(%s[0]));"
%
(
self
.
result
(),
i
,
offset
,
arg
.
result
(),
self
.
result
()
))
else
:
code
.
putln
(
"%s[%s%s] = %s;"
%
(
code
.
putln
(
"%s[%s%s] = %s;"
%
(
self
.
result
(),
self
.
result
(),
i
,
i
,
...
...
tests/run/carray_coercion.pyx
View file @
2b335420
...
@@ -76,6 +76,15 @@ def assign_int_array_array():
...
@@ -76,6 +76,15 @@ def assign_int_array_array():
return
v
return
v
def
assign_int_array_array_from_tuples
():
"""
>>> assign_int_array_array_from_tuples()
[[11, 12, 13], [21, 22, 23]]
"""
cdef
int
[
2
][
3
]
v
=
([
11
,
12
,
13
],
[
21
,
22
,
23
])
return
v
def
build_from_list_of_arrays
():
def
build_from_list_of_arrays
():
"""
"""
>>> build_from_list_of_arrays()
>>> build_from_list_of_arrays()
...
@@ -87,6 +96,17 @@ def build_from_list_of_arrays():
...
@@ -87,6 +96,17 @@ def build_from_list_of_arrays():
return
v
return
v
def
build_from_tuple_of_arrays
():
"""
>>> build_from_tuple_of_arrays()
[[11, 12, 13], [21, 22, 23]]
"""
cdef
int
[
3
]
x
=
[
11
,
12
,
13
]
cdef
int
[
3
]
y
=
[
21
,
22
,
23
]
cdef
int
[
2
][
3
]
v
=
(
x
,
y
)
return
v
ctypedef
struct
MyStructType
:
ctypedef
struct
MyStructType
:
int
x
int
x
double
y
double
y
...
...
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