"Pointer base type cannot be a Python object")
ptr_type = PyrexTypes.c_ptr_type(base_type)
return self.base.analyse(ptr_type, env, nonempty = nonempty)
-
+
+class CReferenceDeclaratorNode(CDeclaratorNode):
+ # base CDeclaratorNode
+
+ child_attrs = ["base"]
+
+ def analyse(self, base_type, env, nonempty = 0):
+ if base_type.is_pyobject:
+ error(self.pos,
+ "Reference base type cannot be a Python object")
+ ref_type = Pyrextypes.c_ref_type(base_type)
+ return self.base.analyse(ref_type, env, nonempty = nonempty)
+
class CArrayDeclaratorNode(CDeclaratorNode):
# base CDeclaratorNode
# dimension ExprNode
if s.sy == 'IDENT' and s.systring in basic_c_type_names:
name = s.systring
s.next()
+ if s.sy == '&':
+ s.next()
+ #TODO (Danilo)
else:
name = 'int'
if s.sy == 'IDENT' and s.systring == 'complex':
elif s.sy not in ('*', '**', '['):
s.put_back('IDENT', name)
name = None
-
+
type_node = Nodes.CSimpleBaseTypeNode(pos,
name = name, module_path = module_path,
is_basic_c_type = is_basic, signed = signed,
# is_array boolean Is a C array type
# is_ptr boolean Is a C pointer type
# is_null_ptr boolean Is the type of NULL
+ # is_reference boolean Is a C reference type
# is_cfunction boolean Is a C function type
# is_struct_or_union boolean Is a C struct or union type
# is_struct boolean Is a C struct type
is_null_ptr = 1
+
+class CReferenceType(CType):
+
+ is_reference = 1
+
+ def __init__(self, base_type):
+ self.base_type = base_type
+
+ def __repr__(self):
+ return "<CReferenceType %s>" % repr(self.base_type)
+
+ def same_as_resolved_type(self, other_type):
+ return self.base_type.same_as(other_type.base_type)
+
+ def declaration_code(self, entity_code,
+ for_display = 0, dll_linkage = None, pyrex = 0):
+ #print "CPtrType.declaration_code: pointer to", self.base_type ###
+ return self.base_type.declaration_code(
+ "&%s" % entity_code,
+ for_display, dll_linkage, pyrex)
+
+ def assignable_from_resolved_type(self, other_type):
+ return 0 #TODO (Danilo) implement this
+
+ def specialize(self, values):
+ base_type = self.base_type.specialize(values)
+ if base_type == self.base_type:
+ return self
+ else:
+ return CReferenceType(base_type)
+
class CFuncType(CType):
# return_type CType
# args [CFuncTypeArg]
return error_type
else:
return CPtrType(base_type)
+
+def c_ref_type(base_type):
+ # Construct a C reference type
+ if base_type is c_char_type:
+ return None #TODO (Danilo) create c_char_ref_type
+ elif base_type is error_type:
+ return error_type
+ else:
+ return CReferenceType(base_type)
def Node_to_type(node, env):
from ExprNodes import NameNode, AttributeNode, StringNode, error
if visibility == 'extern':
warning(pos, "'%s' redeclared " % name, 0)
elif visibility != 'ignore':
- error(pos, "'%s' redeclared " % name)
+ pass
+ #error(pos, "'%s' redeclared " % name)
entry = Entry(name, cname, type, pos = pos)
entry.in_cinclude = self.in_cinclude
if name:
if visibility != 'private' and visibility != entry.visibility:
warning(pos, "Function '%s' previously declared as '%s'" % (name, entry.visibility), 1)
if not entry.type.same_as(type):
- if visibility == 'extern' and entry.visibility == 'extern':
- warning(pos, "Function signature does not match previous declaration", 1)
+ #if visibility == 'extern' and entry.visibility == 'extern':
+ #warning(pos, "Function signature does not match previous declaration", 1)
#entry.type = type
- entry.overloaded_alternatives.append(
- self.add_cfunction(name, type, pos, cname, visibility, modifiers))
- else:
- error(pos, "Function signature does not match previous declaration")
+ temp = self.add_cfunction(name, type, pos, cname, visibility, modifiers)
+ entry.overloaded_alternatives.append(temp)
+ entry = temp
+ #else:
+ #error(pos, "Function signature does not match previous declaration")
else:
entry = self.add_cfunction(name, type, pos, cname, visibility, modifiers)
entry.func_cname = cname