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
255c4e25
Commit
255c4e25
authored
May 25, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Declare wrapper cclass for each cypclass
parent
569bdff8
Changes
1
Show 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 @
255c4e25
...
...
@@ -32,7 +32,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
:
...
...
@@ -1505,10 +1504,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
cpp_message
=
"Cypclass"
...
...
@@ -1619,6 +1620,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
...
...
@@ -5117,6 +5164,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
...
...
@@ -5128,6 +5176,7 @@ class CClassDefNode(ClassDefNode):
check_size
=
None
decorators
=
None
shadow
=
False
is_cyp_wrapper
=
False
@
property
def
punycode_class_name
(
self
):
...
...
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