From cba8fe496d6e197311db0afb97e08a2c0fba82ed Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 4 Dec 2010 12:39:59 +0100 Subject: [PATCH] support ext type inheritance from builtin types --- Cython/Compiler/ModuleNode.py | 3 ++- Cython/Compiler/Nodes.py | 4 +++- Cython/Compiler/PyrexTypes.py | 9 ++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 39d8b9dc..0af1a238 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1996,7 +1996,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): def generate_base_type_import_code(self, env, entry, code): 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) def use_type_import_utility_code(self, env): diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 593f9f6a..6fc38988 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -3192,7 +3192,9 @@ class CClassDefNode(ClassDefNode): if base_class_entry: if not base_class_entry.is_type: 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) elif not base_class_entry.type.is_complete(): error(self.pos, "Base class '%s' of type '%s' is incomplete" % ( diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 2c302fc5..43873df1 100755 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -380,10 +380,17 @@ class BuiltinObjectType(PyObjectType): base_type = None 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): self.name = name self.cname = cname - self.typeptr_cname = "&" + cname + self.typeptr_cname = "(&%s)" % cname self.objstruct_cname = objstruct_cname def set_scope(self, scope): -- 2.26.2