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
5361eb62
Commit
5361eb62
authored
Oct 07, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lists as literal structs
parent
fc97fc88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+17
-2
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+3
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
5361eb62
...
...
@@ -2680,6 +2680,15 @@ class ListNode(SequenceNode):
for
i
in
range
(
len
(
self
.
args
)):
arg
=
self
.
args
[
i
]
self
.
args
[
i
]
=
arg
.
coerce_to
(
base_type
,
env
)
elif
dst_type
.
is_struct
:
if
len
(
self
.
args
)
>
len
(
dst_type
.
scope
.
var_entries
):
error
(
self
.
pos
,
"Too may members for '%s'"
%
dst_type
)
else
:
if
len
(
self
.
args
)
<
len
(
dst_type
.
scope
.
var_entries
):
warning
(
self
.
pos
,
"Too few members for '%s'"
%
dst_type
,
1
)
for
i
,
(
arg
,
member
)
in
enumerate
(
zip
(
self
.
args
,
dst_type
.
scope
.
var_entries
)):
self
.
args
[
i
]
=
arg
.
coerce_to
(
member
.
type
,
env
)
self
.
type
=
dst_type
else
:
self
.
type
=
error_type
error
(
self
.
pos
,
"Cannot coerce list to type '%s'"
%
dst_type
)
...
...
@@ -2703,13 +2712,19 @@ class ListNode(SequenceNode):
(
self
.
result
(),
i
,
arg
.
py_result
()))
el
se
:
el
if
self
.
type
.
is_ptr
:
code
.
putln
(
"%s = (%s[]) {"
%
(
self
.
result
(),
self
.
type
.
base_type
))
for
i
,
arg
in
enumerate
(
self
.
args
)
:
for
arg
in
self
.
args
:
code
.
put
(
arg
.
result
())
code
.
put
(
", "
)
code
.
putln
();
code
.
putln
(
"};"
)
else
:
for
arg
,
member
in
zip
(
self
.
args
,
self
.
type
.
scope
.
var_entries
):
code
.
putln
(
"%s.%s = %s;"
%
(
self
.
result
(),
member
.
cname
,
arg
.
result
()))
def
generate_subexpr_disposal_code
(
self
,
code
):
# We call generate_post_assignment_code here instead
...
...
Cython/Compiler/PyrexTypes.py
View file @
5361eb62
...
...
@@ -37,6 +37,7 @@ class PyrexType(BaseType):
# is_null_ptr boolean Is the type of NULL
# is_cfunction boolean Is a C function type
# is_struct_or_union boolean Is a C struct or union type
# is_struct boolean Is a C struct type
# is_enum boolean Is a C enum type
# is_typedef boolean Is a typedef type
# is_string boolean Is a C char * type
...
...
@@ -88,6 +89,7 @@ class PyrexType(BaseType):
is_null_ptr
=
0
is_cfunction
=
0
is_struct_or_union
=
0
is_struct
=
0
is_enum
=
0
is_typedef
=
0
is_string
=
0
...
...
@@ -929,6 +931,7 @@ class CStructOrUnionType(CType):
self
.
kind
=
kind
self
.
scope
=
scope
self
.
typedef_flag
=
typedef_flag
self
.
is_struct
=
kind
==
'struct'
def
__repr__
(
self
):
return
"<CStructOrUnionType %s %s%s>"
%
(
self
.
name
,
self
.
cname
,
...
...
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