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
85a64ea4
Commit
85a64ea4
authored
May 27, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve synthesis of cypclass method wrappers
parent
4199dab9
Changes
2
Show 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 @
85a64ea4
...
@@ -85,11 +85,6 @@ def cypclass_iter_scopes(scope):
...
@@ -85,11 +85,6 @@ def cypclass_iter_scopes(scope):
for
e
,
s
in
cypclass_iter_scopes
(
cypclass_scope
):
for
e
,
s
in
cypclass_iter_scopes
(
cypclass_scope
):
yield
e
,
s
yield
e
,
s
# cypclass entries that take on a special name: reverse mapping
cycplass_special_entry_names
=
{
"<init>"
:
"__init__"
}
underlying_name
=
EncodedString
(
"nogil_cyobject"
)
underlying_name
=
EncodedString
(
"nogil_cyobject"
)
#
#
...
...
Cython/Compiler/Nodes.py
View file @
85a64ea4
...
@@ -1636,29 +1636,26 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
...
@@ -1636,29 +1636,26 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
self
.
cyp_wrapper
.
body
.
stats
.
append
(
py_method_wrapper
)
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
:
if
cfunc_method
.
is_static_method
:
return
# for now skip static methods
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
# 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
:
if
not
skipped_self
:
return
# if this ever happens (?), skip non-static methods without a self argument
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
from
.
import
ExprNodes
cfunc_declarator
=
cfunc_method
.
cfunc_declarator
# > name of the wrapping method: same name as in the original code
cfunc_name
=
cfunc_declarator
.
base
.
name
# > name of the wrapping method: same name
cfunc_name
=
cfunc_method
.
entry
.
name
py_name
=
cfunc_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 argument of the wrapper method: same name, but type of the wrapper cclass
self_name
,
self_type
,
self_pos
,
self_arg
=
skipped_self
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