diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 2818c8363..816c51cc8 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1217,7 +1217,7 @@ template using default_holder_type = std::unique_ptr; -# define PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, ...) +# define PYBIND11_TYPE_CASTER_BASE_HOLDER(T, ...) #else @@ -1225,7 +1225,7 @@ using default_holder_type = smart_holder; // This define could be hidden away inside detail/smart_holder_type_casters.h, but is kept here // for clarity. -# define PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, ...) \ +# define PYBIND11_TYPE_CASTER_BASE_HOLDER(T, ...) \ namespace pybind11 { \ namespace detail { \ template <> \ @@ -1292,12 +1292,12 @@ public: !(detail::is_instantiation::value && wrapped_type_uses_smart_holder_type_caster), "py::class_ holder vs type_caster mismatch:" - " missing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, std::unique_ptr)?"); + " missing PYBIND11_TYPE_CASTER_BASE_HOLDER(T, std::unique_ptr)?"); static_assert( !(detail::is_instantiation::value && wrapped_type_uses_smart_holder_type_caster), "py::class_ holder vs type_caster mismatch:" - " missing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, std::shared_ptr)?"); + " missing PYBIND11_TYPE_CASTER_BASE_HOLDER(T, std::shared_ptr)?"); static_assert(!(holder_is_smart_holder && type_caster_type_is_type_caster_base_subtype), "py::class_ holder vs type_caster mismatch:" " missing PYBIND11_SMART_HOLDER_TYPE_CASTERS(T)?"); @@ -1309,7 +1309,7 @@ public: " or collision with custom py::detail::type_caster?"); static_assert(!holder_is_smart_holder == type_caster_type_is_type_caster_base_subtype, "py::class_ holder vs type_caster mismatch:" - " missing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, ...)" + " missing PYBIND11_TYPE_CASTER_BASE_HOLDER(T, ...)" " or collision with custom py::detail::type_caster?"); #endif // clang-format off diff --git a/tests/test_class.cpp b/tests/test_class.cpp index 4b1857e85..53a8858a1 100644 --- a/tests/test_class.cpp +++ b/tests/test_class.cpp @@ -45,11 +45,11 @@ struct SamePointer {}; } // namespace -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MismatchBase1, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MismatchDerived1, std::unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MismatchBase2, std::unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MismatchDerived2, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SamePointer, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MismatchBase1, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MismatchDerived1, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MismatchBase2, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MismatchDerived2, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(SamePointer, std::unique_ptr) TEST_SUBMODULE(class_, m) { // test_instance diff --git a/tests/test_factory_constructors.cpp b/tests/test_factory_constructors.cpp index 26d081dc3..a4e4829e5 100644 --- a/tests/test_factory_constructors.cpp +++ b/tests/test_factory_constructors.cpp @@ -139,10 +139,10 @@ public: static std::shared_ptr construct3(int a) { return std::shared_ptr(new TestFactory3(a)); } }; -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TestFactory3, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TestFactory4, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TestFactory5, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TestFactory7, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(TestFactory3, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(TestFactory4, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(TestFactory5, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(TestFactory7, std::shared_ptr) TEST_SUBMODULE(factory_constructors, m) { diff --git a/tests/test_methods_and_attributes.cpp b/tests/test_methods_and_attributes.cpp index 53855c367..d4c2c1466 100644 --- a/tests/test_methods_and_attributes.cpp +++ b/tests/test_methods_and_attributes.cpp @@ -148,7 +148,7 @@ struct RefQualified { int constRefQualified(int other) const & { return value + other; } }; -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(NoneTester, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(NoneTester, std::shared_ptr) TEST_SUBMODULE(methods_and_attributes, m) { // test_methods_and_attributes diff --git a/tests/test_multiple_inheritance.cpp b/tests/test_multiple_inheritance.cpp index c0e3b9482..23e6341dd 100644 --- a/tests/test_multiple_inheritance.cpp +++ b/tests/test_multiple_inheritance.cpp @@ -69,13 +69,13 @@ struct I801D : I801C {}; // Indirect MI } // namespace -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(Base1a, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(Base2a, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(Base12a, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(I801B1, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(I801B2, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(I801C, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(I801D, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(Base1a, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(Base2a, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(Base12a, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(I801B1, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(I801B2, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(I801C, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(I801D, std::shared_ptr) TEST_SUBMODULE(multiple_inheritance, m) { // Please do not interleave `struct` and `class` definitions with bindings code, diff --git a/tests/test_smart_ptr.cpp b/tests/test_smart_ptr.cpp index e5e678ef8..2074ccfaa 100644 --- a/tests/test_smart_ptr.cpp +++ b/tests/test_smart_ptr.cpp @@ -272,26 +272,26 @@ PYBIND11_DECLARE_HOLDER_TYPE(T, custom_unique_ptr); PYBIND11_DECLARE_HOLDER_TYPE(T, shared_ptr_with_addressof_operator); PYBIND11_DECLARE_HOLDER_TYPE(T, unique_ptr_with_addressof_operator); -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(Object, ref) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject1, ref) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject2, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject3, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject4, std::unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject4a, std::unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject4b, std::unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject5, huge_unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedPtrRef::A, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedPtrRef, std::unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedFromThisRef::B, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedFromThisRef, std::unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedFromThisVirt, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(C, custom_unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TypeForHolderWithAddressOf, shared_ptr_with_addressof_operator) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TypeForMoveOnlyHolderWithAddressOf, unique_ptr_with_addressof_operator) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(HeldByDefaultHolder, std::unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(ElementBase, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(ElementA, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(ElementList, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(Object, ref) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject1, ref) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject2, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject3, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject4, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject4a, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject4b, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject5, huge_unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedPtrRef::A, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedPtrRef, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedFromThisRef::B, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedFromThisRef, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedFromThisVirt, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(C, custom_unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(TypeForHolderWithAddressOf, shared_ptr_with_addressof_operator) +PYBIND11_TYPE_CASTER_BASE_HOLDER(TypeForMoveOnlyHolderWithAddressOf, unique_ptr_with_addressof_operator) +PYBIND11_TYPE_CASTER_BASE_HOLDER(HeldByDefaultHolder, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(ElementBase, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(ElementA, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(ElementList, std::shared_ptr) #ifdef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT // To prevent triggering a static_assert in the smart_holder code. diff --git a/ubench/holder_comparison.cpp b/ubench/holder_comparison.cpp index 720464a91..75896c1bb 100644 --- a/ubench/holder_comparison.cpp +++ b/ubench/holder_comparison.cpp @@ -39,9 +39,9 @@ static_assert(sizeof(padded_unique_ptr) == sizeof(py::smart_holder), PYBIND11_DECLARE_HOLDER_TYPE(T, hc::padded_unique_ptr); -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(hc::nb_up, std::unique_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(hc::nb_sp, std::shared_ptr) -PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(hc::nb_pu, hc::padded_unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(hc::nb_up, std::unique_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(hc::nb_sp, std::shared_ptr) +PYBIND11_TYPE_CASTER_BASE_HOLDER(hc::nb_pu, hc::padded_unique_ptr) PYBIND11_SMART_HOLDER_TYPE_CASTERS(hc::nb_sh) PYBIND11_MODULE(pybind11_ubench_holder_comparison, m) {