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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
bcb93877
Commit
bcb93877
authored
May 23, 2020
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Invoke binop super method via direct slot access.
parent
d849fb23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
32 deletions
+7
-32
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+7
-8
Cython/Utility/ExtensionTypes.c
Cython/Utility/ExtensionTypes.c
+0
-24
No files found.
Cython/Compiler/ModuleNode.py
View file @
bcb93877
...
...
@@ -1916,15 +1916,14 @@ 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
,
operands
,
extra_arg
)
return
"%s(%s%s)"
%
(
entry
.
func_cname
,
"right, left"
if
reverse
else
"left, right"
,
extra_arg
)
else
:
py_ident
=
code
.
intern_identifier
(
EncodedString
(
method_name
))
return
"%s_maybe_call_super(%s, %s)"
%
(
func_name
,
operands
,
py_ident
)
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
)
code
.
putln
(
TempitaUtilityCode
.
load_cached
(
"BinopSlot"
,
"ExtensionTypes.c"
,
...
...
@@ -1934,7 +1933,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"
:
'((PyTypeObject*) %s)'
%
scope
.
namespace
_cname
,
"type_cname"
:
scope
.
parent_type
.
typeptr
_cname
,
"extra_arg"
:
extra_arg
,
"extra_arg_decl"
:
extra_arg_decl
,
}).
impl
.
strip
())
...
...
Cython/Utility/ExtensionTypes.c
View file @
bcb93877
...
...
@@ -281,30 +281,6 @@ __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