🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

  1. #include <cr.h>
  2. #include <entt/core/hashed_string.hpp>
  3. #include <entt/meta/ctx.hpp>
  4. #include <entt/meta/factory.hpp>
  5. #include <entt/meta/meta.hpp>
  6. #include "types.h"
  7. position create_position(int x, int y) {
  8. return position{x, y};
  9. }
  10. void set_up() {
  11. using namespace entt::literals;
  12. entt::meta<position>()
  13. .type("position"_hs)
  14. .ctor<&create_position>()
  15. .data<&position::x>("x"_hs)
  16. .data<&position::y>("y"_hs);
  17. entt::meta<velocity>()
  18. .type("velocity"_hs)
  19. .ctor<>()
  20. .data<&velocity::dx>("dx"_hs)
  21. .data<&velocity::dy>("dy"_hs);
  22. }
  23. void tear_down() {
  24. entt::meta_reset<position>();
  25. entt::meta_reset<velocity>();
  26. }
  27. CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
  28. switch(operation) {
  29. case CR_LOAD:
  30. entt::meta_ctx::bind(static_cast<userdata *>(ctx->userdata)->ctx);
  31. set_up();
  32. break;
  33. case CR_STEP:
  34. static_cast<userdata *>(ctx->userdata)->any = 42;
  35. break;
  36. case CR_UNLOAD:
  37. case CR_CLOSE:
  38. tear_down();
  39. break;
  40. }
  41. return 0;
  42. }