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):
modulecode.putln("")
modulecode.putln("/* Module declarations from '%s' */" % module.qualified_name)
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_cfunction_declarations(module, modulecode, defined_here)
......@@ -1758,6 +1759,16 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if definition or entry.defined_in_pxd:
code.putln("static PyTypeObject *%s = 0;" % (
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):
if env.is_cython_builtin:
......
......@@ -3904,7 +3904,9 @@ class CypClassType(CppClassType):
CppClassType.__init__(self, name, scope, cname, base_classes, templates, template_type, nogil)
self.lock_mode = lock_mode if lock_mode else "autolock"
self.activable = activable
self.typeptr_cname = None # set externally
def empty_declaration_code(self):
if self._empty_declaration is None:
self._empty_declaration = self.declaration_code('', deref=1)
......
......@@ -669,6 +669,7 @@ class Scope(object):
if cypclass:
type = PyrexTypes.CypClassType(
name, scope, cname, base_classes, templates = templates, lock_mode=lock_mode, activable=activable)
type.typeptr_cname = self.mangle(Naming.typeptr_prefix, cname)
else:
type = PyrexTypes.CppClassType(
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