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
48177ec6
Commit
48177ec6
authored
Jan 13, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ticket #643: infer the type of C function names as function pointers
parent
59921a82
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-0
tests/run/type_inference.pyx
tests/run/type_inference.pyx
+11
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
48177ec6
...
...
@@ -1296,6 +1296,9 @@ class NameNode(AtomicExprNode):
# Unfortunately the type attribute of type objects
# is used for the pointer to the type they represent.
return
type_type
elif
self
.
entry
.
type
.
is_cfunction
:
# special case: referring to a C function must return it's pointer
return
PyrexTypes
.
CPtrType
(
self
.
entry
.
type
)
else
:
return
self
.
entry
.
type
...
...
tests/run/type_inference.pyx
View file @
48177ec6
...
...
@@ -199,6 +199,17 @@ def builtin_type_operations():
T2
=
()
*
2
assert
typeof
(
T2
)
==
"tuple object"
,
typeof
(
T2
)
cdef
int
func
(
int
x
):
return
x
+
1
def
c_functions
():
"""
>>> c_functions()
"""
f
=
func
assert
typeof
(
f
)
==
'int (*)(int)'
,
typeof
(
f
)
assert
2
==
f
(
1
)
def
cascade
():
"""
>>> cascade()
...
...
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