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
a5c394cd
Commit
a5c394cd
authored
Jul 13, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle @cname laziness.
parent
191b9231
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-1
Cython/Utils.py
Cython/Utils.py
+13
-0
No files found.
Cython/Compiler/Nodes.py
View file @
a5c394cd
...
...
@@ -27,6 +27,7 @@ from .Code import UtilityCode
from
.StringEncoding
import
EncodedString
,
escape_byte_string
,
split_string_literal
from
.
import
Options
from
.
import
DebugFlags
from
Cython.Utils
import
LazyStr
absolute_path_length
=
0
...
...
@@ -2307,7 +2308,9 @@ class CFuncDefNode(FuncDefNode):
if
omit_optional_args
:
args
=
args
[:
len
(
args
)
-
self
.
type
.
optional_arg_count
]
arg_names
=
[
arg
.
name
for
arg
in
args
]
cfunc
=
ExprNodes
.
PythonCapiFunctionNode
(
self
.
pos
,
self
.
entry
.
name
,
self
.
entry
.
func_cname
,
self
.
type
)
# The @cname decorator may mutate this later.
func_cname
=
LazyStr
(
lambda
:
self
.
entry
.
func_cname
)
cfunc
=
ExprNodes
.
PythonCapiFunctionNode
(
self
.
pos
,
self
.
entry
.
name
,
func_cname
,
self
.
type
)
cfunc
.
entry
=
self
.
entry
skip_dispatch
=
not
is_module_scope
or
Options
.
lookup_module_cpdef
c_call
=
ExprNodes
.
SimpleCallNode
(
self
.
pos
,
function
=
cfunc
,
args
=
[
ExprNodes
.
NameNode
(
self
.
pos
,
name
=
n
)
for
n
in
arg_names
],
wrapper_call
=
skip_dispatch
)
...
...
Cython/Utils.py
View file @
a5c394cd
...
...
@@ -399,3 +399,16 @@ def print_bytes(s, end=b'\n', file=sys.stdout, flush=True):
out
.
write
(
end
)
if
flush
:
out
.
flush
()
class
LazyStr
:
def
__init__
(
self
,
callback
):
self
.
callback
=
callback
def
__str__
(
self
):
return
self
.
callback
()
def
__repr__
(
self
):
return
self
.
callback
()
def
__add__
(
self
,
right
):
return
self
.
callback
()
+
right
def
__radd__
(
self
,
left
):
return
left
+
self
.
callback
()
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