Pure clang-format change (applied to original type_caster_generic::cast).

This commit is contained in:
Ralf W. Grosse-Kunstleve 2021-01-12 20:05:20 -08:00
parent ee6d15647d
commit 6294eb26e5

View File

@ -190,8 +190,9 @@ struct type_caster<mpty> : smart_holder_type_caster_load<mpty> {
// type_caster_base END // type_caster_base END
// Originally type_caster_generic::cast. // Originally type_caster_generic::cast.
// clang-format off PYBIND11_NOINLINE static handle cast(const void *_src,
PYBIND11_NOINLINE static handle cast(const void *_src, return_value_policy policy, handle parent, return_value_policy policy,
handle parent,
const detail::type_info *tinfo, const detail::type_info *tinfo,
void *(*copy_constructor)(const void *), void *(*copy_constructor)(const void *),
void *(*move_constructor)(const void *), void *(*move_constructor)(const void *),
@ -211,21 +212,21 @@ struct type_caster<mpty> : smart_holder_type_caster_load<mpty> {
} }
} }
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type)); auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
auto wrapper = reinterpret_cast<instance *>(inst.ptr()); auto wrapper = reinterpret_cast<instance *>(inst.ptr());
wrapper->owned = false; wrapper->owned = false;
void *&valueptr = values_and_holders(wrapper).begin()->value_ptr(); void *&valueptr = values_and_holders(wrapper).begin()->value_ptr();
switch (policy) { switch (policy) {
case return_value_policy::automatic: case return_value_policy::automatic:
case return_value_policy::take_ownership: case return_value_policy::take_ownership:
valueptr = src; valueptr = src;
wrapper->owned = true; wrapper->owned = true;
break; break;
case return_value_policy::automatic_reference: case return_value_policy::automatic_reference:
case return_value_policy::reference: case return_value_policy::reference:
valueptr = src; valueptr = src;
wrapper->owned = false; wrapper->owned = false;
break; break;
@ -239,8 +240,8 @@ struct type_caster<mpty> : smart_holder_type_caster_load<mpty> {
#else #else
std::string type_name(tinfo->cpptype->name()); std::string type_name(tinfo->cpptype->name());
detail::clean_type_id(type_name); detail::clean_type_id(type_name);
throw cast_error("return_value_policy = copy, but type " + throw cast_error("return_value_policy = copy, but type " + type_name
type_name + " is non-copyable!"); + " is non-copyable!");
#endif #endif
} }
wrapper->owned = true; wrapper->owned = true;
@ -259,15 +260,15 @@ struct type_caster<mpty> : smart_holder_type_caster_load<mpty> {
#else #else
std::string type_name(tinfo->cpptype->name()); std::string type_name(tinfo->cpptype->name());
detail::clean_type_id(type_name); detail::clean_type_id(type_name);
throw cast_error("return_value_policy = move, but type " + throw cast_error("return_value_policy = move, but type " + type_name
type_name + " is neither movable nor copyable!"); + " is neither movable nor copyable!");
#endif #endif
} }
wrapper->owned = true; wrapper->owned = true;
break; break;
case return_value_policy::reference_internal: case return_value_policy::reference_internal:
valueptr = src; valueptr = src;
wrapper->owned = false; wrapper->owned = false;
keep_alive_impl(inst, parent); keep_alive_impl(inst, parent);
break; break;
@ -280,7 +281,6 @@ struct type_caster<mpty> : smart_holder_type_caster_load<mpty> {
return inst.release(); return inst.release();
} }
// clang-format on
}; };
template <> template <>