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
37c57643
Commit
37c57643
authored
Feb 25, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix default arguments for C89 (based on patch by Lisandro)
parent
35efaff7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+8
-6
No files found.
Cython/Compiler/Nodes.py
View file @
37c57643
...
...
@@ -2186,18 +2186,20 @@ class DefNode(FuncDefNode):
max_args
=
len
(
all_args
)
default_args
=
[]
for
arg
in
all_args
:
for
i
,
arg
in
enumerate
(
all_args
)
:
if
arg
.
default
and
arg
.
type
.
is_pyobject
:
default_value
=
arg
.
default_result_code
if
arg
.
type
is
not
PyrexTypes
.
py_object_type
:
default_value
=
"(PyObject*)"
+
default_value
default_args
.
append
(
default_value
)
else
:
default_args
.
append
(
'0'
)
code
.
putln
(
"PyObject* values[%d] = {%s};"
%
(
max_args
,
', '
.
join
(
default_args
)))
default_args
.
append
((
i
,
default_value
))
code
.
putln
(
"Py_ssize_t kw_args = PyDict_Size(%s);"
%
Naming
.
kwds_cname
)
# it looks funny to separate the init-to-0 from setting the
# default value, but C89 needs this
code
.
putln
(
"PyObject* values[%d] = {%s};"
%
(
max_args
,
','
.
join
([
'0'
]
*
max_args
)))
for
i
,
default_value
in
default_args
:
code
.
putln
(
'values[%d] = %s;'
%
(
i
,
default_value
))
# parse the tuple and check that it's not too long
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_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