import Naming
import PyrexTypes
import TypeSlots
-from PyrexTypes import py_object_type, error_type, CTypedefType, CFuncType
+from PyrexTypes import py_object_type, error_type, CFuncType
from Symtab import ModuleScope, LocalScope, GeneratorLocalScope, \
StructOrUnionScope, PyClassScope, CClassScope
from Cython.Utils import open_new_file, replace_suffix
# type information of the struct.
return 1
+
+def create_typedef_type(cname, base_type, 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)
+
class CTypedefType(BaseType):
#
# Pseudo-type defined with a ctypedef statement in a
def __init__(self, cname, base_type, is_external=0):
+ assert not base_type.is_complex
self.typedef_cname = cname
self.typedef_base_type = base_type
self.typedef_is_external = is_external
None,
visibility="extern")
scope.parent_type = self
-
-
scope.declare_var("real", self.real_type, None, "real", is_cdef=True)
scope.declare_var("imag", self.real_type, None, "imag", is_cdef=True)
entry = scope.declare_cfunction(
cname = name
else:
cname = self.mangle(Naming.type_prefix, name)
- type = PyrexTypes.CTypedefType(cname, base_type, (visibility == 'extern'))
+ try:
+ type = PyrexTypes.create_typedef_type(cname, base_type, (visibility == 'extern'))
+ except ValueError, e:
+ error(pos, e.message)
+ type = PyrexTypes.error_type
entry = self.declare_type(name, type, pos, cname, visibility)
type.qualified_name = entry.qualified_name
return entry