| 154 | |
| 155 | |
| 156 | void FFunctionDesc::CallLua(lua_State* L, lua_Integer FunctionRef, lua_Integer SelfRef, FFrame& Stack, RESULT_DECL) |
| 157 | { |
| 158 | lua_pushcfunction(L, UnLua::ReportLuaCallError); |
| 159 | check(Function.IsValid()); |
| 160 | lua_rawgeti(L, LUA_REGISTRYINDEX, FunctionRef); |
| 161 | check(lua_isfunction(L, -1)); |
| 162 | lua_rawgeti(L, LUA_REGISTRYINDEX, SelfRef); |
| 163 | check(lua_istable(L, -1)); |
| 164 | |
| 165 | void* InParms = nullptr; |
| 166 | FOutParmRec* OutParms = Stack.OutParms; |
| 167 | const bool bUnpackParams = Stack.CurrentNativeFunction && Stack.Node != Stack.CurrentNativeFunction; |
| 168 | if (bUnpackParams) |
| 169 | { |
| 170 | #if ENABLE_PERSISTENT_PARAM_BUFFER |
| 171 | InParms = Buffer; |
| 172 | #endif |
| 173 | if (!InParms) |
| 174 | InParms = ParmsSize > 0 ? FMemory::Malloc(ParmsSize, 16) : nullptr; |
| 175 | |
| 176 | FOutParmRec* FirstOut = nullptr; |
| 177 | FOutParmRec* LastOut = nullptr; |
| 178 | |
| 179 | for (FProperty* Property = (FProperty*)(Function->ChildProperties); |
| 180 | *Stack.Code != EX_EndFunctionParms; |
| 181 | Property = (FProperty*)(Property->Next)) |
| 182 | { |
| 183 | if (Property->PropertyFlags & CPF_OutParm) |
| 184 | { |
| 185 | Stack.Step(Stack.Object, Property->ContainerPtrToValuePtr<uint8>(InParms)); |
| 186 | |
| 187 | CA_SUPPRESS(6263) |
| 188 | FOutParmRec* Out = (FOutParmRec*)FMemory_Alloca(sizeof(FOutParmRec)); |
| 189 | ensure(Stack.MostRecentPropertyAddress); |
| 190 | Out->PropAddr = (Stack.MostRecentPropertyAddress != nullptr) ? Stack.MostRecentPropertyAddress : Property->ContainerPtrToValuePtr<uint8>(InParms); |
| 191 | Out->Property = Property; |
| 192 | |
| 193 | if (FirstOut) |
| 194 | { |
| 195 | LastOut->NextOutParm = Out; |
| 196 | LastOut = Out; |
| 197 | } |
| 198 | else |
| 199 | { |
| 200 | FirstOut = Out; |
| 201 | LastOut = Out; |
| 202 | } |
| 203 | } |
| 204 | else |
| 205 | { |
| 206 | Stack.Step(Stack.Object, Property->ContainerPtrToValuePtr<uint8>(InParms)); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | if (LastOut) |
| 211 | { |
| 212 | LastOut->NextOutParm = Stack.OutParms; |
| 213 | OutParms = FirstOut; |
no test coverage detected