Commit d6f77d78 authored by Robert Bradshaw's avatar Robert Bradshaw

Auto-wrap cpdef extern functions.

parent 13f931d4
...@@ -11,6 +11,10 @@ Features added ...@@ -11,6 +11,10 @@ Features added
* C functions can coerce to Python functions, which allows passing them * C functions can coerce to Python functions, which allows passing them
around as callable objects. around as callable objects.
* Extern C functions can now be declared as cpdef to export them to
the module's Python namespace. Extern C functions in pxd files export
their values to their own module, iff it exists.
* Missing C-API declarations in ``cpython.unicode`` were added. * Missing C-API declarations in ``cpython.unicode`` were added.
* Passing ``language='c++'`` into cythonize() globally enables C++ mode for * Passing ``language='c++'`` into cythonize() globally enables C++ mode for
......
...@@ -1272,6 +1272,11 @@ class CVarDefNode(StatNode): ...@@ -1272,6 +1272,11 @@ class CVarDefNode(StatNode):
"Each pointer declaration should be on its own line.", 1) "Each pointer declaration should be on its own line.", 1)
if isinstance(declarator, CFuncDeclaratorNode): if isinstance(declarator, CFuncDeclaratorNode):
create_extern_wrapper = (self.overridable
and self.visibility == 'extern'
and env.is_module_scope)
if create_extern_wrapper:
declarator.overridable = False
name_declarator, type = declarator.analyse(base_type, env, directive_locals=self.directive_locals) name_declarator, type = declarator.analyse(base_type, env, directive_locals=self.directive_locals)
else: else:
name_declarator, type = declarator.analyse(base_type, env) name_declarator, type = declarator.analyse(base_type, env)
...@@ -1296,6 +1301,8 @@ class CVarDefNode(StatNode): ...@@ -1296,6 +1301,8 @@ class CVarDefNode(StatNode):
self.entry.directive_locals = copy.copy(self.directive_locals) self.entry.directive_locals = copy.copy(self.directive_locals)
if 'staticmethod' in env.directives: if 'staticmethod' in env.directives:
type.is_static_method = True type.is_static_method = True
if create_extern_wrapper:
self.entry.create_wrapper = True
else: else:
if self.directive_locals: if self.directive_locals:
error(self.pos, "Decorators can only be followed by functions") error(self.pos, "Decorators can only be followed by functions")
......
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