1
0

plugin.cpp 1.1 KB

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