Skip to content

Commit a4e4f3e

Browse files
修正:UE5.3的工程编译报错找不到符号CallFunctionInternal #670
1 parent 4ce902a commit a4e4f3e

File tree

1 file changed

+39
-41
lines changed

1 file changed

+39
-41
lines changed

Plugins/UnLua/Source/UnLua/Public/UnLuaLegacy.h

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,45 @@ namespace UnLua
612612
return Cast<UClass>(UnLua::GetUObject(L, Index));
613613
}
614614

615+
/**
616+
* Push arguments for Lua function
617+
*/
618+
template <bool bCopy> FORCEINLINE int32 PushArgs(lua_State* L)
619+
{
620+
return 0;
621+
}
622+
623+
template <bool bCopy, typename T1, typename... T2>
624+
FORCEINLINE int32 PushArgs(lua_State* L, T1&& V1, T2&&... V2)
625+
{
626+
const int32 Ret1 = UnLua::Push(L, Forward<T1>(V1), bCopy);
627+
const int32 Ret2 = PushArgs<bCopy>(L, Forward<T2>(V2)...);
628+
return Ret1 + Ret2;
629+
}
630+
631+
/**
632+
* Internal helper to call a Lua function. Used internally only. Please do not use!
633+
*/
634+
template <typename... T>
635+
FORCEINLINE_DEBUGGABLE FLuaRetValues CallFunctionInternal(lua_State* L, T&&... Args)
636+
{
637+
// make sure the function is on the top of the stack, and the message handler is below the function
638+
int32 MessageHandlerIdx = lua_gettop(L) - 1;
639+
check(MessageHandlerIdx > 0);
640+
int32 NumArgs = PushArgs<false>(L, Forward<T>(Args)...);
641+
int32 Code = lua_pcall(L, NumArgs, LUA_MULTRET, MessageHandlerIdx);
642+
int32 TopIdx = lua_gettop(L);
643+
if (Code == LUA_OK)
644+
{
645+
int32 NumResults = TopIdx - MessageHandlerIdx;
646+
lua_remove(L, MessageHandlerIdx);
647+
FLuaRetValues Result(L, NumResults);
648+
return Result; // MoveTemp(Result);
649+
}
650+
lua_pop(L, TopIdx - MessageHandlerIdx + 1);
651+
return FLuaRetValues(L, INDEX_NONE);
652+
}
653+
615654
/**
616655
* Call Lua global function.
617656
*
@@ -729,47 +768,6 @@ namespace UnLua
729768
return UnLua::Get(L, Index, TType<TMap<KeyType, ValueType, Allocator, KeyFunc>&>());
730769
}
731770

732-
/**
733-
* Push arguments for Lua function
734-
*/
735-
template <bool bCopy> FORCEINLINE int32 PushArgs(lua_State* L)
736-
{
737-
return 0;
738-
}
739-
740-
template <bool bCopy, typename T1, typename... T2>
741-
FORCEINLINE int32 PushArgs(lua_State* L, T1&& V1, T2&&... V2)
742-
{
743-
const int32 Ret1 = UnLua::Push(L, Forward<T1>(V1), bCopy);
744-
const int32 Ret2 = PushArgs<bCopy>(L, Forward<T2>(V2)...);
745-
return Ret1 + Ret2;
746-
}
747-
748-
749-
/**
750-
* Internal helper to call a Lua function. Used internally only. Please do not use!
751-
*/
752-
template <typename... T>
753-
FORCEINLINE_DEBUGGABLE FLuaRetValues CallFunctionInternal(lua_State* L, T&&... Args)
754-
{
755-
// make sure the function is on the top of the stack, and the message handler is below the function
756-
int32 MessageHandlerIdx = lua_gettop(L) - 1;
757-
check(MessageHandlerIdx > 0);
758-
int32 NumArgs = PushArgs<false>(L, Forward<T>(Args)...);
759-
int32 Code = lua_pcall(L, NumArgs, LUA_MULTRET, MessageHandlerIdx);
760-
int32 TopIdx = lua_gettop(L);
761-
if (Code == LUA_OK)
762-
{
763-
int32 NumResults = TopIdx - MessageHandlerIdx;
764-
lua_remove(L, MessageHandlerIdx);
765-
FLuaRetValues Result(L, NumResults);
766-
return Result; // MoveTemp(Result);
767-
}
768-
lua_pop(L, TopIdx - MessageHandlerIdx + 1);
769-
return FLuaRetValues(L, INDEX_NONE);
770-
}
771-
772-
773771
/**
774772
* Call function in Lua table
775773
*/

0 commit comments

Comments
 (0)