Commit 5ec3a112 authored by Xavier Thompson's avatar Xavier Thompson

Generate declarations of PyTypeObject pointer for cypclasses

parent 76bedd37
......@@ -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)
......@@ -1805,6 +1806,16 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
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:
return
......
......@@ -3966,6 +3966,7 @@ class CypClassType(CppClassType):
self.lock_mode = lock_mode if lock_mode else "autolock"
self.activable = activable
self._mro = None
self.typeptr_cname = None # set externally
# Return the MRO for this cypclass
# Compute all the mro needed when a previous computation is not available
......@@ -3987,6 +3988,7 @@ class CypClassType(CppClassType):
self._mro = mro_C3_merge(inputs)
return self._mro
def empty_declaration_code(self):
if self._empty_declaration is None:
self._empty_declaration = self.declaration_code('', deref=1)
......
......@@ -707,6 +707,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