Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
669aa294
Commit
669aa294
authored
Aug 20, 2017
by
Dean Moldovan
Browse files
Improve type safety of internals.registered_types_cpp
parent
96997a4b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
include/pybind11/cast.h
include/pybind11/cast.h
+2
-2
include/pybind11/detail/internals.h
include/pybind11/detail/internals.h
+3
-3
No files found.
include/pybind11/cast.h
View file @
669aa294
...
...
@@ -169,7 +169,7 @@ inline detail::type_info *get_local_type_info(const std::type_index &tp) {
auto
&
locals
=
registered_local_types_cpp
();
auto
it
=
locals
.
find
(
tp
);
if
(
it
!=
locals
.
end
())
return
(
detail
::
type_info
*
)
it
->
second
;
return
it
->
second
;
return
nullptr
;
}
...
...
@@ -177,7 +177,7 @@ inline detail::type_info *get_global_type_info(const std::type_index &tp) {
auto
&
types
=
get_internals
().
registered_types_cpp
;
auto
it
=
types
.
find
(
tp
);
if
(
it
!=
types
.
end
())
return
(
detail
::
type_info
*
)
it
->
second
;
return
it
->
second
;
return
nullptr
;
}
...
...
include/pybind11/detail/internals.h
View file @
669aa294
...
...
@@ -65,7 +65,7 @@ struct overload_hash {
/// Whenever binary incompatible changes are made to this structure,
/// `PYBIND11_INTERNALS_VERSION` must be incremented.
struct
internals
{
type_map
<
void
*>
registered_types_cpp
;
// std::type_index -> type
_
info
type_map
<
type_info
*>
registered_types_cpp
;
// std::type_index ->
pybind11's
type
info
rmation
std
::
unordered_map
<
PyTypeObject
*
,
std
::
vector
<
type_info
*>>
registered_types_py
;
// PyTypeObject* -> base type_info(s)
std
::
unordered_multimap
<
const
void
*
,
instance
*>
registered_instances
;
// void * -> instance*
std
::
unordered_set
<
std
::
pair
<
const
PyObject
*
,
const
char
*>
,
overload_hash
>
inactive_overload_cache
;
...
...
@@ -196,8 +196,8 @@ PYBIND11_NOINLINE inline internals &get_internals() {
}
/// Works like `internals.registered_types_cpp`, but for module-local registered types:
PYBIND11_NOINLINE
inline
type_map
<
void
*>
&
registered_local_types_cpp
()
{
static
type_map
<
void
*>
locals
{};
PYBIND11_NOINLINE
inline
type_map
<
type_info
*>
&
registered_local_types_cpp
()
{
static
type_map
<
type_info
*>
locals
{};
return
locals
;
}
...
...
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