make overridable a type-level property, now overriding functions must agree
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 1 Nov 2007 09:45:45 +0000 (02:45 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 1 Nov 2007 09:45:45 +0000 (02:45 -0700)
Cython/Compiler/ExprNodes.py
Cython/Compiler/Nodes.py
Cython/Compiler/PyrexTypes.py
Cython/Compiler/Symtab.py

index cd1313e24620446c081b91e6f6f144f036e81eb4..7f4dc1be72ccfd736d09af2138198ecb1ee19b7d 100644 (file)
@@ -1550,7 +1550,7 @@ class SimpleCallNode(ExprNode):
         result = "%s(%s)" % (self.function.result_code,
             join(arg_list_code, ","))
         if self.wrapper_call or \
-                self.function.entry.is_unbound_cmethod and self.function.entry.is_overridable:
+                self.function.entry.is_unbound_cmethod and self.function.entry.type.is_overridable:
             result = "(%s = 1, %s)" % (Naming.skip_dispatch_cname, result)
         return result
     
@@ -1770,7 +1770,6 @@ class AttributeNode(ExprNode):
                 ubcm_entry.is_cfunction = 1
                 ubcm_entry.func_cname = entry.func_cname
                 ubcm_entry.is_unbound_cmethod = 1
-                ubcm_entry.is_overridable = entry.is_overridable
                 self.mutate_into_name_node(env, ubcm_entry, None)
                 return 1
         return 0
index 3a69f00ffc45512c5df00fb76347e814c0a5b4f6..83ef12b4a34bf07065a4f3f3074d2acf7a4e1b1a 100644 (file)
@@ -761,6 +761,7 @@ class CFuncDefNode(FuncDefNode):
         # may be different if we're overriding a C method inherited
         # from the base type of an extension type.
         self.type = type
+        type.is_overridable = self.overridable
         name = name_declarator.name
         cname = name_declarator.cname
         self.entry = env.declare_cfunction(
@@ -768,7 +769,6 @@ class CFuncDefNode(FuncDefNode):
             cname = cname, visibility = self.visibility,
             defining = self.body is not None,
             api = self.api)
-        self.entry.is_overridable = self.overridable
         self.return_type = type.return_type
 
         if self.overridable:
index 3874474e0bf1ed7db2ba7fb03c1e4c36a1c69073..2f8baf2bad4303277adeb6fa24f74882be680b9f 100644 (file)
@@ -535,7 +535,7 @@ class CFuncType(CType):
     
     def __init__(self, return_type, args, has_varargs = 0,
             exception_value = None, exception_check = 0, calling_convention = "",
-            nogil = 0, with_gil = 0):
+            nogil = 0, with_gil = 0, is_overridable = 0):
         self.return_type = return_type
         self.args = args
         self.has_varargs = has_varargs
@@ -544,6 +544,7 @@ class CFuncType(CType):
         self.calling_convention = calling_convention
         self.nogil = nogil
         self.with_gil = with_gil
+        self.is_overridable = is_overridable
     
     def __repr__(self):
         arg_reprs = map(repr, self.args)
@@ -572,6 +573,8 @@ class CFuncType(CType):
             return 1
         if not other_type.is_cfunction:
             return 0
+        if self.is_overridable != other_type.is_overridable:
+            return 0
         nargs = len(self.args)
         if nargs <> len(other_type.args):
             return 0
index af4e20706eb52c6bc13cbd99238abe696f190eec..3a580778d8867243e619a4045449b3673aba9034 100644 (file)
@@ -109,6 +109,7 @@ class Entry:
     defined_in_pxd = 0
     api = 0
     utility_code = None
+    is_overridable = 0
 
     def __init__(self, name, cname, type, pos = None, init = None):
         self.name = name