mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-26 23:54:48 +00:00
Small cleanup in detail/init.h: strip originally_smart_holder_type_casters_h
namespace.
This commit is contained in:
parent
62b6c8e404
commit
35b1177f42
@ -200,20 +200,13 @@ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
|
|||||||
|
|
||||||
#ifdef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
|
#ifdef PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
|
||||||
|
|
||||||
namespace originally_smart_holder_type_casters_h {
|
|
||||||
template <typename T, typename D>
|
template <typename T, typename D>
|
||||||
smart_holder smart_holder_from_unique_ptr(std::unique_ptr<T, D> &&unq_ptr,
|
smart_holder init_smart_holder_from_unique_ptr(std::unique_ptr<T, D> &&unq_ptr,
|
||||||
bool void_cast_raw_ptr) {
|
bool void_cast_raw_ptr) {
|
||||||
void *void_ptr = void_cast_raw_ptr ? static_cast<void *>(unq_ptr.get()) : nullptr;
|
void *void_ptr = void_cast_raw_ptr ? static_cast<void *>(unq_ptr.get()) : nullptr;
|
||||||
return smart_holder::from_unique_ptr(std::move(unq_ptr), void_ptr);
|
return smart_holder::from_unique_ptr(std::move(unq_ptr), void_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
smart_holder smart_holder_from_shared_ptr(std::shared_ptr<T> shd_ptr) {
|
|
||||||
return smart_holder::from_shared_ptr(shd_ptr);
|
|
||||||
}
|
|
||||||
} // namespace originally_smart_holder_type_casters_h
|
|
||||||
|
|
||||||
template <typename Class,
|
template <typename Class,
|
||||||
typename D = std::default_delete<Cpp<Class>>,
|
typename D = std::default_delete<Cpp<Class>>,
|
||||||
detail::enable_if_t<is_smart_holder<Holder<Class>>::value, int> = 0>
|
detail::enable_if_t<is_smart_holder<Holder<Class>>::value, int> = 0>
|
||||||
@ -230,7 +223,7 @@ void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr,
|
|||||||
// trampoline Python object alive. For types that don't inherit from enable_shared_from_this
|
// trampoline Python object alive. For types that don't inherit from enable_shared_from_this
|
||||||
// it does not matter if void_cast_raw_ptr is true or false, therefore it's not necessary
|
// it does not matter if void_cast_raw_ptr is true or false, therefore it's not necessary
|
||||||
// to also inspect the type.
|
// to also inspect the type.
|
||||||
auto smhldr = originally_smart_holder_type_casters_h::smart_holder_from_unique_ptr(
|
auto smhldr = init_smart_holder_from_unique_ptr(
|
||||||
std::move(unq_ptr), /*void_cast_raw_ptr*/ Class::has_alias && is_alias<Class>(ptr));
|
std::move(unq_ptr), /*void_cast_raw_ptr*/ Class::has_alias && is_alias<Class>(ptr));
|
||||||
v_h.value_ptr() = ptr;
|
v_h.value_ptr() = ptr;
|
||||||
v_h.type->init_instance(v_h.inst, &smhldr);
|
v_h.type->init_instance(v_h.inst, &smhldr);
|
||||||
@ -244,8 +237,8 @@ void construct(value_and_holder &v_h,
|
|||||||
bool /*need_alias*/) {
|
bool /*need_alias*/) {
|
||||||
auto *ptr = unq_ptr.get();
|
auto *ptr = unq_ptr.get();
|
||||||
no_nullptr(ptr);
|
no_nullptr(ptr);
|
||||||
auto smhldr = originally_smart_holder_type_casters_h::smart_holder_from_unique_ptr(
|
auto smhldr
|
||||||
std::move(unq_ptr), /*void_cast_raw_ptr*/ true);
|
= init_smart_holder_from_unique_ptr(std::move(unq_ptr), /*void_cast_raw_ptr*/ true);
|
||||||
v_h.value_ptr() = ptr;
|
v_h.value_ptr() = ptr;
|
||||||
v_h.type->init_instance(v_h.inst, &smhldr);
|
v_h.type->init_instance(v_h.inst, &smhldr);
|
||||||
}
|
}
|
||||||
@ -259,7 +252,7 @@ void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, boo
|
|||||||
throw type_error("pybind11::init(): construction failed: returned std::shared_ptr pointee "
|
throw type_error("pybind11::init(): construction failed: returned std::shared_ptr pointee "
|
||||||
"is not an alias instance");
|
"is not an alias instance");
|
||||||
}
|
}
|
||||||
auto smhldr = originally_smart_holder_type_casters_h::smart_holder_from_shared_ptr(shd_ptr);
|
auto smhldr = smart_holder::from_shared_ptr(shd_ptr);
|
||||||
v_h.value_ptr() = ptr;
|
v_h.value_ptr() = ptr;
|
||||||
v_h.type->init_instance(v_h.inst, &smhldr);
|
v_h.type->init_instance(v_h.inst, &smhldr);
|
||||||
}
|
}
|
||||||
@ -270,7 +263,7 @@ void construct(value_and_holder &v_h,
|
|||||||
bool /*need_alias*/) {
|
bool /*need_alias*/) {
|
||||||
auto *ptr = shd_ptr.get();
|
auto *ptr = shd_ptr.get();
|
||||||
no_nullptr(ptr);
|
no_nullptr(ptr);
|
||||||
auto smhldr = originally_smart_holder_type_casters_h::smart_holder_from_shared_ptr(shd_ptr);
|
auto smhldr = smart_holder::from_shared_ptr(shd_ptr);
|
||||||
v_h.value_ptr() = ptr;
|
v_h.value_ptr() = ptr;
|
||||||
v_h.type->init_instance(v_h.inst, &smhldr);
|
v_h.type->init_instance(v_h.inst, &smhldr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user