Ralf W. Grosse-Kunstleve
52c3f4cc30
This was meant to be PR #3065 : pure clang-format changes. NO manual changes. ( #3073 )
2021-07-02 16:51:24 -07:00
Ralf W. Grosse-Kunstleve
84cbec0bc1
Merge branch 'master' into smart_holder
2021-07-02 07:07:49 -07:00
Dustin Spicuzza
6d4409466b
Check dict item accesses where it isn't already checked ( #2863 )
...
* Convert PyDict_GetXXX to internal error checking variant
* Check unlikely error return from PyDict_DelItemString
2021-07-02 07:02:33 -07:00
Antony Lee
5bcaaa0423
Add a std::filesystem::path <-> os.PathLike caster. ( #2730 )
2021-07-02 07:00:50 -07:00
Ralf W. Grosse-Kunstleve
9ae7f87fb6
Merge branch 'master' into smart_holder
2021-06-30 23:39:32 -07:00
cyy
f067deb563
avoid unnecessary strlen ( #3058 )
2021-06-30 23:35:25 -07:00
jonathan-conder-sm
733f8de24f
Avoid string copy if possible when passing a Python object to std::ostream ( #3042 )
2021-06-30 22:19:14 -07:00
Ralf W. Grosse-Kunstleve
c2111fd353
Merge branch 'master' into smart_holder
2021-06-30 12:36:27 -07:00
Ralf W. Grosse-Kunstleve
fbae8f313b
pickle setstate: setattr __dict__ only if not empty ( #2972 )
...
* pickle setstate: setattr __dict__ only if not empty, to not force use of py::dynamic_attr() unnecessarily.
* Adding unit test.
* Clang 3.6 & 3.7 compatibility.
* PyPy compatibility.
* Minor iwyu fix, additional comment.
* Addressing reviewer requests.
* Applying clang-tidy suggested fixes.
* Adding check_dynamic_cast_SimpleCppDerived, related to issue #3062 .
2021-06-30 12:34:32 -07:00
Ralf W. Grosse-Kunstleve
93169cc907
Small reduction in code complexity.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
f128f1b6db
Converting C assert to pybind11_fail (to play safe).
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
a021e045a9
Adding test_multiple_registered_instances_for_same_pointee_leak. Subtle changes in smart_holder_type_caster_load, trying to work on weak_ptr for shared_ptr_trampoline_self_life_support, but that didn't work out. Manually fully leak-checked again.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
e2108546e1
Adding unit tests: 2 x test_std_make_shared_factory
...
Completes unit test coverage for the changed code in smart_holder_type_casters.h.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
1b752f56c1
Adding unit test: test_multiple_registered_instances_for_same_pointee
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
cb548bb3cc
This change fixes the 6 unit tests in
...
bbfb0259b5/open_spiel/python/mfg/algorithms
best_response_value_test
distribution_test
fictitious_play_test
greedy_policy_test
nash_conv_test
policy_value_test
CAVEAT: The fix is NOT covered by pybind11 unit tests.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
9fce2956bc
A couple more enhancements based on feedback by @laramiel.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
64716cc14c
Adding a few comments after review by @laramiel.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
ab3c5134ad
Cleaning out debug code.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
146a925e4e
Resolving TODOs for from_unique_ptr
void_cast_raw_ptr
. Adding test to exercise the path through cast
. The path through init.h is missing a test that would fail if the flag is incorrect. The plan is to systematically cover all situations (there are many that are not exercised for shared_from_this).
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
a0e19bdc46
Use casting to void *
to evade to shared_from_this mechanism only if pointee_depends_on_holder_owner
, but currently only for from_raw_ptr_take_ownership
.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
1b9f85a09e
Preparation for being smarter about casting to void *
to evade to shared_from_this mechanism.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
48eb78ae77
Simpler and safe implementation based on new requirement: C++ (outside of the Python object) needs to hold a shared_ptr before shared_from_this is called. This is more similar to the existing implementation on current smart_holder HEAD, but still uses a weak_ptr to always return the same shared_ptr as long as C++ does not let it expire.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
3dd89f14df
smart_holder_poc.h: type-erase raw_ptr before passing to shared_ptr::reset, to not trigger populating the shared_from_this weak_ptr. This way the only way the weak_ptr is populated is through loaded_as_shared_ptr. Breaks all but one test in test_class_sh_trampoline_shared_from_this.py, now marked skip WIP to test everything else with the GitHub CI.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
adfd3e1700
Partial cleanup of tests. WIP. The cleanup uncovered a major problem.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
bfd4c4893e
Leveraging new noop_deleter_acting_as_weak_ptr_owner
to retrieve released vptr
.
...
The placeholder `vptr` is never exposed anymore, therefore the externally visible `use_count`s are more intuitive.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
4b872febcc
Adding test_pass_released_shared_ptr_as_unique_ptr
, exercising new guard in smart_holder_type_casters.h.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
223283295f
Two minor platform-specific fixes. Using static_cast instead of reinterpret_cast.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
993613d9bf
Trying again, to get around unused parameter warnings-as-erros.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
20ef96c87d
Disabling debugging call of weak_from_this
for C++ < 17.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
bf8d6a2900
First fully successful attempt to make shared_from_this
and trampolines play nicely.
...
Now also passes the open_spiel iterated_prisoners_dilemma_test ASAN clean, in addition to all pybind11 and PyCLIF unit tests.
The problem was that calling `std::shared_ptr<void>::reset()` with a `void` pointer cannot possibly update the `shared_from_this` `weak_ptr`.
The solution is to store a `shd_ptr_reset` function pointer in `guarded_deleter` (similar in idea to the stored function pointer for calling `delete`).
This commit still includes all debugging code, i.e. is "dirty". The code will be cleaned up after the GitHub CI is fully successful.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
dcf8d0762f
First attempt to make shared_from_this and trampolines play nicely. Passes all pybind11 and PyCLIF unit tests ASAN clean, but not the open_spiel iterated_prisoners_dilemma_test.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
bc21158082
Fixing git rebase -X theirs
accident.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
4ab4f36a92
Fixing silly oversight (discovered while creating PR #3041 ).
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
cd5fbc56db
Replacing virtual guarded_operator_call
with non-virtual guarded_delete
.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
1e6cc9dd69
Adding back explicit but default copy constructor, to keep some older compilers happy.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
275aaf977a
Inserting const_cast
for std::get_deleter
return, to keep Ubuntu 20 GCC 6.3.0 happy.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
b04a70b5cc
Fixing oversight (clang-tidy error).
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
362e64e1ca
WIP snapshot: replacing std::shared_ptr<bool> flag_ptr
with simple bool armed_flag
.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
459301d9a8
WIP snapshot: std::get_deleter experiment.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
e80a1f0617
WIP snapshot.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
eae174b491
Revert "Experiment: effectively undoing all shared_from_this modifications."
...
This reverts commit d72d54ebb0b7784f5616edc02910dbd9cce0b2a4.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
a6abb7cff1
Revert "Experiment: undoing even more."
...
This reverts commit 59bc2e183e7aef5e45c06aed6965de0ac52d7b06.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
5f92b4ff1c
Revert "Experiment: restoring original smart_holder_type_casters.h from smart_holder branch."
...
This reverts commit 19c5a3613fee71878ba2af0339eed325a5916089.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
2ae3c2ceb7
Experiment: restoring original smart_holder_type_casters.h from smart_holder branch.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
9da1e81590
Experiment: undoing even more.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
715ceb4bf3
Experiment: effectively undoing all shared_from_this modifications.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
05bd93543b
Fully emulating type_caster_base-related behavior: trying shared_from_this also for unowned pointees.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
775873d0b6
Adding from_raw_pointer_take_ownership_or_shared_from_this().
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
2a265860a7
enable_shared_from_this_from_raw_ptr_take_ownership_guard: better static_assert that also triggers for derived classes.
2021-06-30 07:04:31 -07:00
Ralf W. Grosse-Kunstleve
24c223ad8e
static_assert in from_raw_ptr_take_ownership, to be tested.
2021-06-30 07:04:31 -07:00