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
Kirill Smelkov
cython
Commits
a442b59d
Commit
a442b59d
authored
Jun 17, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Invoke binop super method via direct slot access."
This reverts commit
bcb93877
.
parent
5a8a513a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
7 deletions
+32
-7
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+8
-7
Cython/Utility/ExtensionTypes.c
Cython/Utility/ExtensionTypes.c
+24
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
a442b59d
...
...
@@ -1918,14 +1918,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
return
bool
(
entry
and
entry
.
is_special
and
entry
.
func_cname
)
def
call_slot_method
(
method_name
,
reverse
):
entry
=
scope
.
lookup
(
method_name
)
if
reverse
:
operands
=
"right, left"
else
:
operands
=
"left, right"
if
entry
and
entry
.
is_special
and
entry
.
func_cname
:
return
"%s(%s%s)"
%
(
entry
.
func_cname
,
"right, left"
if
reverse
else
"left, right"
,
extra_arg
)
return
"%s(%s%s)"
%
(
entry
.
func_cname
,
operands
,
extra_arg
)
else
:
super
=
'Py_TYPE(right)->tp_base'
if
reverse
else
'Py_TYPE(left)->tp_base'
return
(
'(%s->tp_as_number && %s->tp_as_number->%s)'
' ? %s->tp_as_number->%s(left, right %s)'
' : (Py_INCREF(Py_NotImplemented), Py_NotImplemented)'
)
%
(
super
,
super
,
slot
.
slot_name
,
super
,
slot
.
slot_name
,
extra_arg
)
py_ident
=
code
.
intern_identifier
(
EncodedString
(
method_name
))
return
"%s_maybe_call_super(%s, %s)"
%
(
func_name
,
operands
,
py_ident
)
code
.
putln
(
TempitaUtilityCode
.
load_cached
(
"BinopSlot"
,
"ExtensionTypes.c"
,
...
...
@@ -1935,7 +1936,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"overloads_left"
:
int
(
has_slot_method
(
slot
.
left_slot
.
method_name
)),
"call_left"
:
call_slot_method
(
slot
.
left_slot
.
method_name
,
reverse
=
False
),
"call_right"
:
call_slot_method
(
slot
.
right_slot
.
method_name
,
reverse
=
True
),
"type_cname"
:
scope
.
parent_type
.
typeptr
_cname
,
"type_cname"
:
'((PyTypeObject*) %s)'
%
scope
.
namespace
_cname
,
"extra_arg"
:
extra_arg
,
"extra_arg_decl"
:
extra_arg_decl
,
}).
impl
.
strip
())
...
...
Cython/Utility/ExtensionTypes.c
View file @
a442b59d
...
...
@@ -281,6 +281,30 @@ __PYX_GOOD:
/////////////// BinopSlot ///////////////
static
CYTHON_INLINE
PyObject
*
{{
func_name
}}
_maybe_call_super
(
PyObject
*
self
,
PyObject
*
other
,
PyObject
*
name
{{
extra_arg_decl
}})
{
PyObject
*
res
;
PyObject
*
method
;
if
(
!
Py_TYPE
(
self
)
->
tp_base
)
{
return
Py_INCREF
(
Py_NotImplemented
),
Py_NotImplemented
;
}
// TODO: Use _PyType_LookupId or similar.
method
=
PyObject_GetAttr
((
PyObject
*
)
Py_TYPE
(
self
)
->
tp_base
,
name
);
if
(
!
method
)
{
PyErr_Clear
();
return
Py_INCREF
(
Py_NotImplemented
),
Py_NotImplemented
;
}
#if {{int(not extra_arg)}}
res
=
__Pyx_PyObject_Call2Args
(
method
,
self
,
other
);
#else
res
=
PyObject_CallFunctionObjArgs
(
method
,
self
,
other
{{
extra_arg
}},
NULL
);
#endif
Py_DECREF
(
method
);
if
(
!
res
)
{
return
Py_INCREF
(
Py_NotImplemented
),
Py_NotImplemented
;
}
return
res
;
}
static
PyObject
*
{{
func_name
}}(
PyObject
*
left
,
PyObject
*
right
{{
extra_arg_decl
}})
{
PyObject
*
res
;
int
maybe_self_is_left
,
maybe_self_is_right
=
0
;
...
...
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