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
c8a910fb
Commit
c8a910fb
authored
Jun 11, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate code to correctly resolve cypclass methods according to MRO
parent
bae3c65e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+9
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
c8a910fb
...
...
@@ -7578,6 +7578,8 @@ class AttributeNode(ExprNode):
if
obj
.
type
.
is_builtin_type
and
self
.
entry
and
self
.
entry
.
is_variable
:
# accessing a field of a builtin type, need to cast better than result_as() does
obj_code
=
obj
.
type
.
cast_code
(
obj
.
result
(),
to_object_struct
=
True
)
if
obj
.
type
.
is_cyp_class
and
self
.
entry
and
self
.
entry
.
from_type
:
self
.
member
=
"%s::%s"
%
(
self
.
entry
.
from_type
.
empty_declaration_code
(),
self
.
member
)
return
"%s%s%s"
%
(
obj_code
,
self
.
op
,
self
.
member
)
def
generate_result_code
(
self
,
code
):
...
...
Cython/Compiler/Symtab.py
View file @
c8a910fb
...
...
@@ -165,6 +165,11 @@ class Entry(object):
#
# is_default boolean This entry is a compiler-generated default and
# is not user-defined (e.g default contructor)
#
# from_type CypClassType or CppClassType or CStructOrUnionType or None
# The type in which this entry was first declared
# when it is later inherited by a cypclass
#
# mro_index integer The index of the type where this entry was originally
# declared in the mro of the cypclass where it is now
...
...
@@ -256,6 +261,7 @@ class Entry(object):
self
.
inner_entries
=
[]
self
.
defining_entry
=
self
self
.
mro_index
=
0
self
.
from_type
=
None
def
__repr__
(
self
):
return
"%s(<%x>, name=%s, type=%s)"
%
(
type
(
self
).
__name__
,
id
(
self
),
self
.
name
,
self
.
type
)
...
...
@@ -537,12 +543,14 @@ class Scope(object):
if
alt_entry
.
is_default
:
previous_alternative_indices
.
append
(
index
)
cpp_override_allowed
=
True
continue
# Any inherited method is visible
# until overloaded by a method with the same signature
if
alt_entry
.
is_inherited
:
previous_alternative_indices
.
append
(
index
)
cpp_override_allowed
=
True
continue
if
cpp_override_allowed
:
# C++ function/method overrides with different signatures are ok.
...
...
@@ -569,6 +577,7 @@ class Scope(object):
entry
=
Entry
(
name
,
cname
,
type
,
pos
=
pos
)
if
from_type
and
self
.
is_cyp_class_scope
:
entry
.
mro_index
=
self
.
parent_type
.
mro
().
index
(
from_type
)
entry
.
from_type
=
from_type
entry
.
in_cinclude
=
self
.
in_cinclude
entry
.
create_wrapper
=
create_wrapper
...
...
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