Michele Caini 6 лет назад
Родитель
Сommit
5a7e954aee
5 измененных файлов с 15 добавлено и 13 удалено
  1. 1 2
      TODO
  2. 6 3
      src/entt/meta/meta.hpp
  3. 2 2
      test/lib/a_module.cpp
  4. 2 2
      test/lib/another_module.cpp
  5. 4 4
      test/lib/lib.cpp

+ 1 - 2
TODO

@@ -36,5 +36,4 @@
 
 
 * make meta work across boundaries
 * make meta work across boundaries
   - extend and make factory::prop more flexible
   - extend and make factory::prop more flexible
-  - a better context
-  - tests, doc
+  - doc

+ 6 - 3
src/entt/meta/meta.hpp

@@ -1731,9 +1731,12 @@ private:
 
 
 /*! @brief Opaque container for a meta context. */
 /*! @brief Opaque container for a meta context. */
 struct meta_ctx {
 struct meta_ctx {
-    /*! @brief Sets the context as the current one. */
-    void set() const ENTT_NOEXCEPT {
-        internal::meta_info<>::global = ctx;
+    /**
+     * @brief Binds the meta system to the given context.
+     * @param other A valid context to which to bind.
+     */
+    static void bind(meta_ctx other) ENTT_NOEXCEPT {
+        internal::meta_info<>::global = other.ctx;
     }
     }
 
 
 private:
 private:

+ 2 - 2
test/lib/a_module.cpp

@@ -47,8 +47,8 @@ LIB_EXPORT void emit_another_event(test_emitter &emitter) {
     emitter.publish<another_event>();
     emitter.publish<another_event>();
 }
 }
 
 
-LIB_EXPORT void a_module_meta_ctx(entt::meta_ctx context) {
-    context.set();
+LIB_EXPORT void a_module_bind_ctx(entt::meta_ctx context) {
+    entt::meta_ctx::bind(context);
 }
 }
 
 
 LIB_EXPORT void a_module_meta_init() {
 LIB_EXPORT void a_module_meta_init() {

+ 2 - 2
test/lib/another_module.cpp

@@ -52,8 +52,8 @@ LIB_EXPORT void emit_an_event(int payload, test_emitter &emitter) {
     emitter.publish<an_event>(payload);
     emitter.publish<an_event>(payload);
 }
 }
 
 
-LIB_EXPORT void another_module_meta_ctx(entt::meta_ctx context) {
-    context.set();
+LIB_EXPORT void another_module_bind_ctx(entt::meta_ctx context) {
+    entt::meta_ctx::bind(context);
 }
 }
 
 
 LIB_EXPORT void another_module_meta_init() {
 LIB_EXPORT void another_module_meta_init() {

+ 4 - 4
test/lib/lib.cpp

@@ -20,8 +20,8 @@ extern void trigger_another_event(entt::dispatcher &);
 extern void emit_an_event(int, test_emitter &);
 extern void emit_an_event(int, test_emitter &);
 extern void emit_another_event(test_emitter &);
 extern void emit_another_event(test_emitter &);
 
 
-extern void a_module_meta_ctx(entt::meta_ctx);
-extern void another_module_meta_ctx(entt::meta_ctx);
+extern void a_module_bind_ctx(entt::meta_ctx);
+extern void another_module_bind_ctx(entt::meta_ctx);
 
 
 extern void a_module_meta_init();
 extern void a_module_meta_init();
 extern void another_module_meta_init();
 extern void another_module_meta_init();
@@ -115,8 +115,8 @@ TEST(Lib, Meta) {
     ASSERT_FALSE(entt::resolve<int>().data("0"_hs));
     ASSERT_FALSE(entt::resolve<int>().data("0"_hs));
     ASSERT_FALSE(entt::resolve<char>().data("c"_hs));
     ASSERT_FALSE(entt::resolve<char>().data("c"_hs));
 
 
-    a_module_meta_ctx(entt::meta_ctx{});
-    another_module_meta_ctx(entt::meta_ctx{});
+    a_module_bind_ctx(entt::meta_ctx{});
+    another_module_bind_ctx(entt::meta_ctx{});
 
 
     entt::meta<double>().type("double"_hs).conv<int>();
     entt::meta<double>().type("double"_hs).conv<int>();
     another_module_meta_init();
     another_module_meta_init();