2 * lualib.h - useful functions and type for Lua
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 void luaA_checkfunction(lua_State
*L
, int idx
)
24 if(!lua_isfunction(L
, idx
))
25 luaA_typerror(L
, idx
, "function");
28 void luaA_checktable(lua_State
*L
, int idx
)
30 if(!lua_istable(L
, idx
))
31 luaA_typerror(L
, idx
, "table");
34 void luaA_dumpstack(lua_State
*L
)
36 fprintf(stderr
, "-------- Lua stack dump ---------\n");
37 for(int i
= lua_gettop(L
); i
; i
--)
39 int t
= lua_type(L
, i
);
43 fprintf(stderr
, "%d: string: `%s'\n", i
, lua_tostring(L
, i
));
46 fprintf(stderr
, "%d: bool: %s\n", i
, lua_toboolean(L
, i
) ? "true" : "false");
49 fprintf(stderr
, "%d: number: %g\n", i
, lua_tonumber(L
, i
));
52 fprintf(stderr
, "%d: nil\n", i
);
55 fprintf(stderr
, "%d: %s\t#%d\t%p\n", i
, lua_typename(L
, t
),
56 (int) luaA_rawlen(L
, i
),
61 fprintf(stderr
, "------- Lua stack dump end ------\n");