lib.cpp 822 B

12345678910111213141516171819202122232425262728293031323334
  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 set_up(entt::meta_ctx ctx) {
  10. entt::meta_ctx::bind(ctx);
  11. entt::meta<position>()
  12. .alias("position"_hs)
  13. .ctor<&create_position>()
  14. .data<&position::x>("x"_hs)
  15. .data<&position::y>("y"_hs);
  16. entt::meta<velocity>()
  17. .alias("velocity"_hs)
  18. .ctor<>()
  19. .data<&velocity::dx>("dx"_hs)
  20. .data<&velocity::dy>("dy"_hs);
  21. }
  22. ENTT_API void tear_down() {
  23. entt::meta<position>().reset();
  24. entt::meta<velocity>().reset();
  25. }
  26. ENTT_API entt::meta_any wrap_int(int value) {
  27. return value;
  28. }