plugin.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <cr.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/boxed_type.h"
  8. #include "../../../common/value_type.h"
  9. #include "userdata.h"
  10. test::boxed_int create_boxed_int(int value) {
  11. return test::boxed_int{value};
  12. }
  13. void set_up() {
  14. using namespace entt::literals;
  15. entt::meta_factory<test::boxed_int>{}
  16. .type("boxed_int"_hs)
  17. .ctor<&create_boxed_int>()
  18. .data<&test::boxed_int::value>("value"_hs);
  19. entt::meta_factory<test::empty>{}
  20. .type("empty"_hs)
  21. .ctor<>();
  22. }
  23. void tear_down() {
  24. entt::meta_reset<test::boxed_int>();
  25. entt::meta_reset<test::empty>();
  26. }
  27. CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
  28. switch(operation) {
  29. case CR_LOAD:
  30. entt::locator<entt::meta_ctx>::reset(static_cast<userdata *>(ctx->userdata)->ctx);
  31. set_up();
  32. break;
  33. case CR_STEP:
  34. static_cast<userdata *>(ctx->userdata)->any = 4;
  35. break;
  36. case CR_UNLOAD:
  37. case CR_CLOSE:
  38. tear_down();
  39. break;
  40. }
  41. return 0;
  42. }