meta: standalone meta_data/meta_func
This commit is contained in:
3
TODO
3
TODO
@@ -31,16 +31,15 @@ TODO:
|
||||
* cleanup common view from tricks to handle single swap-only and in-place, if constexpr branches
|
||||
* entity based component_traits
|
||||
* review cmake warning about FetchContent_Populate (need .28 and EXCLUDE_FROM_ALL for FetchContent)
|
||||
* after removing meta prop vectors, copy meta objects in their handles directly
|
||||
* suppress -Wself-move on CI with g++13
|
||||
* view specializations for multi, single and filtered elements
|
||||
* organizer support to groups
|
||||
* meta range: move id to meta objects and return plain types (?), then remove id from meta base and meta ctor too
|
||||
* don't pass reactive storage by default to callback
|
||||
* runtime types support for meta for types that aren't backed by C++ types
|
||||
* dtor, traits and custom should be part of meta descriptor (update meta_factory tests then)
|
||||
* allow attaching const values of non-Type type to meta types
|
||||
* built-in no-pagination storage - no_pagination page size as limits::max
|
||||
* sparse_set shrink_to_fit argument for sparse array shrink policy (none, empty, deep, whatever)
|
||||
* any cdynamic to support const ownership construction
|
||||
* track meta context on meta elements
|
||||
* safer meta_data/meta_func (no blind indirections)
|
||||
|
||||
@@ -833,8 +833,8 @@ struct meta_data {
|
||||
* @param area The context from which to search for meta types.
|
||||
* @param curr The underlying node with which to construct the instance.
|
||||
*/
|
||||
meta_data(const meta_ctx &area, const internal::meta_data_node &curr) noexcept
|
||||
: node{&curr},
|
||||
meta_data(const meta_ctx &area, internal::meta_data_node curr) noexcept
|
||||
: node{std::move(curr)},
|
||||
ctx{&area} {}
|
||||
|
||||
/**
|
||||
@@ -842,7 +842,7 @@ struct meta_data {
|
||||
* @return The number of setters available.
|
||||
*/
|
||||
[[nodiscard]] size_type arity() const noexcept {
|
||||
return node->arity;
|
||||
return node.arity;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -850,7 +850,7 @@ struct meta_data {
|
||||
* @return True if the data member is constant, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_const() const noexcept {
|
||||
return static_cast<bool>(node->traits & internal::meta_traits::is_const);
|
||||
return static_cast<bool>(node.traits & internal::meta_traits::is_const);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -858,7 +858,7 @@ struct meta_data {
|
||||
* @return True if the data member is static, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_static() const noexcept {
|
||||
return static_cast<bool>(node->traits & internal::meta_traits::is_static);
|
||||
return static_cast<bool>(node.traits & internal::meta_traits::is_static);
|
||||
}
|
||||
|
||||
/*! @copydoc meta_any::type */
|
||||
@@ -874,7 +874,7 @@ struct meta_data {
|
||||
template<typename Type>
|
||||
// NOLINTNEXTLINE(modernize-use-nodiscard)
|
||||
bool set(meta_handle instance, Type &&value) const {
|
||||
return node->set && node->set(meta_handle{*ctx, std::move(instance)}, meta_any{*ctx, std::forward<Type>(value)});
|
||||
return node.set && node.set(meta_handle{*ctx, std::move(instance)}, meta_any{*ctx, std::forward<Type>(value)});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -883,7 +883,7 @@ struct meta_data {
|
||||
* @return A wrapper containing the value of the underlying variable.
|
||||
*/
|
||||
[[nodiscard]] meta_any get(meta_handle instance) const {
|
||||
return node->get(*ctx, meta_handle{*ctx, std::move(instance)});
|
||||
return node.get(*ctx, meta_handle{*ctx, std::move(instance)});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -900,7 +900,7 @@ struct meta_data {
|
||||
*/
|
||||
template<typename Type>
|
||||
[[nodiscard]] Type traits() const noexcept {
|
||||
return internal::meta_to_user_traits<Type>(node->traits);
|
||||
return internal::meta_to_user_traits<Type>(node.traits);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -908,7 +908,7 @@ struct meta_data {
|
||||
* @return User defined arbitrary data.
|
||||
*/
|
||||
[[nodiscard]] meta_custom custom() const noexcept {
|
||||
return {node->custom};
|
||||
return {node.custom};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -925,11 +925,11 @@ struct meta_data {
|
||||
* @return True if the objects refer to the same type, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool operator==(const meta_data &other) const noexcept {
|
||||
return (ctx == other.ctx && node == other.node);
|
||||
return (ctx == other.ctx) && (node.set == other.node.set) && (node.get == other.node.get);
|
||||
}
|
||||
|
||||
private:
|
||||
const internal::meta_data_node *node{};
|
||||
internal::meta_data_node node{};
|
||||
const meta_ctx *ctx{};
|
||||
};
|
||||
|
||||
@@ -956,8 +956,8 @@ struct meta_func {
|
||||
* @param area The context from which to search for meta types.
|
||||
* @param curr The underlying node with which to construct the instance.
|
||||
*/
|
||||
meta_func(const meta_ctx &area, const internal::meta_func_node &curr) noexcept
|
||||
: node{&curr},
|
||||
meta_func(const meta_ctx &area, internal::meta_func_node curr) noexcept
|
||||
: node{std::move(curr)},
|
||||
ctx{&area} {}
|
||||
|
||||
/**
|
||||
@@ -965,7 +965,7 @@ struct meta_func {
|
||||
* @return The number of arguments accepted by the member function.
|
||||
*/
|
||||
[[nodiscard]] size_type arity() const noexcept {
|
||||
return node->arity;
|
||||
return node.arity;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -973,7 +973,7 @@ struct meta_func {
|
||||
* @return True if the member function is constant, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_const() const noexcept {
|
||||
return static_cast<bool>(node->traits & internal::meta_traits::is_const);
|
||||
return static_cast<bool>(node.traits & internal::meta_traits::is_const);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -981,7 +981,7 @@ struct meta_func {
|
||||
* @return True if the member function is static, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_static() const noexcept {
|
||||
return static_cast<bool>(node->traits & internal::meta_traits::is_static);
|
||||
return static_cast<bool>(node.traits & internal::meta_traits::is_static);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1005,7 +1005,7 @@ struct meta_func {
|
||||
* @return A wrapper containing the returned value, if any.
|
||||
*/
|
||||
meta_any invoke(meta_handle instance, meta_any *const args, const size_type sz) const {
|
||||
return sz == arity() ? node->invoke(*ctx, meta_handle{*ctx, std::move(instance)}, args) : meta_any{meta_ctx_arg, *ctx};
|
||||
return sz == arity() ? node.invoke(*ctx, meta_handle{*ctx, std::move(instance)}, args) : meta_any{meta_ctx_arg, *ctx};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1025,12 +1025,12 @@ struct meta_func {
|
||||
/*! @copydoc meta_data::traits */
|
||||
template<typename Type>
|
||||
[[nodiscard]] Type traits() const noexcept {
|
||||
return internal::meta_to_user_traits<Type>(node->traits);
|
||||
return internal::meta_to_user_traits<Type>(node.traits);
|
||||
}
|
||||
|
||||
/*! @copydoc meta_data::custom */
|
||||
[[nodiscard]] meta_custom custom() const noexcept {
|
||||
return {node->custom};
|
||||
return {node.custom};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1038,7 +1038,7 @@ struct meta_func {
|
||||
* @return The next overload of the given function, if any.
|
||||
*/
|
||||
[[nodiscard]] meta_func next() const {
|
||||
return node->next ? meta_func{*ctx, *node->next} : meta_func{};
|
||||
return node.next ? meta_func{*ctx, *node.next} : meta_func{};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1051,11 +1051,11 @@ struct meta_func {
|
||||
|
||||
/*! @copydoc meta_data::operator== */
|
||||
[[nodiscard]] bool operator==(const meta_func &other) const noexcept {
|
||||
return (ctx == other.ctx && node == other.node);
|
||||
return (ctx == other.ctx) && (node.invoke == other.node.invoke);
|
||||
}
|
||||
|
||||
private:
|
||||
const internal::meta_func_node *node{};
|
||||
internal::meta_func_node node{};
|
||||
const meta_ctx *ctx{};
|
||||
};
|
||||
|
||||
@@ -1582,19 +1582,19 @@ inline bool meta_any::assign(meta_any &&other) {
|
||||
}
|
||||
|
||||
[[nodiscard]] inline meta_type meta_data::type() const noexcept {
|
||||
return meta_type{*ctx, node->type(internal::meta_context::from(*ctx))};
|
||||
return meta_type{*ctx, node.type(internal::meta_context::from(*ctx))};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline meta_type meta_data::arg(const size_type index) const noexcept {
|
||||
return index < arity() ? node->arg(*ctx, index) : meta_type{};
|
||||
return index < arity() ? node.arg(*ctx, index) : meta_type{};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline meta_type meta_func::ret() const noexcept {
|
||||
return meta_type{*ctx, node->ret(internal::meta_context::from(*ctx))};
|
||||
return meta_type{*ctx, node.ret(internal::meta_context::from(*ctx))};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline meta_type meta_func::arg(const size_type index) const noexcept {
|
||||
return index < arity() ? node->arg(*ctx, index) : meta_type{};
|
||||
return index < arity() ? node.arg(*ctx, index) : meta_type{};
|
||||
}
|
||||
|
||||
/*! @cond TURN_OFF_DOXYGEN */
|
||||
|
||||
Reference in New Issue
Block a user