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
f60dbeac
Commit
f60dbeac
authored
May 22, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve mangling of cypclass related names in the global namespace
parent
d72f78f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+25
-1
No files found.
Cython/Compiler/Symtab.py
View file @
f60dbeac
...
@@ -460,6 +460,9 @@ class Scope(object):
...
@@ -460,6 +460,9 @@ class Scope(object):
else
:
else
:
return
self
.
parent_scope
.
mangle
(
prefix
,
self
.
name
)
return
self
.
parent_scope
.
mangle
(
prefix
,
self
.
name
)
# mangle cypclass related C names in the global namespace
c_mangle
=
mangle
def
mangle_internal
(
self
,
name
):
def
mangle_internal
(
self
,
name
):
# Mangle an internal name so as not to clash with any
# Mangle an internal name so as not to clash with any
# user-defined name in this scope.
# user-defined name in this scope.
...
@@ -734,7 +737,7 @@ class Scope(object):
...
@@ -734,7 +737,7 @@ class Scope(object):
if
cypclass
:
if
cypclass
:
type
=
PyrexTypes
.
CypClassType
(
type
=
PyrexTypes
.
CypClassType
(
name
,
scope
,
cname
,
base_classes
,
templates
=
templates
,
lock_mode
=
lock_mode
,
activable
=
activable
)
name
,
scope
,
cname
,
base_classes
,
templates
=
templates
,
lock_mode
=
lock_mode
,
activable
=
activable
)
type
.
typeptr_cname
=
self
.
mangle
(
Naming
.
typeptr_prefix
,
c
name
)
type
.
typeptr_cname
=
self
.
c_mangle
(
Naming
.
typeptr_prefix
,
name
)
else
:
else
:
type
=
PyrexTypes
.
CppClassType
(
type
=
PyrexTypes
.
CppClassType
(
name
,
scope
,
cname
,
base_classes
,
templates
=
templates
)
name
,
scope
,
cname
,
base_classes
,
templates
=
templates
)
...
@@ -2734,6 +2737,13 @@ class CppClassScope(Scope):
...
@@ -2734,6 +2737,13 @@ class CppClassScope(Scope):
self
.
inherited_var_entries
=
[]
self
.
inherited_var_entries
=
[]
self
.
inherited_type_entries
=
[]
self
.
inherited_type_entries
=
[]
self
.
reifying_entries
=
[]
self
.
reifying_entries
=
[]
# _scope_prefix is used interally for mangling in cases where c++ namespaces aren't used
# it is used in conjunction with 'c_mangle'
if
(
outer_scope
):
outer_prefix
=
outer_scope
.
_scope_prefix
if
outer_scope
.
is_cpp_class_scope
else
outer_scope
.
scope_prefix
self
.
_scope_prefix
=
outer_prefix
+
self
.
scope_prefix
else
:
self
.
_scope_prefix
=
self
.
scope_prefix
if
templates
is
not
None
:
if
templates
is
not
None
:
for
T
in
templates
:
for
T
in
templates
:
template_entry
=
self
.
declare
(
template_entry
=
self
.
declare
(
...
@@ -3098,6 +3108,20 @@ class CppClassScope(Scope):
...
@@ -3098,6 +3108,20 @@ class CppClassScope(Scope):
name
=
'operator '
+
as_operator_name
name
=
'operator '
+
as_operator_name
return
super
(
CppClassScope
,
self
).
lookup_here
(
name
)
return
super
(
CppClassScope
,
self
).
lookup_here
(
name
)
# mangle names in the global namespace.
# Normally 'mangle' would be used for this, but CppClassScope doesn't
# have a parent_scope, and therefore no qualified 'scope_prefix':
# unneeded thanks to C++ namespaces.
# '_scope_prefix' is used instead to use a scope-qualified name
# only when required.
def
c_mangle
(
self
,
prefix
,
name
=
None
):
if
name
:
return
"%s%s%s"
%
(
prefix
,
self
.
_scope_prefix
,
name
)
elif
self
.
outer_scope
:
return
self
.
outer_scope
.
mangle
(
prefix
,
self
.
name
)
else
:
return
self
.
mangle
(
prefix
,
name
)
class
CppScopedEnumScope
(
Scope
):
class
CppScopedEnumScope
(
Scope
):
# Namespace of a ScopedEnum
# Namespace of a ScopedEnum
...
...
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