Commit 83daa936 authored by Xavier Thompson's avatar Xavier Thompson

Predeclare a cypclass PyTyObject directly instead of predeclaring a pointer

parent af8c3c1d
......@@ -84,7 +84,7 @@ def cypclass_iter_scopes(scope):
def generate_cypclass_typeobj_declarations(env, code, definition):
"""
Generate declarations of global pointers to the PyTypeObject for each cypclass
Generate pre-declarations of the PyTypeObject for each cypclass
"""
for entry in cypclass_iter(env):
......@@ -93,7 +93,7 @@ def generate_cypclass_typeobj_declarations(env, code, definition):
# actually returns an instance of the cypclass type.
# and do this computation only once
# (cf generate_cyp_class_wrapper_definition)
code.putln("static PyTypeObject *%s = 0;" % (entry.type.typeptr_cname))
code.putln("static PyTypeObject %s;" % (entry.type.typeobj_cname))
......@@ -595,7 +595,7 @@ def generate_cyp_class_wrapper_definition(type, wrapper_entry, constructor_entry
code.putln("if(self) {")
code.putln("self->ob_refcnt = 0;")
# code.putln("self->ob_type = NULL;")
code.putln("self->ob_type = %s;" % type.typeptr_cname)
code.putln("self->ob_type = &%s;" % type.typeobj_cname)
code.putln("}")
if init_entry:
......
......@@ -3967,7 +3967,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
self.typeobj_cname = None # set externally
# Return the MRO for this cypclass
# Compute all the mro needed when a previous computation is not available
......
......@@ -710,7 +710,8 @@ 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.c_mangle(Naming.typeptr_prefix, name)
# generate PyTypeObject cname for cypclass
type.typeobj_cname = self.c_mangle(Naming.typeobj_prefix, name)
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