Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
a9fa4bda
Commit
a9fa4bda
authored
Aug 17, 2007
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docstrings for special methods
parent
eaa47be5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+8
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+7
-2
No files found.
Cython/Compiler/Code.py
View file @
a9fa4bda
...
...
@@ -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
))
...
...
Cython/Compiler/Symtab.py
View file @
a9fa4bda
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment