# is_basic_c_type boolean
# signed boolean
# longness integer
+ # complex boolean
# is_self_arg boolean Is self argument of C method
child_attrs = []
self.arg_name = self.name
else:
error(self.pos, "'%s' is not a type identifier" % self.name)
+ if self.complex:
+ type = PyrexTypes.CCompelxType(type)
if type:
return type
else:
is_basic = 0
signed = 1
longness = 0
+ complex = 0
module_path = []
pos = s.position()
if not s.sy == 'IDENT':
s.next()
else:
name = 'int'
+ if s.sy == 'IDENT' and s.systring == 'complex':
+ complex = 1
+ s.next()
elif looking_at_dotted_name(s):
#print "p_c_simple_base_type: looking_at_type_name at", s.position()
name = s.systring
type_node = Nodes.CSimpleBaseTypeNode(pos,
name = name, module_path = module_path,
is_basic_c_type = is_basic, signed = signed,
- longness = longness, is_self_arg = self_flag)
+ complex = complex, longness = longness,
+ is_self_arg = self_flag)
# Treat trailing [] on type as buffer access if it appears in a context
# is_int boolean Is a C integer type
# is_longlong boolean Is a long long or unsigned long long.
# is_float boolean Is a C floating point type
+ # is_complex boolean Is a C complex type
# is_void boolean Is the C void type
# is_array boolean Is a C array type
# is_ptr boolean Is a C pointer type
is_int = 0
is_longlong = 0
is_float = 0
+ is_complex = 0
is_void = 0
is_array = 0
is_ptr = 0
self.math_h_modifier = math_h_modifier
def assignable_from_resolved_type(self, src_type):
- return src_type.is_numeric or src_type is error_type
+ return (src_type.is_numeric and not src_type.is_complex) or src_type is error_type
+
+class CCompelxType(CNumericType):
+
+ is_complex = 1
+
+ def __init__(self, real_type):
+ self.real_type = real_type
+ CNumericType.__init__(self, real_type.rank + 0.5, real_type.signed)
+
+ def sign_and_name(self):
+ return self.real_type.sign_and_name() + " complex"
+
+ def assignable_from_resolved_type(self, src_type):
+ return (src_type.is_complex and self.real_type.assignable_from_resolved_type(src_type.real_type)
+ or src_type.is_numeric and self.real_type.assignable_from_resolved_type(src_type)
+ or src_type is error_type)
+
class CArrayType(CType):
}
""" + type_conversion_functions
+
+