Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Mar 1, 2019
1 parent 78c171e commit 07a2bd8
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions src/entt/meta/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2035,37 +2035,39 @@ bool setter([[maybe_unused]] meta_handle handle, [[maybe_unused]] meta_any &any)
bool accepted = false;

if constexpr(Const) {
return false;
} else if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Data)>> || std::is_member_function_pointer_v<decltype(Data)>) {
using helper_type = meta_function_helper<std::integral_constant<decltype(Data), Data>>;
using data_type = std::decay_t<std::tuple_element_t<!std::is_member_function_pointer_v<decltype(Data)>, typename helper_type::args_type>>;
static_assert(std::is_invocable_v<decltype(Data), Type *, data_type>);
accepted = any.can_cast<data_type>() || any.convert<data_type>();
auto *clazz = handle.try_cast<Type>();

if(accepted && clazz) {
std::invoke(Data, clazz, any.cast<data_type>());
}
} else if constexpr(std::is_member_object_pointer_v<decltype(Data)>) {
using data_type = std::decay_t<decltype(std::declval<Type>().*Data)>;
static_assert(std::is_invocable_v<decltype(Data), Type>);
accepted = any.can_cast<data_type>() || any.convert<data_type>();
auto *clazz = handle.try_cast<Type>();

if(accepted && clazz) {
std::invoke(Data, clazz) = any.cast<data_type>();
}
return accepted;
} else {
static_assert(std::is_pointer_v<decltype(Data)>);
using data_type = std::decay_t<decltype(*Data)>;
accepted = any.can_cast<data_type>() || any.convert<data_type>();
if constexpr(std::is_function_v<std::remove_pointer_t<decltype(Data)>> || std::is_member_function_pointer_v<decltype(Data)>) {
using helper_type = meta_function_helper<std::integral_constant<decltype(Data), Data>>;
using data_type = std::decay_t<std::tuple_element_t<!std::is_member_function_pointer_v<decltype(Data)>, typename helper_type::args_type>>;
static_assert(std::is_invocable_v<decltype(Data), Type *, data_type>);
accepted = any.can_cast<data_type>() || any.convert<data_type>();
auto *clazz = handle.try_cast<Type>();

if(accepted && clazz) {
std::invoke(Data, clazz, any.cast<data_type>());
}
} else if constexpr(std::is_member_object_pointer_v<decltype(Data)>) {
using data_type = std::decay_t<decltype(std::declval<Type>().*Data)>;
static_assert(std::is_invocable_v<decltype(Data), Type>);
accepted = any.can_cast<data_type>() || any.convert<data_type>();
auto *clazz = handle.try_cast<Type>();

if(accepted && clazz) {
std::invoke(Data, clazz) = any.cast<data_type>();
}
} else {
static_assert(std::is_pointer_v<decltype(Data)>);
using data_type = std::decay_t<decltype(*Data)>;
accepted = any.can_cast<data_type>() || any.convert<data_type>();

if(accepted) {
*Data = any.cast<data_type>();
if(accepted) {
*Data = any.cast<data_type>();
}
}
}

return accepted;
return accepted;
}
}


Expand Down

0 comments on commit 07a2bd8

Please sign in to comment.