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
11432231
Commit
11432231
authored
Jun 04, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid naming collisions between cypclass wrappers and user-defined names
parent
706e1bc8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
Cython/Compiler/CypclassWrapper.py
Cython/Compiler/CypclassWrapper.py
+22
-3
No files found.
Cython/Compiler/CypclassWrapper.py
View file @
11432231
...
@@ -107,6 +107,7 @@ class CypclassWrapperInjection(CythonTransform):
...
@@ -107,6 +107,7 @@ class CypclassWrapperInjection(CythonTransform):
def
visit_ModuleNode
(
self
,
node
):
def
visit_ModuleNode
(
self
,
node
):
self
.
cypclass_wrappers
=
[]
self
.
cypclass_wrappers
=
[]
self
.
cypclass_entries_to_wrapper_names
=
{}
self
.
nesting_stack
=
[]
self
.
nesting_stack
=
[]
self
.
module_scope
=
node
.
scope
self
.
module_scope
=
node
.
scope
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
...
@@ -151,10 +152,24 @@ class CypclassWrapperInjection(CythonTransform):
...
@@ -151,10 +152,24 @@ class CypclassWrapperInjection(CythonTransform):
# whether the is declared with ':' and a suite, or just a forward declaration
# whether the is declared with ':' and a suite, or just a forward declaration
node_has_suite
=
node
.
attributes
is
not
None
node_has_suite
=
node
.
attributes
is
not
None
# TODO: take nesting into account for the name
# if a wrapper for this cypclass entry has already been declared, use the same name
# TODO: check that there is no collision with another name
# (only happens when there are forward declarations for the cypclass itself)
cclass_name
=
EncodedString
(
"%s_cyp_wrapper"
%
node
.
name
)
if
node
.
entry
in
self
.
cypclass_entries_to_wrapper_names
:
cclass_name
=
self
.
cypclass_entries_to_wrapper_names
[
node
.
entry
]
# otherwise derive a unique name that avoid collisions with user-defined names
else
:
qualifying_names
=
[
node
.
name
for
node
in
self
.
nesting_stack
]
qualifying_names
.
append
(
node
.
name
)
qualified_name
=
"_"
.
join
(
qualifying_names
)
suffix_name
=
"__cyp_wrapper"
cclass_name
=
"%s%s"
%
(
qualified_name
,
suffix_name
)
while
cclass_name
in
self
.
module_scope
.
entries
:
suffix_name
=
"%s__cyp_wrapper"
%
"_"
cclass_name
=
"%s%s"
%
(
qualified_name
,
suffix_name
)
cclass_name
=
EncodedString
(
cclass_name
)
# determine if the wrapper has a base class
from
.ExprNodes
import
TupleNode
from
.ExprNodes
import
TupleNode
bases_args
=
[]
bases_args
=
[]
node_type
=
node
.
entry
.
type
node_type
=
node
.
entry
.
type
...
@@ -210,6 +225,10 @@ class CypclassWrapperInjection(CythonTransform):
...
@@ -210,6 +225,10 @@ class CypclassWrapperInjection(CythonTransform):
# indicate that the cypclass will have a wrapper
# indicate that the cypclass will have a wrapper
node
.
entry
.
type
.
support_wrapper
=
True
node
.
entry
.
type
.
support_wrapper
=
True
# associate the wrapper name to the cypclass entry to distinguish
# future declarations from collisions with user defined names
self
.
cypclass_entries_to_wrapper_names
[
node
.
entry
]
=
cclass_name
return
wrapper
return
wrapper
def
synthesize_underlying_cyobject_attribute
(
self
,
node
):
def
synthesize_underlying_cyobject_attribute
(
self
,
node
):
...
...
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