Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEV-master-smart_holder] Bake smart_holder functionality into class_ and type_caster_base #5213

Closed
wants to merge 155 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
8b0b377
Bring in smart_holder_poc.h from smart_holder branch (baby step).
rwgk Jun 29, 2024
ced85c9
Add tests/test_wip.cpp,py (empty)
rwgk Jun 29, 2024
e590748
Add `py::class_<SomeType>` with default ctor.
rwgk Jun 29, 2024
97a3a49
make smart_holder the default holder (baby step; does not build)
rwgk Jun 29, 2024
00a9157
fix build failure by introducing init_instance() specialization for s…
rwgk Jun 29, 2024
fbf88cb
Bring smart_holder init_instance_for_type<> directly into the init_in…
rwgk Jun 29, 2024
144ae8b
Also bring in try_initialization_using_shared_from_this() from smart_…
rwgk Jun 29, 2024
9a88c09
Comment out or skip: with this test_class passes.
rwgk Jun 29, 2024
a1e312e
Comment out or skip: with this test_pickling passes.
rwgk Jun 29, 2024
bcc3b87
Comment out or skip: with this test_factory_constructors passes.
rwgk Jun 29, 2024
33b0b38
Minimal reproducer for one of the test_factory_constructors.cpp build…
rwgk Jun 29, 2024
dfaa49b
Bring in pybind11/detail/class.h, init.h as-is from smart_holder bran…
rwgk Jun 30, 2024
03e6a93
Remove stray line (probably from an accident/oversight a long time ag…
rwgk Jun 30, 2024
e8cd429
pybind11/detail/init.h: replace type_uses_smart_holder_type_caster<> …
rwgk Jun 30, 2024
381fdc5
Bring in smart_holder_from_unique_ptr(), smart_holder_from_shared_ptr…
rwgk Jun 30, 2024
8fe75ff
Remove all (3) BAKEIN_BREAK from test_factory_constructors.cpp and al…
rwgk Jun 30, 2024
c6a917e
Add make_some_type() to test_wip (reproduces Segmentation fault in te…
rwgk Jun 30, 2024
e4d0a55
Remove is_holder_type<unique_ptr>
rwgk Jul 1, 2024
5518e01
Copy-paste-and-specialize copyable_holder_caster<shared_ptr>, move_on…
rwgk Jul 1, 2024
6ff547e
Introduce type_caster_base<>::unique_ptr_to_python()
rwgk Jul 1, 2024
ae08f51
Start pybind11/detail/smart_holder_type_caster_support.h, move unique…
rwgk Jul 1, 2024
8254d77
Add pytest.skip("BAKEIN_BREAK: ...") in test_smart_ptr.py (all non-sk…
rwgk Jul 1, 2024
7de474f
Add new include files to CMakeLists.txt, tests/extra_python_package/t…
rwgk Jul 2, 2024
b0cfeec
Merge branch 'master' into bakein
rwgk Jul 2, 2024
6c227c7
Remove pytest.skip("BAKEIN_BREAK: ...") in test_class.py (not needed …
rwgk Jul 2, 2024
6b89ca0
test_class.cpp: transfer CHECK_SMART_HOLDER from smart_holder branch …
rwgk Jul 2, 2024
107bcf9
Bring in tests/pure_cpp/smart_holder_poc_test.cpp from smart_holder b…
rwgk Jul 2, 2024
9e3cdf7
Update .codespell-ignore-lines for tests/pure_cpp/smart_holder_poc_te…
rwgk Jul 2, 2024
c92b4d8
Insert PYBIND11_SMART_HOLDER_PADDING (with the idea to catch undefine…
rwgk Jul 2, 2024
f84be2e
Remove all BAKEIN_BREAK in test_pickling.cpp,py (tests pass without a…
rwgk Jul 2, 2024
66a775e
Replace BAKEIN_BREAK with BAKEIN_EXPECTED in test_smart_ptr_from_defa…
rwgk Jul 2, 2024
b6171bc
Bring in tests/test_class_sh_basic.cpp,py from smart_holder branch as…
rwgk Jul 2, 2024
12b0130
Add no-op pybind11/smart_holder.h, 21 BAKEIN_BREAK in test_class_sh_b…
rwgk Jul 2, 2024
a332fe8
Fix oversights: Add pybind11/smart_holder.h in CMakeLists.txt, tests/…
rwgk Jul 2, 2024
7a6d30c
Fix `rtrn_shmp`, `rtrn_shmp` by transferring `smart_holder_from_share…
rwgk Jul 3, 2024
5957133
Add `smart_holder_from_unique_ptr()` specialization for `std::unique_…
rwgk Jul 3, 2024
556f28a
Add `smart_holder_from_shared_ptr()` specialization for `std::shared_…
rwgk Jul 3, 2024
17c0354
`copyable_holder_caster<type, std::shared_ptr<type>>`: split `load_va…
rwgk Jul 3, 2024
2837df1
Rename `holder` to `shared_ptr_holder` to improve readability. No fun…
rwgk Jul 3, 2024
fc5678b
Add `value_and_holder loaded_v_h;` member (set, but currently unused).
rwgk Jul 3, 2024
af66246
Resolve clang-tidy errors:
rwgk Jul 3, 2024
224e934
Implement `operator std::shared_ptr<type> &()`, remove 2 BAKEIN_BREAK…
rwgk Jul 3, 2024
d4fc392
`move_only_holder_caster<type, std::unique_ptr<T, D>>`: inherit from …
rwgk Jul 3, 2024
391d772
Remove `operator type *() unique_ptr`, and `&` (not sure how they wou…
rwgk Jul 4, 2024
0eb23f2
Remove all but 3 BAKEIN_BREAK in test_class_sh_basic.cpp
rwgk Jul 4, 2024
ebbe066
Implement `operator std::unique_ptr<type, deleter>()`. Resolves all b…
rwgk Jul 4, 2024
874f69d
Add `cast(const std::unique_ptr<type, deleter> &, ...)`. Remove the l…
rwgk Jul 4, 2024
66fb5c9
Merge branch 'master' into bakein
rwgk Jul 5, 2024
fd1afdb
`move_only_holder_caster<...unique_ptr...>::load_value()`: `throw` in…
rwgk Jul 5, 2024
0b7a628
Check for Python instance is uninitialized/disowned in type_caster_ba…
rwgk Jul 5, 2024
12c0eb3
inline shared_ptr_to_python() in cast.h
rwgk Jul 5, 2024
e593589
inline unique_ptr_to_python() in cast.h
rwgk Jul 5, 2024
c84dacc
Factor out smart_holder_value_and_holder_support.h to avoid code dupl…
rwgk Jul 5, 2024
46ab14e
Add missing `explicit` to resolve clang-tidy error.
rwgk Jul 5, 2024
470a765
Bring in tests/test_class_sh_factory_constructors.cpp,py from smart_h…
rwgk Jul 5, 2024
d9d9611
Bring in all tests/test_class_*.cpp,py from smart_holder branch as-is…
rwgk Jul 5, 2024
4ce1524
Bring in tests/test_class_sh_shared_ptr_copy_move.cpp,py from smart_h…
rwgk Jul 5, 2024
fcc868d
Add `PYBIND11_TYPE_CASTER_BASE_HOLDER(...) (no-op)`
rwgk Jul 5, 2024
288442c
Add more test_class_sh_* in tests/CMakeLists.txt
rwgk Jul 5, 2024
25c8edf
Bring in tests/test_class_sh_mi_thunks.cpp,py from smart_holder branc…
rwgk Jul 5, 2024
3466ce5
Add pytest.skip("BAKEIN_BREAK: ...") in test_class_sh_mi_thunks.py
rwgk Jul 5, 2024
7173a3a
Bring in tests/test_class_sh_disowning_mi.cpp,py from smart_holder br…
rwgk Jul 5, 2024
34b8d36
Add pytest.skip("BAKEIN_BREAK: ...") in test_class_sh_disowning_mi.py
rwgk Jul 5, 2024
2180dd4
Add test_class_sh_disowning_mi, test_class_sh_mi_thunks in CMakeLists…
rwgk Jul 5, 2024
70ba91f
Inline smart_holder_type_caster_support, trampoline_self_life_support…
rwgk Jul 6, 2024
af467ea
WIP
rwgk Jul 6, 2024
4114e97
throw from `convert_type()` to expose bug.
rwgk Jul 6, 2024
b201eec
Remove pytest.skip("BAKEIN_BREAK: ...") in test_class_sh_mi_thunks.py…
rwgk Jul 6, 2024
eb15f1a
WIP: remove convert_type() call from loaded_as_shared_ptr()
rwgk Jul 6, 2024
bb6b429
MESSY but success for: test_get_vec_size_raw_shared[get_drvd_as_base0…
rwgk Jul 6, 2024
1fbc4a2
Clean out dead-end and debug code.
rwgk Jul 7, 2024
103666a
Micro-scale cleanup/consolidation.
rwgk Jul 7, 2024
042ea81
Pass thunk-corrected pointer to loaded_as_unique_ptr(). With this all…
rwgk Jul 7, 2024
1158dbc
Remove `pytest.skip("BAKEIN_BREAK: ...")` in test_class_sh_disowning_…
rwgk Jul 7, 2024
bd37d69
Bug fix: `typeid(cpptype)` -> `cpptype->name()`
rwgk Jul 7, 2024
011c795
test_class_sh_disowning.py: BAKEIN_WIP: Why is the behavior different?
rwgk Jul 7, 2024
56019a2
Clean out debug code in test_class_sh_mi_thunks.cpp,py
rwgk Jul 7, 2024
b82892a
Resolve clang-tidy errors and warnings.
rwgk Jul 7, 2024
89c58c4
Add `pytest.skip("BAKEIN_BREAK: ...)` in test_class_sh_shared_ptr_cop…
rwgk Jul 7, 2024
7fc2ef4
Merge branch 'master' into bakein
rwgk Jul 7, 2024
f1f0eef
Remove cruft from `smart_holder_type_caster_support::load_helper<>`
rwgk Jul 7, 2024
c453013
Move `pytest.skip("BAKEIN_BREAK: ...)` in test_class_sh_shared_ptr_co…
rwgk Jul 7, 2024
c7bd78c
Bring in tests/test_class_sh_property.cpp,py from smart_holder branch…
rwgk Jul 7, 2024
b89ec00
Add `BAKEIN_BREAK` in test_class_sh_property.cpp,py
rwgk Jul 7, 2024
f52456e
Bring in tests/test_class_sh_property_non_owning.cpp,py from smart_ho…
rwgk Jul 7, 2024
ac055a4
Add `BAKEIN_BREAK` in test_class_sh_property_non_owning.cpp,py
rwgk Jul 7, 2024
9e3bee0
Bring in tests/test_classh_mock.cpp,py from smart_holder branch as-is…
rwgk Jul 7, 2024
68c9d13
Bring in tests/*class_sh_module_local* from smart_holder branch as-is…
rwgk Jul 7, 2024
91d4003
Disable for now (to be debugged later): CI / 🐍 3 • GCC 7 • C++17• x64
rwgk Jul 7, 2024
cc86fb3
test_class_sh_property_non_owning.py appears to cause memory corrupti…
rwgk Jul 8, 2024
3ddfc58
Add two `pytest.skip("BAKEIN_BREAK: Segmentation fault")` in test_cla…
rwgk Jul 8, 2024
625c88b
Add two more `pytest.skip("BAKEIN_BREAK: Segmentation fault")` in tes…
rwgk Jul 8, 2024
0296d33
Stress test: use PYBIND11_SMART_HOLDER_PADDING unconditionally.
rwgk Jul 9, 2024
752626d
SegFault 20.04 C++11 MinSizeRel all tests, but only first pass after …
rwgk Jul 9, 2024
5a4442f
pytest.skip() right before m.disown_b(...) in test_class_sh_property_…
rwgk Jul 9, 2024
c0f5078
Pull in from smart_holder branch: Additional `assert is_disowned()` i…
rwgk Jul 9, 2024
c527814
Transfer test_mixed from test_class_sh_disowning to test_wip (prepara…
rwgk Jul 9, 2024
36bbac1
LOOOK to trace disowning
rwgk Jul 9, 2024
c6a87e8
Call new load_helper.get_void_ptr_or_nullptr() instead of calling typ…
rwgk Jul 9, 2024
e254264
Restore original test_class_sh_disowning.py from smart_holder branch.
rwgk Jul 9, 2024
5759190
Remove all LOOOK in type_caster_base.h
rwgk Jul 9, 2024
1ea3855
Reducing 1.
rwgk Jul 10, 2024
d3537e4
Reducing 2: rename C++ namespace from class_sh_disowning_mi to wip.
rwgk Jul 10, 2024
7e1eced
test_ccccccccccccccccccccc
rwgk Jul 10, 2024
f855283
Restore test_class_sh_disowning_mi.cpp,py as it last worked with GHA …
rwgk Jul 10, 2024
127058c
Replace `loaded_v_h.type = get_type_info(typeid(type))` with `loaded_…
rwgk Jul 10, 2024
f852cf5
Copy code `property_cpp_function<>` code from smart_holder branch as-…
rwgk Jul 10, 2024
1bcf572
First pass adapting all `property_cpp_function<>` implementations. St…
rwgk Jul 10, 2024
048e36d
Bring in `shared_ptr_with_responsible_parent()` from smart_holder bra…
rwgk Jul 12, 2024
0b14d5b
test_class_sh_property.py `test_valu_getter()` works without any furt…
rwgk Jul 12, 2024
d373a08
Remove remaining BAKEIN_BREAK in test_class_sh_property.cpp,py and ad…
rwgk Jul 12, 2024
63044cc
Bring in `default_holder_type` from smart_holder branch including usi…
rwgk Jul 12, 2024
d021bb1
Remove redundant `check_holder_compat()` no-op implementation.
rwgk Jul 12, 2024
092d236
Remove test_wip.cpp,py (not needed anymore).
rwgk Jul 12, 2024
6fa0a2e
PYBIND11_HAVE_HOLDER_CASTER_WITH_SMART_HOLDER_SUPPORT
rwgk Jul 13, 2024
2600bb6
Remove test_ccccccccccccccccccccc.cpp,py (not needed anymore).
rwgk Jul 13, 2024
3406be6
New test_class_sh_property_bakein.py
rwgk Jul 14, 2024
c65d5df
Systematically use `is_base_of<type_caster_generic, make_caster<D>>` …
rwgk Jul 14, 2024
89da1e2
Use `memcpy` instead of `strcpy` to resolve MSVC errors.
rwgk Jul 14, 2024
ff3693f
Introduce `detail::both_t_and_d_use_type_caster_base<T, D>` helper an…
rwgk Jul 15, 2024
0f874de
Move `must_be_member_function_pointer` to the `detail` namespace.
rwgk Jul 15, 2024
884305e
Add `"_sh_baked_in"` to `PYBIND11_INTERNALS_ID`, `PYBIND11_MODULE_LOC…
rwgk Jul 15, 2024
12f384b
`smart_holder_from_unique_ptr`: also accept `return_value_policy::ref…
rwgk Jul 15, 2024
ecd01da
`smart_holder_from_unique_ptr`: also accept `return_value_policy::tak…
rwgk Jul 15, 2024
ed27c37
Merge branch 'master' into bakein
rwgk Jul 16, 2024
8ca5593
Merge branch 'master' into bakein
rwgk Jul 18, 2024
5e30064
Factor out detail/value_and_holder.h (from detail/type_caster_base.h)
rwgk Jul 18, 2024
54fd559
Fix a minor and inconsequential inconsistency in `copyable_holder_cas…
rwgk Jul 18, 2024
7fa6dd9
Merge branch 'bakein_prep_on_master' into bakein
rwgk Jul 18, 2024
9a27e29
Leverage PR #5251 to bring back trampoline_self_life_support.h from s…
rwgk Jul 18, 2024
1ca810e
Undo `DANGER ZONE` comment (brought in from smart_holder branch; befo…
rwgk Jul 18, 2024
92d7724
Add `DANGER ZONE` comment in detail/init.h, similar to a comment adde…
rwgk Jul 18, 2024
4aa2f6b
Merge branch 'bakein_prep_on_master' into bakein
rwgk Jul 18, 2024
6d8952a
Merge branch 'master' into bakein
rwgk Jul 19, 2024
1ea1787
Remove overlooked BAKEIN_BREAK in test_class_sh_property_non_owning.c…
rwgk Jul 19, 2024
cd4f5f6
PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
rwgk Jul 19, 2024
58a1b75
Reinterpret `detail::type_info::default_holder` as "uses `std::unique…
rwgk Jul 19, 2024
583c07b
Use `std::unique_ptr<T>` as default holder again.
rwgk Jul 19, 2024
7296c39
Introduce detail/using_smart_holder.h and remove `pybindit::memory::`…
rwgk Jul 19, 2024
cc2a428
Bring in ci.yml, ci_sh_def.yml, ci_sh_def.yml.patch from smart_holder…
rwgk Jul 19, 2024
6fb8b51
Add back original `copyable_holder_caster` `check_holder_compat()` in…
rwgk Jul 19, 2024
95e9053
Boilerplate changes: Skip all test_class_sh_* if PYBIND11_HAVE_INTERN…
rwgk Jul 19, 2024
e445619
Ignore PYBIND11_USE_SMART_HOLDER_AS_DEFAULT if PYBIND11_HAVE_INTERNAL…
rwgk Jul 19, 2024
41433f6
ifdef out classh if PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT…
rwgk Jul 19, 2024
4a66b46
ifdef out more code if PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPP…
rwgk Jul 19, 2024
62b6c8e
Revert "Add `"_sh_baked_in"` to `PYBIND11_INTERNALS_ID`, `PYBIND11_MO…
rwgk Jul 20, 2024
35b1177
Small cleanup in detail/init.h: strip `originally_smart_holder_type_c…
rwgk Jul 20, 2024
5566c63
Move `try_initialization_using_shared_from_this` into `PYBIND11_HAVE_…
rwgk Jul 20, 2024
df54a82
Introduce PYBIND11_SMART_HOLDER_PADDING_ON (as the only way to turn o…
rwgk Jul 20, 2024
84f71f1
Import https://github.com/pybind/pybind11/pull/5256 from smart_holder…
rwgk Jul 20, 2024
9f9a698
Remove redundant test_class_sh_property_bakein.cpp,py
rwgk Jul 20, 2024
d0003f5
Move `classh` into pybind11/pybind11.h and update test_classh_mock.cp…
rwgk Jul 21, 2024
89d0ddd
test_class.cpp: simpler approach, leveraging new `PYBIND11_ACTUALLY_U…
rwgk Jul 21, 2024
18b72c0
Tie `PYBIND11_INTERNALS_VERSION 6` to `PYBIND11_VERSION_MAJOR >= 3`
rwgk Jul 21, 2024
c4c3d9a
Import non-functional test changes made on smart_holder branch under …
rwgk Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .codespell-ignore-lines
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ template <op_id id, op_type ot, typename L, typename R>
template <detail::op_id id, detail::op_type ot, typename L, typename R, typename... Extra>
class_ &def(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
class_ &def_cast(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
int valu;
explicit movable_int(int v) : valu{v} {}
movable_int(movable_int &&other) noexcept : valu(other.valu) { other.valu = 91; }
explicit indestructible_int(int v) : valu{v} {}
REQUIRE(hld.as_raw_ptr_unowned<zombie>()->valu == 19);
REQUIRE(othr.valu == 19);
REQUIRE(orig.valu == 91);
(m.pass_valu, "Valu", "pass_valu:Valu(_MvCtor)*_CpCtor"),
atyp_valu rtrn_valu() { atyp_valu obj{"Valu"}; return obj; }
assert m.atyp_valu().get_mtxt() == "Valu"
// valu(e), ref(erence), ptr or p (pointer), r = rvalue, m = mutable, c = const,
@pytest.mark.parametrize("access", ["ro", "rw", "static_ro", "static_rw"])
struct IntStruct {
explicit IntStruct(int v) : value(v){};
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ on:
branches:
- master
- stable
- smart_holder
- v*

permissions: read-all

concurrency:
group: test-${{ github.ref }}
group: test-sh-avl${{ github.ref }}
cancel-in-progress: true

env:
Expand Down
Loading