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
17e6b1aa
Commit
17e6b1aa
authored
May 27, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve synthesis of cypclass method wrappers
parent
589800e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
19 deletions
+11
-19
Cython/Compiler/CypclassWrapper.py
Cython/Compiler/CypclassWrapper.py
+0
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+11
-14
No files found.
Cython/Compiler/CypclassWrapper.py
View file @
17e6b1aa
...
...
@@ -85,11 +85,6 @@ def cypclass_iter_scopes(scope):
for
e
,
s
in
cypclass_iter_scopes
(
cypclass_scope
):
yield
e
,
s
# cypclass entries that take on a special name: reverse mapping
cycplass_special_entry_names
=
{
"<init>"
:
"__init__"
}
underlying_name
=
EncodedString
(
"nogil_cyobject"
)
#
...
...
Cython/Compiler/Nodes.py
View file @
17e6b1aa
...
...
@@ -1635,30 +1635,27 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
# so their declaration analysis will still occur
self
.
cyp_wrapper
.
body
.
stats
.
append
(
py_method_wrapper
)
def
synthesize_cypclass_method_wrapper
(
self
,
cfunc_method
):
def
synthesize_cypclass_method_wrapper
(
self
,
cfunc_method
):
if
cfunc_method
.
is_static_method
:
return
# for now skip static methods
alternatives
=
cfunc_method
.
entry
.
all_alternatives
()
if
len
(
alternatives
)
>
1
:
return
# for now skip overloaded methods
cfunc_declarator
=
cfunc_method
.
cfunc_declarator
# C++ methods have an implict 'this', so the 'self' argument is skipped in the declarator
skipped_self
=
cfunc_
method
.
cfunc_
declarator
.
skipped_self
skipped_self
=
cfunc_declarator
.
skipped_self
if
not
skipped_self
:
return
# if this ever happens (?), skip non-static methods without a self argument
from
.CypclassWrapper
import
underlying_name
,
cycplass_special_entry_names
from
.CypclassWrapper
import
underlying_name
from
.
import
ExprNodes
cfunc_declarator
=
cfunc_method
.
cfunc_declarator
# > name of the wrapping method: same name
cfunc_name
=
cfunc_method
.
entry
.
name
# > name of the wrapping method: same name as in the original code
cfunc_name
=
cfunc_declarator
.
base
.
name
py_name
=
cfunc_name
try
:
# transform e.g. <init> back into __init__
py_name
=
cycplass_special_entry_names
[
py_name
]
except
KeyError
:
# no need to transform this name
pass
# > self argument of the wrapper method: same name, but type of the wrapper cclass
self_name
,
self_type
,
self_pos
,
self_arg
=
skipped_self
...
...
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