29 [[nodiscard]]
static Result
push(lua_State* L,
const Type& array)
31#if LUABRIDGE_SAFE_STACK_CHECKS
32 if (!lua_checkstack(L, 3))
33 return makeErrorCode(ErrorCode::LuaStackOverflow);
36 StackRestore stackRestore(L);
38 lua_createtable(L,
static_cast<int>(Size), 0);
40 for (std::size_t i = 0; i < Size; ++i)
42 lua_pushinteger(L,
static_cast<lua_Integer
>(i + 1));
44 auto result = Stack<T>::push(L, array[i]);
55 [[nodiscard]]
static TypeResult<Type>
get(lua_State* L,
int index)
57 if (!lua_istable(L, index))
58 return makeErrorCode(ErrorCode::InvalidTypeCast);
60 if (get_length(L, index) != Size)
61 return makeErrorCode(ErrorCode::InvalidTableSizeInCast);
63 const StackRestore stackRestore(L);
67 int absIndex = lua_absindex(L, index);
71 while (lua_next(L, absIndex) != 0)
73 auto item = Stack<T>::get(L, -1);
75 return makeErrorCode(ErrorCode::InvalidTypeCast);
77 array[arrayIndex++] = *item;