Fix assignable_from for cpp classes.
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 4 Feb 2010 21:58:00 +0000 (13:58 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 4 Feb 2010 21:58:00 +0000 (13:58 -0800)
Cython/Compiler/PyrexTypes.py
tests/run/cpp_classes.pyx

index 4f068ace33fe86658f082b8c56f6f7e9ceabdb80..5b78c8f1df652527ad37cab24f142b5a3c99f4da 100755 (executable)
@@ -1891,6 +1891,10 @@ class CppClassType(CType):
                 return 1
         return 0
 
+    def assignable_from_resolved_type(self, other_type):
+        # TODO: handle operator=(...) here?
+        return other_type.is_cpp_class and other_type.is_subclass(self)
+    
     def attributes_known(self):
         return self.scope is not None
 
index 5e5747df03f2f11000ae08663c1f858f2b9de964..9c51aed9da67dee0a4abcc6a483a03d3822174a0 100644 (file)
@@ -48,3 +48,17 @@ def test_square_area(w):
     finally:
         del sqr
 
+cdef double get_area(Rectangle s):
+    return s.area()
+
+def test_value_call(int w):
+    """
+    >>> test_value_call(5)
+    (25.0, 25.0)
+    """
+    cdef Square *sqr = new Square(w)
+    cdef Rectangle *rect = sqr
+    try:
+        return get_area(sqr[0]), get_area(rect[0])
+    finally:
+        del sqr