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
3e0dfd71
Commit
3e0dfd71
authored
May 25, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Declare wrapper cclass for each cypclass
parent
5c88de32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
1 deletion
+50
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+50
-1
No files found.
Cython/Compiler/Nodes.py
View file @
3e0dfd71
...
...
@@ -31,7 +31,6 @@ from . import DebugFlags
from
.Pythran
import
has_np_pythran
,
pythran_type
,
is_pythran_buffer
from
..Utils
import
add_metaclass
if
sys
.
version_info
[
0
]
>=
3
:
_py_int_types
=
int
else
:
...
...
@@ -1508,10 +1507,12 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
# base_classes [CBaseTypeNode]
# templates [(string, bool)] or None
# decorators [DecoratorNode] or None
# cyp_wrapper CClassDefNode or None
decorators
=
None
scope
=
None
template_types
=
None
cyp_wrapper
=
None
def
declare
(
self
,
env
):
if
not
env
.
is_cpp
():
...
...
@@ -1620,6 +1621,52 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
for
thunk
in
self
.
entry
.
type
.
deferred_declarations
:
thunk
()
if
self
.
cypclass
:
self
.
declare_cypclass_wrapper_cclass
(
env
)
def
find_module_scope
(
self
,
scope
):
module_scope
=
scope
while
module_scope
and
not
module_scope
.
is_module_scope
:
module_scope
=
module_scope
.
outer_scope
return
module_scope
def
declare_cypclass_wrapper_cclass
(
self
,
env
):
module_scope
=
self
.
find_module_scope
(
env
)
cclass_name
=
EncodedString
(
"%s_cyp_wrapper"
%
self
.
name
)
from
.ExprNodes
import
TupleNode
cclass_bases
=
TupleNode
(
self
.
pos
,
args
=
[])
if
self
.
attributes
is
not
None
:
# for now
cclass_body
=
StatListNode
(
pos
=
self
.
pos
,
stats
=
[])
else
:
cclass_body
=
None
wrapper
=
CClassDefNode
(
self
.
pos
,
visibility
=
'private'
,
typedef_flag
=
0
,
api
=
0
,
module_name
=
""
,
class_name
=
cclass_name
,
as_name
=
cclass_name
,
bases
=
cclass_bases
,
objstruct_name
=
None
,
typeobj_name
=
None
,
check_size
=
None
,
in_pxd
=
0
,
doc
=
EncodedString
(
"Python Object wrapper for underlying cypclass %s"
%
self
.
name
),
body
=
cclass_body
,
is_cyp_wrapper
=
1
)
if
module_scope
:
wrapper
.
declare
(
module_scope
)
if
self
.
scope
:
wrapper
.
analyse_declarations
(
module_scope
)
self
.
cyp_wrapper
=
wrapper
def
analyse_expressions
(
self
,
env
):
self
.
body
=
self
.
body
.
analyse_expressions
(
self
.
entry
.
type
.
scope
)
return
self
...
...
@@ -4965,6 +5012,7 @@ class CClassDefNode(ClassDefNode):
# base_type PyExtensionType or None
# buffer_defaults_node DictNode or None Declares defaults for a buffer
# buffer_defaults_pos
# is_cyp_wrapper boolean Whether this cclass wraps a cypclass
child_attrs
=
[
"body"
]
buffer_defaults_node
=
None
...
...
@@ -4976,6 +5024,7 @@ class CClassDefNode(ClassDefNode):
check_size
=
None
decorators
=
None
shadow
=
False
is_cyp_wrapper
=
False
def
buffer_defaults
(
self
,
env
):
if
not
hasattr
(
self
,
'_buffer_defaults'
):
...
...
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