MCPcopy Create free account
hub / github.com/Tencent/UnLua / Class_CallLatentFunction

Function Class_CallLatentFunction

Plugins/UnLua/Source/UnLua/Private/LuaCore.cpp:1523–1543  ·  view source on GitHub ↗

* Generic closure to call a latent function */

Source from the content-addressed store, hash-verified

1521 * Generic closure to call a latent function
1522 */
1523int32 Class_CallLatentFunction(lua_State *L)
1524{
1525 auto& Env = UnLua::FLuaEnv::FindEnvChecked(L);
1526 auto Function = Env.GetObjectRegistry()->Get<FFunctionDesc>(L, lua_upvalueindex(1));
1527 if (!Function->IsValid())
1528 {
1529 UE_LOG(LogUnLua, Log, TEXT("%s: Invalid function descriptor!"), ANSI_TO_TCHAR(__FUNCTION__));
1530 return 0;
1531 }
1532
1533 auto ThreadRef = Env.FindOrAddThread(L);
1534 if (ThreadRef == LUA_REFNIL)
1535 {
1536 UNLUA_LOGERROR(L, LogUnLua, Warning, TEXT("%s: Can't call latent action in main lua thread!"), ANSI_TO_TCHAR(__FUNCTION__));
1537 return 0;
1538 }
1539
1540 int32 NumParams = lua_gettop(L);
1541 int32 NumResults = Function->CallUE(L, NumParams, &ThreadRef);
1542 return lua_yield(L, NumResults);
1543}
1544
1545FClassDesc* Class_CheckParam(lua_State *L)
1546{

Callers

nothing calls this directly

Calls 4

lua_gettopFunction · 0.85
FindOrAddThreadMethod · 0.80
CallUEMethod · 0.80
IsValidMethod · 0.45

Tested by

no test coverage detected