meta: context review
This commit is contained in:
3
TODO
3
TODO
@@ -36,5 +36,4 @@
|
||||
|
||||
* make meta work across boundaries
|
||||
- extend and make factory::prop more flexible
|
||||
- a better context
|
||||
- tests, doc
|
||||
- doc
|
||||
|
||||
@@ -1731,9 +1731,12 @@ private:
|
||||
|
||||
/*! @brief Opaque container for a meta context. */
|
||||
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:
|
||||
|
||||
@@ -47,8 +47,8 @@ LIB_EXPORT void emit_another_event(test_emitter &emitter) {
|
||||
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() {
|
||||
|
||||
@@ -52,8 +52,8 @@ LIB_EXPORT void emit_an_event(int payload, test_emitter &emitter) {
|
||||
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() {
|
||||
|
||||
@@ -20,8 +20,8 @@ extern void trigger_another_event(entt::dispatcher &);
|
||||
extern void emit_an_event(int, 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 another_module_meta_init();
|
||||
@@ -115,8 +115,8 @@ TEST(Lib, Meta) {
|
||||
ASSERT_FALSE(entt::resolve<int>().data("0"_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>();
|
||||
another_module_meta_init();
|
||||
|
||||
Reference in New Issue
Block a user