meta: added internal meta_trait enum to reduce memory usage due to meta node traits
This commit is contained in:
@@ -403,8 +403,9 @@ struct meta_factory<Type> {
|
||||
{},
|
||||
nullptr,
|
||||
nullptr,
|
||||
std::is_same_v<Type, data_type> || std::is_const_v<data_type>,
|
||||
true,
|
||||
internal::meta_trait::IS_NONE
|
||||
| ((std::is_same_v<Type, data_type> || std::is_const_v<data_type>) ? internal::meta_trait::IS_CONST : internal::meta_trait::IS_NONE)
|
||||
| internal::meta_trait::IS_STATIC,
|
||||
internal::meta_info<data_type>::resolve(),
|
||||
&meta_setter<Type, Data>,
|
||||
&meta_getter<Type, Data, Policy>
|
||||
@@ -451,8 +452,9 @@ struct meta_factory<Type> {
|
||||
{},
|
||||
nullptr,
|
||||
nullptr,
|
||||
std::is_same_v<decltype(Setter), std::nullptr_t> || (std::is_member_object_pointer_v<decltype(Setter)> && std::is_const_v<underlying_type>),
|
||||
false,
|
||||
internal::meta_trait::IS_NONE
|
||||
| (std::is_same_v<decltype(Setter), std::nullptr_t> || (std::is_member_object_pointer_v<decltype(Setter)> && std::is_const_v<underlying_type>)) ? internal::meta_trait::IS_CONST : internal::meta_trait::IS_NONE
|
||||
/* this is never static */,
|
||||
internal::meta_info<underlying_type>::resolve(),
|
||||
&meta_setter<Type, Setter>,
|
||||
&meta_getter<Type, Getter, Policy>
|
||||
@@ -492,8 +494,9 @@ struct meta_factory<Type> {
|
||||
nullptr,
|
||||
nullptr,
|
||||
descriptor::args_type::size,
|
||||
descriptor::is_const,
|
||||
descriptor::is_static,
|
||||
internal::meta_trait::IS_NONE
|
||||
| (descriptor::is_const ? internal::meta_trait::IS_CONST : internal::meta_trait::IS_NONE)
|
||||
| (descriptor::is_static ? internal::meta_trait::IS_STATIC : internal::meta_trait::IS_NONE),
|
||||
internal::meta_info<std::conditional_t<std::is_same_v<Policy, as_void_t>, void, typename descriptor::return_type>>::resolve(),
|
||||
&meta_arg<typename descriptor::args_type>,
|
||||
&meta_invoke<Type, Candidate, Policy>
|
||||
|
||||
@@ -831,7 +831,7 @@ struct meta_data {
|
||||
* @return True if the data member is constant, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_const() const ENTT_NOEXCEPT {
|
||||
return node->is_const;
|
||||
return (node->traits & internal::meta_trait::IS_CONST);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -839,7 +839,7 @@ struct meta_data {
|
||||
* @return True if the data member is static, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_static() const ENTT_NOEXCEPT {
|
||||
return node->is_static;
|
||||
return (node->traits & internal::meta_trait::IS_STATIC);
|
||||
}
|
||||
|
||||
/*! @copydoc meta_any::type */
|
||||
@@ -940,7 +940,7 @@ struct meta_func {
|
||||
* @return True if the member function is constant, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_const() const ENTT_NOEXCEPT {
|
||||
return node->is_const;
|
||||
return (node->traits & internal::meta_trait::IS_CONST);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -948,7 +948,7 @@ struct meta_func {
|
||||
* @return True if the member function is static, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_static() const ENTT_NOEXCEPT {
|
||||
return node->is_static;
|
||||
return (node->traits & internal::meta_trait::IS_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1132,7 +1132,7 @@ public:
|
||||
* @return True if the underlying type is an integral type, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_integral() const ENTT_NOEXCEPT {
|
||||
return node->is_integral;
|
||||
return (node->traits & internal::meta_trait::IS_INTEGRAL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1141,7 +1141,7 @@ public:
|
||||
* otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_floating_point() const ENTT_NOEXCEPT {
|
||||
return node->is_floating_point;
|
||||
return (node->traits & internal::meta_trait::IS_FLOATING_POINT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1149,7 +1149,7 @@ public:
|
||||
* @return True if the underlying type is an array type, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_array() const ENTT_NOEXCEPT {
|
||||
return node->is_array;
|
||||
return (node->traits & internal::meta_trait::IS_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1157,7 +1157,7 @@ public:
|
||||
* @return True if the underlying type is an enum, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_enum() const ENTT_NOEXCEPT {
|
||||
return node->is_enum;
|
||||
return (node->traits & internal::meta_trait::IS_ENUM);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1165,7 +1165,7 @@ public:
|
||||
* @return True if the underlying type is an union, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_union() const ENTT_NOEXCEPT {
|
||||
return node->is_union;
|
||||
return (node->traits & internal::meta_trait::IS_UNION);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1173,7 +1173,7 @@ public:
|
||||
* @return True if the underlying type is a class, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_class() const ENTT_NOEXCEPT {
|
||||
return node->is_class;
|
||||
return (node->traits & internal::meta_trait::IS_CLASS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1181,7 +1181,7 @@ public:
|
||||
* @return True if the underlying type is a pointer, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_pointer() const ENTT_NOEXCEPT {
|
||||
return node->is_pointer;
|
||||
return (node->traits & internal::meta_trait::IS_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1190,7 +1190,7 @@ public:
|
||||
* otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_function_pointer() const ENTT_NOEXCEPT {
|
||||
return node->is_function_pointer;
|
||||
return (node->traits & internal::meta_trait::IS_FUNCTION_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1199,7 +1199,7 @@ public:
|
||||
* otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_member_object_pointer() const ENTT_NOEXCEPT {
|
||||
return node->is_member_object_pointer;
|
||||
return (node->traits & internal::meta_trait::IS_MEMBER_OBJECT_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1209,7 +1209,7 @@ public:
|
||||
* false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_member_function_pointer() const ENTT_NOEXCEPT {
|
||||
return node->is_member_function_pointer;
|
||||
return (node->traits & internal::meta_trait::IS_MEMBER_FUNCTION_POINTER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1218,7 +1218,7 @@ public:
|
||||
* otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_pointer_like() const ENTT_NOEXCEPT {
|
||||
return node->is_pointer_like;
|
||||
return (node->traits & internal::meta_trait::IS_META_POINTER_LIKE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1226,7 +1226,7 @@ public:
|
||||
* @return True if the type is a sequence container, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_sequence_container() const ENTT_NOEXCEPT {
|
||||
return node->is_sequence_container;
|
||||
return (node->traits & internal::meta_trait::IS_META_SEQUENCE_CONTAINER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1234,7 +1234,7 @@ public:
|
||||
* @return True if the type is an associative container, false otherwise.
|
||||
*/
|
||||
[[nodiscard]] bool is_associative_container() const ENTT_NOEXCEPT {
|
||||
return node->is_associative_container;
|
||||
return (node->traits & internal::meta_trait::IS_META_ASSOCIATIVE_CONTAINER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,26 @@ struct meta_handle;
|
||||
namespace internal {
|
||||
|
||||
|
||||
enum meta_trait: std::uint32_t {
|
||||
IS_NONE = 0x0000,
|
||||
IS_CONST = 0x0001,
|
||||
IS_STATIC = 0x0002,
|
||||
IS_INTEGRAL = 0x0004,
|
||||
IS_FLOATING_POINT = 0x0008,
|
||||
IS_ARRAY = 0x0010,
|
||||
IS_ENUM = 0x0020,
|
||||
IS_UNION = 0x0040,
|
||||
IS_CLASS = 0x0080,
|
||||
IS_POINTER = 0x0100,
|
||||
IS_FUNCTION_POINTER = 0x0200,
|
||||
IS_MEMBER_OBJECT_POINTER = 0x0400,
|
||||
IS_MEMBER_FUNCTION_POINTER = 0x0800,
|
||||
IS_META_POINTER_LIKE = 0x1000,
|
||||
IS_META_SEQUENCE_CONTAINER = 0x2000,
|
||||
IS_META_ASSOCIATIVE_CONTAINER = 0x4000
|
||||
};
|
||||
|
||||
|
||||
struct meta_type_node;
|
||||
|
||||
|
||||
@@ -68,8 +88,7 @@ struct meta_data_node {
|
||||
id_type id;
|
||||
meta_data_node * next;
|
||||
meta_prop_node * prop;
|
||||
const bool is_const;
|
||||
const bool is_static;
|
||||
std::underlying_type_t<meta_trait> traits;
|
||||
meta_type_node * const type;
|
||||
bool(* const set)(meta_handle, meta_any);
|
||||
meta_any(* const get)(meta_handle);
|
||||
@@ -82,8 +101,7 @@ struct meta_func_node {
|
||||
meta_func_node * next;
|
||||
meta_prop_node * prop;
|
||||
const size_type arity;
|
||||
const bool is_const;
|
||||
const bool is_static;
|
||||
std::underlying_type_t<meta_trait> traits;
|
||||
meta_type_node * const ret;
|
||||
meta_type(* const arg)(const size_type) ENTT_NOEXCEPT;
|
||||
meta_any(* const invoke)(meta_handle, meta_any * const);
|
||||
@@ -105,19 +123,7 @@ struct meta_type_node {
|
||||
meta_type_node * next;
|
||||
meta_prop_node * prop;
|
||||
const size_type size_of;
|
||||
const bool is_integral;
|
||||
const bool is_floating_point;
|
||||
const bool is_array;
|
||||
const bool is_enum;
|
||||
const bool is_union;
|
||||
const bool is_class;
|
||||
const bool is_pointer;
|
||||
const bool is_function_pointer;
|
||||
const bool is_member_object_pointer;
|
||||
const bool is_member_function_pointer;
|
||||
const bool is_pointer_like;
|
||||
const bool is_sequence_container;
|
||||
const bool is_associative_container;
|
||||
std::underlying_type_t<meta_trait> traits;
|
||||
const size_type rank;
|
||||
size_type(* const extent)(const size_type) ENTT_NOEXCEPT ;
|
||||
meta_type_node *(* const remove_pointer)() ENTT_NOEXCEPT;
|
||||
@@ -188,19 +194,20 @@ public:
|
||||
nullptr,
|
||||
nullptr,
|
||||
size_of_v<Type>,
|
||||
std::is_integral_v<Type>,
|
||||
std::is_floating_point_v<Type>,
|
||||
std::is_array_v<Type>,
|
||||
std::is_enum_v<Type>,
|
||||
std::is_union_v<Type>,
|
||||
std::is_class_v<Type>,
|
||||
std::is_pointer_v<Type>,
|
||||
std::is_pointer_v<Type> && std::is_function_v<std::remove_pointer_t<Type>>,
|
||||
std::is_member_object_pointer_v<Type>,
|
||||
std::is_member_function_pointer_v<Type>,
|
||||
is_meta_pointer_like_v<Type>,
|
||||
is_complete_v<meta_sequence_container_traits<Type>>,
|
||||
is_complete_v<meta_associative_container_traits<Type>>,
|
||||
internal::meta_trait::IS_NONE
|
||||
| (std::is_integral_v<Type> ? internal::meta_trait::IS_INTEGRAL : internal::meta_trait::IS_NONE)
|
||||
| (std::is_floating_point_v<Type> ? internal::meta_trait::IS_FLOATING_POINT : internal::meta_trait::IS_NONE)
|
||||
| (std::is_array_v<Type> ? internal::meta_trait::IS_ARRAY : internal::meta_trait::IS_NONE)
|
||||
| (std::is_enum_v<Type> ? internal::meta_trait::IS_ENUM : internal::meta_trait::IS_NONE)
|
||||
| (std::is_union_v<Type> ? internal::meta_trait::IS_UNION : internal::meta_trait::IS_NONE)
|
||||
| (std::is_class_v<Type> ? internal::meta_trait::IS_CLASS : internal::meta_trait::IS_NONE)
|
||||
| (std::is_pointer_v<Type> ? internal::meta_trait::IS_POINTER : internal::meta_trait::IS_NONE)
|
||||
| (std::is_pointer_v<Type> && std::is_function_v<std::remove_pointer_t<Type>> ? internal::meta_trait::IS_FUNCTION_POINTER : internal::meta_trait::IS_NONE)
|
||||
| (std::is_member_object_pointer_v<Type> ? internal::meta_trait::IS_MEMBER_OBJECT_POINTER : internal::meta_trait::IS_NONE)
|
||||
| (std::is_member_function_pointer_v<Type> ? internal::meta_trait::IS_MEMBER_FUNCTION_POINTER : internal::meta_trait::IS_NONE)
|
||||
| (is_meta_pointer_like_v<Type> ? internal::meta_trait::IS_META_POINTER_LIKE : internal::meta_trait::IS_NONE)
|
||||
| (is_complete_v<meta_sequence_container_traits<Type>> ? internal::meta_trait::IS_META_SEQUENCE_CONTAINER : internal::meta_trait::IS_NONE)
|
||||
| (is_complete_v<meta_associative_container_traits<Type>> ? internal::meta_trait::IS_META_ASSOCIATIVE_CONTAINER : internal::meta_trait::IS_NONE),
|
||||
std::rank_v<Type>,
|
||||
[](meta_type_node::size_type dim) ENTT_NOEXCEPT { return extent(dim, std::make_index_sequence<std::rank_v<Type>>{}); },
|
||||
&meta_node<std::remove_cv_t<std::remove_reference_t<std::remove_pointer_t<Type>>>>::resolve,
|
||||
|
||||
Reference in New Issue
Block a user