Commit 0cb28898 authored by Xavier Thompson's avatar Xavier Thompson

Generate declarations of PyTypeObject pointer for cypclasses

parent 9935e364
...@@ -615,6 +615,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -615,6 +615,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
modulecode.putln("") modulecode.putln("")
modulecode.putln("/* Module declarations from '%s' */" % module.qualified_name) modulecode.putln("/* Module declarations from '%s' */" % module.qualified_name)
self.generate_c_class_declarations(module, modulecode, defined_here) self.generate_c_class_declarations(module, modulecode, defined_here)
self.generate_cypclass_typeobj_declarations(module, modulecode, defined_here)
self.generate_cvariable_declarations(module, modulecode, defined_here) self.generate_cvariable_declarations(module, modulecode, defined_here)
self.generate_cfunction_declarations(module, modulecode, defined_here) self.generate_cfunction_declarations(module, modulecode, defined_here)
...@@ -1759,6 +1760,16 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1759,6 +1760,16 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("static PyTypeObject *%s = 0;" % ( code.putln("static PyTypeObject *%s = 0;" % (
entry.type.typeptr_cname)) entry.type.typeptr_cname))
def generate_cypclass_typeobj_declarations(self, env, code, definition):
for entry in env.cypclass_entries:
if definition or entry.defined_in_pxd:
code.putln("static PyTypeObject *%s = 0;" % (
entry.type.typeptr_cname))
cyp_scope = entry.type.scope
if cyp_scope:
# generate declarations for nested cycplasses
self.generate_cypclass_typeobj_declarations(cyp_scope, code, definition)
def generate_cvariable_declarations(self, env, code, definition): def generate_cvariable_declarations(self, env, code, definition):
if env.is_cython_builtin: if env.is_cython_builtin:
return return
......
...@@ -3904,6 +3904,8 @@ class CypClassType(CppClassType): ...@@ -3904,6 +3904,8 @@ class CypClassType(CppClassType):
CppClassType.__init__(self, name, scope, cname, base_classes, templates, template_type, nogil) CppClassType.__init__(self, name, scope, cname, base_classes, templates, template_type, nogil)
self.lock_mode = lock_mode if lock_mode else "autolock" self.lock_mode = lock_mode if lock_mode else "autolock"
self.activable = activable self.activable = activable
self.typeptr_cname = None # set externally
def empty_declaration_code(self): def empty_declaration_code(self):
if self._empty_declaration is None: if self._empty_declaration is None:
......
...@@ -669,6 +669,7 @@ class Scope(object): ...@@ -669,6 +669,7 @@ class Scope(object):
if cypclass: if cypclass:
type = PyrexTypes.CypClassType( type = PyrexTypes.CypClassType(
name, scope, cname, base_classes, templates = templates, lock_mode=lock_mode, activable=activable) name, scope, cname, base_classes, templates = templates, lock_mode=lock_mode, activable=activable)
type.typeptr_cname = self.mangle(Naming.typeptr_prefix, cname)
else: else:
type = PyrexTypes.CppClassType( type = PyrexTypes.CppClassType(
name, scope, cname, base_classes, templates = templates) name, scope, cname, base_classes, templates = templates)
......
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