lib.cpp 974 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <entt/core/attribute.h>
  2. #include <entt/core/hashed_string.hpp>
  3. #include <entt/locator/locator.hpp>
  4. #include <entt/meta/context.hpp>
  5. #include <entt/meta/factory.hpp>
  6. #include <entt/meta/meta.hpp>
  7. #include "../common/types.h"
  8. position create_position(int x, int y) {
  9. return position{x, y};
  10. }
  11. ENTT_API void share(entt::locator<entt::meta_ctx>::node_type handle) {
  12. entt::locator<entt::meta_ctx>::reset(handle);
  13. }
  14. ENTT_API void set_up() {
  15. using namespace entt::literals;
  16. entt::meta<position>()
  17. .type("position"_hs)
  18. .ctor<&create_position>()
  19. .data<&position::x>("x"_hs)
  20. .data<&position::y>("y"_hs);
  21. entt::meta<velocity>()
  22. .type("velocity"_hs)
  23. .ctor<>()
  24. .data<&velocity::dx>("dx"_hs)
  25. .data<&velocity::dy>("dy"_hs);
  26. }
  27. ENTT_API void tear_down() {
  28. entt::meta_reset<position>();
  29. entt::meta_reset<velocity>();
  30. }
  31. ENTT_API entt::meta_any wrap_int(int value) {
  32. return value;
  33. }