Make callbacks to rules.execute optional
[awesome.git] / common / lualib.c
bloba2bbcf68ac5ea0add925b3aef34cd0c0284efec6
1 /*
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.
20 #include "common/lualib.h"
21 #include "luaa.h"
23 void luaA_checkfunction(lua_State *L, int idx)
25 if(!lua_isfunction(L, idx))
26 luaA_typerror(L, idx, "function");
29 void luaA_checktable(lua_State *L, int idx)
31 if(!lua_istable(L, idx))
32 luaA_typerror(L, idx, "table");
35 void luaA_dumpstack(lua_State *L)
37 fprintf(stderr, "-------- Lua stack dump ---------\n");
38 for(int i = lua_gettop(L); i; i--)
40 int t = lua_type(L, i);
41 switch (t)
43 case LUA_TSTRING:
44 fprintf(stderr, "%d: string: `%s'\n", i, lua_tostring(L, i));
45 break;
46 case LUA_TBOOLEAN:
47 fprintf(stderr, "%d: bool: %s\n", i, lua_toboolean(L, i) ? "true" : "false");
48 break;
49 case LUA_TNUMBER:
50 fprintf(stderr, "%d: number: %g\n", i, lua_tonumber(L, i));
51 break;
52 case LUA_TNIL:
53 fprintf(stderr, "%d: nil\n", i);
54 break;
55 default:
56 fprintf(stderr, "%d: %s\t#%d\t%p\n", i, lua_typename(L, t),
57 (int) luaA_rawlen(L, i),
58 lua_topointer(L, i));
59 break;
62 fprintf(stderr, "------- Lua stack dump end ------\n");