mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Use the actual callback function instead of mocking it
This commit is contained in:
parent
0044346b49
commit
5dbe86e9ee
1 changed files with 7 additions and 8 deletions
|
@ -14,12 +14,11 @@ namespace
|
||||||
void SetUp() override
|
void SetUp() override
|
||||||
{
|
{
|
||||||
mLua.protectedCall([&](LuaUtil::LuaView& view) {
|
mLua.protectedCall([&](LuaUtil::LuaView& view) {
|
||||||
view.sol()["callback"] = [](sol::this_state state, sol::protected_function fn) -> LuaUtil::Callback {
|
sol::table hiddenData(view.sol(), sol::create);
|
||||||
sol::table hiddenData(state, sol::create);
|
|
||||||
hiddenData[LuaUtil::ScriptsContainer::sScriptIdKey] = LuaUtil::ScriptId{};
|
hiddenData[LuaUtil::ScriptsContainer::sScriptIdKey] = LuaUtil::ScriptId{};
|
||||||
return LuaUtil::Callback{ std::move(fn), hiddenData };
|
view.sol()["async"] = LuaUtil::getAsyncPackageInitializer(
|
||||||
};
|
view.sol(), []() { return 0.; }, []() { return 0.; })(hiddenData);
|
||||||
view.sol()["pass"] = [&](LuaUtil::Callback callback) { mCb = callback; };
|
view.sol()["pass"] = [&](const sol::table& t) { mCb = LuaUtil::Callback::fromLua(t); };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@ namespace
|
||||||
view.sol().safe_script(R"X(
|
view.sol().safe_script(R"X(
|
||||||
local s = 'test'
|
local s = 'test'
|
||||||
coroutine.wrap(function()
|
coroutine.wrap(function()
|
||||||
pass(callback(function(v) print(s) end))
|
pass(async:callback(function(v) print(s) end))
|
||||||
end)()
|
end)()
|
||||||
)X");
|
)X");
|
||||||
view.sol().collect_garbage();
|
view.sol().collect_garbage();
|
||||||
|
@ -48,7 +47,7 @@ namespace
|
||||||
mLua.protectedCall([&](LuaUtil::LuaView& view) {
|
mLua.protectedCall([&](LuaUtil::LuaView& view) {
|
||||||
view.sol().safe_script(R"X(
|
view.sol().safe_script(R"X(
|
||||||
coroutine.wrap(function()
|
coroutine.wrap(function()
|
||||||
pass(callback(function() error('COROUTINE CALLBACK') end))
|
pass(async:callback(function() error('COROUTINE CALLBACK') end))
|
||||||
end)()
|
end)()
|
||||||
)X");
|
)X");
|
||||||
view.sol().collect_garbage();
|
view.sol().collect_garbage();
|
||||||
|
|
Loading…
Reference in a new issue