initial
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
#define CR_HOST
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cr.h>
|
||||
#include <entt/locator/locator.hpp>
|
||||
#include "../../../common/boxed_type.h"
|
||||
#include "userdata.h"
|
||||
|
||||
TEST(Lib, Locator) {
|
||||
entt::locator<test::boxed_int>::emplace().value = 4;
|
||||
|
||||
ASSERT_EQ(entt::locator<test::boxed_int>::value().value, 4);
|
||||
|
||||
userdata ud{entt::locator<test::boxed_int>::handle(), 3};
|
||||
|
||||
cr_plugin ctx;
|
||||
ctx.userdata = &ud;
|
||||
|
||||
cr_plugin_load(ctx, PLUGIN);
|
||||
cr_plugin_update(ctx);
|
||||
|
||||
ASSERT_EQ(entt::locator<test::boxed_int>::value().value, ud.value);
|
||||
|
||||
// service updates do not propagate across boundaries
|
||||
entt::locator<test::boxed_int>::emplace().value = 4;
|
||||
cr_plugin_update(ctx);
|
||||
|
||||
ASSERT_NE(entt::locator<test::boxed_int>::value().value, ud.value);
|
||||
|
||||
cr_plugin_close(ctx);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <cr.h>
|
||||
#include <entt/locator/locator.hpp>
|
||||
#include "../../../common/boxed_type.h"
|
||||
#include "userdata.h"
|
||||
|
||||
CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
|
||||
switch(operation) {
|
||||
case CR_LOAD:
|
||||
entt::locator<test::boxed_int>::reset(static_cast<userdata *>(ctx->userdata)->handle);
|
||||
break;
|
||||
case CR_STEP:
|
||||
entt::locator<test::boxed_int>::value().value = static_cast<userdata *>(ctx->userdata)->value;
|
||||
break;
|
||||
case CR_UNLOAD:
|
||||
case CR_CLOSE:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef ENTT_LIB_LOCATOR_PLUGIN_USERDATA_H
|
||||
#define ENTT_LIB_LOCATOR_PLUGIN_USERDATA_H
|
||||
|
||||
#include <entt/locator/locator.hpp>
|
||||
#include "../../../common/boxed_type.h"
|
||||
|
||||
struct userdata {
|
||||
entt::locator<test::boxed_int>::node_type handle{};
|
||||
int value{};
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user