FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pybind11/tests/test_class_sh_virtual_py_cpp_mix.cpp at master · SimplexZhao/pybind11 · GitHub
SimplexZhao
/
pybind11
Public
forked from
pybind/pybind11
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pybind11
/
tests
/
test_class_sh_virtual_py_cpp_mix.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (40 loc) · 1.64 KB
Breadcrumbs
pybind11
/
tests
/
test_class_sh_virtual_py_cpp_mix.cpp
Copy path
File metadata and controls
58 lines (40 loc) · 1.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
include
"
pybind11_tests.h
"
#
include
<
memory
>
namespace
pybind11_tests
{
namespace
class_sh_virtual_py_cpp_mix
{
class
Base
{
public:
virtual
~Base
() =
default
;
virtual
int
get
()
const
{
return
101
; }
//
Some compilers complain about implicitly defined versions of some of the following:
Base
() =
default
;
Base
(
const
Base &) =
default
;
};
class
CppDerivedPlain
:
public
Base
{
public:
int
get
()
const
override
{
return
202
; }
};
class
CppDerived
:
public
Base
{
public:
int
get
()
const
override
{
return
212
; }
};
int
get_from_cpp_plainc_ptr
(
const
Base *b) {
return
b->
get
() +
4000
; }
int
get_from_cpp_unique_ptr
(std::unique_ptr<Base> b) {
return
b->
get
() +
5000
; }
struct
BaseVirtualOverrider
: Base, py::trampoline_self_life_support {
using
Base::Base;
int
get
()
const
override
{
PYBIND11_OVERRIDE
(
int
, Base, get); }
};
struct
CppDerivedVirtualOverrider
: CppDerived, py::trampoline_self_life_support {
using
CppDerived::CppDerived;
int
get
()
const
override
{
PYBIND11_OVERRIDE
(
int
, CppDerived, get); }
};
}
//
namespace class_sh_virtual_py_cpp_mix
}
//
namespace pybind11_tests
using
namespace
pybind11_tests
::class_sh_virtual_py_cpp_mix
;
TEST_SUBMODULE
(class_sh_virtual_py_cpp_mix, m) {
py::classh<Base, BaseVirtualOverrider>(m,
"
Base
"
).
def
(py::init<>()).
def
(
"
get
"
, &Base::get);
py::classh<CppDerivedPlain, Base>(m,
"
CppDerivedPlain
"
).
def
(py::init<>());
py::classh<CppDerived, Base, CppDerivedVirtualOverrider>(m,
"
CppDerived
"
).
def
(py::init<>());
m.
def
(
"
get_from_cpp_plainc_ptr
"
, get_from_cpp_plainc_ptr,
py::arg
(
"
b
"
));
m.
def
(
"
get_from_cpp_unique_ptr
"
, get_from_cpp_unique_ptr,
py::arg
(
"
b
"
));
}
Back
|
FazBrowse Home
|
New Git URL