From 6b9f544df46000501d9309eb8bff3adaf24f9795 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 24 Jan 2021 22:35:18 -0800 Subject: [PATCH] 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. --- .../detail/smart_holder_type_casters.h | 36 ++++++++++--------- tests/classh_module_local_0.cpp | 2 +- tests/classh_module_local_1.cpp | 2 +- tests/classh_module_local_2.cpp | 2 +- tests/test_classh_inheritance.cpp | 10 +++--- tests/test_classh_wip.cpp | 2 +- tests/test_unique_ptr_member.cpp | 2 +- 7 files changed, 29 insertions(+), 27 deletions(-) diff --git a/include/pybind11/detail/smart_holder_type_casters.h b/include/pybind11/detail/smart_holder_type_casters.h index cd2e19efb..77297c454 100644 --- a/include/pybind11/detail/smart_holder_type_casters.h +++ b/include/pybind11/detail/smart_holder_type_casters.h @@ -60,7 +60,7 @@ public: " Python instance is uninitialized or was disowned."); } if (v_h.value_ptr() == nullptr) { - pybind11_fail("classh_type_casters: Unexpected v_h.value_ptr() nullptr."); + pybind11_fail("smart_holder_type_casters: Unexpected v_h.value_ptr() nullptr."); } loaded_v_h.type = typeinfo; } @@ -70,7 +70,7 @@ public: modified_type_caster_generic_load_impl sub_caster(*cast.first); if (sub_caster.load(src, convert)) { if (loaded_v_h_cpptype != nullptr) { - pybind11_fail("classh_type_casters: try_implicit_casts failure."); + pybind11_fail("smart_holder_type_casters: try_implicit_casts failure."); } loaded_v_h = sub_caster.loaded_v_h; loaded_v_h_cpptype = cast.first; @@ -124,11 +124,11 @@ public: // Magic number intentionally hard-coded for simplicity and maximum robustness. if (foreign_loader->local_load_safety_guard != 37726257887406645) { pybind11_fail( - "Unexpected local_load_safety_guard," - " possibly due to py::class_ vs py::classh mixup."); + "smart_holder_type_casters: Unexpected local_load_safety_guard," + " possibly due to py::class_ holder mixup."); } if (loaded_v_h_cpptype != nullptr) { - pybind11_fail("classh_type_casters: try_load_foreign_module_local failure."); + pybind11_fail("smart_holder_type_casters: try_load_foreign_module_local failure."); } loaded_v_h = foreign_loader->loaded_v_h; loaded_v_h_cpptype = foreign_loader->loaded_v_h_cpptype; @@ -232,7 +232,7 @@ public: void *(*implicit_cast)(void *) = nullptr; value_and_holder loaded_v_h; bool reinterpret_cast_deemed_ok = false; - // Magic number intentionally hard-coded, to guard against class_ vs classh 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. std::size_t local_load_safety_guard = 37726257887406645; }; @@ -336,7 +336,7 @@ struct make_constructor { // type_caster_base END template -struct classh_type_caster : smart_holder_type_caster_load { +struct smart_holder_type_caster : smart_holder_type_caster_load { static constexpr auto name = _(); // static handle cast(T, ...) @@ -494,7 +494,7 @@ struct classh_type_caster : smart_holder_type_caster_load { }; template -struct classh_type_caster> : smart_holder_type_caster_load { +struct smart_holder_type_caster> : smart_holder_type_caster_load { static constexpr auto name = _>(); static handle cast(const std::shared_ptr &src, return_value_policy policy, handle parent) { @@ -539,7 +539,7 @@ struct classh_type_caster> : smart_holder_type_caster_load }; template -struct classh_type_caster> : smart_holder_type_caster_load { +struct smart_holder_type_caster> : smart_holder_type_caster_load { static constexpr auto name = _>(); static handle @@ -557,7 +557,7 @@ struct classh_type_caster> : smart_holder_type_caster_l }; template -struct classh_type_caster> : smart_holder_type_caster_load { +struct smart_holder_type_caster> : smart_holder_type_caster_load { static constexpr auto name = _>(); static handle cast(std::unique_ptr &&src, return_value_policy policy, handle parent) { @@ -600,7 +600,7 @@ struct classh_type_caster> : smart_holder_type_caster_load }; template -struct classh_type_caster> : smart_holder_type_caster_load { +struct smart_holder_type_caster> : smart_holder_type_caster_load { static constexpr auto name = _>(); static handle cast(std::unique_ptr &&src, return_value_policy policy, handle parent) { @@ -616,21 +616,23 @@ struct classh_type_caster> : smart_holder_type_caster_l operator std::unique_ptr() { return this->loaded_as_unique_ptr(); } }; -#define PYBIND11_CLASSH_TYPE_CASTERS(T) \ +#define PYBIND11_SMART_HOLDER_TYPE_CASTERS(T) \ namespace pybind11 { \ namespace detail { \ template <> \ - class type_caster : public classh_type_caster {}; \ + class type_caster : public smart_holder_type_caster {}; \ template <> \ - class type_caster> : public classh_type_caster> {}; \ + class type_caster> : public smart_holder_type_caster> { \ + }; \ template <> \ class type_caster> \ - : public classh_type_caster> {}; \ + : public smart_holder_type_caster> {}; \ template <> \ - class type_caster> : public classh_type_caster> {}; \ + class type_caster> : public smart_holder_type_caster> { \ + }; \ template <> \ class type_caster> \ - : public classh_type_caster> {}; \ + : public smart_holder_type_caster> {}; \ } \ } diff --git a/tests/classh_module_local_0.cpp b/tests/classh_module_local_0.cpp index fecf850cc..c52cce8ab 100644 --- a/tests/classh_module_local_0.cpp +++ b/tests/classh_module_local_0.cpp @@ -17,7 +17,7 @@ atyp rtrn_valu_atyp() { return atyp(); } } // namespace classh_module_local } // namespace pybind11_tests -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_module_local::atyp) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::classh_module_local::atyp) PYBIND11_MODULE(classh_module_local_0, m) { using namespace pybind11_tests::classh_module_local; diff --git a/tests/classh_module_local_1.cpp b/tests/classh_module_local_1.cpp index c38577178..8efa4a87a 100644 --- a/tests/classh_module_local_1.cpp +++ b/tests/classh_module_local_1.cpp @@ -16,7 +16,7 @@ std::string get_mtxt(const atyp &obj) { return obj.mtxt; } } // namespace classh_module_local } // namespace pybind11_tests -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_module_local::atyp) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::classh_module_local::atyp) PYBIND11_MODULE(classh_module_local_1, m) { namespace py = pybind11; diff --git a/tests/classh_module_local_2.cpp b/tests/classh_module_local_2.cpp index 2d33b04a0..a6531ef41 100644 --- a/tests/classh_module_local_2.cpp +++ b/tests/classh_module_local_2.cpp @@ -16,7 +16,7 @@ std::string get_mtxt(const atyp &obj) { return obj.mtxt; } } // namespace classh_module_local } // namespace pybind11_tests -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_module_local::atyp) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::classh_module_local::atyp) PYBIND11_MODULE(classh_module_local_2, m) { namespace py = pybind11; diff --git a/tests/test_classh_inheritance.cpp b/tests/test_classh_inheritance.cpp index ddaaefd51..b6d7fc0b0 100644 --- a/tests/test_classh_inheritance.cpp +++ b/tests/test_classh_inheritance.cpp @@ -56,12 +56,12 @@ inline int pass_cptr_drvd2(drvd2 const *d) { return d->id() + 23; } } // namespace classh_inheritance } // namespace pybind11_tests -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_inheritance::base) -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_inheritance::drvd) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::classh_inheritance::base) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::classh_inheritance::drvd) -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_inheritance::base1) -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_inheritance::base2) -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_inheritance::drvd2) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::classh_inheritance::base1) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::classh_inheritance::base2) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::classh_inheritance::drvd2) namespace pybind11_tests { namespace classh_inheritance { diff --git a/tests/test_classh_wip.cpp b/tests/test_classh_wip.cpp index 8a504f244..ae4a6f06b 100644 --- a/tests/test_classh_wip.cpp +++ b/tests/test_classh_wip.cpp @@ -49,7 +49,7 @@ std::unique_ptr unique_ptr_roundtrip(std::unique_ptr obj) { return o } // namespace classh_wip } // namespace pybind11_tests -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::classh_wip::atyp) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::classh_wip::atyp) namespace pybind11_tests { namespace classh_wip { diff --git a/tests/test_unique_ptr_member.cpp b/tests/test_unique_ptr_member.cpp index 89ff00a30..a9484c0fc 100644 --- a/tests/test_unique_ptr_member.cpp +++ b/tests/test_unique_ptr_member.cpp @@ -40,7 +40,7 @@ private: } // namespace unique_ptr_member } // namespace pybind11_tests -PYBIND11_CLASSH_TYPE_CASTERS(pybind11_tests::unique_ptr_member::pointee) +PYBIND11_SMART_HOLDER_TYPE_CASTERS(pybind11_tests::unique_ptr_member::pointee) namespace pybind11_tests { namespace unique_ptr_member {