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
02b256cd
Commit
02b256cd
authored
May 27, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid wrapping cypcass methods with Python-incompatible return types
parent
17e6b1aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+13
-5
No files found.
Cython/Compiler/Nodes.py
View file @
02b256cd
...
...
@@ -1508,6 +1508,8 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
# templates [(string, bool)] or None
# decorators [DecoratorNode] or None
# cypclass boolean
# lock_mode 'nolock', 'checklock', 'autolock', or None
# activable boolean
# cyp_wrapper CClassDefNode or None
...
...
@@ -1623,19 +1625,19 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
for
thunk
in
self
.
entry
.
type
.
deferred_declarations
:
thunk
()
self
.
insert_cypclass_method_wrappers
()
self
.
insert_cypclass_method_wrappers
(
env
)
def
insert_cypclass_method_wrappers
(
self
):
def
insert_cypclass_method_wrappers
(
self
,
env
):
if
self
.
cyp_wrapper
:
for
attr
in
self
.
attributes
:
if
isinstance
(
attr
,
CFuncDefNode
):
py_method_wrapper
=
self
.
synthesize_cypclass_method_wrapper
(
attr
)
py_method_wrapper
=
self
.
synthesize_cypclass_method_wrapper
(
attr
,
env
)
if
py_method_wrapper
:
# the wrapper cclasses are inserted after the wrapped node
# so their declaration analysis will still occur
self
.
cyp_wrapper
.
body
.
stats
.
append
(
py_method_wrapper
)
def
synthesize_cypclass_method_wrapper
(
self
,
cfunc_method
):
def
synthesize_cypclass_method_wrapper
(
self
,
cfunc_method
,
env
):
if
cfunc_method
.
is_static_method
:
return
# for now skip static methods
...
...
@@ -1650,6 +1652,12 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
if
not
skipped_self
:
return
# if this ever happens (?), skip non-static methods without a self argument
cfunc_return_type
=
cfunc_method
.
type
.
return_type
# we pass the global scope as argument, should not affect the result (?)
if
not
cfunc_return_type
.
can_coerce_to_pyobject
(
env
.
global_scope
()):
return
# skip c methods with Python-incompatible return types
from
.CypclassWrapper
import
underlying_name
from
.
import
ExprNodes
...
...
@@ -1705,7 +1713,7 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
)
# > return the result of the call if the underlying return type is not void
if
cfunc_
method
.
type
.
return_type
.
is_void
:
if
cfunc_return_type
.
is_void
:
py_stat
=
ExprStatNode
(
pos
=
cfunc_method
.
pos
,
expr
=
c_call
)
else
:
py_stat
=
ReturnStatNode
(
pos
=
cfunc_method
.
pos
,
return_type
=
PyrexTypes
.
py_object_type
,
value
=
c_call
)
...
...
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