C++ references
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 21 Feb 2010 08:58:44 +0000 (00:58 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 21 Feb 2010 08:58:44 +0000 (00:58 -0800)
Implemented like typedef.

Cython/Compiler/PyrexTypes.py

index 2e6bdc05dd5bbb464219743f3bdd5940bde439d9..c5e65642400ef98ca5b03d345fae8c61791250ea 100755 (executable)
@@ -1358,43 +1358,37 @@ class CNullPtrType(CPtrType):
     is_null_ptr = 1
     
 
-class CReferenceType(CType):
+class CReferenceType(BaseType):
 
     is_reference = 1
 
     def __init__(self, base_type):
-        self.base_type = base_type
+        self.ref_base_type = base_type
 
     def __repr__(self):
-        return "<CReferenceType %s>" % repr(self.base_type)
+        return "<CReferenceType %s>" % repr(self.ref_base_type)
+
+    def as_argument_type(self):
+        return self
 
-    def same_as_resolved_type(self, other_type):
-        return other_type.is_reference and self.base_type.same_as(other_type.base_type)
-    
     def declaration_code(self, entity_code, 
             for_display = 0, dll_linkage = None, pyrex = 0):
         #print "CReferenceType.declaration_code: pointer to", self.base_type ###
-        return self.base_type.declaration_code(
+        return self.ref_base_type.declaration_code(
             "&%s" % entity_code,
             for_display, dll_linkage, pyrex)
     
-    def assignable_from_resolved_type(self, other_type):
-        if other_type is error_type:
-            return 1
-        elif other_type.is_reference and self.base_type == other_type.base_type:
-            return 1
-        elif other_type == self.base_type:
-            return 1
-        else: #for now
-            return 0
-        
     def specialize(self, values):
-        base_type = self.base_type.specialize(values)
-        if base_type == self.base_type:
+        base_type = self.ref_base_type.specialize(values)
+        if base_type == self.ref_base_type:
             return self
         else:
             return CReferenceType(base_type)
 
+    def __getattr__(self, name):
+        return getattr(self.ref_base_type, name)
+
+
 class CFuncType(CType):
     #  return_type      CType
     #  args             [CFuncTypeArg]