Renaming is_smart_holder_type_caster -> type_uses_smart_holder_type_caster for clarity.

parent 658cf3ba
...@@ -66,7 +66,7 @@ template <typename type> ...@@ -66,7 +66,7 @@ template <typename type>
using make_caster = type_caster<intrinsic_t<type>>; using make_caster = type_caster<intrinsic_t<type>>;
template <typename T> template <typename T>
struct is_smart_holder_type_caster { struct type_uses_smart_holder_type_caster {
static constexpr bool value static constexpr bool value
= std::is_base_of<is_smart_holder_type_caster_base_tag, make_caster<T>>::value; = std::is_base_of<is_smart_holder_type_caster_base_tag, make_caster<T>>::value;
}; };
...@@ -846,7 +846,7 @@ template <typename T> using move_never = none_of<move_always<T>, move_if_unrefer ...@@ -846,7 +846,7 @@ template <typename T> using move_never = none_of<move_always<T>, move_if_unrefer
template <typename type> using cast_is_temporary_value_reference = bool_constant< template <typename type> using cast_is_temporary_value_reference = bool_constant<
(std::is_reference<type>::value || std::is_pointer<type>::value) && (std::is_reference<type>::value || std::is_pointer<type>::value) &&
!std::is_base_of<type_caster_generic, make_caster<type>>::value && !std::is_base_of<type_caster_generic, make_caster<type>>::value &&
!is_smart_holder_type_caster<intrinsic_t<type>>::value && !type_uses_smart_holder_type_caster<intrinsic_t<type>>::value &&
!std::is_same<intrinsic_t<type>, void>::value !std::is_same<intrinsic_t<type>, void>::value
>; >;
...@@ -1391,7 +1391,7 @@ template<typename T> ...@@ -1391,7 +1391,7 @@ template<typename T>
handle type::handle_of() { handle type::handle_of() {
static_assert( static_assert(
detail::any_of<std::is_base_of<detail::type_caster_generic, detail::make_caster<T>>, detail::any_of<std::is_base_of<detail::type_caster_generic, detail::make_caster<T>>,
detail::is_smart_holder_type_caster<T>>::value, detail::type_uses_smart_holder_type_caster<T>>::value,
"py::type::of<T> only supports the case where T is a registered C++ types."); "py::type::of<T> only supports the case where T is a registered C++ types.");
return detail::get_type_handle(typeid(T), true); return detail::get_type_handle(typeid(T), true);
......
...@@ -133,7 +133,7 @@ void construct(value_and_holder &v_h, Alias<Class> *alias_ptr, bool) { ...@@ -133,7 +133,7 @@ void construct(value_and_holder &v_h, Alias<Class> *alias_ptr, bool) {
// holder. This also handles types like std::shared_ptr<T> and std::unique_ptr<T> where T is a // holder. This also handles types like std::shared_ptr<T> and std::unique_ptr<T> where T is a
// derived type (through those holder's implicit conversion from derived class holder constructors). // derived type (through those holder's implicit conversion from derived class holder constructors).
template <typename Class, template <typename Class,
detail::enable_if_t<!detail::is_smart_holder_type_caster<Cpp<Class>>::value, int> = 0> detail::enable_if_t<!detail::type_uses_smart_holder_type_caster<Cpp<Class>>::value, int> = 0>
void construct(value_and_holder &v_h, Holder<Class> holder, bool need_alias) { void construct(value_and_holder &v_h, Holder<Class> holder, bool need_alias) {
auto *ptr = holder_helper<Holder<Class>>::get(holder); auto *ptr = holder_helper<Holder<Class>>::get(holder);
no_nullptr(ptr); no_nullptr(ptr);
...@@ -171,9 +171,10 @@ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) { ...@@ -171,9 +171,10 @@ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
} }
// clang-format on // clang-format on
template <typename Class, template <
typename Class,
typename D = std::default_delete<Cpp<Class>>, typename D = std::default_delete<Cpp<Class>>,
detail::enable_if_t<detail::is_smart_holder_type_caster<Cpp<Class>>::value, int> = 0> detail::enable_if_t<detail::type_uses_smart_holder_type_caster<Cpp<Class>>::value, int> = 0>
void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr, bool need_alias) { void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr, bool need_alias) {
auto *ptr = unq_ptr.get(); auto *ptr = unq_ptr.get();
no_nullptr(ptr); no_nullptr(ptr);
...@@ -186,9 +187,10 @@ void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr, ...@@ -186,9 +187,10 @@ void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr,
v_h.type->init_instance(v_h.inst, &smhldr); v_h.type->init_instance(v_h.inst, &smhldr);
} }
template <typename Class, template <
typename Class,
typename D = std::default_delete<Alias<Class>>, typename D = std::default_delete<Alias<Class>>,
detail::enable_if_t<detail::is_smart_holder_type_caster<Alias<Class>>::value, int> = 0> detail::enable_if_t<detail::type_uses_smart_holder_type_caster<Alias<Class>>::value, int> = 0>
void construct(value_and_holder &v_h, void construct(value_and_holder &v_h,
std::unique_ptr<Alias<Class>, D> &&unq_ptr, std::unique_ptr<Alias<Class>, D> &&unq_ptr,
bool /*need_alias*/) { bool /*need_alias*/) {
...@@ -200,8 +202,9 @@ void construct(value_and_holder &v_h, ...@@ -200,8 +202,9 @@ void construct(value_and_holder &v_h,
v_h.type->init_instance(v_h.inst, &smhldr); v_h.type->init_instance(v_h.inst, &smhldr);
} }
template <typename Class, template <
detail::enable_if_t<detail::is_smart_holder_type_caster<Cpp<Class>>::value, int> = 0> typename Class,
detail::enable_if_t<detail::type_uses_smart_holder_type_caster<Cpp<Class>>::value, int> = 0>
void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, bool need_alias) { void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, bool need_alias) {
auto *ptr = shd_ptr.get(); auto *ptr = shd_ptr.get();
no_nullptr(ptr); no_nullptr(ptr);
...@@ -213,8 +216,9 @@ void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, boo ...@@ -213,8 +216,9 @@ void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, boo
v_h.type->init_instance(v_h.inst, &smhldr); v_h.type->init_instance(v_h.inst, &smhldr);
} }
template <typename Class, template <
detail::enable_if_t<detail::is_smart_holder_type_caster<Alias<Class>>::value, int> = 0> typename Class,
detail::enable_if_t<detail::type_uses_smart_holder_type_caster<Alias<Class>>::value, int> = 0>
void construct(value_and_holder &v_h, void construct(value_and_holder &v_h,
std::shared_ptr<Alias<Class>> &&shd_ptr, std::shared_ptr<Alias<Class>> &&shd_ptr,
bool /*need_alias*/) { bool /*need_alias*/) {
......
...@@ -19,11 +19,11 @@ PYBIND11_NAMESPACE_BEGIN(detail) ...@@ -19,11 +19,11 @@ PYBIND11_NAMESPACE_BEGIN(detail)
template <typename T> template <typename T>
struct is_smart_holder_type : std::false_type {}; struct is_smart_holder_type : std::false_type {};
// Tag to be used as base class, inspected by is_smart_holder_type_caster<T> test. // Tag to be used as base class, inspected by type_uses_smart_holder_type_caster<T> test.
struct is_smart_holder_type_caster_base_tag {}; struct is_smart_holder_type_caster_base_tag {};
template <typename T> template <typename T>
struct is_smart_holder_type_caster; struct type_uses_smart_holder_type_caster;
PYBIND11_NAMESPACE_END(detail) PYBIND11_NAMESPACE_END(detail)
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
...@@ -287,7 +287,7 @@ struct smart_holder_type_caster_load { ...@@ -287,7 +287,7 @@ struct smart_holder_type_caster_load {
using holder_type = pybindit::memory::smart_holder; using holder_type = pybindit::memory::smart_holder;
bool load(handle src, bool convert) { bool load(handle src, bool convert) {
static_assert(is_smart_holder_type_caster<T>::value, "Internal consistency error."); static_assert(type_uses_smart_holder_type_caster<T>::value, "Internal consistency error.");
load_impl = modified_type_caster_generic_load_impl(typeid(T)); load_impl = modified_type_caster_generic_load_impl(typeid(T));
if (!load_impl.load(src, convert)) if (!load_impl.load(src, convert))
return false; return false;
......
...@@ -1275,10 +1275,11 @@ class class_ : public detail::generic_type { ...@@ -1275,10 +1275,11 @@ class class_ : public detail::generic_type {
template <typename T> using is_base = detail::is_strict_base_of<T, type_>; template <typename T> using is_base = detail::is_strict_base_of<T, type_>;
template <typename T> template <typename T>
// clang-format on // clang-format on
using is_holder = detail::any_of<detail::is_holder_type<type_, T>, using is_holder
= detail::any_of<detail::is_holder_type<type_, T>,
detail::all_of<detail::negation<is_base<T>>, detail::all_of<detail::negation<is_base<T>>,
detail::negation<is_subtype<T>>, detail::negation<is_subtype<T>>,
detail::is_smart_holder_type_caster<type_>>>; detail::type_uses_smart_holder_type_caster<type_>>>;
// clang-format off // clang-format off
// struct instead of using here to help MSVC: // struct instead of using here to help MSVC:
template <typename T> struct is_valid_class_option : template <typename T> struct is_valid_class_option :
...@@ -1314,7 +1315,7 @@ public: ...@@ -1314,7 +1315,7 @@ public:
static constexpr bool holder_is_smart_holder static constexpr bool holder_is_smart_holder
= detail::is_smart_holder_type<holder_type>::value; = detail::is_smart_holder_type<holder_type>::value;
static constexpr bool type_caster_type_is_smart_holder_type_caster static constexpr bool type_caster_type_is_smart_holder_type_caster
= detail::is_smart_holder_type_caster<type>::value; = detail::type_uses_smart_holder_type_caster<type>::value;
static constexpr bool type_caster_type_is_type_caster_base_subtype static constexpr bool type_caster_type_is_type_caster_base_subtype
= std::is_base_of<detail::type_caster_base<type>, detail::type_caster<type>>::value; = std::is_base_of<detail::type_caster_base<type>, detail::type_caster<type>>::value;
// Necessary conditions, but not strict. // Necessary conditions, but not strict.
...@@ -1574,13 +1575,13 @@ public: ...@@ -1574,13 +1575,13 @@ public:
private: private:
// clang-format on // clang-format on
template <typename T = type, template <typename T = type,
detail::enable_if_t<!detail::is_smart_holder_type_caster<T>::value, int> = 0> detail::enable_if_t<!detail::type_uses_smart_holder_type_caster<T>::value, int> = 0>
void generic_type_initialize(const detail::type_record &record) { void generic_type_initialize(const detail::type_record &record) {
generic_type::initialize(record, &detail::type_caster_generic::local_load); generic_type::initialize(record, &detail::type_caster_generic::local_load);
} }
template <typename T = type, template <typename T = type,
detail::enable_if_t<detail::is_smart_holder_type_caster<T>::value, int> = 0> detail::enable_if_t<detail::type_uses_smart_holder_type_caster<T>::value, int> = 0>
void generic_type_initialize(const detail::type_record &record) { void generic_type_initialize(const detail::type_record &record) {
generic_type::initialize(record, detail::type_caster<T>::get_local_load_function_ptr()); generic_type::initialize(record, detail::type_caster<T>::get_local_load_function_ptr());
} }
...@@ -1632,7 +1633,7 @@ private: ...@@ -1632,7 +1633,7 @@ private:
/// `.owned`, a new holder will be constructed to manage the value pointer. /// `.owned`, a new holder will be constructed to manage the value pointer.
template < template <
typename T = type, typename T = type,
detail::enable_if_t<!detail::is_smart_holder_type_caster<T>::value, int> = 0> detail::enable_if_t<!detail::type_uses_smart_holder_type_caster<T>::value, int> = 0>
static void init_instance(detail::instance *inst, const void *holder_ptr) { static void init_instance(detail::instance *inst, const void *holder_ptr) {
auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(type))); auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(type)));
if (!v_h.instance_registered()) { if (!v_h.instance_registered()) {
...@@ -1644,7 +1645,7 @@ private: ...@@ -1644,7 +1645,7 @@ private:
// clang-format on // clang-format on
template <typename T = type, template <typename T = type,
detail::enable_if_t<detail::is_smart_holder_type_caster<T>::value, int> = 0> detail::enable_if_t<detail::type_uses_smart_holder_type_caster<T>::value, int> = 0>
static void init_instance(detail::instance *inst, const void *holder_ptr) { static void init_instance(detail::instance *inst, const void *holder_ptr) {
detail::type_caster<T>::template init_instance_for_type<type>(inst, holder_ptr); detail::type_caster<T>::template init_instance_for_type<type>(inst, holder_ptr);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment