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
Xavier Thompson
cython
Commits
3d5ac9f9
Commit
3d5ac9f9
authored
Jun 23, 2019
by
Jeroen Demeyer
Committed by
Stefan Behnel
Jun 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanup in handling METH_xxx flags (#3004)
parent
d48b30fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
5 deletions
+15
-5
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+4
-5
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+11
-0
No files found.
Cython/Compiler/Code.py
View file @
3d5ac9f9
...
...
@@ -2202,9 +2202,7 @@ class CCodeWriter(object):
method_flags
+=
[
TypeSlots
.
method_coexist
]
func_ptr
=
wrapper_code_writer
.
put_pymethoddef_wrapper
(
entry
)
if
wrapper_code_writer
else
entry
.
func_cname
# Add required casts, but try not to shadow real warnings.
cast
=
'__Pyx_PyCFunctionFast'
if
'METH_FASTCALL'
in
method_flags
else
'PyCFunction'
if
'METH_KEYWORDS'
in
method_flags
:
cast
+=
'WithKeywords'
cast
=
entry
.
signature
.
method_function_type
()
if
cast
!=
'PyCFunction'
:
func_ptr
=
'(void*)(%s)%s'
%
(
cast
,
func_ptr
)
self
.
putln
(
...
...
@@ -2218,8 +2216,9 @@ class CCodeWriter(object):
def
put_pymethoddef_wrapper
(
self
,
entry
):
func_cname
=
entry
.
func_cname
if
entry
.
is_special
:
method_flags
=
entry
.
signature
.
method_flags
()
if
method_flags
and
'METH_NOARGS'
in
method_flags
:
method_flags
=
entry
.
signature
.
method_flags
()
or
[]
from
.TypeSlots
import
method_noargs
if
method_noargs
in
method_flags
:
# Special NOARGS methods really take no arguments besides 'self', but PyCFunction expects one.
func_cname
=
Naming
.
method_wrapper_prefix
+
func_cname
self
.
putln
(
"static PyObject *%s(PyObject *self, CYTHON_UNUSED PyObject *arg) {return %s(self);}"
%
(
...
...
Cython/Compiler/TypeSlots.py
View file @
3d5ac9f9
...
...
@@ -170,6 +170,17 @@ class Signature(object):
return
[
method_varargs
,
method_keywords
]
return
None
def
method_function_type
(
self
):
# Return the C function type
mflags
=
self
.
method_flags
()
kw
=
"WithKeywords"
if
(
method_keywords
in
mflags
)
else
""
for
m
in
mflags
:
if
m
==
method_noargs
or
m
==
method_onearg
:
return
"PyCFunction"
if
m
==
method_varargs
:
return
"PyCFunction"
+
kw
return
None
class
SlotDescriptor
(
object
):
# Abstract base class for type slot descriptors.
...
...
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