Commit a9fa4bda authored by Robert Bradshaw's avatar Robert Bradshaw

Docstrings for special methods

parent eaa47be5
......@@ -6,6 +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
class CCodeWriter:
# f file output file
......@@ -288,10 +289,15 @@ class CCodeWriter:
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, METH_VARARGS|METH_KEYWORDS, %s}%s' % (
'{"%s", (PyCFunction)%s, %s, %s}%s' % (
entry.name,
entry.func_cname,
entry.func_cname,
meth_flags,
doc_code,
term))
......
......@@ -1079,14 +1079,19 @@ class CClassScope(ClassScope):
def declare_pyfunction(self, name, pos):
# Add an entry for a method.
if name in ('__eq__', '__ne__', '__lt__', '__gt__', '__le__', '__ge__'):
error(pos, "Special method %s must be implemented via __richcmp__"
% name)
entry = self.declare(name, name, py_object_type, pos)
special_sig = get_special_method_signature(name)
if special_sig:
# Special methods get put in the method table with a particular
# signature declared in advance.
entry.signature = special_sig
# Special methods don't get put in the method table
else:
entry.signature = pymethod_signature
self.pyfunc_entries.append(entry)
self.pyfunc_entries.append(entry)
return entry
def declare_cfunction(self, name, type, pos,
......
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