meta: minor changes
This commit is contained in:
57
TODO
57
TODO
@@ -23,3 +23,60 @@ Next:
|
||||
* WIP: snapshot rework
|
||||
- snapshot: support for range-based archives
|
||||
- update documentation to describe alternatives
|
||||
|
||||
* WIP:
|
||||
- meta: update doc
|
||||
- static constexpr -> inline constexpr
|
||||
- test: meta type seq/assoc traits, containers
|
||||
- document meta type traits
|
||||
- remove internal::find_if
|
||||
|
||||
|
||||
struct meta_view_node {
|
||||
using size_type = std::size_t;
|
||||
meta_type_node *(* const key_type)() ENTT_NOEXCEPT;
|
||||
meta_type_node *(* const value_type)() ENTT_NOEXCEPT;
|
||||
void(* const next)(meta_handle) ENTT_NOEXCEPT;
|
||||
void(* const prev)(meta_handle) ENTT_NOEXCEPT;
|
||||
bool(* const empty)(meta_handle) ENTT_NOEXCEPT;
|
||||
void(* const clear)(meta_handle);
|
||||
size_type(* const size)(meta_handle) ENTT_NOEXCEPT;
|
||||
meta_any(* const begin)(meta_handle) ENTT_NOEXCEPT;
|
||||
meta_any(* const end)(meta_handle) ENTT_NOEXCEPT;
|
||||
meta_any(* const erase)(meta_handle, meta_handle);
|
||||
meta_any(* const insert)(meta_handle, meta_any, meta_any);
|
||||
bool(* const set)(meta_handle, meta_any, meta_any);
|
||||
meta_any(* const get)(meta_handle, meta_any);
|
||||
};
|
||||
|
||||
static meta_view_node * view() ENTT_NOEXCEPT {
|
||||
if constexpr(is_container_v<Type>) {
|
||||
static meta_view_node node{
|
||||
[]() {
|
||||
if constexpr(is_sequence_container_v<Type>) {
|
||||
return &internal::meta_node<typename Type::size_type>::resolve;
|
||||
} else {
|
||||
return &internal::meta_node<typename Type::key_type>::resolve;
|
||||
}
|
||||
},
|
||||
&internal::meta_node<typename Type::value_type>::resolve,
|
||||
nullptr, // void(* const next)(meta_handle) ENTT_NOEXCEPT;
|
||||
nullptr, // void(* const prev)(meta_handle) ENTT_NOEXCEPT;
|
||||
nullptr, // bool(* const empty)(meta_handle) ENTT_NOEXCEPT;
|
||||
nullptr, // void(* const clear)(meta_handle);
|
||||
[](meta_handle instance) -> typename meta_view_node::size_type {
|
||||
return (*instance).cast<Type>().size();
|
||||
}, // size_type(* const size)(meta_handle) ENTT_NOEXCEPT;
|
||||
nullptr, // meta_any(* const begin)(meta_handle) ENTT_NOEXCEPT;
|
||||
nullptr, // meta_any(* const end)(meta_handle) ENTT_NOEXCEPT;
|
||||
nullptr, // meta_any(* const erase)(meta_handle, meta_handle);
|
||||
nullptr, // meta_any(* const insert)(meta_handle, meta_any, meta_any);
|
||||
nullptr, // bool(* const set)(meta_handle, meta_any, meta_any);
|
||||
nullptr // meta_any(* const get)(meta_handle, meta_any);
|
||||
};
|
||||
|
||||
return &node;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
#include "meta/factory.hpp"
|
||||
#include "meta/internal.hpp"
|
||||
#include "meta/meta.hpp"
|
||||
#include "meta/policy.hpp"
|
||||
#include "meta/range.hpp"
|
||||
#include "meta/resolve.hpp"
|
||||
#include "meta/policy.hpp"
|
||||
#include "process/process.hpp"
|
||||
#include "process/scheduler.hpp"
|
||||
#include "resource/cache.hpp"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <functional>
|
||||
@@ -605,12 +606,8 @@ struct meta_ctor {
|
||||
*/
|
||||
template<typename... Args>
|
||||
[[nodiscard]] meta_any invoke([[maybe_unused]] Args &&... args) const {
|
||||
if constexpr(sizeof...(Args) == 0) {
|
||||
return sizeof...(Args) == size() ? node->invoke(nullptr) : meta_any{};
|
||||
} else {
|
||||
meta_any arguments[]{std::forward<Args>(args)...};
|
||||
return sizeof...(Args) == size() ? node->invoke(arguments) : meta_any{};
|
||||
}
|
||||
std::array<meta_any, sizeof...(Args)> arguments{std::forward<Args>(args)...};
|
||||
return sizeof...(Args) == size() ? node->invoke(arguments.data()) : meta_any{};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -846,12 +843,8 @@ struct meta_func {
|
||||
meta_any any{};
|
||||
|
||||
if(sizeof...(Args) == size()) {
|
||||
if constexpr(sizeof...(Args) == 0) {
|
||||
any = node->invoke(std::move(instance), nullptr);
|
||||
} else {
|
||||
meta_any arguments[]{std::forward<Args>(args)...};
|
||||
any = node->invoke(std::move(instance), arguments);
|
||||
}
|
||||
std::array<meta_any, sizeof...(Args)> arguments{std::forward<Args>(args)...};
|
||||
any = node->invoke(std::move(instance), arguments.data());
|
||||
}
|
||||
|
||||
return any;
|
||||
@@ -1270,12 +1263,8 @@ public:
|
||||
return any;
|
||||
};
|
||||
|
||||
if constexpr(sizeof...(Args) == 0) {
|
||||
return construct_if(nullptr);
|
||||
} else {
|
||||
meta_any arguments[]{std::forward<Args>(args)...};
|
||||
return construct_if(arguments);
|
||||
}
|
||||
std::array<meta_any, sizeof...(Args)> arguments{std::forward<Args>(args)...};
|
||||
return construct_if(arguments.data());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/core/hashed_string.hpp>
|
||||
#include <entt/meta/factory.hpp>
|
||||
@@ -127,21 +129,45 @@ TEST_F(MetaType, Functionalities) {
|
||||
|
||||
TEST_F(MetaType, Traits) {
|
||||
ASSERT_TRUE(entt::resolve<void>().is_void());
|
||||
ASSERT_FALSE(entt::resolve<int>().is_void());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<bool>().is_integral());
|
||||
ASSERT_FALSE(entt::resolve<double>().is_integral());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<double>().is_floating_point());
|
||||
ASSERT_TRUE(entt::resolve<int[3]>().is_array());
|
||||
ASSERT_FALSE(entt::resolve<int>().is_floating_point());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<int[5]>().is_array());
|
||||
ASSERT_TRUE(entt::resolve<int[5][3]>().is_array());
|
||||
ASSERT_FALSE(entt::resolve<int>().is_array());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<property_t>().is_enum());
|
||||
ASSERT_FALSE(entt::resolve<char>().is_enum());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<union_t>().is_union());
|
||||
ASSERT_FALSE(entt::resolve<derived_t>().is_union());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<derived_t>().is_class());
|
||||
ASSERT_FALSE(entt::resolve<union_t>().is_class());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<int *>().is_pointer());
|
||||
ASSERT_FALSE(entt::resolve<int>().is_pointer());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<decltype(&clazz_t::func)>().is_function_pointer());
|
||||
ASSERT_FALSE(entt::resolve<decltype(&clazz_t::member)>().is_function_pointer());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<decltype(&clazz_t::value)>().is_member_object_pointer());
|
||||
ASSERT_FALSE(entt::resolve<decltype(&clazz_t::member)>().is_member_object_pointer());
|
||||
|
||||
ASSERT_TRUE(entt::resolve<decltype(&clazz_t::member)>().is_member_function_pointer());
|
||||
ASSERT_FALSE(entt::resolve<decltype(&clazz_t::value)>().is_member_function_pointer());
|
||||
|
||||
ASSERT_EQ(entt::resolve<int>().rank(), 0u);
|
||||
ASSERT_EQ(entt::resolve<int[5][3]>().rank(), 2u);
|
||||
ASSERT_EQ(entt::resolve<int>().extent(), 0u);
|
||||
ASSERT_EQ(entt::resolve<int[5][3]>().extent(), 5u);
|
||||
ASSERT_EQ(entt::resolve<int[5][3]>().extent(1u), 3u);
|
||||
ASSERT_EQ(entt::resolve<int[5][3]>().extent(2u), 0u);
|
||||
|
||||
}
|
||||
|
||||
TEST_F(MetaType, RemovePointer) {
|
||||
|
||||
Reference in New Issue
Block a user