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
f49fc8fe
Commit
f49fc8fe
authored
Jun 09, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make cypclass always inherit virtually from all bases
parent
baa6c7f1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
9 deletions
+36
-9
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+8
-4
tests/run/cypclass_multiple_inheritance.pyx
tests/run/cypclass_multiple_inheritance.pyx
+28
-5
No files found.
Cython/Compiler/ModuleNode.py
View file @
f49fc8fe
...
...
@@ -1005,8 +1005,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
put
(
"struct %s"
%
type
.
cname
)
if
type
.
base_classes
:
base_class_list
=
[
base_class
.
empty_declaration_code
()
for
base_class
in
type
.
base_classes
]
if
type
.
is_cyp_class
and
(
type
.
base_classes
[
-
1
]
is
cy_object_type
or
type
.
base_classes
[
-
1
].
name
==
"ActhonActivableClass"
):
base_class_list
[
-
1
]
=
"virtual "
+
base_class_list
[
-
1
]
# if type.is_cyp_class and (type.base_classes[-1] is cy_object_type or type.base_classes[-1].name == "ActhonActivableClass"):
# base_class_list[-1] = "virtual " + base_class_list[-1]
if
type
.
is_cyp_class
:
base_class_decl
=
",virtual public "
.
join
(
base_class_list
)
code
.
put
(
" : virtual public %s"
%
base_class_decl
)
else
:
base_class_decl
=
", public "
.
join
(
base_class_list
)
code
.
put
(
" : public %s"
%
base_class_decl
)
code
.
putln
(
" {"
)
...
...
tests/run/cypclass_multiple_inheritance.pyx
View file @
f49fc8fe
...
...
@@ -32,13 +32,36 @@ cdef cypclass Diamond(InplaceAddition, InplaceSubstraction):
InplaceAddition
.
__init__
(
self
,
a
)
InplaceSubstraction
.
__init__
(
self
,
b
)
def
test_non_virtual_inheritance
():
# def test_non_virtual_inheritance():
# """
# >>> test_non_virtual_inheritance()
# 1
# 2
# 3
# 0
# """
# cdef Diamond diamond = Diamond(1, 2)
#
# diamond.print_IA_base()
# diamond.print_IS_base()
#
# cdef InplaceAddition iadd_obj = InplaceAddition(2)
# cdef InplaceSubstraction isub_obj = InplaceSubstraction(2)
#
# diamond += iadd_obj
# diamond -= isub_obj
#
# diamond.print_IA_base()
# diamond.print_IS_base()
def
test_virtual_inheritance
():
"""
>>> test_non_virtual_inheritance()
1
>>> test_virtual_inheritance()
2
2
2
2
3
0
"""
cdef
Diamond
diamond
=
Diamond
(
1
,
2
)
...
...
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