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
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
Hide 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,11 +6767,18 @@ class ListNode(SequenceNode):
else
:
offset
=
''
for
i
,
arg
in
enumerate
(
self
.
args
):
code
.
putln
(
"%s[%s%s] = %s;"
%
(
self
.
result
(),
i
,
offset
,
arg
.
result
()))
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;"
%
(
self
.
result
(),
i
,
offset
,
arg
.
result
()))
if
self
.
mult_factor
:
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
...
...
tests/run/carray_coercion.pyx
View file @
2b335420
...
...
@@ -76,6 +76,15 @@ def assign_int_array_array():
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
():
"""
>>> build_from_list_of_arrays()
...
...
@@ -87,6 +96,17 @@ def build_from_list_of_arrays():
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
:
int
x
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