|
|
@ -14,8 +14,8 @@ namespace
|
|
|
|
void SetUp() override
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mLua.protectedCall([&](LuaUtil::LuaView& view) {
|
|
|
|
mLua.protectedCall([&](LuaUtil::LuaView& view) {
|
|
|
|
view.sol()["callback"] = [&](sol::protected_function fn) -> LuaUtil::Callback {
|
|
|
|
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 };
|
|
|
|
return LuaUtil::Callback{ std::move(fn), hiddenData };
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -32,11 +32,11 @@ namespace
|
|
|
|
internal::CaptureStdout();
|
|
|
|
internal::CaptureStdout();
|
|
|
|
mLua.protectedCall([&](LuaUtil::LuaView& view) {
|
|
|
|
mLua.protectedCall([&](LuaUtil::LuaView& view) {
|
|
|
|
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(callback(function(v) print(s) end))
|
|
|
|
end)()
|
|
|
|
end)()
|
|
|
|
)X");
|
|
|
|
)X");
|
|
|
|
view.sol().collect_garbage();
|
|
|
|
view.sol().collect_garbage();
|
|
|
|
mCb.call();
|
|
|
|
mCb.call();
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -47,10 +47,10 @@ 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(callback(function() error('COROUTINE CALLBACK') end))
|
|
|
|
end)()
|
|
|
|
end)()
|
|
|
|
)X");
|
|
|
|
)X");
|
|
|
|
view.sol().collect_garbage();
|
|
|
|
view.sol().collect_garbage();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
EXPECT_ERROR(mCb.call(), "COROUTINE CALLBACK");
|
|
|
|
EXPECT_ERROR(mCb.call(), "COROUTINE CALLBACK");
|
|
|
|