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
669aa294
Commit
669aa294
authored
Aug 20, 2017
by
Dean Moldovan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve type safety of internals.registered_types_cpp
parent
96997a4b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
include/pybind11/cast.h
+2
-2
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) {
...
@@ -169,7 +169,7 @@ inline detail::type_info *get_local_type_info(const std::type_index &tp) {
auto
&
locals
=
registered_local_types_cpp
();
auto
&
locals
=
registered_local_types_cpp
();
auto
it
=
locals
.
find
(
tp
);
auto
it
=
locals
.
find
(
tp
);
if
(
it
!=
locals
.
end
())
if
(
it
!=
locals
.
end
())
return
(
detail
::
type_info
*
)
it
->
second
;
return
it
->
second
;
return
nullptr
;
return
nullptr
;
}
}
...
@@ -177,7 +177,7 @@ inline detail::type_info *get_global_type_info(const std::type_index &tp) {
...
@@ -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
&
types
=
get_internals
().
registered_types_cpp
;
auto
it
=
types
.
find
(
tp
);
auto
it
=
types
.
find
(
tp
);
if
(
it
!=
types
.
end
())
if
(
it
!=
types
.
end
())
return
(
detail
::
type_info
*
)
it
->
second
;
return
it
->
second
;
return
nullptr
;
return
nullptr
;
}
}
...
...
include/pybind11/detail/internals.h
View file @
669aa294
...
@@ -65,7 +65,7 @@ struct overload_hash {
...
@@ -65,7 +65,7 @@ struct overload_hash {
/// Whenever binary incompatible changes are made to this structure,
/// Whenever binary incompatible changes are made to this structure,
/// `PYBIND11_INTERNALS_VERSION` must be incremented.
/// `PYBIND11_INTERNALS_VERSION` must be incremented.
struct
internals
{
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 information
std
::
unordered_map
<
PyTypeObject
*
,
std
::
vector
<
type_info
*>>
registered_types_py
;
// PyTypeObject* -> base type_info(s)
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_multimap
<
const
void
*
,
instance
*>
registered_instances
;
// void * -> instance*
std
::
unordered_set
<
std
::
pair
<
const
PyObject
*
,
const
char
*>
,
overload_hash
>
inactive_overload_cache
;
std
::
unordered_set
<
std
::
pair
<
const
PyObject
*
,
const
char
*>
,
overload_hash
>
inactive_overload_cache
;
...
@@ -196,8 +196,8 @@ PYBIND11_NOINLINE inline internals &get_internals() {
...
@@ -196,8 +196,8 @@ PYBIND11_NOINLINE inline internals &get_internals() {
}
}
/// Works like `internals.registered_types_cpp`, but for module-local registered types:
/// Works like `internals.registered_types_cpp`, but for module-local registered types:
PYBIND11_NOINLINE
inline
type_map
<
void
*>
&
registered_local_types_cpp
()
{
PYBIND11_NOINLINE
inline
type_map
<
type_info
*>
&
registered_local_types_cpp
()
{
static
type_map
<
void
*>
locals
{};
static
type_map
<
type_info
*>
locals
{};
return
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