fix (or work-around?) for base class vtab type cast problem
authorStefan Behnel <scoder@users.berlios.de>
Wed, 30 Jul 2008 20:38:38 +0000 (22:38 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 30 Jul 2008 20:38:38 +0000 (22:38 +0200)
Cython/Compiler/ModuleNode.py

index 68394529e46eb2d20eeff18d98758827e4725808..33c4e9a4165696e6a4ed51ea5ef3b3f3cf0579f0 100644 (file)
@@ -836,8 +836,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         #if need_self_cast:
         #      self.generate_self_cast(scope, code)
         if type.vtabslot_cname:
-            if base_type:
-                struct_type_cast = "(struct %s*)" % base_type.vtabstruct_cname
+            vtab_base_type = type
+            while vtab_base_type.base_type and vtab_base_type.base_type.vtabstruct_cname:
+                vtab_base_type = vtab_base_type.base_type
+            if vtab_base_type is not type:
+                struct_type_cast = "(struct %s*)" % vtab_base_type.vtabstruct_cname
             else:
                 struct_type_cast = ""
             code.putln("p->%s = %s%s;" % (