diff --git a/core/imgui/luajit_driver.cc b/core/imgui/luajit_driver.cc index b061ba9..028c7ae 100644 --- a/core/imgui/luajit_driver.cc +++ b/core/imgui/luajit_driver.cc @@ -12,7 +12,15 @@ namespace nf7::core::imgui { std::shared_ptr 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(); } diff --git a/core/imgui/luajit_driver_test.cc b/core/imgui/luajit_driver_test.cc index 1264229..34aa60e 100644 --- a/core/imgui/luajit_driver_test.cc +++ b/core/imgui/luajit_driver_test.cc @@ -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();