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
Kirill Smelkov
cython
Commits
0860c918
Commit
0860c918
authored
Jul 08, 2017
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inherit C++ nested types.
parent
ae11b63c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
0 deletions
+50
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+5
-0
tests/run/cpp_nested_classes.pyx
tests/run/cpp_nested_classes.pyx
+43
-0
tests/run/cpp_nested_classes_support.h
tests/run/cpp_nested_classes_support.h
+2
-0
No files found.
Cython/Compiler/Symtab.py
View file @
0860c918
...
...
@@ -2299,6 +2299,11 @@ class CppClassScope(Scope):
modifiers
=
base_entry
.
func_modifiers
,
utility_code
=
base_entry
.
utility_code
)
entry
.
is_inherited
=
1
for
base_entry
in
base_scope
.
type_entries
:
entry
=
self
.
declare_type
(
base_entry
.
name
,
base_entry
.
type
,
base_entry
.
pos
,
base_entry
.
cname
,
base_entry
.
visibility
)
entry
.
is_inherited
=
1
def
specialize
(
self
,
values
,
type_entry
):
scope
=
CppClassScope
(
self
.
name
,
self
.
outer_scope
)
...
...
tests/run/cpp_nested_classes.pyx
View file @
0860c918
...
...
@@ -22,6 +22,10 @@ cdef extern from "cpp_nested_classes_support.h":
enum
MyEnum
:
value
cdef
cppclass
SpecializedTypedClass
(
TypedClass
[
double
]):
pass
def
test_nested_classes
():
"""
>>> test_nested_classes()
...
...
@@ -80,3 +84,42 @@ def test_nested_struct(x):
assert
s
.
int_value
==
x
s
.
typed_value
=
x
return
s
.
typed_value
def
test_typed_nested_sub_typedef
(
x
):
"""
>>> test_typed_nested_sub_typedef(4)
4.0
"""
cdef
SpecializedTypedClass
.
MyType
dx
=
x
return
dx
def
test_nested_sub_enum
(
SpecializedTypedClass
.
MyEnum
x
):
"""
>>> test_nested_sub_enum(4)
False
"""
return
x
==
0
def
test_nested_sub_union
(
x
):
"""
>>> test_nested_sub_union(2)
2.0
"""
cdef
SpecializedTypedClass
.
MyUnion
u
u
.
int_value
=
x
assert
u
.
int_value
==
x
u
.
typed_value
=
x
return
u
.
typed_value
def
test_nested_sub_struct
(
x
):
"""
>>> test_nested_sub_struct(2)
2.0
"""
cdef
SpecializedTypedClass
.
MyStruct
s
s
.
int_value
=
x
assert
s
.
int_value
==
x
s
.
typed_value
=
x
return
s
.
typed_value
tests/run/cpp_nested_classes_support.h
View file @
0860c918
...
...
@@ -33,3 +33,5 @@ public:
};
typedef
T
MyType
;
};
class
SpecializedTypedClass
:
public
TypedClass
<
double
>
{};
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