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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
c02020b0
Commit
c02020b0
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
109e1ace
Changes
2
Hide 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 @
c02020b0
...
...
@@ -931,10 +931,14 @@ 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
]
base_class_decl
=
", public "
.
join
(
base_class_list
)
code
.
put
(
" : public %s"
%
base_class_decl
)
# 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
(
" {"
)
self
.
generate_type_header_code
(
scope
.
type_entries
,
code
)
py_attrs
=
[
e
for
e
in
scope
.
entries
.
values
()
...
...
tests/run/cypclass_multiple_inheritance.pyx
View file @
c02020b0
...
...
@@ -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