Commit f8920f1f authored by Stefan Behnel's avatar Stefan Behnel

show argument types in docstring of wrapped C function

parent cba125d2
...@@ -2669,6 +2669,7 @@ class CFuncType(CType): ...@@ -2669,6 +2669,7 @@ class CFuncType(CType):
self.type = arg.type self.type = arg.type
self.type_name = 'TYPE%s' % ix self.type_name = 'TYPE%s' % ix
self.type_cname = self.type.declaration_code("") self.type_cname = self.type.declaration_code("")
self.type_displayname = self.type.declaration_code("", for_display=True)
if self.type.is_extension_type or self.type.is_builtin_type: if self.type.is_extension_type or self.type.is_builtin_type:
self.type_convert = '<%s>' % self.type_name self.type_convert = '<%s>' % self.type_name
elif self.type.is_pyobject: elif self.type.is_pyobject:
......
...@@ -14,7 +14,7 @@ cdef extern from *: ...@@ -14,7 +14,7 @@ cdef extern from *:
@cname("{{cname}}") @cname("{{cname}}")
cdef object {{cname}}({{return_type}} (*f)({{ ', '.join(arg.type_name for arg in args) }}) {{except_clause}}): cdef object {{cname}}({{return_type}} (*f)({{ ', '.join(arg.type_name for arg in args) }}) {{except_clause}}):
def wrap({{ ', '.join(arg.name for arg in args) }}): def wrap({{ ', '.join(arg.name for arg in args) }}):
"""wrap({{', '.join(arg.name for arg in args)}})""" """wrap({{', '.join('{arg.name}: {arg.type_displayname!r}'.format(arg=arg) for arg in args)}})"""
{{for arg in args}} {{for arg in args}}
{{arg.check_type()}} {{arg.check_type()}}
{{endfor}} {{endfor}}
......
...@@ -38,7 +38,7 @@ def return_square_c(): ...@@ -38,7 +38,7 @@ def return_square_c():
>>> square_c(x=4) >>> square_c(x=4)
16.0 16.0
>>> square_c.__doc__ # FIXME: try to make original C function name available >>> square_c.__doc__ # FIXME: try to make original C function name available
'wrap(x)' "wrap(x: 'double')"
""" """
return square_c return square_c
...@@ -88,6 +88,16 @@ def call_abc(a, b, c): ...@@ -88,6 +88,16 @@ def call_abc(a, b, c):
cdef object py_func = abc cdef object py_func = abc
return py_func(a, b, c) return py_func(a, b, c)
def return_abc():
"""
>>> abc = return_abc()
>>> abc(2, 3, 5)
False
>>> abc.__doc__
"wrap(a: 'long long', b: 'long long', c: 'long long')"
"""
return abc
ctypedef double foo ctypedef double foo
cdef foo test_typedef_cfunc(foo x): cdef foo test_typedef_cfunc(foo x):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment