Skip to content

Commit 9351a0e

Browse files
committed
Merge branch 'callbackhell' into 'master'
Use the actual callback function instead of mocking it Closes #8183 See merge request OpenMW/openmw!4452
2 parents 97522c2 + 5dbe86e commit 9351a0e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

apps/components_tests/lua/test_async.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ namespace
1414
void SetUp() override
1515
{
1616
mLua.protectedCall([&](LuaUtil::LuaView& view) {
17-
view.sol()["callback"] = [](sol::this_state state, sol::protected_function fn) -> LuaUtil::Callback {
18-
sol::table hiddenData(state, sol::create);
19-
hiddenData[LuaUtil::ScriptsContainer::sScriptIdKey] = LuaUtil::ScriptId{};
20-
return LuaUtil::Callback{ std::move(fn), hiddenData };
21-
};
22-
view.sol()["pass"] = [&](LuaUtil::Callback callback) { mCb = callback; };
17+
sol::table hiddenData(view.sol(), sol::create);
18+
hiddenData[LuaUtil::ScriptsContainer::sScriptIdKey] = LuaUtil::ScriptId{};
19+
view.sol()["async"] = LuaUtil::getAsyncPackageInitializer(
20+
view.sol(), []() { return 0.; }, []() { return 0.; })(hiddenData);
21+
view.sol()["pass"] = [&](const sol::table& t) { mCb = LuaUtil::Callback::fromLua(t); };
2322
});
2423
}
2524

@@ -34,7 +33,7 @@ namespace
3433
view.sol().safe_script(R"X(
3534
local s = 'test'
3635
coroutine.wrap(function()
37-
pass(callback(function(v) print(s) end))
36+
pass(async:callback(function(v) print(s) end))
3837
end)()
3938
)X");
4039
view.sol().collect_garbage();
@@ -48,7 +47,7 @@ namespace
4847
mLua.protectedCall([&](LuaUtil::LuaView& view) {
4948
view.sol().safe_script(R"X(
5049
coroutine.wrap(function()
51-
pass(callback(function() error('COROUTINE CALLBACK') end))
50+
pass(async:callback(function() error('COROUTINE CALLBACK') end))
5251
end)()
5352
)X");
5453
view.sol().collect_garbage();

0 commit comments

Comments
 (0)