Commit 2bff23cb authored by Robert Bradshaw's avatar Robert Bradshaw

avoid argument parsing (via meth_o, meth_noargs) for non-python-object...

avoid argument parsing (via meth_o, meth_noargs) for non-python-object arguments, upgrade version number to 0.9.6.4

compiles and runs SAGE fine
parent 4eba71dc
......@@ -6,7 +6,7 @@ import Naming
import Options
from Cython.Utils import open_new_file
from PyrexTypes import py_object_type, typecast
from TypeSlots import get_special_method_signature, method_coexist
from TypeSlots import method_coexist
class CCodeWriter:
# f file output file
......@@ -291,7 +291,7 @@ class CCodeWriter:
doc_code = 0
method_flags = entry.signature.method_flags()
if method_flags:
if get_special_method_signature(entry.name):
if entry.is_special:
method_flags += [method_coexist]
self.putln(
'{"%s", (PyCFunction)%s, %s, %s}%s' % (
......
......@@ -821,16 +821,17 @@ class DefNode(FuncDefNode):
def analyse_signature(self, env):
any_type_tests_needed = 0
# Use the simpler calling signature for zero- and one-argument functions.
if self.entry.signature is TypeSlots.pyfunction_signature:
if len(self.args) == 0:
self.entry.signature = TypeSlots.pyfunction_noargs
elif len(self.args) == 1 and self.args[0].type.is_pyobject and self.args[0].default is None:
self.entry.signature = TypeSlots.pyfunction_onearg
elif self.entry.signature is TypeSlots.pymethod_signature:
if len(self.args) == 1:
self.entry.signature = TypeSlots.unaryfunc
elif len(self.args) == 2 and self.args[1].type.is_pyobject and self.args[1].default is None:
self.entry.signature = TypeSlots.ibinaryfunc
if not self.entry.is_special and not self.star_arg and not self.starstar_arg:
if self.entry.signature is TypeSlots.pyfunction_signature:
if len(self.args) == 0:
self.entry.signature = TypeSlots.pyfunction_noargs
elif len(self.args) == 1 and self.args[0].default is None:
self.entry.signature = TypeSlots.pyfunction_onearg
elif self.entry.signature is TypeSlots.pymethod_signature:
if len(self.args) == 1:
self.entry.signature = TypeSlots.unaryfunc
elif len(self.args) == 2 and self.args[1].default is None:
self.entry.signature = TypeSlots.ibinaryfunc
sig = self.entry.signature
nfixed = sig.num_fixed_args()
for i in range(nfixed):
......@@ -975,7 +976,7 @@ class DefNode(FuncDefNode):
else:
arg_code_list.append(
arg.hdr_type.declaration_code(arg.hdr_cname))
if self.entry.meth_flags == [TypeSlots.method_noargs]:
if not self.entry.is_special and sig.method_flags() == [TypeSlots.method_noargs]:
arg_code_list.append("PyObject *unused")
if sig.has_generic_args:
arg_code_list.append(
......@@ -1004,7 +1005,6 @@ class DefNode(FuncDefNode):
code.putln("PyObject *%s = 0;" % arg.hdr_cname)
else:
code.put_var_declaration(arg.entry)
def generate_keyword_list(self, code):
if self.entry.signature.has_generic_args:
......@@ -1116,7 +1116,7 @@ class DefNode(FuncDefNode):
old_type = arg.hdr_type
new_type = arg.type
if old_type.is_pyobject:
code.putln("if (%s) {" % arg.hdr_cname)
code.putln("if (likely(%s)) {" % arg.hdr_cname)
self.generate_arg_conversion_from_pyobject(arg, code)
code.putln("}")
elif new_type.is_pyobject:
......
......@@ -29,6 +29,7 @@ class Entry:
# is_pyglobal boolean Is a Python module-level variable
# or class attribute during
# class construction
# is_special boolean Is a special class method
# is_variable boolean Is a variable
# is_cfunction boolean Is a C function
# is_cmethod boolean Is a C method of an extension type
......@@ -69,6 +70,7 @@ class Entry:
is_builtin = 0
is_cglobal = 0
is_pyglobal = 0
is_special = 0
is_variable = 0
is_cfunction = 0
is_cmethod = 0
......@@ -199,9 +201,9 @@ class Scope:
# Create new entry, and add to dictionary if
# name is not None. Reports a warning if already
# declared.
if not self.in_cinclude and re.match("^_[_A-Z]+$", cname):
if not self.in_cinclude and cname and re.match("^_[_A-Z]+$", cname):
# See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names
error(pos, "'%s' is a reserved name in C." % cname)
warning(pos, "'%s' is a reserved name in C." % cname, -1)
dict = self.entries
if name and dict.has_key(name):
warning(pos, "'%s' redeclared " % name, 0)
......@@ -1089,8 +1091,10 @@ class CClassScope(ClassScope):
# Special methods get put in the method table with a particular
# signature declared in advance.
entry.signature = special_sig
entry.is_special = 1
else:
entry.signature = pymethod_signature
entry.is_special = 0
self.pyfunc_entries.append(entry)
return entry
......
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