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
ccd14647
Commit
ccd14647
authored
Jun 13, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make __activate__ support inheritance (C++ trick about non-virtual functions)
parent
e1f95d01
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+7
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+2
-1
No files found.
Cython/Compiler/ModuleNode.py
View file @
ccd14647
...
...
@@ -948,6 +948,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
activated_class_entry
=
scope
.
lookup_here
(
"Activated"
)
if
activated_class_entry
:
code
.
putln
(
"struct %s;"
%
activated_class_entry
.
cname
)
code
.
putln
(
"%s;"
%
activated_class_entry
.
type
.
declaration_code
(
"__activate__(void)"
))
for
attr
in
scope
.
var_entries
:
cname
=
attr
.
cname
if
attr
.
type
.
is_cfunction
and
attr
.
type
.
is_static_method
:
...
...
@@ -1104,7 +1105,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def
generate_cyp_class_activated_class
(
self
,
entry
,
code
):
result_interface_entry
=
entry
.
scope
.
lookup_here
(
"ActhonResultInterface"
)
# TODO: handle inheritance
code
.
putln
(
"struct %s::Activated : public CyObject {"
%
entry
.
type
.
empty_declaration_code
())
activable_bases
=
[
"public %s::Activated"
%
base
.
cname
for
base
in
entry
.
type
.
base_classes
if
base
.
activable
]
if
activable_bases
:
base_classes_code
=
", "
.
join
(
activable_bases
)
else
:
base_classes_code
=
"public CyObject"
code
.
putln
(
"struct %s::Activated : %s {"
%
(
entry
.
type
.
empty_declaration_code
(),
base_classes_code
))
code
.
putln
(
"%s * _passive_self;"
%
entry
.
type
.
empty_declaration_code
())
code
.
putln
(
"Activated(){} // Used for inheritance, never used for classic instantiation"
)
code
.
putln
(
"Activated(%s * passive_object):_passive_self(passive_object){} // Used by _passive_self.activate()"
%
entry
.
type
.
empty_declaration_code
())
...
...
Cython/Compiler/Symtab.py
View file @
ccd14647
...
...
@@ -721,7 +721,8 @@ class Scope(object):
act_attr_name
=
Naming
.
builtin_prefix
+
"_active_self"
scope
.
declare_var
(
"<active_self>"
,
act_type
,
pos
,
cname
=
act_attr_name
)
activate_type
=
PyrexTypes
.
CFuncType
(
act_type
,
[],
nogil
=
1
)
scope
.
declare_var
(
"__activate__"
,
activate_type
,
pos
,
cname
=
"__activate__"
,
defining
=
1
)
activate_entry
=
scope
.
declare
(
"__activate__"
,
"__activate__"
,
activate_type
,
None
,
'extern'
)
activate_entry
.
is_variable
=
activate_entry
.
is_cfunction
=
1
if
self
.
is_cpp_class_scope
:
entry
.
type
.
namespace
=
self
.
outer_scope
.
lookup
(
self
.
name
).
type
...
...
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