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
c4a81808
Commit
c4a81808
authored
Feb 08, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support keyword arguments for C function pointers
parent
d44a0845
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-2
tests/run/cdef_function_kwargs.pyx
tests/run/cdef_function_kwargs.pyx
+24
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
c4a81808
...
...
@@ -4388,12 +4388,17 @@ class GeneralCallNode(CallNode):
return
self
function
=
self
.
function
entry
=
getattr
(
function
,
'entry'
,
None
)
if
not
entry
or
not
entry
.
is_cfunction
:
if
not
entry
:
return
self
function_type
=
entry
.
type
if
function_type
.
is_ptr
:
function_type
=
function_type
.
base_type
if
not
function_type
.
is_cfunction
:
return
self
pos_args
=
self
.
positional_args
.
args
kwargs
=
self
.
keyword_args
declared_args
=
entry
.
type
.
args
declared_args
=
function_
type
.
args
if
entry
.
is_cmethod
:
declared_args
=
declared_args
[
1
:]
# skip 'self'
...
...
tests/run/cdef_function_kwargs.pyx
View file @
c4a81808
...
...
@@ -11,6 +11,13 @@ cpdef cpfunc(a,b,c,d):
cdef
optargs
(
a
,
b
=
2
,
c
=
3
):
return
(
a
,
b
,
c
)
ctypedef
int
(
*
cfuncptr_type
)(
int
a
,
int
b
)
cdef
int
cfuncptr
(
int
a
,
int
b
):
print
a
,
b
cdef
cfuncptr_type
get_cfuncptr
():
return
cfuncptr
sideeffect
=
[]
cdef
side_effect
(
x
):
...
...
@@ -156,3 +163,20 @@ def cdef_optargs():
print
(
optargs
(
b
=
12
,
a
=
11
,
c
=
13
))
print
(
optargs
(
b
=
12
,
c
=
13
,
a
=
11
))
print
(
optargs
(
c
=
13
,
a
=
11
,
b
=
12
))
@
cython
.
test_fail_if_path_exists
(
'//GeneralCallNode'
)
@
cython
.
test_assert_path_exists
(
'//SimpleCallNode'
)
def
cdef_funcptr
():
"""
>>> cdef_funcptr()
1 2
1 2
1 2
1 2
"""
cdef
cfuncptr_type
cfunc_ptr
=
get_cfuncptr
()
cfunc_ptr
(
1
,
2
)
cfunc_ptr
(
1
,
b
=
2
)
cfunc_ptr
(
a
=
1
,
b
=
2
)
cfunc_ptr
(
b
=
2
,
a
=
1
)
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