implement building luajit extension of imgui
This commit is contained in:
parent
72cf28cd14
commit
671a5e9903
@ -12,7 +12,15 @@ namespace nf7::core::imgui {
|
||||
|
||||
std::shared_ptr<luajit::Value> LuaJITDriver::MakeExtensionObject(
|
||||
luajit::TaskContext& lua) {
|
||||
lua_pushnil(*lua);
|
||||
auto L = *lua;
|
||||
|
||||
lua_newuserdata(L, 0);
|
||||
if (luaL_newmetatable(L, "nf7::core::imgui::LuaJITDriver::Extension")) {
|
||||
lua_createtable(L, 0, 0);
|
||||
# include "generated/imgui4lua.inc"
|
||||
lua_setfield(L, -2, "__index");
|
||||
}
|
||||
lua_setmetatable(L, -2);
|
||||
return lua.Register();
|
||||
}
|
||||
|
||||
|
@ -38,12 +38,16 @@ TEST_F(ImGuiLuaJITDriver, CompileAndInstall) {
|
||||
|
||||
auto fu = nf7::core::imgui::LuaJITDriver::CompileAndInstall(
|
||||
*subenv,
|
||||
toVector("local ctx = ...\nctx:trace(\"hello world\")"),
|
||||
toVector(
|
||||
"local ctx = ...\nctx:trace(\"hello world\")\n"
|
||||
"local imgui = ctx:recv():lua()\n"
|
||||
"imgui.Begin(\"helloworld\", true, 0)\n"
|
||||
"imgui.End()"),
|
||||
"test chunk");
|
||||
|
||||
concurrency->Push(
|
||||
nf7::SyncTask {
|
||||
clock->now() + std::chrono::seconds {2},
|
||||
clock->now() + std::chrono::seconds {10},
|
||||
[&](auto&) { DropEnv(); },
|
||||
});
|
||||
ConsumeTasks();
|
||||
|
Loading…
x
Reference in New Issue
Block a user