Commit 4e3c2d75 authored by Xavier Thompson's avatar Xavier Thompson

Generate declarations of PyTypeObject pointer for cypclasses

parent 708faf67
......@@ -680,6 +680,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
modulecode.putln("")
modulecode.putln("/* Module declarations from %s */" % module.qualified_name.as_c_string_literal())
self.generate_c_class_declarations(module, modulecode, defined_here, globalstate)
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)
......@@ -1906,6 +1907,16 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"Py_VISIT(traverse_module_state->%s);" % (
entry.type.typeobj_cname))
code.putln("#endif")
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:
......
......@@ -4111,6 +4111,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
......@@ -4132,6 +4133,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)
......
......@@ -734,6 +734,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