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
bbf54287
Commit
bbf54287
authored
Dec 25, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup, comments, less code for special case of no positional arguments
parent
33fa345d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+12
-11
No files found.
Cython/Compiler/Nodes.py
View file @
bbf54287
...
@@ -2118,15 +2118,9 @@ class DefNode(FuncDefNode):
...
@@ -2118,15 +2118,9 @@ class DefNode(FuncDefNode):
code
.
put_goto
(
argtuple_error_label
)
code
.
put_goto
(
argtuple_error_label
)
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
# now fill up the required arguments with values from the kw dict
# parse all keyword arguments, check for duplicates, etc.
last_required_arg
=
-
1
for
i
,
arg
in
enumerate
(
all_args
):
if
not
arg
.
default
:
last_required_arg
=
i
if
not
self
.
num_required_kw_args
:
if
not
self
.
num_required_kw_args
:
code
.
putln
(
'if (PyDict_Size(%s) > 0) {'
%
Naming
.
kwds_cname
)
code
.
putln
(
'if (PyDict_Size(%s) > 0) {'
%
Naming
.
kwds_cname
)
# non-positional kw args left in dict: default args, **kwargs or error
if
self
.
star_arg
:
if
self
.
star_arg
:
code
.
putln
(
"const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(%s) < %d) ? PyTuple_GET_SIZE(%s) : %d;"
%
(
code
.
putln
(
"const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(%s) < %d) ? PyTuple_GET_SIZE(%s) : %d;"
%
(
Naming
.
args_cname
,
max_positional_args
,
Naming
.
args_cname
,
max_positional_args
,
...
@@ -2146,10 +2140,16 @@ class DefNode(FuncDefNode):
...
@@ -2146,10 +2140,16 @@ class DefNode(FuncDefNode):
if
not
self
.
num_required_kw_args
:
if
not
self
.
num_required_kw_args
:
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
if
last_required_arg
>=
0
:
# make sure we found all required args
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_cname
)
if
self
.
num_required_args
:
last_required_arg
=
-
1
for
i
,
arg
in
enumerate
(
all_args
):
if
not
arg
.
default
:
last_required_arg
=
i
if
max_positional_args
:
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_cname
)
for
i
,
arg
in
enumerate
(
all_args
[:
last_required_arg
+
1
]):
for
i
,
arg
in
enumerate
(
all_args
[:
last_required_arg
+
1
]):
if
i
<=
max_positional_args
:
if
max_positional_args
and
i
<=
max_positional_args
:
if
self
.
star_arg
and
i
==
max_positional_args
:
if
self
.
star_arg
and
i
==
max_positional_args
:
code
.
putln
(
'default:'
)
code
.
putln
(
'default:'
)
else
:
else
:
...
@@ -2167,7 +2167,8 @@ class DefNode(FuncDefNode):
...
@@ -2167,7 +2167,8 @@ class DefNode(FuncDefNode):
self
.
name
.
utf8encode
(),
arg
.
name_entry
.
pystring_cname
))
self
.
name
.
utf8encode
(),
arg
.
name_entry
.
pystring_cname
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
if
max_positional_args
:
code
.
putln
(
'}'
)
# convert arg values to their final type and assign them
# convert arg values to their final type and assign them
for
i
,
arg
in
enumerate
(
all_args
):
for
i
,
arg
in
enumerate
(
all_args
):
...
...
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