Commit cba8fe49 authored by Stefan Behnel's avatar Stefan Behnel

support ext type inheritance from builtin types

parent 5646b808
...@@ -1996,7 +1996,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1996,7 +1996,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def generate_base_type_import_code(self, env, entry, code): def generate_base_type_import_code(self, env, entry, code):
base_type = entry.type.base_type base_type = entry.type.base_type
if base_type and base_type.module_name != env.qualified_name: if base_type and base_type.module_name != env.qualified_name \
and not base_type.is_builtin_type:
self.generate_type_import_code(env, base_type, self.pos, code) self.generate_type_import_code(env, base_type, self.pos, code)
def use_type_import_utility_code(self, env): def use_type_import_utility_code(self, env):
......
...@@ -3192,7 +3192,9 @@ class CClassDefNode(ClassDefNode): ...@@ -3192,7 +3192,9 @@ class CClassDefNode(ClassDefNode):
if base_class_entry: if base_class_entry:
if not base_class_entry.is_type: if not base_class_entry.is_type:
error(self.pos, "'%s' is not a type name" % self.base_class_name) error(self.pos, "'%s' is not a type name" % self.base_class_name)
elif not base_class_entry.type.is_extension_type: elif not base_class_entry.type.is_extension_type and \
not (base_class_entry.type.is_builtin_type and \
base_class_entry.type.objstruct_cname):
error(self.pos, "'%s' is not an extension type" % self.base_class_name) error(self.pos, "'%s' is not an extension type" % self.base_class_name)
elif not base_class_entry.type.is_complete(): elif not base_class_entry.type.is_complete():
error(self.pos, "Base class '%s' of type '%s' is incomplete" % ( error(self.pos, "Base class '%s' of type '%s' is incomplete" % (
......
...@@ -380,10 +380,17 @@ class BuiltinObjectType(PyObjectType): ...@@ -380,10 +380,17 @@ class BuiltinObjectType(PyObjectType):
base_type = None base_type = None
module_name = '__builtin__' module_name = '__builtin__'
# fields that let it look like an extension type
vtabslot_cname = None
vtabstruct_cname = None
vtabptr_cname = None
typedef_flag = True
is_external = True
def __init__(self, name, cname, objstruct_cname=None): def __init__(self, name, cname, objstruct_cname=None):
self.name = name self.name = name
self.cname = cname self.cname = cname
self.typeptr_cname = "&" + cname self.typeptr_cname = "(&%s)" % cname
self.objstruct_cname = objstruct_cname self.objstruct_cname = objstruct_cname
def set_scope(self, scope): def set_scope(self, scope):
......
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