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
af201548
Commit
af201548
authored
Jul 10, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow closures in cdef functions.
parent
0369269d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+11
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-6
No files found.
Cython/Compiler/Nodes.py
View file @
af201548
...
@@ -2388,8 +2388,8 @@ class CFuncDefNode(FuncDefNode):
...
@@ -2388,8 +2388,8 @@ class CFuncDefNode(FuncDefNode):
def
generate_argument_parsing_code
(
self
,
env
,
code
):
def
generate_argument_parsing_code
(
self
,
env
,
code
):
i
=
0
i
=
0
used
=
0
used
=
0
scope
=
self
.
local_scope
if
self
.
type
.
optional_arg_count
:
if
self
.
type
.
optional_arg_count
:
scope
=
self
.
local_scope
code
.
putln
(
'if (%s) {'
%
Naming
.
optional_args_cname
)
code
.
putln
(
'if (%s) {'
%
Naming
.
optional_args_cname
)
for
arg
in
self
.
args
:
for
arg
in
self
.
args
:
if
arg
.
default
:
if
arg
.
default
:
...
@@ -2410,6 +2410,16 @@ class CFuncDefNode(FuncDefNode):
...
@@ -2410,6 +2410,16 @@ class CFuncDefNode(FuncDefNode):
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
# Move arguments into closure if required
def
put_into_closure
(
entry
):
if
entry
.
in_closure
and
not
arg
.
default
:
code
.
putln
(
'%s = %s;'
%
(
entry
.
cname
,
entry
.
original_cname
))
code
.
put_var_incref
(
entry
)
code
.
put_var_giveref
(
entry
)
for
arg
in
self
.
args
:
put_into_closure
(
scope
.
lookup_here
(
arg
.
name
))
def
generate_argument_conversion_code
(
self
,
code
):
def
generate_argument_conversion_code
(
self
,
code
):
pass
pass
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
af201548
...
@@ -2261,8 +2261,8 @@ class MarkClosureVisitor(CythonTransform):
...
@@ -2261,8 +2261,8 @@ class MarkClosureVisitor(CythonTransform):
def
visit_CFuncDefNode
(
self
,
node
):
def
visit_CFuncDefNode
(
self
,
node
):
self
.
visit_FuncDefNode
(
node
)
self
.
visit_FuncDefNode
(
node
)
if
node
.
needs_closure
:
if
node
.
needs_closure
and
node
.
overridable
:
error
(
node
.
pos
,
"closures inside cdef functions not yet supported"
)
error
(
node
.
pos
,
"closures inside c
p
def functions not yet supported"
)
return
node
return
node
def
visit_LambdaNode
(
self
,
node
):
def
visit_LambdaNode
(
self
,
node
):
...
@@ -2400,10 +2400,6 @@ class CreateClosureClasses(CythonTransform):
...
@@ -2400,10 +2400,6 @@ class CreateClosureClasses(CythonTransform):
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
return
node
return
node
def
visit_CFuncDefNode
(
self
,
node
):
self
.
visitchildren
(
node
)
return
node
class
GilCheck
(
VisitorTransform
):
class
GilCheck
(
VisitorTransform
):
"""
"""
...
...
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