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
Gwenaël Samain
cython
Commits
05c79eaf
Commit
05c79eaf
authored
Jun 29, 2016
by
empyrical
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow C++ class methods to use base class' methods
parent
2c3c04b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
tests/run/cpp_classes_def.pyx
tests/run/cpp_classes_def.pyx
+30
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
05c79eaf
...
...
@@ -6302,7 +6302,7 @@ class AttributeNode(ExprNode):
# as an ordinary function.
if
entry
.
func_cname
and
not
hasattr
(
entry
.
type
,
'op_arg_struct'
):
cname
=
entry
.
func_cname
if
entry
.
type
.
is_static_method
:
if
entry
.
type
.
is_static_method
or
env
.
parent_scope
.
is_cpp_class_scope
:
ctype
=
entry
.
type
elif
type
.
is_cpp_class
:
error
(
self
.
pos
,
"%s not a static member of %s"
%
(
entry
.
name
,
type
))
...
...
tests/run/cpp_classes_def.pyx
View file @
05c79eaf
...
...
@@ -5,6 +5,7 @@
cdef
double
pi
from
math
import
pi
from
libc.math
cimport
sin
,
cos
from
libcpp
cimport
bool
cdef
extern
from
"shapes.h"
namespace
"shapes"
:
cdef
cppclass
Shape
:
...
...
@@ -42,6 +43,35 @@ def test_Poly(int n, float radius=1):
finally
:
del
poly
cdef
cppclass
BaseClass
:
int
n
int
method
():
return
this
.
n
cdef
cppclass
SubClass
(
BaseClass
):
bool
override
__init__
(
bool
override
):
this
.
n
=
1
this
.
override
=
override
int
method
():
if
override
:
return
0
else
:
return
BaseClass
.
method
()
def
test_BaseMethods
(
x
):
"""
>>> test_BaseMethods(True)
0
>>> test_BaseMethods(False)
1
"""
cdef
SubClass
*
subClass
try
:
subClass
=
new
SubClass
(
x
)
return
subClass
.
method
()
finally
:
del
subClass
cdef
cppclass
WithStatic
:
@
staticmethod
...
...
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