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
a5d5f19e
Commit
a5d5f19e
authored
Apr 27, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pure mode: propagate @returns() declaration for @ccall functions
parent
9b40a7d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+1
-1
tests/run/pure_py.py
tests/run/pure_py.py
+26
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
a5d5f19e
...
...
@@ -1897,7 +1897,7 @@ class AdjustDefByDirectives(CythonTransform, SkipDeclarations):
def
visit_DefNode
(
self
,
node
):
if
'ccall'
in
self
.
directives
:
node
=
node
.
as_cfunction
(
overridable
=
True
)
node
=
node
.
as_cfunction
(
overridable
=
True
,
returns
=
self
.
directives
.
get
(
'returns'
)
)
return
self
.
visit
(
node
)
if
'cfunc'
in
self
.
directives
:
if
self
.
in_py_class
:
...
...
tests/run/pure_py.py
View file @
a5d5f19e
import
cython
is_compiled
=
cython
.
compiled
NULL
=
5
_NULL
=
NULL
...
...
@@ -170,3 +172,27 @@ def test_declare_c_types(n):
#z01 = cython.declare(cython.floatcomplex, n+1j)
#z02 = cython.declare(cython.doublecomplex, n+1j)
#z03 = cython.declare(cython.longdoublecomplex, n+1j)
@
cython
.
ccall
@
cython
.
returns
(
cython
.
double
)
def
c_call
(
x
):
"""
Test that a declared return type is honoured when compiled.
>>> result, return_type = call_ccall(1)
>>> (not is_compiled and 'double') or return_type
'double'
>>> (is_compiled and 'int') or return_type
'int'
>>> (not is_compiled and 1.0) or result
1.0
>>> (is_compiled and 1) or result
1
"""
return
x
def
call_ccall
(
x
):
ret
=
c_call
(
x
)
return
ret
,
cython
.
typeof
(
ret
)
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