doc_code = entry.doc_cname
else:
doc_code = 0
- # Add METH_COEXIST to special methods
- meth_flags = "METH_VARARGS|METH_KEYWORDS"
- if get_special_method_signature(entry.name):
- meth_flags = "METH_VARARGS|METH_KEYWORDS|METH_COEXIST"
- self.putln(
- '{"%s", (PyCFunction)%s, %s, %s}%s' % (
- entry.name,
- entry.func_cname,
- meth_flags,
- doc_code,
- term))
+ if entry.meth_flags:
+ self.putln(
+ '{"%s", (PyCFunction)%s, %s, %s}%s' % (
+ entry.name,
+ entry.func_cname,
+ entry.meth_flags,
+ doc_code,
+ term))
def put_error_if_neg(self, pos, value):
# return self.putln("if (unlikely(%s < 0)) %s" % (value, self.error_goto(pos))) # TODO this path is almost _never_ taken, yet this macro makes is slower!
import Options
import Naming
from PyrexTypes import *
+import TypeSlots
from TypeSlots import \
pyfunction_signature, pymethod_signature, \
get_special_method_signature, get_property_accessor_signature
# Add an entry for a Python function.
entry = self.declare_var(name, py_object_type, pos)
entry.signature = pyfunction_signature
+ entry.meth_flags = "METH_VARARGS|METH_KEYWORDS"
self.pyfunc_entries.append(entry)
return entry
# Special methods get put in the method table with a particular
# signature declared in advance.
entry.signature = special_sig
+ if special_sig == TypeSlots.unaryfunc:
+ entry.meth_flags = "METH_NOARGS|METH_COEXIST"
+ elif special_sig == TypeSlots.binaryfunc or special_sig == TypeSlots.ibinaryfunc:
+ entry.meth_flags = "METH_O|METH_COEXIST"
+ else:
+ entry.meth_flags = None # should it generate a wrapper function?
else:
+ entry.meth_flags = "METH_VARARGS|METH_KEYWORDS"
entry.signature = pymethod_signature
self.pyfunc_entries.append(entry)
if signature:
entry = self.declare(name, name, py_object_type, pos)
entry.signature = signature
+ entry.meth_flags = None
return entry
else:
error(pos, "Only __get__, __set__ and __del__ methods allowed "