1
0

lib.cpp 895 B

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