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
797fe060
Commit
797fe060
authored
Feb 17, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding source code comments in response to review.
parent
6005632b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
0 deletions
+10
-0
include/pybind11/cast.h
+7
-0
include/pybind11/detail/smart_holder_poc.h
+1
-0
include/pybind11/detail/smart_holder_type_casters_inline_include.h
+2
-0
No files found.
include/pybind11/cast.h
View file @
797fe060
...
@@ -11,9 +11,16 @@
...
@@ -11,9 +11,16 @@
#pragma once
#pragma once
// clang-format on
#ifndef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
#ifndef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
// #define PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
// #define PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
// Currently the main purpose of this switch is to enable non-intrusive comprehensive testing. If
// and when `smart_holder` will actually become the released default is currently open. In the
// meantime, the full functionality is easily available by using `py::classh`, which is just a
// handy shortcut for `py::class_<T, py::smart_holder>` (see `pybind11/smart_holder.h`). Classes
// wrapped in this way are fully compatible with everything existing.
#endif
#endif
// clang-format off
#include "pytypes.h"
#include "pytypes.h"
#include "detail/typeid.h"
#include "detail/typeid.h"
...
...
include/pybind11/detail/smart_holder_poc.h
View file @
797fe060
...
@@ -154,6 +154,7 @@ struct smart_holder {
...
@@ -154,6 +154,7 @@ struct smart_holder {
// race conditions, but in the context of Python it is a bug (elsewhere)
// race conditions, but in the context of Python it is a bug (elsewhere)
// if the Global Interpreter Lock (GIL) is not being held when this code
// if the Global Interpreter Lock (GIL) is not being held when this code
// is reached.
// is reached.
// SMART_HOLDER_WIP: IMPROVABLE: assert(GIL is held).
if
(
vptr
.
use_count
()
!=
1
)
{
if
(
vptr
.
use_count
()
!=
1
)
{
throw
std
::
runtime_error
(
std
::
string
(
"Cannot disown use_count != 1 ("
)
+
context
throw
std
::
runtime_error
(
std
::
string
(
"Cannot disown use_count != 1 ("
)
+
context
+
")."
);
+
")."
);
...
...
include/pybind11/detail/smart_holder_type_casters_inline_include.h
View file @
797fe060
...
@@ -229,6 +229,8 @@ public:
...
@@ -229,6 +229,8 @@ public:
bool
reinterpret_cast_deemed_ok
=
false
;
bool
reinterpret_cast_deemed_ok
=
false
;
// Magic number intentionally hard-coded, to guard against class_ holder mixups.
// Magic number intentionally hard-coded, to guard against class_ holder mixups.
// Ideally type_caster_generic would have a similar guard, but this requires a change there.
// Ideally type_caster_generic would have a similar guard, but this requires a change there.
// SMART_HOLDER_WIP: If it is decided that this guard is useful long term, potentially
// set/reset this value in ctor/dtor, mark volatile.
std
::
size_t
local_load_safety_guard
=
1887406645
;
// 32-bit compatible value for portability.
std
::
size_t
local_load_safety_guard
=
1887406645
;
// 32-bit compatible value for portability.
};
};
// clang-format on
// clang-format on
...
...
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