* @see FLuaArray::Get(...). Create a copy for the element */
| 306 | * @see FLuaArray::Get(...). Create a copy for the element |
| 307 | */ |
| 308 | static int32 TArray_Get(lua_State* L) |
| 309 | { |
| 310 | int32 NumParams = lua_gettop(L); |
| 311 | if (NumParams != 2) |
| 312 | return luaL_error(L, "invalid parameters"); |
| 313 | |
| 314 | FLuaArray* Array = (FLuaArray*)(GetCppInstanceFast(L, 1)); |
| 315 | TArray_Guard(L, Array); |
| 316 | |
| 317 | int32 Index = lua_tointeger(L, 2); |
| 318 | --Index; |
| 319 | if (!Array->IsValidIndex(Index)) |
| 320 | { |
| 321 | UNLUA_LOGERROR(L, LogUnLua, Log, TEXT("%s: TArray Invalid Index!"), ANSI_TO_TCHAR(__FUNCTION__)); |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | Array->Inner->Initialize(Array->ElementCache); |
| 326 | Array->Get(Index, Array->ElementCache); |
| 327 | Array->Inner->Read(L, Array->ElementCache, true); |
| 328 | Array->Inner->Destruct(Array->ElementCache); |
| 329 | return 1; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * @see FLuaArray::Get(...). Return a reference for the element |
no test coverage detected