Commit ae6700cc authored by Xavier Thompson's avatar Xavier Thompson

Generate declarations of PyTypeObject pointer for cypclasses

parent 587d280d
......@@ -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)
......@@ -1807,6 +1808,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
......
......@@ -3967,6 +3967,7 @@ class CypClassType(CppClassType):
self.activable = activable
self._mro = None
self._left_path_to_base = {}
self.typeptr_cname = None # set externally
# Return the MRO for this cypclass
# Compute all the mro needed when a previous computation is not available
......
......@@ -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