From: Robert Bradshaw Date: Sun, 21 Feb 2010 08:58:44 +0000 (-0800) Subject: C++ references X-Git-Tag: 0.13.beta0~333 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=b60ba931da8f6a2c0f33a07b9c13cb40ba0b7a9a;p=cython.git C++ references Implemented like typedef. --- diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 2e6bdc05..c5e65642 100755 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -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 "" % repr(self.base_type) + return "" % 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]