userdata.h 837 B

123456789101112131415161718192021222324252627282930
  1. #ifndef ENTT_LIB_META_PLUGIN_STD_USERDATA_H
  2. #define ENTT_LIB_META_PLUGIN_STD_USERDATA_H
  3. #include <type_traits>
  4. #include <entt/core/hashed_string.hpp>
  5. #include <entt/core/type_info.hpp>
  6. #include <entt/meta/context.hpp>
  7. #include <entt/meta/meta.hpp>
  8. #include "../../../common/value_type.h"
  9. #define ASSIGN_TYPE_ID(clazz) \
  10. template<> \
  11. struct entt::type_hash<clazz> { \
  12. static ENTT_CONSTEVAL entt::id_type value() noexcept { \
  13. return entt::basic_hashed_string<std::remove_const_t<std::remove_pointer_t<std::decay_t<decltype(#clazz)>>>>{#clazz}; \
  14. } \
  15. }
  16. struct userdata {
  17. entt::locator<entt::meta_ctx>::node_type ctx{};
  18. entt::meta_any any{};
  19. };
  20. ASSIGN_TYPE_ID(std::size_t);
  21. ASSIGN_TYPE_ID(test::boxed_int);
  22. ASSIGN_TYPE_ID(test::empty);
  23. ASSIGN_TYPE_ID(double);
  24. ASSIGN_TYPE_ID(int);
  25. #endif