print "no constructor declared"
# create one
self.class_entry = entry
+ self.entry = constructor
self.type = constructor.type
def generate_result_code(self, code):
expected_type, env)
# Insert coerced 'self' argument into argument list.
self.args.insert(0, self.coerced_self)
+ entry = self.function.entry
self.analyse_c_function_call(env)
def function_type(self):
self.type = PyrexTypes.error_type
self.result_code = "<error>"
return
+ if not self.analyse_args(env, func_type):
+ entry = self.function.entry
+ has_overloaded = 0
+ for overloaded in entry.overloaded_alternatives:
+ if self.analyse_args(env, overloaded.type.base_type):
+ has_overloaded = 1
+ break
+ if not has_overloaded:
+ error(self.pos, "Call with wrong number of arguments")
+ # "Call with wrong number of arguments (expected %s, got %s)"
+ # % (expected_str, actual_nargs))
+ self.args = None
+ self.type = PyrexTypes.error_type
+ self.result_code = "<error>"
+
+ def analyse_args(self, env, func_type):
# Check no. of args
max_nargs = len(func_type.args)
expected_nargs = max_nargs - func_type.optional_arg_count
expected_str = "at least " + expected_str
else:
expected_str = "at most " + str(max_nargs)
- error(self.pos,
- "Call with wrong number of arguments (expected %s, got %s)"
- % (expected_str, actual_nargs))
- self.args = None
- self.type = PyrexTypes.error_type
- self.result_code = "<error>"
- return
- if func_type.optional_arg_count and expected_nargs != actual_nargs:
- self.has_optional_args = 1
- self.is_temp = 1
- self.opt_arg_struct = env.allocate_temp(func_type.op_arg_struct.base_type)
- env.release_temp(self.opt_arg_struct)
+ #error(self.pos,
+ # "Call with wrong number of arguments (expected %s, got %s)"
+ # % (expected_str, actual_nargs))
+ #self.args = None
+ #self.type = PyrexTypes.error_type
+ #self.result_code = "<error>"
+ return 0
# Coerce arguments
for i in range(min(max_nargs, actual_nargs)):
formal_type = func_type.args[i].type
# Check gil
if not func_type.nogil:
self.gil_check(env)
-
+ if func_type.optional_arg_count and expected_nargs != actual_nargs:
+ self.has_optional_args = 1
+ self.is_temp = 1
+ self.opt_arg_struct = env.allocate_temp(func_type.op_arg_struct.base_type)
+ env.release_temp(self.opt_arg_struct)
+ return 1
+
def calculate_result_code(self):
return self.c_call_code()
self.type = type
self.pos = pos
self.init = init
+ self.overloaded_alternatives = []
def redeclared(self, pos):
error(pos, "'%s' does not match previous declaration" % self.name)
# See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names
warning(pos, "'%s' is a reserved name in C." % cname, -1)
entries = self.entries
+ overloaded = False
if name and name in entries:
if visibility == 'extern':
warning(pos, "'%s' redeclared " % name, 0)
elif visibility != 'ignore':
- error(pos, "'%s' redeclared " % name)
+ overloaded = True
+ #error(pos, "'%s' redeclared " % name)
entry = Entry(name, cname, type, pos = pos)
entry.in_cinclude = self.in_cinclude
if name:
entry.qualified_name = self.qualify_name(name)
- entries[name] = entry
+ if overloaded:
+ entries[name].overloaded_alternatives.append(entry)
+ #print entries[name].overloaded_alternatives
+ else:
+ entries[name] = entry
entry.scope = self
entry.visibility = visibility
return entry