return 1
-def create_typedef_type(cname, base_type, is_external=0):
+def create_typedef_type(name, base_type, cname, is_external=0):
if base_type.is_complex:
if is_external:
raise ValueError("Complex external typedefs not supported")
return base_type
else:
- return CTypedefType(cname, base_type, is_external)
+ return CTypedefType(name, base_type, cname, is_external)
class CTypedefType(BaseType):
#
# HERE IS DELEGATED!
#
# qualified_name string
+ # typedef_name string
# typedef_cname string
# typedef_base_type PyrexType
# typedef_is_external bool
from_py_utility_code = None
- def __init__(self, cname, base_type, is_external=0):
+ def __init__(self, name, base_type, cname, is_external=0):
assert not base_type.is_complex
+ self.typedef_name = name
self.typedef_cname = cname
self.typedef_base_type = base_type
self.typedef_is_external = is_external
def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0):
- name = self.declaration_name(for_display, pyrex)
if pyrex or for_display:
- base_code = name
+ base_code = self.typedef_name
else:
- base_code = public_decl(name, dll_linkage)
+ base_code = public_decl(self.typedef_cname, dll_linkage)
return self.base_declaration_code(base_code, entity_code)
- def declaration_name(self, for_display = 0, pyrex = 0):
- if pyrex or for_display:
- return self.qualified_name
- else:
- return self.typedef_cname
-
def as_argument_type(self):
return self
return "<CTypedefType %s>" % self.typedef_cname
def __str__(self):
- return self.declaration_name(for_display = 1)
+ return self.typedef_name
def _create_utility_code(self, template_utility_code,
template_function_name):
else:
cname = self.mangle(Naming.type_prefix, name)
try:
- type = PyrexTypes.create_typedef_type(cname, base_type, (visibility == 'extern'))
+ type = PyrexTypes.create_typedef_type(name, base_type, cname,
+ (visibility == 'extern'))
except ValueError, e:
error(pos, e.message)
type = PyrexTypes.error_type
grail = spam # type mismatch
spam = grail # type mismatch
_ERRORS = u"""
-7:28: Cannot assign type 'e_excvalfunctype.spamfunc' to 'e_excvalfunctype.grailfunc'
-8:28: Cannot assign type 'e_excvalfunctype.grailfunc' to 'e_excvalfunctype.spamfunc'
+7:28: Cannot assign type 'spamfunc' to 'grailfunc'
+8:28: Cannot assign type 'grailfunc' to 'spamfunc'
"""
>>> printbuf_td_cy_int(ShortMockBuffer(None, range(3)), (3,))
Traceback (most recent call last):
...
- ValueError: Buffer dtype mismatch, expected 'bufaccess.td_cy_int' but got 'short'
+ ValueError: Buffer dtype mismatch, expected 'td_cy_int' but got 'short'
"""
cdef int i
for i in range(shape[0]):
>>> printbuf_td_h_short(IntMockBuffer(None, range(3)), (3,))
Traceback (most recent call last):
...
- ValueError: Buffer dtype mismatch, expected 'bufaccess.td_h_short' but got 'int'
+ ValueError: Buffer dtype mismatch, expected 'td_h_short' but got 'int'
"""
cdef int i
for i in range(shape[0]):
>>> printbuf_td_h_cy_short(IntMockBuffer(None, range(3)), (3,))
Traceback (most recent call last):
...
- ValueError: Buffer dtype mismatch, expected 'bufaccess.td_h_cy_short' but got 'int'
+ ValueError: Buffer dtype mismatch, expected 'td_h_cy_short' but got 'int'
"""
cdef int i
for i in range(shape[0]):
>>> printbuf_td_h_ushort(ShortMockBuffer(None, range(3)), (3,))
Traceback (most recent call last):
...
- ValueError: Buffer dtype mismatch, expected 'bufaccess.td_h_ushort' but got 'short'
+ ValueError: Buffer dtype mismatch, expected 'td_h_ushort' but got 'short'
"""
cdef int i
for i in range(shape[0]):
>>> printbuf_td_h_double(FloatMockBuffer(None, [0.25, 1, 3.125]), (3,))
Traceback (most recent call last):
...
- ValueError: Buffer dtype mismatch, expected 'bufaccess.td_h_double' but got 'float'
+ ValueError: Buffer dtype mismatch, expected 'td_h_double' but got 'float'
"""
cdef int i
for i in range(shape[0]):
>>> print (f_D.__doc__)
f_D(long double D) -> long double
+ >>> print (f_my_i.__doc__)
+ f_my_i(MyInt i) -> MyInt
+
+ >>> print (f_my_f.__doc__)
+ f_my_f(MyFloat f) -> MyFloat
+
"""
cdef class Ext:
cpdef long double f_D(long double D):
return D
+
+ctypedef int MyInt
+cpdef MyInt f_my_i(MyInt i):
+ return i
+
+ctypedef float MyFloat
+cpdef MyFloat f_my_f(MyFloat f):
+ return f