Ralf W. Grosse-Kunstleve
6b9f544df4
Renaming all "classh" to "smart_holder" in pybind11/detail/smart_holder_type_casters.h.
...
The user-facing macro is now PYBIND11_SMART_HOLDER_TYPE_CASTERS.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
7f67db974a
Renaming files in include directory, creating pybind11/smart_holder.h.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
ab7d11f2d9
Adding py::smart_holder support to py::class_, purging py::classh completely.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
eb5678665f
Moving several tests to github.com/rwgk/rwgk_tbx/tree/main/pybind11_tests
...
a2c2f88174
These tests are from experimenting, and for demonstrating UB in pybind11 multiple inheritance handling ("first_base"), to be fixed later.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
0dffc292a4
Purging obsolete pybind11/vptr_holder.h and associated test.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
6f7b10fe9f
Removing debugging comments (GET_STACK, GET_INT_STACK). cast.h is identical to current master again, pybind11.h only has the generic_type::initialize(..., &type_caster_generic::local_load) change.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
d2807d895c
Converting test_unique_ptr_member to using classh: fully working, ASAN, MSAN, UBSAN clean.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
2351d4b424
Using unique_ptr in local_load to replace static variable. Also adding local_load_safety_guard.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
c322f981ab
Folding convert_type into lvalue_ref and rvalue_ref paths. Some smart_holder_type_caster_load cleanup.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
89da41b4c0
Factoring out convert_type and folding into loaded_as_unique_ptr.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
048ebc8a85
Cleaning up loaded_as_raw_ptr_unowned, loaded_as_shared_ptr.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
01eb1904a5
Removing rtti_held from smart_holder. See updated comment.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
494331a67b
Adding smart_holder_type_caster_load::loaded_as_shared_ptr, currently bypassing smart_holder shared_ptr tracking completely, but the tests pass and are sanitizer clean.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
3b6a20c398
Moving const after type name, for functions that cover a systematic scheme. NO functional changes.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
effda3e31a
Adopting systematic naming scheme from test_classh_wip. NO functional changes.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
1d8c27d101
Pure renaming of function and variable names, for better generalization when convoluting with inheritance. NO functional changes.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
25b254574f
Pure renaming of function names in test_classh_inheritance, similar to the systematic approach used in test_class_wip. NO functional changes.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
d5f92c7d25
Tests for classh py::module_local() feature.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
e1c8a98b1b
Removing stray isinstance<T>(src): it interferes with the py::module_local feature. Adding missing #includes.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
543a04ff18
Minimal test covering classh_type_casters load_impl Case 2b.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
98162ff356
Changes and tests covering classh_type_casters try_implicit_casts.
2021-01-29 14:11:56 -08:00
Ralf W. Grosse-Kunstleve
ecd22fa103
Decoupling generic_type from type_caster_generic.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
7a841082f2
First pass adjusting try_implicit_casts and try_load_foreign_module_local to capture loaded_v_h, but untested and guarded with pybind11_failure("Untested"). This was done mainly to determine general feasibility. Note the TODO in pybind11.h, where type_caster_generic::local_load is currently hard-coded. test_classh_wip and test_classh_inheritance still pass, as before.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
f0c2d10d35
Minimal changes needed to pass test_classh_inheritance.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
f2329d8cca
Folding in modified_type_caster_generic_load_impl, just enough to pass test_class_wip. test_classh_inheritance is still failing, but with a different error: [RuntimeError: Incompatible type (as_raw_ptr_unowned).]
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
463788af26
Bringing back .clang-format, the previous rm was a bad idea.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
f066e43052
Removing .clang-format before git rebase master (where the file was added).
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
c29134cdf9
Adding test_classh_inheritance, currently failing (passes with class_).
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
238cc1222b
Adding & using PYBIND11_CLASSH_TYPE_CASTERS define.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
1c6be1dc72
Using pybind11/detail/classh_type_casters.h from test_classh_wip.cpp.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
9b1c7e7579
Copying classh type_casters from test_classh_wip.cpp UNMODIFIED, as a baseline for generalizing the code.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
20fe4e9319
Moving factored-out make_constructor to test_classh_wip.cpp, restoring previous version of cast.h. This is currently the most practical approach. See PR #2798 for background.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
07fbe0f417
Factoring out find_existing_python_instance().
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
d014eca1d8
Adding minor comment (change to internals needed to distinguish uninitialized/disowned in error message).
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
f21dac6b5b
Inserting additional assert to ensure a returned unique_ptr is always a new Python instance.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
3ebb723146
Using factored-out make_constructor (PR #2798 ), removing duplicate code.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
f78ac3c911
Fixing clang-format oversight.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
e7e136b535
Using type_caster_base<mpty>::src_and_type directly, removing copy. Also renaming one cast to cast_const_raw_ptr, for clarity.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
71409b5624
Cosmetical change around helper functions.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
07ed8aaab1
Removing enable_shared_from_this stub, simplifying existing code, clang-format.
...
Open question, with respect to the original code:
76a160070b/include/pybind11/pybind11.h (L1510)
To me it looks like the exact situation marked as `std::shared_ptr<Good> gp1 = not_so_good.getptr();` here: https://en.cppreference.com/w/cpp/memory/enable_shared_from_this
The comment there is: `// undefined behavior (until C++17) and std::bad_weak_ptr thrown (since C++17)`
Does the existing code have UB pre C++17?
I'll leave handling of enable_shared_from_this for later, as the need arises.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
e26bd404c4
Calling deregister_instance after disowning via unique_ptr.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
4f135ce851
Making test_type_caster_bare_interface_demo.cpp slightly more realistic, ASAN, MSAN, UBSAN clean.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
1ac08dbc5e
Fixing bugs discovered by ASAN. The code is now ASAN, MSAN, UBSAN clean.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
c3627d2195
Bug fix: vptr_deleter_armed_flag_ptr has to live on the heap.
...
See new bullet point in comment section near the top.
The variable was also renamed to reflect its function more accurately.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
f47fe70bfc
static handle cast implementations for rtrn_uqmp, rtrn_uqcp.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
60597f3db3
Adding MISSING comments in operator std::unique_ptr<mpty[ const]>.
2021-01-29 14:11:55 -08:00
Ralf W. Grosse-Kunstleve
034c95caf3
static handle cast implementations for rtrn_shmp, rtrn_shcp.
2021-01-29 14:11:54 -08:00
Ralf W. Grosse-Kunstleve
ccf594376a
Adding comment re potential use_count data race.
2021-01-29 14:11:54 -08:00
Ralf W. Grosse-Kunstleve
31838564e2
Pure clang-format change (applied to original type_caster_generic::cast).
2021-01-29 14:11:54 -08:00
Ralf W. Grosse-Kunstleve
783852aa22
Copying type_caster_generic::cast into type_caster<mpty> as-is (preparation for handling smart pointers).
2021-01-29 14:11:54 -08:00