Commit 9ce66875 authored by Robert Bradshaw's avatar Robert Bradshaw

remove trailing whitespace

parent 44892185
...@@ -613,7 +613,7 @@ def run_pipeline(source, options, full_module_name = None): ...@@ -613,7 +613,7 @@ def run_pipeline(source, options, full_module_name = None):
if os.path.exists(html_filename): if os.path.exists(html_filename):
line = codecs.open(html_filename, "r", encoding="UTF-8").readline() line = codecs.open(html_filename, "r", encoding="UTF-8").readline()
if line.startswith(u'<!-- Generated by Cython'): if line.startswith(u'<!-- Generated by Cython'):
options.annotate = True options.annotate = True
# Get pipeline # Get pipeline
if source_ext.lower() == '.py': if source_ext.lower() == '.py':
......
...@@ -73,7 +73,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -73,7 +73,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self.generate_c_code(env, options, result) self.generate_c_code(env, options, result)
self.generate_h_code(env, options, result) self.generate_h_code(env, options, result)
self.generate_api_code(env, result) self.generate_api_code(env, result)
def has_imported_c_functions(self): def has_imported_c_functions(self):
for module in self.referenced_modules: for module in self.referenced_modules:
for entry in module.cfunc_entries: for entry in module.cfunc_entries:
...@@ -166,7 +166,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -166,7 +166,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def api_name(self, env): def api_name(self, env):
return env.qualified_name.replace(".", "__") return env.qualified_name.replace(".", "__")
def generate_api_code(self, env, result): def generate_api_code(self, env, result):
def api_entries(entries, pxd=0): def api_entries(entries, pxd=0):
return [entry for entry in entries return [entry for entry in entries
...@@ -249,7 +249,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -249,7 +249,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def generate_cclass_header_code(self, type, h_code): def generate_cclass_header_code(self, type, h_code):
h_code.putln("%s %s %s;" % ( h_code.putln("%s %s %s;" % (
Naming.extern_c_macro, Naming.extern_c_macro,
PyrexTypes.public_decl("PyTypeObject", "DL_IMPORT"), PyrexTypes.public_decl("PyTypeObject", "DL_IMPORT"),
type.typeobj_cname)) type.typeobj_cname))
...@@ -1002,7 +1002,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1002,7 +1002,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
storage_class = "static " storage_class = "static "
dll_linkage = None dll_linkage = None
type = entry.type type = entry.type
if not definition and entry.defined_in_pxd: if not definition and entry.defined_in_pxd:
type = CPtrType(type) type = CPtrType(type)
header = type.declaration_code(entry.cname, header = type.declaration_code(entry.cname,
...@@ -1775,7 +1775,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1775,7 +1775,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("#endif") code.putln("#endif")
code.putln("{") code.putln("{")
tempdecl_code = code.insertion_point() tempdecl_code = code.insertion_point()
code.put_declare_refcount_context() code.put_declare_refcount_context()
code.putln("#if CYTHON_REFNANNY") code.putln("#if CYTHON_REFNANNY")
code.putln("__Pyx_RefNanny = __Pyx_RefNannyImportAPI(\"refnanny\");") code.putln("__Pyx_RefNanny = __Pyx_RefNannyImportAPI(\"refnanny\");")
......
...@@ -548,7 +548,7 @@ class CFuncDeclaratorNode(CDeclaratorNode): ...@@ -548,7 +548,7 @@ class CFuncDeclaratorNode(CDeclaratorNode):
other_type = type_node.analyse_as_type(env) other_type = type_node.analyse_as_type(env)
if other_type is None: if other_type is None:
error(type_node.pos, "Not a type") error(type_node.pos, "Not a type")
elif (type is not PyrexTypes.py_object_type elif (type is not PyrexTypes.py_object_type
and not type.same_as(other_type)): and not type.same_as(other_type)):
error(self.base.pos, "Signature does not agree with previous declaration") error(self.base.pos, "Signature does not agree with previous declaration")
error(type_node.pos, "Previous declaration here") error(type_node.pos, "Previous declaration here")
...@@ -1099,7 +1099,7 @@ class CEnumDefNode(StatNode): ...@@ -1099,7 +1099,7 @@ class CEnumDefNode(StatNode):
# api boolean # api boolean
# in_pxd boolean # in_pxd boolean
# entry Entry # entry Entry
child_attrs = ["items"] child_attrs = ["items"]
def analyse_declarations(self, env): def analyse_declarations(self, env):
...@@ -1146,7 +1146,7 @@ class CEnumDefItemNode(StatNode): ...@@ -1146,7 +1146,7 @@ class CEnumDefItemNode(StatNode):
if not self.value.type.is_int: if not self.value.type.is_int:
self.value = self.value.coerce_to(PyrexTypes.c_int_type, env) self.value = self.value.coerce_to(PyrexTypes.c_int_type, env)
self.value.analyse_const_expression(env) self.value.analyse_const_expression(env)
entry = env.declare_const(self.name, enum_entry.type, entry = env.declare_const(self.name, enum_entry.type,
self.value, self.pos, cname = self.cname, self.value, self.pos, cname = self.cname,
visibility = enum_entry.visibility, api = enum_entry.api) visibility = enum_entry.visibility, api = enum_entry.api)
enum_entry.enum_values.append(entry) enum_entry.enum_values.append(entry)
...@@ -1170,7 +1170,7 @@ class CTypeDefNode(StatNode): ...@@ -1170,7 +1170,7 @@ class CTypeDefNode(StatNode):
cname = cname, visibility = self.visibility, api = self.api) cname = cname, visibility = self.visibility, api = self.api)
if self.in_pxd and not env.in_cinclude: if self.in_pxd and not env.in_cinclude:
entry.defined_in_pxd = 1 entry.defined_in_pxd = 1
def analyse_expressions(self, env): def analyse_expressions(self, env):
pass pass
def generate_execution_code(self, code): def generate_execution_code(self, code):
...@@ -1221,7 +1221,7 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1221,7 +1221,7 @@ class FuncDefNode(StatNode, BlockNode):
other_type = type_node.analyse_as_type(env) other_type = type_node.analyse_as_type(env)
if other_type is None: if other_type is None:
error(type_node.pos, "Not a type") error(type_node.pos, "Not a type")
elif (type is not PyrexTypes.py_object_type elif (type is not PyrexTypes.py_object_type
and not type.same_as(other_type)): and not type.same_as(other_type)):
error(arg.base_type.pos, "Signature does not agree with previous declaration") error(arg.base_type.pos, "Signature does not agree with previous declaration")
error(type_node.pos, "Previous declaration here") error(type_node.pos, "Previous declaration here")
...@@ -1815,7 +1815,7 @@ class CFuncDefNode(FuncDefNode): ...@@ -1815,7 +1815,7 @@ class CFuncDefNode(FuncDefNode):
self.modifiers[self.modifiers.index('inline')] = 'cython_inline' self.modifiers[self.modifiers.index('inline')] = 'cython_inline'
if self.modifiers: if self.modifiers:
modifiers = "%s " % ' '.join(self.modifiers).upper() modifiers = "%s " % ' '.join(self.modifiers).upper()
header = self.return_type.declaration_code(entity, dll_linkage=dll_linkage) header = self.return_type.declaration_code(entity, dll_linkage=dll_linkage)
#print (storage_class, modifiers, header) #print (storage_class, modifiers, header)
code.putln("%s%s%s {" % (storage_class, modifiers, header)) code.putln("%s%s%s {" % (storage_class, modifiers, header))
...@@ -3446,7 +3446,7 @@ class CClassDefNode(ClassDefNode): ...@@ -3446,7 +3446,7 @@ class CClassDefNode(ClassDefNode):
visibility = self.visibility, visibility = self.visibility,
typedef_flag = self.typedef_flag, typedef_flag = self.typedef_flag,
api = self.api, api = self.api,
buffer_defaults = buffer_defaults, buffer_defaults = buffer_defaults,
shadow = self.shadow) shadow = self.shadow)
if self.shadow: if self.shadow:
home_scope.lookup(self.class_name).as_variable = self.entry home_scope.lookup(self.class_name).as_variable = self.entry
...@@ -4172,8 +4172,8 @@ class RaiseStatNode(StatNode): ...@@ -4172,8 +4172,8 @@ class RaiseStatNode(StatNode):
if self.exc_type and not self.exc_value and not self.exc_tb: if self.exc_type and not self.exc_value and not self.exc_tb:
exc = self.exc_type exc = self.exc_type
import ExprNodes import ExprNodes
if (isinstance(exc, ExprNodes.SimpleCallNode) and if (isinstance(exc, ExprNodes.SimpleCallNode) and
not (exc.args or (exc.arg_tuple is not None and not (exc.args or (exc.arg_tuple is not None and
exc.arg_tuple.args))): exc.arg_tuple.args))):
exc = exc.function # extract the exception type exc = exc.function # extract the exception type
if exc.is_name and exc.entry.is_builtin: if exc.is_name and exc.entry.is_builtin:
......
...@@ -1211,7 +1211,7 @@ if VALUE is not None: ...@@ -1211,7 +1211,7 @@ if VALUE is not None:
arg = copy.deepcopy(arg_template) arg = copy.deepcopy(arg_template)
arg.declarator.name = entry.name arg.declarator.name = entry.name
init_method.args.append(arg) init_method.args.append(arg)
# setters/getters # setters/getters
for entry, attr in zip(var_entries, attributes): for entry, attr in zip(var_entries, attributes):
# TODO: branch on visibility # TODO: branch on visibility
...@@ -1224,7 +1224,7 @@ if VALUE is not None: ...@@ -1224,7 +1224,7 @@ if VALUE is not None:
}, pos = entry.pos).stats[0] }, pos = entry.pos).stats[0]
property.name = entry.name property.name = entry.name
wrapper_class.body.stats.append(property) wrapper_class.body.stats.append(property)
wrapper_class.analyse_declarations(self.env_stack[-1]) wrapper_class.analyse_declarations(self.env_stack[-1])
return self.visit_CClassDefNode(wrapper_class) return self.visit_CClassDefNode(wrapper_class)
......
...@@ -2525,7 +2525,7 @@ def p_c_struct_or_union_definition(s, pos, ctx): ...@@ -2525,7 +2525,7 @@ def p_c_struct_or_union_definition(s, pos, ctx):
s.expect_dedent() s.expect_dedent()
else: else:
s.expect_newline("Syntax error in struct or union definition") s.expect_newline("Syntax error in struct or union definition")
return Nodes.CStructOrUnionDefNode(pos, return Nodes.CStructOrUnionDefNode(pos,
name = name, cname = cname, kind = kind, attributes = attributes, name = name, cname = cname, kind = kind, attributes = attributes,
typedef_flag = ctx.typedef_flag, visibility = ctx.visibility, typedef_flag = ctx.typedef_flag, visibility = ctx.visibility,
api = ctx.api, in_pxd = ctx.level == 'module_pxd', packed = packed) api = ctx.api, in_pxd = ctx.level == 'module_pxd', packed = packed)
...@@ -2613,7 +2613,7 @@ def p_ctypedef_statement(s, ctx): ...@@ -2613,7 +2613,7 @@ def p_ctypedef_statement(s, ctx):
s.expect_newline("Syntax error in ctypedef statement") s.expect_newline("Syntax error in ctypedef statement")
return Nodes.CTypeDefNode( return Nodes.CTypeDefNode(
pos, base_type = base_type, pos, base_type = base_type,
declarator = declarator, declarator = declarator,
visibility = visibility, api = api, visibility = visibility, api = api,
in_pxd = ctx.level == 'module_pxd') in_pxd = ctx.level == 'module_pxd')
......
...@@ -17,10 +17,10 @@ class BaseType(object): ...@@ -17,10 +17,10 @@ class BaseType(object):
def cast_code(self, expr_code): def cast_code(self, expr_code):
return "((%s)%s)" % (self.declaration_code(""), expr_code) return "((%s)%s)" % (self.declaration_code(""), expr_code)
def specialization_name(self): def specialization_name(self):
return self.declaration_code("").replace(" ", "__") return self.declaration_code("").replace(" ", "__")
def base_declaration_code(self, base_code, entity_code): def base_declaration_code(self, base_code, entity_code):
if entity_code: if entity_code:
return "%s %s" % (base_code, entity_code) return "%s %s" % (base_code, entity_code)
...@@ -56,7 +56,7 @@ class PyrexType(BaseType): ...@@ -56,7 +56,7 @@ class PyrexType(BaseType):
# has_attributes boolean Has C dot-selectable attributes # has_attributes boolean Has C dot-selectable attributes
# default_value string Initial value # default_value string Initial value
# #
# declaration_code(entity_code, # declaration_code(entity_code,
# for_display = 0, dll_linkage = None, pyrex = 0) # for_display = 0, dll_linkage = None, pyrex = 0)
# Returns a code fragment for the declaration of an entity # Returns a code fragment for the declaration of an entity
# of this type, given a code fragment for the entity. # of this type, given a code fragment for the entity.
...@@ -80,7 +80,7 @@ class PyrexType(BaseType): ...@@ -80,7 +80,7 @@ class PyrexType(BaseType):
# Coerces array type into pointer type for use as # Coerces array type into pointer type for use as
# a formal argument type. # a formal argument type.
# #
is_pyobject = 0 is_pyobject = 0
is_unspecified = 0 is_unspecified = 0
is_extension_type = 0 is_extension_type = 0
...@@ -108,44 +108,44 @@ class PyrexType(BaseType): ...@@ -108,44 +108,44 @@ class PyrexType(BaseType):
is_buffer = 0 is_buffer = 0
has_attributes = 0 has_attributes = 0
default_value = "" default_value = ""
def resolve(self): def resolve(self):
# If a typedef, returns the base type. # If a typedef, returns the base type.
return self return self
def specialize(self, values): def specialize(self, values):
# TODO(danilo): Override wherever it makes sense. # TODO(danilo): Override wherever it makes sense.
return self return self
def literal_code(self, value): def literal_code(self, value):
# Returns a C code fragment representing a literal # Returns a C code fragment representing a literal
# value of this type. # value of this type.
return str(value) return str(value)
def __str__(self): def __str__(self):
return self.declaration_code("", for_display = 1).strip() return self.declaration_code("", for_display = 1).strip()
def same_as(self, other_type, **kwds): def same_as(self, other_type, **kwds):
return self.same_as_resolved_type(other_type.resolve(), **kwds) return self.same_as_resolved_type(other_type.resolve(), **kwds)
def same_as_resolved_type(self, other_type): def same_as_resolved_type(self, other_type):
return self == other_type or other_type is error_type return self == other_type or other_type is error_type
def subtype_of(self, other_type): def subtype_of(self, other_type):
return self.subtype_of_resolved_type(other_type.resolve()) return self.subtype_of_resolved_type(other_type.resolve())
def subtype_of_resolved_type(self, other_type): def subtype_of_resolved_type(self, other_type):
return self.same_as(other_type) return self.same_as(other_type)
def assignable_from(self, src_type): def assignable_from(self, src_type):
return self.assignable_from_resolved_type(src_type.resolve()) return self.assignable_from_resolved_type(src_type.resolve())
def assignable_from_resolved_type(self, src_type): def assignable_from_resolved_type(self, src_type):
return self.same_as(src_type) return self.same_as(src_type)
def as_argument_type(self): def as_argument_type(self):
return self return self
def is_complete(self): def is_complete(self):
# A type is incomplete if it is an unsized array, # A type is incomplete if it is an unsized array,
# a struct whose attributes are not defined, etc. # a struct whose attributes are not defined, etc.
...@@ -167,7 +167,7 @@ def public_decl(base_code, dll_linkage): ...@@ -167,7 +167,7 @@ def public_decl(base_code, dll_linkage):
return "%s(%s)" % (dll_linkage, base_code) return "%s(%s)" % (dll_linkage, base_code)
else: else:
return base_code return base_code
def create_typedef_type(name, base_type, cname, is_external=0): def create_typedef_type(name, base_type, cname, is_external=0):
if base_type.is_complex: if base_type.is_complex:
if is_external: if is_external:
...@@ -189,38 +189,38 @@ class CTypedefType(BaseType): ...@@ -189,38 +189,38 @@ class CTypedefType(BaseType):
# typedef_cname string # typedef_cname string
# typedef_base_type PyrexType # typedef_base_type PyrexType
# typedef_is_external bool # typedef_is_external bool
is_typedef = 1 is_typedef = 1
typedef_is_external = 0 typedef_is_external = 0
to_py_utility_code = None to_py_utility_code = None
from_py_utility_code = None from_py_utility_code = None
def __init__(self, name, base_type, cname, is_external=0): def __init__(self, name, base_type, cname, is_external=0):
assert not base_type.is_complex assert not base_type.is_complex
self.typedef_name = name self.typedef_name = name
self.typedef_cname = cname self.typedef_cname = cname
self.typedef_base_type = base_type self.typedef_base_type = base_type
self.typedef_is_external = is_external self.typedef_is_external = is_external
def resolve(self): def resolve(self):
return self.typedef_base_type.resolve() return self.typedef_base_type.resolve()
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if pyrex or for_display: if pyrex or for_display:
base_code = self.typedef_name base_code = self.typedef_name
else: else:
base_code = public_decl(self.typedef_cname, dll_linkage) base_code = public_decl(self.typedef_cname, dll_linkage)
return self.base_declaration_code(base_code, entity_code) return self.base_declaration_code(base_code, entity_code)
def as_argument_type(self): def as_argument_type(self):
return self return self
def cast_code(self, expr_code): def cast_code(self, expr_code):
# If self is really an array (rather than pointer), we can't cast. # If self is really an array (rather than pointer), we can't cast.
# For example, the gmp mpz_t. # For example, the gmp mpz_t.
if self.typedef_base_type.is_array: if self.typedef_base_type.is_array:
base_type = self.typedef_base_type.base_type base_type = self.typedef_base_type.base_type
return CPtrType(base_type).cast_code(expr_code) return CPtrType(base_type).cast_code(expr_code)
...@@ -229,7 +229,7 @@ class CTypedefType(BaseType): ...@@ -229,7 +229,7 @@ class CTypedefType(BaseType):
def __repr__(self): def __repr__(self):
return "<CTypedefType %s>" % self.typedef_cname return "<CTypedefType %s>" % self.typedef_cname
def __str__(self): def __str__(self):
return self.typedef_name return self.typedef_name
...@@ -303,7 +303,7 @@ class BufferType(BaseType): ...@@ -303,7 +303,7 @@ class BufferType(BaseType):
# Delegates most attribute # Delegates most attribute
# lookups to the base type. ANYTHING NOT DEFINED # lookups to the base type. ANYTHING NOT DEFINED
# HERE IS DELEGATED! # HERE IS DELEGATED!
# dtype PyrexType # dtype PyrexType
# ndim int # ndim int
# mode str # mode str
...@@ -322,7 +322,7 @@ class BufferType(BaseType): ...@@ -322,7 +322,7 @@ class BufferType(BaseType):
self.mode = mode self.mode = mode
self.negative_indices = negative_indices self.negative_indices = negative_indices
self.cast = cast self.cast = cast
def as_argument_type(self): def as_argument_type(self):
return self return self
...@@ -345,10 +345,10 @@ class PyObjectType(PyrexType): ...@@ -345,10 +345,10 @@ class PyObjectType(PyrexType):
buffer_defaults = None buffer_defaults = None
is_extern = False is_extern = False
is_subclassed = False is_subclassed = False
def __str__(self): def __str__(self):
return "Python object" return "Python object"
def __repr__(self): def __repr__(self):
return "<PyObjectType>" return "<PyObjectType>"
...@@ -362,8 +362,8 @@ class PyObjectType(PyrexType): ...@@ -362,8 +362,8 @@ class PyObjectType(PyrexType):
def assignable_from(self, src_type): def assignable_from(self, src_type):
# except for pointers, conversion will be attempted # except for pointers, conversion will be attempted
return not src_type.is_ptr or src_type.is_string return not src_type.is_ptr or src_type.is_string
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if pyrex or for_display: if pyrex or for_display:
base_code = "object" base_code = "object"
...@@ -398,15 +398,15 @@ class BuiltinObjectType(PyObjectType): ...@@ -398,15 +398,15 @@ class BuiltinObjectType(PyObjectType):
self.cname = cname self.cname = cname
self.typeptr_cname = "(&%s)" % cname self.typeptr_cname = "(&%s)" % cname
self.objstruct_cname = objstruct_cname self.objstruct_cname = objstruct_cname
def set_scope(self, scope): def set_scope(self, scope):
self.scope = scope self.scope = scope
if scope: if scope:
scope.parent_type = self scope.parent_type = self
def __str__(self): def __str__(self):
return "%s object" % self.name return "%s object" % self.name
def __repr__(self): def __repr__(self):
return "<%s>"% self.cname return "<%s>"% self.cname
...@@ -427,13 +427,13 @@ class BuiltinObjectType(PyObjectType): ...@@ -427,13 +427,13 @@ class BuiltinObjectType(PyObjectType):
src_type.name == self.name) src_type.name == self.name)
else: else:
return True return True
def typeobj_is_available(self): def typeobj_is_available(self):
return True return True
def attributes_known(self): def attributes_known(self):
return True return True
def subtype_of(self, type): def subtype_of(self, type):
return type.is_pyobject and self.assignable_from(type) return type.is_pyobject and self.assignable_from(type)
...@@ -460,7 +460,7 @@ class BuiltinObjectType(PyObjectType): ...@@ -460,7 +460,7 @@ class BuiltinObjectType(PyObjectType):
error = '(PyErr_Format(PyExc_TypeError, "Expected %s, got %%.200s", Py_TYPE(%s)->tp_name), 0)' % (self.name, arg) error = '(PyErr_Format(PyExc_TypeError, "Expected %s, got %%.200s", Py_TYPE(%s)->tp_name), 0)' % (self.name, arg)
return check + '||' + error return check + '||' + error
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if pyrex or for_display: if pyrex or for_display:
base_code = self.name base_code = self.name
...@@ -493,12 +493,12 @@ class PyExtensionType(PyObjectType): ...@@ -493,12 +493,12 @@ class PyExtensionType(PyObjectType):
# vtabstruct_cname string Name of C method table struct # vtabstruct_cname string Name of C method table struct
# vtabptr_cname string Name of pointer to C method table # vtabptr_cname string Name of pointer to C method table
# vtable_cname string Name of C method table definition # vtable_cname string Name of C method table definition
is_extension_type = 1 is_extension_type = 1
has_attributes = 1 has_attributes = 1
objtypedef_cname = None objtypedef_cname = None
def __init__(self, name, typedef_flag, base_type, is_external=0): def __init__(self, name, typedef_flag, base_type, is_external=0):
self.name = name self.name = name
self.scope = None self.scope = None
...@@ -515,28 +515,28 @@ class PyExtensionType(PyObjectType): ...@@ -515,28 +515,28 @@ class PyExtensionType(PyObjectType):
self.vtabptr_cname = None self.vtabptr_cname = None
self.vtable_cname = None self.vtable_cname = None
self.is_external = is_external self.is_external = is_external
def set_scope(self, scope): def set_scope(self, scope):
self.scope = scope self.scope = scope
if scope: if scope:
scope.parent_type = self scope.parent_type = self
def subtype_of_resolved_type(self, other_type): def subtype_of_resolved_type(self, other_type):
if other_type.is_extension_type: if other_type.is_extension_type:
return self is other_type or ( return self is other_type or (
self.base_type and self.base_type.subtype_of(other_type)) self.base_type and self.base_type.subtype_of(other_type))
else: else:
return other_type is py_object_type return other_type is py_object_type
def typeobj_is_available(self): def typeobj_is_available(self):
# Do we have a pointer to the type object? # Do we have a pointer to the type object?
return self.typeptr_cname return self.typeptr_cname
def typeobj_is_imported(self): def typeobj_is_imported(self):
# If we don't know the C name of the type object but we do # If we don't know the C name of the type object but we do
# know which module it's defined in, it will be imported. # know which module it's defined in, it will be imported.
return self.typeobj_cname is None and self.module_name is not None return self.typeobj_cname is None and self.module_name is not None
def assignable_from(self, src_type): def assignable_from(self, src_type):
if self == src_type: if self == src_type:
return True return True
...@@ -545,7 +545,7 @@ class PyExtensionType(PyObjectType): ...@@ -545,7 +545,7 @@ class PyExtensionType(PyObjectType):
return self.assignable_from(src_type.base_type) return self.assignable_from(src_type.base_type)
return False return False
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0, deref = 0): for_display = 0, dll_linkage = None, pyrex = 0, deref = 0):
if pyrex or for_display: if pyrex or for_display:
base_code = self.name base_code = self.name
...@@ -573,14 +573,14 @@ class PyExtensionType(PyObjectType): ...@@ -573,14 +573,14 @@ class PyExtensionType(PyObjectType):
def attributes_known(self): def attributes_known(self):
return self.scope is not None return self.scope is not None
def __str__(self): def __str__(self):
return self.name return self.name
def __repr__(self): def __repr__(self):
return "<PyExtensionType %s%s>" % (self.scope.class_name, return "<PyExtensionType %s%s>" % (self.scope.class_name,
("", " typedef")[self.typedef_flag]) ("", " typedef")[self.typedef_flag])
class CType(PyrexType): class CType(PyrexType):
# #
...@@ -589,7 +589,7 @@ class CType(PyrexType): ...@@ -589,7 +589,7 @@ class CType(PyrexType):
# to_py_function string C function for converting to Python object # to_py_function string C function for converting to Python object
# from_py_function string C function for constructing from Python object # from_py_function string C function for constructing from Python object
# #
to_py_function = None to_py_function = None
from_py_function = None from_py_function = None
exception_value = None exception_value = None
...@@ -597,7 +597,7 @@ class CType(PyrexType): ...@@ -597,7 +597,7 @@ class CType(PyrexType):
def create_to_py_utility_code(self, env): def create_to_py_utility_code(self, env):
return self.to_py_function is not None return self.to_py_function is not None
def create_from_py_utility_code(self, env): def create_from_py_utility_code(self, env):
return self.from_py_function is not None return self.from_py_function is not None
...@@ -624,18 +624,18 @@ class CVoidType(CType): ...@@ -624,18 +624,18 @@ class CVoidType(CType):
# #
is_void = 1 is_void = 1
def __repr__(self): def __repr__(self):
return "<CVoidType>" return "<CVoidType>"
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if pyrex or for_display: if pyrex or for_display:
base_code = "void" base_code = "void"
else: else:
base_code = public_decl("void", dll_linkage) base_code = public_decl("void", dll_linkage)
return self.base_declaration_code(base_code, entity_code) return self.base_declaration_code(base_code, entity_code)
def is_complete(self): def is_complete(self):
return 0 return 0
...@@ -647,27 +647,27 @@ class CNumericType(CType): ...@@ -647,27 +647,27 @@ class CNumericType(CType):
# rank integer Relative size # rank integer Relative size
# signed integer 0 = unsigned, 1 = unspecified, 2 = explicitly signed # signed integer 0 = unsigned, 1 = unspecified, 2 = explicitly signed
# #
is_numeric = 1 is_numeric = 1
default_value = "0" default_value = "0"
has_attributes = True has_attributes = True
scope = None scope = None
sign_words = ("unsigned ", "", "signed ") sign_words = ("unsigned ", "", "signed ")
def __init__(self, rank, signed = 1): def __init__(self, rank, signed = 1):
self.rank = rank self.rank = rank
self.signed = signed self.signed = signed
def sign_and_name(self): def sign_and_name(self):
s = self.sign_words[self.signed] s = self.sign_words[self.signed]
n = rank_to_type_name[self.rank] n = rank_to_type_name[self.rank]
return s + n return s + n
def __repr__(self): def __repr__(self):
return "<CNumericType %s>" % self.sign_and_name() return "<CNumericType %s>" % self.sign_and_name()
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
type_name = self.sign_and_name() type_name = self.sign_and_name()
if pyrex or for_display: if pyrex or for_display:
...@@ -675,7 +675,7 @@ class CNumericType(CType): ...@@ -675,7 +675,7 @@ class CNumericType(CType):
else: else:
base_code = public_decl(type_name, dll_linkage) base_code = public_decl(type_name, dll_linkage)
return self.base_declaration_code(base_code, entity_code) return self.base_declaration_code(base_code, entity_code)
def attributes_known(self): def attributes_known(self):
if self.scope is None: if self.scope is None:
import Symtab import Symtab
...@@ -846,7 +846,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_%(TypeName)s(%(type)s val) { ...@@ -846,7 +846,7 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_%(TypeName)s(%(type)s val) {
} else { } else {
int one = 1; int little = (int)*(unsigned char *)&one; int one = 1; int little = (int)*(unsigned char *)&one;
unsigned char *bytes = (unsigned char *)&val; unsigned char *bytes = (unsigned char *)&val;
return _PyLong_FromByteArray(bytes, sizeof(%(type)s), return _PyLong_FromByteArray(bytes, sizeof(%(type)s),
little, !is_unsigned); little, !is_unsigned);
} }
} }
...@@ -1101,22 +1101,22 @@ class CFloatType(CNumericType): ...@@ -1101,22 +1101,22 @@ class CFloatType(CNumericType):
from_py_function = "__pyx_PyFloat_AsDouble" from_py_function = "__pyx_PyFloat_AsDouble"
exception_value = -1 exception_value = -1
def __init__(self, rank, math_h_modifier = ''): def __init__(self, rank, math_h_modifier = ''):
CNumericType.__init__(self, rank, 1) CNumericType.__init__(self, rank, 1)
self.math_h_modifier = math_h_modifier self.math_h_modifier = math_h_modifier
def assignable_from_resolved_type(self, src_type): def assignable_from_resolved_type(self, src_type):
return (src_type.is_numeric and not src_type.is_complex) or src_type is error_type return (src_type.is_numeric and not src_type.is_complex) or src_type is error_type
class CComplexType(CNumericType): class CComplexType(CNumericType):
is_complex = 1 is_complex = 1
to_py_function = "__pyx_PyComplex_FromComplex" to_py_function = "__pyx_PyComplex_FromComplex"
has_attributes = 1 has_attributes = 1
scope = None scope = None
def __init__(self, real_type): def __init__(self, real_type):
while real_type.is_typedef and not real_type.typedef_is_external: while real_type.is_typedef and not real_type.typedef_is_external:
real_type = real_type.typedef_base_type real_type = real_type.typedef_base_type
...@@ -1128,7 +1128,7 @@ class CComplexType(CNumericType): ...@@ -1128,7 +1128,7 @@ class CComplexType(CNumericType):
self.funcsuffix = real_type.math_h_modifier self.funcsuffix = real_type.math_h_modifier
else: else:
self.funcsuffix = "_%s" % real_type.specialization_name() self.funcsuffix = "_%s" % real_type.specialization_name()
self.real_type = real_type self.real_type = real_type
CNumericType.__init__(self, real_type.rank + 0.5, real_type.signed) CNumericType.__init__(self, real_type.rank + 0.5, real_type.signed)
self.binops = {} self.binops = {}
...@@ -1140,7 +1140,7 @@ class CComplexType(CNumericType): ...@@ -1140,7 +1140,7 @@ class CComplexType(CNumericType):
return self.real_type == other.real_type return self.real_type == other.real_type
else: else:
return False return False
def __ne__(self, other): def __ne__(self, other):
if isinstance(self, CComplexType) and isinstance(other, CComplexType): if isinstance(self, CComplexType) and isinstance(other, CComplexType):
return self.real_type != other.real_type return self.real_type != other.real_type
...@@ -1158,7 +1158,7 @@ class CComplexType(CNumericType): ...@@ -1158,7 +1158,7 @@ class CComplexType(CNumericType):
def __hash__(self): def __hash__(self):
return ~hash(self.real_type) return ~hash(self.real_type)
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if pyrex or for_display: if pyrex or for_display:
real_code = self.real_type.declaration_code("", for_display, dll_linkage, pyrex) real_code = self.real_type.declaration_code("", for_display, dll_linkage, pyrex)
...@@ -1172,7 +1172,7 @@ class CComplexType(CNumericType): ...@@ -1172,7 +1172,7 @@ class CComplexType(CNumericType):
real_type_name = real_type_name.replace('long__double','long_double') real_type_name = real_type_name.replace('long__double','long_double')
real_type_name = real_type_name.replace('PY_LONG_LONG','long_long') real_type_name = real_type_name.replace('PY_LONG_LONG','long_long')
return Naming.type_prefix + real_type_name + "_complex" return Naming.type_prefix + real_type_name + "_complex"
def assignable_from(self, src_type): def assignable_from(self, src_type):
# Temporary hack/feature disabling, see #441 # Temporary hack/feature disabling, see #441
if (not src_type.is_complex and src_type.is_numeric and src_type.is_typedef if (not src_type.is_complex and src_type.is_numeric and src_type.is_typedef
...@@ -1180,12 +1180,12 @@ class CComplexType(CNumericType): ...@@ -1180,12 +1180,12 @@ class CComplexType(CNumericType):
return False return False
else: else:
return super(CComplexType, self).assignable_from(src_type) return super(CComplexType, self).assignable_from(src_type)
def assignable_from_resolved_type(self, src_type): 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) 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_numeric and self.real_type.assignable_from_resolved_type(src_type)
or src_type is error_type) or src_type is error_type)
def attributes_known(self): def attributes_known(self):
if self.scope is None: if self.scope is None:
import Symtab import Symtab
...@@ -1216,7 +1216,7 @@ class CComplexType(CNumericType): ...@@ -1216,7 +1216,7 @@ class CComplexType(CNumericType):
complex_arithmetic_utility_code): complex_arithmetic_utility_code):
env.use_utility_code( env.use_utility_code(
utility_code.specialize( utility_code.specialize(
self, self,
real_type = self.real_type.declaration_code(''), real_type = self.real_type.declaration_code(''),
m = self.funcsuffix, m = self.funcsuffix,
is_float = self.real_type.is_float)) is_float = self.real_type.is_float))
...@@ -1234,13 +1234,13 @@ class CComplexType(CNumericType): ...@@ -1234,13 +1234,13 @@ class CComplexType(CNumericType):
complex_from_py_utility_code): complex_from_py_utility_code):
env.use_utility_code( env.use_utility_code(
utility_code.specialize( utility_code.specialize(
self, self,
real_type = self.real_type.declaration_code(''), real_type = self.real_type.declaration_code(''),
m = self.funcsuffix, m = self.funcsuffix,
is_float = self.real_type.is_float)) is_float = self.real_type.is_float))
self.from_py_function = "__Pyx_PyComplex_As_" + self.specialization_name() self.from_py_function = "__Pyx_PyComplex_As_" + self.specialization_name()
return True return True
def lookup_op(self, nargs, op): def lookup_op(self, nargs, op):
try: try:
return self.binops[nargs, op] return self.binops[nargs, op]
...@@ -1255,10 +1255,10 @@ class CComplexType(CNumericType): ...@@ -1255,10 +1255,10 @@ class CComplexType(CNumericType):
def unary_op(self, op): def unary_op(self, op):
return self.lookup_op(1, op) return self.lookup_op(1, op)
def binary_op(self, op): def binary_op(self, op):
return self.lookup_op(2, op) return self.lookup_op(2, op)
complex_ops = { complex_ops = {
(1, '-'): 'neg', (1, '-'): 'neg',
(1, 'zero'): 'is_zero', (1, 'zero'): 'is_zero',
...@@ -1529,31 +1529,31 @@ impl=""" ...@@ -1529,31 +1529,31 @@ impl="""
class CArrayType(CType): class CArrayType(CType):
# base_type CType Element type # base_type CType Element type
# size integer or None Number of elements # size integer or None Number of elements
is_array = 1 is_array = 1
def __init__(self, base_type, size): def __init__(self, base_type, size):
self.base_type = base_type self.base_type = base_type
self.size = size self.size = size
if base_type in (c_char_type, c_uchar_type, c_schar_type): if base_type in (c_char_type, c_uchar_type, c_schar_type):
self.is_string = 1 self.is_string = 1
def __repr__(self): def __repr__(self):
return "<CArrayType %s %s>" % (self.size, repr(self.base_type)) return "<CArrayType %s %s>" % (self.size, repr(self.base_type))
def same_as_resolved_type(self, other_type): def same_as_resolved_type(self, other_type):
return ((other_type.is_array and return ((other_type.is_array and
self.base_type.same_as(other_type.base_type)) self.base_type.same_as(other_type.base_type))
or other_type is error_type) or other_type is error_type)
def assignable_from_resolved_type(self, src_type): def assignable_from_resolved_type(self, src_type):
# Can't assign to a variable of an array type # Can't assign to a variable of an array type
return 0 return 0
def element_ptr_type(self): def element_ptr_type(self):
return c_ptr_type(self.base_type) return c_ptr_type(self.base_type)
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if self.size is not None: if self.size is not None:
dimension_code = self.size dimension_code = self.size
...@@ -1564,38 +1564,38 @@ class CArrayType(CType): ...@@ -1564,38 +1564,38 @@ class CArrayType(CType):
return self.base_type.declaration_code( return self.base_type.declaration_code(
"%s[%s]" % (entity_code, dimension_code), "%s[%s]" % (entity_code, dimension_code),
for_display, dll_linkage, pyrex) for_display, dll_linkage, pyrex)
def as_argument_type(self): def as_argument_type(self):
return c_ptr_type(self.base_type) return c_ptr_type(self.base_type)
def is_complete(self): def is_complete(self):
return self.size is not None return self.size is not None
class CPtrType(CType): class CPtrType(CType):
# base_type CType Referenced type # base_type CType Referenced type
is_ptr = 1 is_ptr = 1
default_value = "0" default_value = "0"
def __init__(self, base_type): def __init__(self, base_type):
self.base_type = base_type self.base_type = base_type
def __repr__(self): def __repr__(self):
return "<CPtrType %s>" % repr(self.base_type) return "<CPtrType %s>" % repr(self.base_type)
def same_as_resolved_type(self, other_type): def same_as_resolved_type(self, other_type):
return ((other_type.is_ptr and return ((other_type.is_ptr and
self.base_type.same_as(other_type.base_type)) self.base_type.same_as(other_type.base_type))
or other_type is error_type) or other_type is error_type)
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
#print "CPtrType.declaration_code: pointer to", self.base_type ### #print "CPtrType.declaration_code: pointer to", self.base_type ###
return self.base_type.declaration_code( return self.base_type.declaration_code(
"*%s" % entity_code, "*%s" % entity_code,
for_display, dll_linkage, pyrex) for_display, dll_linkage, pyrex)
def assignable_from_resolved_type(self, other_type): def assignable_from_resolved_type(self, other_type):
if other_type is error_type: if other_type is error_type:
return 1 return 1
...@@ -1608,13 +1608,13 @@ class CPtrType(CType): ...@@ -1608,13 +1608,13 @@ class CPtrType(CType):
return self.base_type.pointer_assignable_from_resolved_type(other_type) return self.base_type.pointer_assignable_from_resolved_type(other_type)
else: else:
return 0 return 0
if (self.base_type.is_cpp_class and other_type.is_ptr if (self.base_type.is_cpp_class and other_type.is_ptr
and other_type.base_type.is_cpp_class and other_type.base_type.is_subclass(self.base_type)): and other_type.base_type.is_cpp_class and other_type.base_type.is_subclass(self.base_type)):
return 1 return 1
if other_type.is_array or other_type.is_ptr: if other_type.is_array or other_type.is_ptr:
return self.base_type.is_void or self.base_type.same_as(other_type.base_type) return self.base_type.is_void or self.base_type.same_as(other_type.base_type)
return 0 return 0
def specialize(self, values): def specialize(self, values):
base_type = self.base_type.specialize(values) base_type = self.base_type.specialize(values)
if base_type == self.base_type: if base_type == self.base_type:
...@@ -1626,7 +1626,7 @@ class CPtrType(CType): ...@@ -1626,7 +1626,7 @@ class CPtrType(CType):
class CNullPtrType(CPtrType): class CNullPtrType(CPtrType):
is_null_ptr = 1 is_null_ptr = 1
class CReferenceType(BaseType): class CReferenceType(BaseType):
...@@ -1637,20 +1637,20 @@ class CReferenceType(BaseType): ...@@ -1637,20 +1637,20 @@ class CReferenceType(BaseType):
def __repr__(self): def __repr__(self):
return "<CReferenceType %s>" % repr(self.ref_base_type) return "<CReferenceType %s>" % repr(self.ref_base_type)
def __str__(self): def __str__(self):
return "%s &" % self.ref_base_type return "%s &" % self.ref_base_type
def as_argument_type(self): def as_argument_type(self):
return self return self
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
#print "CReferenceType.declaration_code: pointer to", self.base_type ### #print "CReferenceType.declaration_code: pointer to", self.base_type ###
return self.ref_base_type.declaration_code( return self.ref_base_type.declaration_code(
"&%s" % entity_code, "&%s" % entity_code,
for_display, dll_linkage, pyrex) for_display, dll_linkage, pyrex)
def specialize(self, values): def specialize(self, values):
base_type = self.ref_base_type.specialize(values) base_type = self.ref_base_type.specialize(values)
if base_type == self.ref_base_type: if base_type == self.ref_base_type:
...@@ -1672,10 +1672,10 @@ class CFuncType(CType): ...@@ -1672,10 +1672,10 @@ class CFuncType(CType):
# nogil boolean Can be called without gil # nogil boolean Can be called without gil
# with_gil boolean Acquire gil around function body # with_gil boolean Acquire gil around function body
# templates [string] or None # templates [string] or None
is_cfunction = 1 is_cfunction = 1
original_sig = None original_sig = None
def __init__(self, return_type, args, has_varargs = 0, def __init__(self, return_type, args, has_varargs = 0,
exception_value = None, exception_check = 0, calling_convention = "", exception_value = None, exception_check = 0, calling_convention = "",
nogil = 0, with_gil = 0, is_overridable = 0, optional_arg_count = 0, nogil = 0, with_gil = 0, is_overridable = 0, optional_arg_count = 0,
...@@ -1691,7 +1691,7 @@ class CFuncType(CType): ...@@ -1691,7 +1691,7 @@ class CFuncType(CType):
self.with_gil = with_gil self.with_gil = with_gil
self.is_overridable = is_overridable self.is_overridable = is_overridable
self.templates = templates self.templates = templates
def __repr__(self): def __repr__(self):
arg_reprs = map(repr, self.args) arg_reprs = map(repr, self.args)
if self.has_varargs: if self.has_varargs:
...@@ -1707,14 +1707,14 @@ class CFuncType(CType): ...@@ -1707,14 +1707,14 @@ class CFuncType(CType):
self.calling_convention_prefix(), self.calling_convention_prefix(),
",".join(arg_reprs), ",".join(arg_reprs),
except_clause) except_clause)
def calling_convention_prefix(self): def calling_convention_prefix(self):
cc = self.calling_convention cc = self.calling_convention
if cc: if cc:
return cc + " " return cc + " "
else: else:
return "" return ""
def same_c_signature_as(self, other_type, as_cmethod = 0): def same_c_signature_as(self, other_type, as_cmethod = 0):
return self.same_c_signature_as_resolved_type( return self.same_c_signature_as_resolved_type(
other_type.resolve(), as_cmethod) other_type.resolve(), as_cmethod)
...@@ -1750,7 +1750,7 @@ class CFuncType(CType): ...@@ -1750,7 +1750,7 @@ class CFuncType(CType):
def compatible_signature_with(self, other_type, as_cmethod = 0): def compatible_signature_with(self, other_type, as_cmethod = 0):
return self.compatible_signature_with_resolved_type(other_type.resolve(), as_cmethod) return self.compatible_signature_with_resolved_type(other_type.resolve(), as_cmethod)
def compatible_signature_with_resolved_type(self, other_type, as_cmethod): def compatible_signature_with_resolved_type(self, other_type, as_cmethod):
#print "CFuncType.same_c_signature_as_resolved_type:", \ #print "CFuncType.same_c_signature_as_resolved_type:", \
# self, other_type, "as_cmethod =", as_cmethod ### # self, other_type, "as_cmethod =", as_cmethod ###
...@@ -1784,11 +1784,11 @@ class CFuncType(CType): ...@@ -1784,11 +1784,11 @@ class CFuncType(CType):
if as_cmethod: if as_cmethod:
self.args[0] = other_type.args[0] self.args[0] = other_type.args[0]
return 1 return 1
def narrower_c_signature_than(self, other_type, as_cmethod = 0): def narrower_c_signature_than(self, other_type, as_cmethod = 0):
return self.narrower_c_signature_than_resolved_type(other_type.resolve(), as_cmethod) return self.narrower_c_signature_than_resolved_type(other_type.resolve(), as_cmethod)
def narrower_c_signature_than_resolved_type(self, other_type, as_cmethod): def narrower_c_signature_than_resolved_type(self, other_type, as_cmethod):
if other_type is error_type: if other_type is error_type:
return 1 return 1
...@@ -1824,7 +1824,7 @@ class CFuncType(CType): ...@@ -1824,7 +1824,7 @@ class CFuncType(CType):
sc1 = self.calling_convention == '__stdcall' sc1 = self.calling_convention == '__stdcall'
sc2 = other.calling_convention == '__stdcall' sc2 = other.calling_convention == '__stdcall'
return sc1 == sc2 return sc1 == sc2
def same_exception_signature_as(self, other_type): def same_exception_signature_as(self, other_type):
return self.same_exception_signature_as_resolved_type( return self.same_exception_signature_as_resolved_type(
other_type.resolve()) other_type.resolve())
...@@ -1832,18 +1832,18 @@ class CFuncType(CType): ...@@ -1832,18 +1832,18 @@ class CFuncType(CType):
def same_exception_signature_as_resolved_type(self, other_type): def same_exception_signature_as_resolved_type(self, other_type):
return self.exception_value == other_type.exception_value \ return self.exception_value == other_type.exception_value \
and self.exception_check == other_type.exception_check and self.exception_check == other_type.exception_check
def same_as_resolved_type(self, other_type, as_cmethod = 0): def same_as_resolved_type(self, other_type, as_cmethod = 0):
return self.same_c_signature_as_resolved_type(other_type, as_cmethod) \ return self.same_c_signature_as_resolved_type(other_type, as_cmethod) \
and self.same_exception_signature_as_resolved_type(other_type) \ and self.same_exception_signature_as_resolved_type(other_type) \
and self.nogil == other_type.nogil and self.nogil == other_type.nogil
def pointer_assignable_from_resolved_type(self, other_type): def pointer_assignable_from_resolved_type(self, other_type):
return self.same_c_signature_as_resolved_type(other_type) \ return self.same_c_signature_as_resolved_type(other_type) \
and self.same_exception_signature_as_resolved_type(other_type) \ and self.same_exception_signature_as_resolved_type(other_type) \
and not (self.nogil and not other_type.nogil) and not (self.nogil and not other_type.nogil)
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0, for_display = 0, dll_linkage = None, pyrex = 0,
with_calling_convention = 1): with_calling_convention = 1):
arg_decl_list = [] arg_decl_list = []
...@@ -1881,7 +1881,7 @@ class CFuncType(CType): ...@@ -1881,7 +1881,7 @@ class CFuncType(CType):
return self.return_type.declaration_code( return self.return_type.declaration_code(
"%s%s(%s)%s" % (cc, entity_code, arg_decl_code, trailer), "%s%s(%s)%s" % (cc, entity_code, arg_decl_code, trailer),
for_display, dll_linkage, pyrex) for_display, dll_linkage, pyrex)
def function_header_code(self, func_name, arg_code): def function_header_code(self, func_name, arg_code):
return "%s%s(%s)" % (self.calling_convention_prefix(), return "%s%s(%s)" % (self.calling_convention_prefix(),
func_name, arg_code) func_name, arg_code)
...@@ -1893,7 +1893,7 @@ class CFuncType(CType): ...@@ -1893,7 +1893,7 @@ class CFuncType(CType):
def signature_cast_string(self): def signature_cast_string(self):
s = self.declaration_code("(*)", with_calling_convention=False) s = self.declaration_code("(*)", with_calling_convention=False)
return '(%s)' % s return '(%s)' % s
def specialize(self, values): def specialize(self, values):
if self.templates is None: if self.templates is None:
new_templates = None new_templates = None
...@@ -1910,7 +1910,7 @@ class CFuncType(CType): ...@@ -1910,7 +1910,7 @@ class CFuncType(CType):
is_overridable = self.is_overridable, is_overridable = self.is_overridable,
optional_arg_count = self.optional_arg_count, optional_arg_count = self.optional_arg_count,
templates = new_templates) templates = new_templates)
def opt_arg_cname(self, arg_name): def opt_arg_cname(self, arg_name):
return self.op_arg_struct.base_type.scope.lookup(arg_name).cname return self.op_arg_struct.base_type.scope.lookup(arg_name).cname
...@@ -1935,13 +1935,13 @@ class CFuncTypeArg(object): ...@@ -1935,13 +1935,13 @@ class CFuncTypeArg(object):
self.type = type self.type = type
self.pos = pos self.pos = pos
self.needs_type_test = False # TODO: should these defaults be set in analyse_types()? self.needs_type_test = False # TODO: should these defaults be set in analyse_types()?
def __repr__(self): def __repr__(self):
return "%s:%s" % (self.name, repr(self.type)) return "%s:%s" % (self.name, repr(self.type))
def declaration_code(self, for_display = 0): def declaration_code(self, for_display = 0):
return self.type.declaration_code(self.cname, for_display) return self.type.declaration_code(self.cname, for_display)
def specialize(self, values): def specialize(self, values):
return CFuncTypeArg(self.name, self.type.specialize(values), self.pos, self.cname) return CFuncTypeArg(self.name, self.type.specialize(values), self.pos, self.cname)
...@@ -1955,11 +1955,11 @@ class StructUtilityCode(object): ...@@ -1955,11 +1955,11 @@ class StructUtilityCode(object):
return isinstance(other, StructUtilityCode) and self.header == other.header return isinstance(other, StructUtilityCode) and self.header == other.header
def __hash__(self): def __hash__(self):
return hash(self.header) return hash(self.header)
def put_code(self, output): def put_code(self, output):
code = output['utility_code_def'] code = output['utility_code_def']
proto = output['utility_code_proto'] proto = output['utility_code_proto']
code.putln("%s {" % self.header) code.putln("%s {" % self.header)
code.putln("PyObject* res;") code.putln("PyObject* res;")
code.putln("PyObject* member;") code.putln("PyObject* member;")
...@@ -1982,7 +1982,7 @@ class StructUtilityCode(object): ...@@ -1982,7 +1982,7 @@ class StructUtilityCode(object):
if self.forward_decl: if self.forward_decl:
proto.putln(self.type.declaration_code('') + ';') proto.putln(self.type.declaration_code('') + ';')
proto.putln(self.header + ";") proto.putln(self.header + ";")
class CStructOrUnionType(CType): class CStructOrUnionType(CType):
# name string # name string
...@@ -1991,12 +1991,12 @@ class CStructOrUnionType(CType): ...@@ -1991,12 +1991,12 @@ class CStructOrUnionType(CType):
# scope StructOrUnionScope, or None if incomplete # scope StructOrUnionScope, or None if incomplete
# typedef_flag boolean # typedef_flag boolean
# packed boolean # packed boolean
# entry Entry # entry Entry
is_struct_or_union = 1 is_struct_or_union = 1
has_attributes = 1 has_attributes = 1
def __init__(self, name, kind, scope, typedef_flag, cname, packed=False): def __init__(self, name, kind, scope, typedef_flag, cname, packed=False):
self.name = name self.name = name
self.cname = cname self.cname = cname
...@@ -2009,7 +2009,7 @@ class CStructOrUnionType(CType): ...@@ -2009,7 +2009,7 @@ class CStructOrUnionType(CType):
self.exception_check = True self.exception_check = True
self._convert_code = None self._convert_code = None
self.packed = packed self.packed = packed
def create_to_py_utility_code(self, env): def create_to_py_utility_code(self, env):
if env.outer_scope is None: if env.outer_scope is None:
return False return False
...@@ -2024,15 +2024,15 @@ class CStructOrUnionType(CType): ...@@ -2024,15 +2024,15 @@ class CStructOrUnionType(CType):
return False return False
forward_decl = (self.entry.visibility != 'extern') forward_decl = (self.entry.visibility != 'extern')
self._convert_code = StructUtilityCode(self, forward_decl) self._convert_code = StructUtilityCode(self, forward_decl)
env.use_utility_code(self._convert_code) env.use_utility_code(self._convert_code)
return True return True
def __repr__(self): def __repr__(self):
return "<CStructOrUnionType %s %s%s>" % (self.name, self.cname, return "<CStructOrUnionType %s %s%s>" % (self.name, self.cname,
("", " typedef")[self.typedef_flag]) ("", " typedef")[self.typedef_flag])
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if pyrex or for_display: if pyrex or for_display:
base_code = self.name base_code = self.name
...@@ -2064,7 +2064,7 @@ class CStructOrUnionType(CType): ...@@ -2064,7 +2064,7 @@ class CStructOrUnionType(CType):
def is_complete(self): def is_complete(self):
return self.scope is not None return self.scope is not None
def attributes_known(self): def attributes_known(self):
return self.is_complete() return self.is_complete()
...@@ -2087,12 +2087,12 @@ class CppClassType(CType): ...@@ -2087,12 +2087,12 @@ class CppClassType(CType):
# cname string # cname string
# scope CppClassScope # scope CppClassScope
# templates [string] or None # templates [string] or None
is_cpp_class = 1 is_cpp_class = 1
has_attributes = 1 has_attributes = 1
exception_check = True exception_check = True
namespace = None namespace = None
def __init__(self, name, scope, cname, base_classes, templates = None, template_type = None): def __init__(self, name, scope, cname, base_classes, templates = None, template_type = None):
self.name = name self.name = name
self.cname = cname self.cname = cname
...@@ -2108,11 +2108,11 @@ class CppClassType(CType): ...@@ -2108,11 +2108,11 @@ class CppClassType(CType):
error(pos, "'%s' type is not a template" % self); error(pos, "'%s' type is not a template" % self);
return PyrexTypes.error_type return PyrexTypes.error_type
if len(self.templates) != len(template_values): if len(self.templates) != len(template_values):
error(pos, "%s templated type receives %d arguments, got %d" % error(pos, "%s templated type receives %d arguments, got %d" %
(self.name, len(self.templates), len(template_values))) (self.name, len(self.templates), len(template_values)))
return error_type return error_type
return self.specialize(dict(zip(self.templates, template_values))) return self.specialize(dict(zip(self.templates, template_values)))
def specialize(self, values): def specialize(self, values):
if not self.templates and not self.namespace: if not self.templates and not self.namespace:
return self return self
...@@ -2159,7 +2159,7 @@ class CppClassType(CType): ...@@ -2159,7 +2159,7 @@ class CppClassType(CType):
if base_class.is_subclass(other_type): if base_class.is_subclass(other_type):
return 1 return 1
return 0 return 0
def same_as_resolved_type(self, other_type): def same_as_resolved_type(self, other_type):
if other_type.is_cpp_class: if other_type.is_cpp_class:
if self == other_type: if self == other_type:
...@@ -2178,23 +2178,23 @@ class CppClassType(CType): ...@@ -2178,23 +2178,23 @@ class CppClassType(CType):
if other_type is error_type: if other_type is error_type:
return True return True
return other_type.is_cpp_class and other_type.is_subclass(self) return other_type.is_cpp_class and other_type.is_subclass(self)
def attributes_known(self): def attributes_known(self):
return self.scope is not None return self.scope is not None
class TemplatePlaceholderType(CType): class TemplatePlaceholderType(CType):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if entity_code: if entity_code:
return self.name + " " + entity_code return self.name + " " + entity_code
else: else:
return self.name return self.name
def specialize(self, values): def specialize(self, values):
if self in values: if self in values:
return values[self] return values[self]
...@@ -2206,10 +2206,10 @@ class TemplatePlaceholderType(CType): ...@@ -2206,10 +2206,10 @@ class TemplatePlaceholderType(CType):
return self.name == other_type.name return self.name == other_type.name
else: else:
return 0 return 0
def __hash__(self): def __hash__(self):
return hash(self.name) return hash(self.name)
def __cmp__(self, other): def __cmp__(self, other):
if isinstance(other, TemplatePlaceholderType): if isinstance(other, TemplatePlaceholderType):
return cmp(self.name, other.name) return cmp(self.name, other.name)
...@@ -2232,15 +2232,15 @@ class CEnumType(CType): ...@@ -2232,15 +2232,15 @@ class CEnumType(CType):
self.cname = cname self.cname = cname
self.values = [] self.values = []
self.typedef_flag = typedef_flag self.typedef_flag = typedef_flag
def __str__(self): def __str__(self):
return self.name return self.name
def __repr__(self): def __repr__(self):
return "<CEnumType %s %s%s>" % (self.name, self.cname, return "<CEnumType %s %s%s>" % (self.name, self.cname,
("", " typedef")[self.typedef_flag]) ("", " typedef")[self.typedef_flag])
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
if pyrex or for_display: if pyrex or for_display:
base_code = self.name base_code = self.name
...@@ -2258,7 +2258,7 @@ class CStringType(object): ...@@ -2258,7 +2258,7 @@ class CStringType(object):
is_string = 1 is_string = 1
is_unicode = 0 is_unicode = 0
to_py_function = "PyBytes_FromString" to_py_function = "PyBytes_FromString"
from_py_function = "PyBytes_AsString" from_py_function = "PyBytes_AsString"
exception_value = "NULL" exception_value = "NULL"
...@@ -2270,32 +2270,32 @@ class CStringType(object): ...@@ -2270,32 +2270,32 @@ class CStringType(object):
class CUTF8CharArrayType(CStringType, CArrayType): class CUTF8CharArrayType(CStringType, CArrayType):
# C 'char []' type. # C 'char []' type.
is_unicode = 1 is_unicode = 1
to_py_function = "PyUnicode_DecodeUTF8" to_py_function = "PyUnicode_DecodeUTF8"
exception_value = "NULL" exception_value = "NULL"
def __init__(self, size): def __init__(self, size):
CArrayType.__init__(self, c_char_type, size) CArrayType.__init__(self, c_char_type, size)
class CCharArrayType(CStringType, CArrayType): class CCharArrayType(CStringType, CArrayType):
# C 'char []' type. # C 'char []' type.
def __init__(self, size): def __init__(self, size):
CArrayType.__init__(self, c_char_type, size) CArrayType.__init__(self, c_char_type, size)
class CCharPtrType(CStringType, CPtrType): class CCharPtrType(CStringType, CPtrType):
# C 'char *' type. # C 'char *' type.
def __init__(self): def __init__(self):
CPtrType.__init__(self, c_char_type) CPtrType.__init__(self, c_char_type)
class CUCharPtrType(CStringType, CPtrType): class CUCharPtrType(CStringType, CPtrType):
# C 'unsigned char *' type. # C 'unsigned char *' type.
to_py_function = "__Pyx_PyBytes_FromUString" to_py_function = "__Pyx_PyBytes_FromUString"
from_py_function = "__Pyx_PyBytes_AsUString" from_py_function = "__Pyx_PyBytes_AsUString"
...@@ -2305,39 +2305,39 @@ class CUCharPtrType(CStringType, CPtrType): ...@@ -2305,39 +2305,39 @@ class CUCharPtrType(CStringType, CPtrType):
class UnspecifiedType(PyrexType): class UnspecifiedType(PyrexType):
# Used as a placeholder until the type can be determined. # Used as a placeholder until the type can be determined.
is_unspecified = 1 is_unspecified = 1
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
return "<unspecified>" return "<unspecified>"
def same_as_resolved_type(self, other_type): def same_as_resolved_type(self, other_type):
return False return False
class ErrorType(PyrexType): class ErrorType(PyrexType):
# Used to prevent propagation of error messages. # Used to prevent propagation of error messages.
is_error = 1 is_error = 1
exception_value = "0" exception_value = "0"
exception_check = 0 exception_check = 0
to_py_function = "dummy" to_py_function = "dummy"
from_py_function = "dummy" from_py_function = "dummy"
def create_to_py_utility_code(self, env): def create_to_py_utility_code(self, env):
return True return True
def create_from_py_utility_code(self, env): def create_from_py_utility_code(self, env):
return True return True
def declaration_code(self, entity_code, def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0): for_display = 0, dll_linkage = None, pyrex = 0):
return "<error>" return "<error>"
def same_as_resolved_type(self, other_type): def same_as_resolved_type(self, other_type):
return 1 return 1
def error_condition(self, result_code): def error_condition(self, result_code):
return "dummy" return "dummy"
...@@ -2467,7 +2467,7 @@ modifiers_and_name_to_type = { ...@@ -2467,7 +2467,7 @@ modifiers_and_name_to_type = {
def is_promotion(src_type, dst_type): def is_promotion(src_type, dst_type):
# It's hard to find a hard definition of promotion, but empirical # It's hard to find a hard definition of promotion, but empirical
# evidence suggests that the below is all that's allowed. # evidence suggests that the below is all that's allowed.
if src_type.is_numeric: if src_type.is_numeric:
if dst_type.same_as(c_int_type): if dst_type.same_as(c_int_type):
unsigned = (not src_type.signed) unsigned = (not src_type.signed)
...@@ -2490,7 +2490,7 @@ def best_match(args, functions, pos=None): ...@@ -2490,7 +2490,7 @@ def best_match(args, functions, pos=None):
functions based on how much work must be done to convert the functions based on how much work must be done to convert the
arguments, with the following priorities: arguments, with the following priorities:
* identical types or pointers to identical types * identical types or pointers to identical types
* promotions * promotions
* non-Python types * non-Python types
That is, we prefer functions where no arguments need converted, That is, we prefer functions where no arguments need converted,
and failing that, functions where only promotions are required, and and failing that, functions where only promotions are required, and
...@@ -2500,7 +2500,7 @@ def best_match(args, functions, pos=None): ...@@ -2500,7 +2500,7 @@ def best_match(args, functions, pos=None):
the same weight, we return None (as there is no best match). If pos the same weight, we return None (as there is no best match). If pos
is not None, we also generate an error. is not None, we also generate an error.
""" """
# TODO: args should be a list of types, not a list of Nodes. # TODO: args should be a list of types, not a list of Nodes.
actual_nargs = len(args) actual_nargs = len(args)
candidates = [] candidates = []
...@@ -2532,7 +2532,7 @@ def best_match(args, functions, pos=None): ...@@ -2532,7 +2532,7 @@ def best_match(args, functions, pos=None):
errors.append((func, error_mesg)) errors.append((func, error_mesg))
continue continue
candidates.append((func, func_type)) candidates.append((func, func_type))
# Optimize the most common case of no overloading... # Optimize the most common case of no overloading...
if len(candidates) == 1: if len(candidates) == 1:
return candidates[0][0] return candidates[0][0]
...@@ -2543,7 +2543,7 @@ def best_match(args, functions, pos=None): ...@@ -2543,7 +2543,7 @@ def best_match(args, functions, pos=None):
else: else:
error(pos, "no suitable method found") error(pos, "no suitable method found")
return None return None
possibilities = [] possibilities = []
bad_types = [] bad_types = []
for func, func_type in candidates: for func, func_type in candidates:
...@@ -2593,7 +2593,7 @@ def widest_numeric_type(type1, type2): ...@@ -2593,7 +2593,7 @@ def widest_numeric_type(type1, type2):
return ntype return ntype
widest_type = CComplexType( widest_type = CComplexType(
widest_numeric_type( widest_numeric_type(
real_type(type1), real_type(type1),
real_type(type2))) real_type(type2)))
elif type1.is_enum and type2.is_enum: elif type1.is_enum and type2.is_enum:
widest_type = c_int_type widest_type = c_int_type
...@@ -2685,7 +2685,7 @@ def simple_c_type(signed, longness, name): ...@@ -2685,7 +2685,7 @@ def simple_c_type(signed, longness, name):
# Find type descriptor for simple type given name and modifiers. # Find type descriptor for simple type given name and modifiers.
# Returns None if arguments don't make sense. # Returns None if arguments don't make sense.
return modifiers_and_name_to_type.get((signed, longness, name)) return modifiers_and_name_to_type.get((signed, longness, name))
def parse_basic_type(name): def parse_basic_type(name):
base = None base = None
if name.startswith('p_'): if name.startswith('p_'):
...@@ -2719,7 +2719,7 @@ def parse_basic_type(name): ...@@ -2719,7 +2719,7 @@ def parse_basic_type(name):
if name.startswith('u'): if name.startswith('u'):
name = name[1:] name = name[1:]
signed = 0 signed = 0
elif (name.startswith('s') and elif (name.startswith('s') and
not name.startswith('short')): not name.startswith('short')):
name = name[1:] name = name[1:]
signed = 2 signed = 2
...@@ -2763,7 +2763,7 @@ def c_ref_type(base_type): ...@@ -2763,7 +2763,7 @@ def c_ref_type(base_type):
def same_type(type1, type2): def same_type(type1, type2):
return type1.same_as(type2) return type1.same_as(type2)
def assignable_from(type1, type2): def assignable_from(type1, type2):
return type1.assignable_from(type2) return type1.assignable_from(type2)
......
...@@ -401,13 +401,13 @@ class Scope(object): ...@@ -401,13 +401,13 @@ class Scope(object):
except ValueError, e: except ValueError, e:
error(pos, e.args[0]) error(pos, e.args[0])
type = PyrexTypes.error_type type = PyrexTypes.error_type
entry = self.declare_type(name, type, pos, cname, entry = self.declare_type(name, type, pos, cname,
visibility = visibility, api = api) visibility = visibility, api = api)
type.qualified_name = entry.qualified_name type.qualified_name = entry.qualified_name
return entry return entry
def declare_struct_or_union(self, name, kind, scope, def declare_struct_or_union(self, name, kind, scope,
typedef_flag, pos, cname = None, typedef_flag, pos, cname = None,
visibility = 'private', api = 0, visibility = 'private', api = 0,
packed = False): packed = False):
# Add an entry for a struct or union definition. # Add an entry for a struct or union definition.
...@@ -488,7 +488,7 @@ class Scope(object): ...@@ -488,7 +488,7 @@ class Scope(object):
if entry.visibility != visibility: if entry.visibility != visibility:
error(pos, "'%s' previously declared as '%s'" % ( error(pos, "'%s' previously declared as '%s'" % (
entry.name, entry.visibility)) entry.name, entry.visibility))
def declare_enum(self, name, pos, cname, typedef_flag, def declare_enum(self, name, pos, cname, typedef_flag,
visibility = 'private', api = 0): visibility = 'private', api = 0):
if name: if name:
...@@ -504,7 +504,7 @@ class Scope(object): ...@@ -504,7 +504,7 @@ class Scope(object):
visibility = visibility, api = api) visibility = visibility, api = api)
entry.enum_values = [] entry.enum_values = []
self.sue_entries.append(entry) self.sue_entries.append(entry)
return entry return entry
def declare_var(self, name, type, pos, def declare_var(self, name, type, pos,
cname = None, visibility = 'private', api = 0, is_cdef = 0): cname = None, visibility = 'private', api = 0, is_cdef = 0):
...@@ -1059,7 +1059,7 @@ class ModuleScope(Scope): ...@@ -1059,7 +1059,7 @@ class ModuleScope(Scope):
buffer_defaults = None, shadow = 0): buffer_defaults = None, shadow = 0):
# If this is a non-extern typedef class, expose the typedef, but use # If this is a non-extern typedef class, expose the typedef, but use
# the non-typedef struct internally to avoid needing forward # the non-typedef struct internally to avoid needing forward
# declarations for anonymous structs. # declarations for anonymous structs.
if typedef_flag and visibility != 'extern': if typedef_flag and visibility != 'extern':
if not (visibility == 'public' or api): if not (visibility == 'public' or api):
warning(pos, "ctypedef only valid for 'extern' , 'public', and 'api'", 2) warning(pos, "ctypedef only valid for 'extern' , 'public', and 'api'", 2)
...@@ -1462,7 +1462,7 @@ class StructOrUnionScope(Scope): ...@@ -1462,7 +1462,7 @@ class StructOrUnionScope(Scope):
def declare_cfunction(self, name, type, pos, def declare_cfunction(self, name, type, pos,
cname = None, visibility = 'private', defining = 0, cname = None, visibility = 'private', defining = 0,
api = 0, in_pxd = 0, modifiers = ()): # currently no utility code ... api = 0, in_pxd = 0, modifiers = ()): # currently no utility code ...
return self.declare_var(name, type, pos, return self.declare_var(name, type, pos,
cname=cname, visibility=visibility) cname=cname, visibility=visibility)
class ClassScope(Scope): class ClassScope(Scope):
...@@ -1627,7 +1627,7 @@ class CClassScope(ClassScope): ...@@ -1627,7 +1627,7 @@ class CClassScope(ClassScope):
if name == "__new__": if name == "__new__":
error(pos, "__new__ method of extension type will change semantics " error(pos, "__new__ method of extension type will change semantics "
"in a future version of Pyrex and Cython. Use __cinit__ instead.") "in a future version of Pyrex and Cython. Use __cinit__ instead.")
entry = self.declare_var(name, py_object_type, pos, entry = self.declare_var(name, py_object_type, pos,
visibility='extern') visibility='extern')
special_sig = get_special_method_signature(name) special_sig = get_special_method_signature(name)
if special_sig: if special_sig:
...@@ -1753,7 +1753,7 @@ class CppClassScope(Scope): ...@@ -1753,7 +1753,7 @@ class CppClassScope(Scope):
self.inherited_var_entries = [] self.inherited_var_entries = []
def declare_var(self, name, type, pos, def declare_var(self, name, type, pos,
cname = None, visibility = 'extern', api = 0, cname = None, visibility = 'extern', api = 0,
is_cdef = 0, allow_pyobject = 0): is_cdef = 0, allow_pyobject = 0):
# Add an entry for an attribute. # Add an entry for an attribute.
if not cname: if not cname:
...@@ -1795,7 +1795,7 @@ class CppClassScope(Scope): ...@@ -1795,7 +1795,7 @@ class CppClassScope(Scope):
error(pos, "no matching function for call to %s::%s()" % error(pos, "no matching function for call to %s::%s()" %
(self.default_constructor, self.default_constructor)) (self.default_constructor, self.default_constructor))
def declare_cfunction(self, name, type, pos, cname = None, def declare_cfunction(self, name, type, pos, cname = None,
visibility = 'extern', api = 0, defining = 0, visibility = 'extern', api = 0, defining = 0,
in_pxd = 0, modifiers = (), utility_code = None): in_pxd = 0, modifiers = (), utility_code = None):
if name == self.name.split('::')[-1] and cname is None: if name == self.name.split('::')[-1] and cname is None:
...@@ -1803,7 +1803,7 @@ class CppClassScope(Scope): ...@@ -1803,7 +1803,7 @@ class CppClassScope(Scope):
name = '<init>' name = '<init>'
type.return_type = self.lookup(self.name).type type.return_type = self.lookup(self.name).type
prev_entry = self.lookup_here(name) prev_entry = self.lookup_here(name)
entry = self.declare_var(name, type, pos, entry = self.declare_var(name, type, pos,
cname=cname, visibility=visibility) cname=cname, visibility=visibility)
if prev_entry: if prev_entry:
entry.overloaded_alternatives = prev_entry.all_alternatives() entry.overloaded_alternatives = prev_entry.all_alternatives()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment