|
|
@@ -35,22 +35,6 @@ namespace internal {
|
|
|
return context.value[info.hash()];
|
|
|
}
|
|
|
|
|
|
-inline meta_base_node &meta_extend(internal::meta_type_node &parent, const id_type id, meta_base_node node) {
|
|
|
- return parent.details->base.insert_or_assign(id, node).first->second;
|
|
|
-}
|
|
|
-
|
|
|
-inline meta_conv_node &meta_extend(internal::meta_type_node &parent, const id_type id, meta_conv_node node) {
|
|
|
- return parent.details->conv.insert_or_assign(id, node).first->second;
|
|
|
-}
|
|
|
-
|
|
|
-inline meta_ctor_node &meta_extend(internal::meta_type_node &parent, const id_type id, meta_ctor_node node) {
|
|
|
- return parent.details->ctor.insert_or_assign(id, node).first->second;
|
|
|
-}
|
|
|
-
|
|
|
-inline meta_dtor_node &meta_extend(internal::meta_type_node &parent, meta_dtor_node node) {
|
|
|
- return (parent.dtor = node);
|
|
|
-}
|
|
|
-
|
|
|
inline meta_data_node &meta_extend(internal::meta_type_node &parent, const id_type id, meta_data_node node) {
|
|
|
return parent.details->data.insert_or_assign(id, std::move(node)).first->second;
|
|
|
}
|
|
|
@@ -72,10 +56,6 @@ inline meta_func_node &meta_extend(internal::meta_type_node &parent, const id_ty
|
|
|
return parent.details->func.insert_or_assign(id, std::move(node)).first->second;
|
|
|
}
|
|
|
|
|
|
-inline meta_prop_node &meta_extend(dense_map<id_type, meta_prop_node, identity> &prop, const id_type id, meta_prop_node node) {
|
|
|
- return (prop[id] = std::move(node));
|
|
|
-}
|
|
|
-
|
|
|
} // namespace internal
|
|
|
|
|
|
/**
|
|
|
@@ -156,16 +136,8 @@ public:
|
|
|
template<typename Base>
|
|
|
auto base() noexcept {
|
|
|
static_assert(!std::is_same_v<Type, Base> && std::is_base_of_v<Base, Type>, "Invalid base type");
|
|
|
-
|
|
|
- internal::meta_extend(
|
|
|
- internal::owner(*ctx, *info),
|
|
|
- type_id<Base>().hash(),
|
|
|
- internal::meta_base_node{
|
|
|
- &internal::resolve<Base>,
|
|
|
- +[](const void *instance) noexcept {
|
|
|
- return static_cast<const void *>(static_cast<const Base *>(static_cast<const Type *>(instance)));
|
|
|
- }});
|
|
|
-
|
|
|
+ const auto *func = +[](const void *instance) noexcept { return static_cast<const void *>(static_cast<const Base *>(static_cast<const Type *>(instance))); };
|
|
|
+ internal::owner(*ctx, *info).details->base.insert_or_assign(type_id<Base>().hash(), internal::meta_base_node{&internal::resolve<Base>, func});
|
|
|
bucket = nullptr;
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -185,15 +157,8 @@ public:
|
|
|
template<auto Candidate>
|
|
|
auto conv() noexcept {
|
|
|
using conv_type = std::remove_cv_t<std::remove_reference_t<std::invoke_result_t<decltype(Candidate), Type &>>>;
|
|
|
-
|
|
|
- internal::meta_extend(
|
|
|
- internal::owner(*ctx, *info),
|
|
|
- type_id<conv_type>().hash(),
|
|
|
- internal::meta_conv_node{
|
|
|
- +[](const meta_ctx &area, const void *instance) {
|
|
|
- return forward_as_meta(area, std::invoke(Candidate, *static_cast<const Type *>(instance)));
|
|
|
- }});
|
|
|
-
|
|
|
+ const auto *func = +[](const meta_ctx &area, const void *instance) { return forward_as_meta(area, std::invoke(Candidate, *static_cast<const Type *>(instance))); };
|
|
|
+ internal::owner(*ctx, *info).details->conv.insert_or_assign(type_id<conv_type>().hash(), internal::meta_conv_node{func});
|
|
|
bucket = nullptr;
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -210,15 +175,8 @@ public:
|
|
|
template<typename To>
|
|
|
auto conv() noexcept {
|
|
|
using conv_type = std::remove_cv_t<std::remove_reference_t<To>>;
|
|
|
-
|
|
|
- internal::meta_extend(
|
|
|
- internal::owner(*ctx, *info),
|
|
|
- type_id<conv_type>().hash(),
|
|
|
- internal::meta_conv_node{
|
|
|
- +[](const meta_ctx &area, const void *instance) {
|
|
|
- return forward_as_meta(area, static_cast<To>(*static_cast<const Type *>(instance)));
|
|
|
- }});
|
|
|
-
|
|
|
+ const auto *func = +[](const meta_ctx &area, const void *instance) { return forward_as_meta(area, static_cast<To>(*static_cast<const Type *>(instance))); };
|
|
|
+ internal::owner(*ctx, *info).details->conv.insert_or_assign(type_id<conv_type>().hash(), internal::meta_conv_node{func});
|
|
|
bucket = nullptr;
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -241,15 +199,7 @@ public:
|
|
|
using descriptor = meta_function_helper_t<Type, decltype(Candidate)>;
|
|
|
static_assert(Policy::template value<typename descriptor::return_type>, "Invalid return type for the given policy");
|
|
|
static_assert(std::is_same_v<std::remove_cv_t<std::remove_reference_t<typename descriptor::return_type>>, Type>, "The function doesn't return an object of the required type");
|
|
|
-
|
|
|
- internal::meta_extend(
|
|
|
- internal::owner(*ctx, *info),
|
|
|
- type_id<typename descriptor::args_type>().hash(),
|
|
|
- internal::meta_ctor_node{
|
|
|
- descriptor::args_type::size,
|
|
|
- &meta_arg<typename descriptor::args_type>,
|
|
|
- &meta_construct<Type, Candidate, Policy>});
|
|
|
-
|
|
|
+ internal::owner(*ctx, *info).details->ctor.insert_or_assign(type_id<typename descriptor::args_type>().hash(), internal::meta_ctor_node{descriptor::args_type::size, &meta_arg<typename descriptor::args_type>, &meta_construct<Type, Candidate, Policy>});
|
|
|
bucket = nullptr;
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -269,14 +219,7 @@ public:
|
|
|
// default constructor is already implicitly generated, no need for redundancy
|
|
|
if constexpr(sizeof...(Args) != 0u) {
|
|
|
using descriptor = meta_function_helper_t<Type, Type (*)(Args...)>;
|
|
|
-
|
|
|
- internal::meta_extend(
|
|
|
- internal::owner(*ctx, *info),
|
|
|
- type_id<typename descriptor::args_type>().hash(),
|
|
|
- internal::meta_ctor_node{
|
|
|
- descriptor::args_type::size,
|
|
|
- &meta_arg<typename descriptor::args_type>,
|
|
|
- &meta_construct<Type, Args...>});
|
|
|
+ internal::owner(*ctx, *info).details->ctor.insert_or_assign(type_id<typename descriptor::args_type>().hash(), internal::meta_ctor_node{descriptor::args_type::size, &meta_arg<typename descriptor::args_type>, &meta_construct<Type, Args...>});
|
|
|
}
|
|
|
|
|
|
bucket = nullptr;
|
|
|
@@ -304,12 +247,8 @@ public:
|
|
|
template<auto Func>
|
|
|
auto dtor() noexcept {
|
|
|
static_assert(std::is_invocable_v<decltype(Func), Type &>, "The function doesn't accept an object of the type provided");
|
|
|
-
|
|
|
- internal::meta_extend(
|
|
|
- internal::owner(*ctx, *info),
|
|
|
- internal::meta_dtor_node{
|
|
|
- +[](void *instance) { std::invoke(Func, *static_cast<Type *>(instance)); }});
|
|
|
-
|
|
|
+ const auto *func = +[](void *instance) { std::invoke(Func, *static_cast<Type *>(instance)); };
|
|
|
+ internal::owner(*ctx, *info).dtor = internal::meta_dtor_node{func};
|
|
|
bucket = nullptr;
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -497,18 +436,11 @@ public:
|
|
|
ENTT_ASSERT(bucket != nullptr, "Meta object does not support properties");
|
|
|
|
|
|
if constexpr(sizeof...(Value) == 0u) {
|
|
|
- internal::meta_extend(
|
|
|
- *bucket,
|
|
|
- id,
|
|
|
- internal::meta_prop_node{
|
|
|
- &internal::resolve<void>});
|
|
|
+ (*bucket)[id] = internal::meta_prop_node{&internal::resolve<void>};
|
|
|
} else {
|
|
|
- internal::meta_extend(
|
|
|
- *bucket,
|
|
|
- id,
|
|
|
- internal::meta_prop_node{
|
|
|
- &internal::resolve<std::decay_t<Value>>...,
|
|
|
- std::make_shared<std::decay_t<Value>>(std::forward<Value>(value))...});
|
|
|
+ (*bucket)[id] = internal::meta_prop_node{
|
|
|
+ &internal::resolve<std::decay_t<Value>>...,
|
|
|
+ std::make_shared<std::decay_t<Value>>(std::forward<Value>(value))...};
|
|
|
}
|
|
|
|
|
|
return *this;
|