30 #define TAB_RW (TAB_R | TAB_W) 33 #define aux_getn(L,n,w) (checktab(L, n, (w) | TAB_L), luaL_len(L, n)) 74 "position out of bounds");
75 for (i = e; i > pos; i--) {
82 return luaL_error(L,
"wrong number of arguments to 'insert'");
96 "position out of bounds");
98 for ( ; pos < size; pos++) {
124 "too many elements to move");
127 "destination wrap around");
129 for (i = 0; i < n; i++) {
135 for (i = n - 1; i >= 0; i--) {
149 luaL_error(L,
"invalid value (%s) at index %d in table for 'concat'",
163 for (; i < last; i++) {
185 for (i = n; i >= 1; i--)
200 return luaL_error(L,
"too many results to unpack");
231 #if !defined(l_randomizePivot) 236 #define sof(e) (sizeof(e) / sizeof(unsigned int)) 246 time_t t =
time(NULL);
247 unsigned int buff[
sof(c) +
sof(t)];
248 unsigned int i, rnd = 0;
249 memcpy(buff, &c,
sof(c) *
sizeof(
unsigned int));
250 memcpy(buff +
sof(c), &t,
sof(t) *
sizeof(
unsigned int));
251 for (i = 0; i <
sof(buff); i++)
260 #define RANLIMIT 100u 304 luaL_error(L,
"invalid order function for sorting");
311 luaL_error(L,
"invalid order function for sorting");
333 IdxT r4 = (up - lo) / 4;
334 IdxT p = rnd % (r4 * 2) + (lo + r4);
381 if (p - lo < up - p) {
391 if ((up - lo) / 128 > n)
LUA_API int lua_isstring(lua_State *L, int idx)
#define lua_isnoneornil(L, n)
static IdxT partition(lua_State *L, IdxT lo, IdxT up)
static void addfield(lua_State *L, luaL_Buffer *b, lua_Integer i)
LUA_API int lua_rawget(lua_State *L, int idx)
static void set2(lua_State *L, IdxT i, IdxT j)
static int sort_comp(lua_State *L, int a, int b)
static int tpack(lua_State *L)
LUA_API void lua_pushnil(lua_State *L)
LUA_API int lua_toboolean(lua_State *L, int idx)
LUA_API void lua_seti(lua_State *L, int idx, lua_Integer n)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API int lua_compare(lua_State *L, int index1, int index2, int op)
static int tremove(lua_State *L)
#define luaL_typename(L, i)
static int tconcat(lua_State *L)
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
static int checkfield(lua_State *L, const char *key, int n)
LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l)
LUA_API int lua_geti(lua_State *L, int idx, lua_Integer n)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API int lua_getmetatable(lua_State *L, int objindex)
LUAMOD_API int luaopen_table(lua_State *L)
static IdxT choosePivot(IdxT lo, IdxT up, unsigned int rnd)
#define luaL_opt(L, f, n, d)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
static void checktab(lua_State *L, int arg, int what)
static int tinsert(lua_State *L)
LUALIB_API const char * luaL_optlstring(lua_State *L, int arg, const char *def, size_t *len)
static int sort(lua_State *L)
LUALIB_API lua_Integer luaL_len(lua_State *L, int idx)
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int arg)
detail::named_arg< Char, T > arg(const Char *name, const T &arg)
LUA_API int lua_type(lua_State *L, int idx)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int arg, lua_Integer def)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
static int tunpack(lua_State *L)
#define luaL_newlib(L, l)
LUA_UNSIGNED lua_Unsigned
#define lua_call(L, n, r)
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
#define luaL_argcheck(L, cond, arg, extramsg)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
#define aux_getn(L, n, w)
LUALIB_API void luaL_checktype(lua_State *L, int arg, int t)
#define lua_insert(L, idx)
static const luaL_Reg tab_funcs[]
static void auxsort(lua_State *L, IdxT lo, IdxT up, unsigned int rnd)
static int tmove(lua_State *L)
static unsigned int l_randomizePivot(void)
LUA_API int lua_checkstack(lua_State *L, int n)
LUA_API int lua_gettop(lua_State *L)