Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
c362b91a
Commit
c362b91a
authored
Jan 22, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minimal test covering classh_type_casters load_impl Case 2b.
parent
82f619bd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
include/pybind11/detail/classh_type_casters.h
+0
-1
tests/test_classh_inheritance.cpp
+2
-2
tests/test_classh_inheritance.py
+13
-0
No files found.
include/pybind11/detail/classh_type_casters.h
View file @
c362b91a
...
@@ -167,7 +167,6 @@ public:
...
@@ -167,7 +167,6 @@ public:
// we can find an exact match (or, for a simple C++ type, an inherited match); if so, we
// we can find an exact match (or, for a simple C++ type, an inherited match); if so, we
// can safely reinterpret_cast to the relevant pointer.
// can safely reinterpret_cast to the relevant pointer.
else
if
(
bases
.
size
()
>
1
)
{
else
if
(
bases
.
size
()
>
1
)
{
pybind11_fail
(
"classh_type_casters: Case 2b UNTESTED."
);
for
(
auto
base
:
bases
)
{
for
(
auto
base
:
bases
)
{
if
(
no_cpp_mi
?
PyType_IsSubtype
(
base
->
type
,
typeinfo
->
type
)
:
base
->
type
==
typeinfo
->
type
)
{
if
(
no_cpp_mi
?
PyType_IsSubtype
(
base
->
type
,
typeinfo
->
type
)
:
base
->
type
==
typeinfo
->
type
)
{
this_
.
load_value_and_holder
(
reinterpret_cast
<
instance
*>
(
src
.
ptr
())
->
get_value_and_holder
(
base
));
this_
.
load_value_and_holder
(
reinterpret_cast
<
instance
*>
(
src
.
ptr
())
->
get_value_and_holder
(
base
));
...
...
tests/test_classh_inheritance.cpp
View file @
c362b91a
...
@@ -67,8 +67,8 @@ TEST_SUBMODULE(classh_inheritance, m) {
...
@@ -67,8 +67,8 @@ TEST_SUBMODULE(classh_inheritance, m) {
m
.
def
(
"pass_base"
,
pass_base
);
m
.
def
(
"pass_base"
,
pass_base
);
m
.
def
(
"pass_drvd"
,
pass_drvd
);
m
.
def
(
"pass_drvd"
,
pass_drvd
);
py
::
classh
<
base1
>
(
m
,
"base1"
)
;
py
::
classh
<
base1
>
(
m
,
"base1"
)
.
def
(
py
::
init
<>
());
// __init__ needed for Python inheritance.
py
::
classh
<
base2
>
(
m
,
"base2"
);
py
::
classh
<
base2
>
(
m
,
"base2"
)
.
def
(
py
::
init
<>
())
;
py
::
classh
<
drvd2
,
base1
,
base2
>
(
m
,
"drvd2"
);
py
::
classh
<
drvd2
,
base1
,
base2
>
(
m
,
"drvd2"
);
m
.
def
(
"make_drvd2"
,
make_drvd2
,
py
::
return_value_policy
::
take_ownership
);
m
.
def
(
"make_drvd2"
,
make_drvd2
,
py
::
return_value_policy
::
take_ownership
);
...
...
tests/test_classh_inheritance.py
View file @
c362b91a
...
@@ -34,3 +34,16 @@ def test_make_drvd2_up_casts_pass_drvd2():
...
@@ -34,3 +34,16 @@ def test_make_drvd2_up_casts_pass_drvd2():
assert
b2
.
__class__
.
__name__
==
"drvd2"
assert
b2
.
__class__
.
__name__
==
"drvd2"
i2
=
m
.
pass_drvd2
(
b2
)
i2
=
m
.
pass_drvd2
(
b2
)
assert
i2
==
3
*
110
+
4
*
120
+
23
assert
i2
==
3
*
110
+
4
*
120
+
23
def
test_python_drvd2
():
class
Drvd2
(
m
.
base1
,
m
.
base2
):
def
__init__
(
self
):
m
.
base1
.
__init__
(
self
)
m
.
base2
.
__init__
(
self
)
d
=
Drvd2
()
i1
=
m
.
pass_base1
(
d
)
# load_impl Case 2b
assert
i1
==
110
+
21
i2
=
m
.
pass_base2
(
d
)
assert
i2
==
120
+
22
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