"%s;" %
attr.type.declaration_code(attr.cname))
code.putln(footer)
+ if type.objtypedef_cname is not None:
+ # Only for exposing public typedef name.
+ code.putln("typedef struct %s %s;" % (type.objstruct_cname, type.objtypedef_cname))
def generate_global_declarations(self, env, code, definition):
code.putln("")
# base_type PyExtensionType or None
# module_name string or None Qualified name of defining module
# objstruct_cname string Name of PyObject struct
+ # objtypedef_cname string Name of PyObject struct typedef
# typeobj_cname string or None C code fragment referring to type object
# typeptr_cname string or None Name of pointer to external type object
# vtabslot_cname string Name of C method table member
is_extension_type = 1
has_attributes = 1
+ objtypedef_cname = None
+
def __init__(self, name, typedef_flag, base_type):
self.name = name
self.scope = None
module_name = None, base_type = None, objstruct_cname = None,
typeobj_cname = None, visibility = 'private', typedef_flag = 0, api = 0,
buffer_defaults = None):
+ # If this is a non-extern typedef class, expose the typedef, but use
+ # the non-typedef struct internally to avoid needing forward
+ # declarations for anonymous structs.
+ if typedef_flag and visibility != 'extern':
+ objtypedef_cname = objstruct_cname
+ objstruct_cname = None
+ typedef_flag = 0
+ else:
+ objtypedef_cname = None
#
# Look for previous declaration as a type
#
type = PyrexTypes.PyExtensionType(name, typedef_flag, base_type)
type.pos = pos
type.buffer_defaults = buffer_defaults
+ if objtypedef_cname is not None:
+ type.objtypedef_cname = objtypedef_cname
if visibility == 'extern':
type.module_name = module_name
else:
if objstruct_cname:
type.objstruct_cname = objstruct_cname
elif not entry.in_cinclude:
- type.objstruct_cname = self.mangle(Naming.objstruct_prefix, name)
+ type.objstruct_cname = self.mangle(Naming.objstruct_prefix, name)
else:
error(entry.pos,
"Object name required for 'public' or 'extern' C class")