Commit 94938586 authored by Robert Bradshaw's avatar Robert Bradshaw

Fix static methods declared in pxd files.

parent 061b132e
...@@ -23,6 +23,8 @@ Bugs fixed ...@@ -23,6 +23,8 @@ Bugs fixed
* ``ino_t`` in ``posix.types`` was not declared as ``unsigned``. * ``ino_t`` in ``posix.types`` was not declared as ``unsigned``.
* Static cdef methods can now be declared in .pxd files.
0.23.1 (2015-08-22) 0.23.1 (2015-08-22)
=================== ===================
......
...@@ -1327,13 +1327,13 @@ class CVarDefNode(StatNode): ...@@ -1327,13 +1327,13 @@ class CVarDefNode(StatNode):
error(declarator.pos, "Missing name in declaration.") error(declarator.pos, "Missing name in declaration.")
return return
if type.is_cfunction: if type.is_cfunction:
if 'staticmethod' in env.directives:
type.is_static_method = True
self.entry = dest_scope.declare_cfunction(name, type, declarator.pos, self.entry = dest_scope.declare_cfunction(name, type, declarator.pos,
cname=cname, visibility=self.visibility, in_pxd=self.in_pxd, cname=cname, visibility=self.visibility, in_pxd=self.in_pxd,
api=self.api, modifiers=self.modifiers, overridable=self.overridable) api=self.api, modifiers=self.modifiers, overridable=self.overridable)
if self.entry is not None: if self.entry is not None:
self.entry.directive_locals = copy.copy(self.directive_locals) self.entry.directive_locals = copy.copy(self.directive_locals)
if 'staticmethod' in env.directives:
type.is_static_method = True
if create_extern_wrapper: if create_extern_wrapper:
self.entry.type.create_to_py_utility_code(env) self.entry.type.create_to_py_utility_code(env)
self.entry.create_wrapper = True self.entry.create_wrapper = True
......
...@@ -50,3 +50,16 @@ def call_static_cdef(int x): ...@@ -50,3 +50,16 @@ def call_static_cdef(int x):
# ('cpdef', 2) # ('cpdef', 2)
# """ # """
# return A.static_cpdef(x) # return A.static_cpdef(x)
cdef class FromPxd:
@staticmethod
cdef static_cdef(int* x):
return 'pxd_cdef', x[0]
def call_static_pxd_cdef(int x):
"""
>>> call_static_pxd_cdef(2)
('pxd_cdef', 2)
"""
cdef int *x_ptr = &x
return FromPxd.static_cdef(x_ptr)
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