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
78d729aa
Commit
78d729aa
authored
Dec 16, 2020
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding is_polymorphic to void_ptr_with_type_info
parent
c671bd3b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
include/pybind11/detail/internals.h
+16
-4
include/pybind11/pybind11.h
+8
-1
No files found.
include/pybind11/detail/internals.h
View file @
78d729aa
...
...
@@ -123,15 +123,25 @@ struct internals {
#endif
};
template
<
typename
T
,
typename
SFINAE
=
void
>
struct
optional_element_type
{
using
element_type
=
void
;
};
template
<
typename
C
>
struct
optional_element_type
<
C
,
std
::
void_t
<
typename
C
::
element_type
>>
{
using
element_type
=
typename
C
::
element_type
;
};
struct
void_ptr_with_type_info
{
const
void
*
ptr
;
std
::
string
type_info_name_non_const
;
std
::
string
type_info_name_orig
;
bool
is_polymorphic
;
void_ptr_with_type_info
()
:
ptr
{
nullptr
},
type_info_name_
non_const
{
typeid
(
std
::
nullptr_t
).
name
()},
type_info_name_orig
{
typeid
(
std
::
nullptr_t
).
name
()
}
{}
:
ptr
{
nullptr
},
type_info_name_non_const
{
typeid
(
std
::
nullptr_t
).
name
()},
type_info_name_
orig
{
typeid
(
std
::
nullptr_t
).
name
()},
is_polymorphic
{
false
}
{}
template
<
typename
T
>
void_ptr_with_type_info
(
T
orig_ptr
)
...
...
@@ -140,7 +150,9 @@ struct void_ptr_with_type_info {
typeid
(
typename
std
::
add_pointer
<
typename
std
::
remove_cv
<
typename
std
::
remove_pointer
<
T
>::
type
>::
type
>::
type
)
.
name
()},
type_info_name_orig
{
typeid
(
T
).
name
()}
{}
type_info_name_orig
{
typeid
(
T
).
name
()},
is_polymorphic
{
std
::
is_polymorphic
<
typename
optional_element_type
<
typename
std
::
remove_pointer
<
T
>::
type
>::
element_type
>::
value
}
{}
};
/// Additional type information which does not fit into the PyTypeObject.
...
...
include/pybind11/pybind11.h
View file @
78d729aa
...
...
@@ -1508,8 +1508,15 @@ private:
std
::
string
instance_hptn
=
type_id
<
holder_type
*>
();
detail
::
to_cout
(
std
::
string
(
"holder_ptr.type_info_name "
)
+
existing_hptn
);
detail
::
to_cout
(
std
::
string
(
" typeid(holder_type *) "
)
+
instance_hptn
);
bool
existing_poly
=
holder_ptr
.
is_polymorphic
;
bool
instance_poly
=
std
::
is_polymorphic
<
type_
>::
value
;
if
(
existing_hptn
!=
instance_hptn
)
{
detail
::
to_cout
(
std
::
string
(
"HOLDER_MISMATCH # "
)
+
existing_hptn
+
" # "
+
instance_hptn
);
detail
::
to_cout
(
std
::
string
(
"HOLDER_MISMATCH "
)
+
(
existing_poly
?
"V"
:
"C"
)
+
(
instance_poly
?
"V"
:
"C"
)
+
" # "
+
existing_hptn
+
" # "
+
instance_hptn
);
}
}
init_holder
(
inst
,
v_h
,
(
const
holder_type
*
)
holder_ptr
.
ptr
,
v_h
.
xxx_value_ptr
<
type
>
());
// calling init_holder // HOLDER_SHARED_MAKE_UNIQUE STACK #3
...
...
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