support ext type inheritance from builtin types
authorStefan Behnel <scoder@users.berlios.de>
Sat, 4 Dec 2010 11:39:59 +0000 (12:39 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sat, 4 Dec 2010 11:39:59 +0000 (12:39 +0100)
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py
Cython/Compiler/PyrexTypes.py

index 39d8b9dc5b6d5be92a96f95c42af3084b4beca99..0af1a23802df0908d0dc941d87603a054b6352f0 100644 (file)
@@ -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):
index 593f9f6ad0dc011064f99316e8d83ae1d4e3a31e..6fc38988dd35f7c7e45a9614c60376fc2bf102dc 100644 (file)
@@ -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" % (
index 2c302fc5d60a09e6643903201273157667a3183a..43873df16faba4ea000d57558e79b431872274b0 100755 (executable)
@@ -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):