mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
Renaming PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS to PYBIND11_TYPE_CASTER_BASE_HOLDER. (#2907)
This commit is contained in:
parent
2ada792085
commit
245d31cb03
@ -1217,7 +1217,7 @@ template <typename T>
|
||||
|
||||
using default_holder_type = std::unique_ptr<T>;
|
||||
|
||||
# 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<std::unique_ptr, holder_type>::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<T>)?");
|
||||
" missing PYBIND11_TYPE_CASTER_BASE_HOLDER(T, std::unique_ptr<T>)?");
|
||||
static_assert(
|
||||
!(detail::is_instantiation<std::shared_ptr, holder_type>::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<T>)?");
|
||||
" missing PYBIND11_TYPE_CASTER_BASE_HOLDER(T, std::shared_ptr<T>)?");
|
||||
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<T>?");
|
||||
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<T>?");
|
||||
#endif
|
||||
// clang-format off
|
||||
|
@ -45,11 +45,11 @@ struct SamePointer {};
|
||||
|
||||
} // namespace
|
||||
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MismatchBase1, std::shared_ptr<MismatchBase1>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MismatchDerived1, std::unique_ptr<MismatchDerived1>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MismatchBase2, std::unique_ptr<MismatchBase2>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MismatchDerived2, std::shared_ptr<MismatchDerived2>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SamePointer, std::unique_ptr<SamePointer>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MismatchBase1, std::shared_ptr<MismatchBase1>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MismatchDerived1, std::unique_ptr<MismatchDerived1>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MismatchBase2, std::unique_ptr<MismatchBase2>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MismatchDerived2, std::shared_ptr<MismatchDerived2>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(SamePointer, std::unique_ptr<SamePointer>)
|
||||
|
||||
TEST_SUBMODULE(class_, m) {
|
||||
// test_instance
|
||||
|
@ -139,10 +139,10 @@ public:
|
||||
static std::shared_ptr<TestFactory3> construct3(int a) { return std::shared_ptr<TestFactory3>(new TestFactory3(a)); }
|
||||
};
|
||||
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TestFactory3, std::shared_ptr<TestFactory3>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TestFactory4, std::shared_ptr<TestFactory4>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TestFactory5, std::shared_ptr<TestFactory5>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TestFactory7, std::shared_ptr<TestFactory7>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(TestFactory3, std::shared_ptr<TestFactory3>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(TestFactory4, std::shared_ptr<TestFactory4>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(TestFactory5, std::shared_ptr<TestFactory5>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(TestFactory7, std::shared_ptr<TestFactory7>)
|
||||
|
||||
TEST_SUBMODULE(factory_constructors, m) {
|
||||
|
||||
|
@ -148,7 +148,7 @@ struct RefQualified {
|
||||
int constRefQualified(int other) const & { return value + other; }
|
||||
};
|
||||
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(NoneTester, std::shared_ptr<NoneTester>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(NoneTester, std::shared_ptr<NoneTester>)
|
||||
|
||||
TEST_SUBMODULE(methods_and_attributes, m) {
|
||||
// test_methods_and_attributes
|
||||
|
@ -69,13 +69,13 @@ struct I801D : I801C {}; // Indirect MI
|
||||
|
||||
} // namespace
|
||||
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(Base1a, std::shared_ptr<Base1a>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(Base2a, std::shared_ptr<Base2a>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(Base12a, std::shared_ptr<Base12a>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(I801B1, std::shared_ptr<I801B1>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(I801B2, std::shared_ptr<I801B2>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(I801C, std::shared_ptr<I801C>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(I801D, std::shared_ptr<I801D>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(Base1a, std::shared_ptr<Base1a>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(Base2a, std::shared_ptr<Base2a>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(Base12a, std::shared_ptr<Base12a>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(I801B1, std::shared_ptr<I801B1>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(I801B2, std::shared_ptr<I801B2>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(I801C, std::shared_ptr<I801C>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(I801D, std::shared_ptr<I801D>)
|
||||
|
||||
TEST_SUBMODULE(multiple_inheritance, m) {
|
||||
// Please do not interleave `struct` and `class` definitions with bindings code,
|
||||
|
@ -272,26 +272,26 @@ PYBIND11_DECLARE_HOLDER_TYPE(T, custom_unique_ptr<T>);
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, shared_ptr_with_addressof_operator<T>);
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, unique_ptr_with_addressof_operator<T>);
|
||||
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(Object, ref<Object>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject1, ref<MyObject1>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject2, std::shared_ptr<MyObject2>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject3, std::shared_ptr<MyObject3>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject4, std::unique_ptr<MyObject4, py::nodelete>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject4a, std::unique_ptr<MyObject4a, py::nodelete>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject4b, std::unique_ptr<MyObject4b>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(MyObject5, huge_unique_ptr<MyObject5>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedPtrRef::A, std::shared_ptr<SharedPtrRef::A>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedPtrRef, std::unique_ptr<SharedPtrRef>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedFromThisRef::B, std::shared_ptr<SharedFromThisRef::B>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedFromThisRef, std::unique_ptr<SharedFromThisRef>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(SharedFromThisVirt, std::shared_ptr<SharedFromThisVirt>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(C, custom_unique_ptr<C>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TypeForHolderWithAddressOf, shared_ptr_with_addressof_operator<TypeForHolderWithAddressOf>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(TypeForMoveOnlyHolderWithAddressOf, unique_ptr_with_addressof_operator<TypeForMoveOnlyHolderWithAddressOf>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(HeldByDefaultHolder, std::unique_ptr<HeldByDefaultHolder>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(ElementBase, std::shared_ptr<ElementBase>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(ElementA, std::shared_ptr<ElementA>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(ElementList, std::shared_ptr<ElementList>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(Object, ref<Object>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject1, ref<MyObject1>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject2, std::shared_ptr<MyObject2>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject3, std::shared_ptr<MyObject3>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject4, std::unique_ptr<MyObject4, py::nodelete>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject4a, std::unique_ptr<MyObject4a, py::nodelete>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject4b, std::unique_ptr<MyObject4b>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(MyObject5, huge_unique_ptr<MyObject5>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedPtrRef::A, std::shared_ptr<SharedPtrRef::A>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedPtrRef, std::unique_ptr<SharedPtrRef>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedFromThisRef::B, std::shared_ptr<SharedFromThisRef::B>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedFromThisRef, std::unique_ptr<SharedFromThisRef>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(SharedFromThisVirt, std::shared_ptr<SharedFromThisVirt>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(C, custom_unique_ptr<C>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(TypeForHolderWithAddressOf, shared_ptr_with_addressof_operator<TypeForHolderWithAddressOf>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(TypeForMoveOnlyHolderWithAddressOf, unique_ptr_with_addressof_operator<TypeForMoveOnlyHolderWithAddressOf>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(HeldByDefaultHolder, std::unique_ptr<HeldByDefaultHolder>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(ElementBase, std::shared_ptr<ElementBase>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(ElementA, std::shared_ptr<ElementA>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(ElementList, std::shared_ptr<ElementList>)
|
||||
|
||||
#ifdef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
|
||||
// To prevent triggering a static_assert in the smart_holder code.
|
||||
|
@ -39,9 +39,9 @@ static_assert(sizeof(padded_unique_ptr<nb_pu>) == sizeof(py::smart_holder),
|
||||
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, hc::padded_unique_ptr<T>);
|
||||
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(hc::nb_up, std::unique_ptr<hc::nb_up>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(hc::nb_sp, std::shared_ptr<hc::nb_sp>)
|
||||
PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(hc::nb_pu, hc::padded_unique_ptr<hc::nb_pu>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(hc::nb_up, std::unique_ptr<hc::nb_up>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(hc::nb_sp, std::shared_ptr<hc::nb_sp>)
|
||||
PYBIND11_TYPE_CASTER_BASE_HOLDER(hc::nb_pu, hc::padded_unique_ptr<hc::nb_pu>)
|
||||
PYBIND11_SMART_HOLDER_TYPE_CASTERS(hc::nb_sh)
|
||||
|
||||
PYBIND11_MODULE(pybind11_ubench_holder_comparison, m) {
|
||||
|
Loading…
Reference in New Issue
Block a user