From 172d0006798f1c19df112ef3c1d0a409482de7f5 Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Thu, 7 Jun 2012 08:46:55 +0200 Subject: [PATCH] Changed all luaL_typerror to luaA_typerror --- luaa.h | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/luaa.h b/luaa.h index cfdafd6e8..a7780fea3 100644 --- a/luaa.h +++ b/luaa.h @@ -47,11 +47,38 @@ luaL_error(L, "invalid screen number: %d", screen + 1); \ } while(0) +/** Print a warning about some Lua code. + * This is less mean than luaL_error() which setjmp via lua_error() and kills + * everything. This only warn, it's up to you to then do what's should be done. + * \param L The Lua VM state. + * \param fmt The warning message. + */ +static inline void __attribute__ ((format(printf, 2, 3))) +luaA_warn(lua_State *L, const char *fmt, ...) +{ + va_list ap; + luaL_where(L, 1); + fprintf(stderr, "%sW: ", lua_tostring(L, -1)); + lua_pop(L, 1); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + +static inline int +luaA_typerror(lua_State *L, int narg, const char *tname) +{ + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + static inline bool luaA_checkboolean(lua_State *L, int n) { if(!lua_isboolean(L, n)) - luaL_typerror(L, n, "boolean"); + luaA_typerror(L, n, "boolean"); return lua_toboolean(L, n); } @@ -167,33 +194,6 @@ luaA_dofunction_from_registry(lua_State *L, int ref, int nargs, int nret) return luaA_dofunction(L, nargs, nret); } -/** Print a warning about some Lua code. - * This is less mean than luaL_error() which setjmp via lua_error() and kills - * everything. This only warn, it's up to you to then do what's should be done. - * \param L The Lua VM state. - * \param fmt The warning message. - */ -static inline void __attribute__ ((format(printf, 2, 3))) -luaA_warn(lua_State *L, const char *fmt, ...) -{ - va_list ap; - luaL_where(L, 1); - fprintf(stderr, "%sW: ", lua_tostring(L, -1)); - lua_pop(L, 1); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, "\n"); -} - -static inline int -luaA_typerror(lua_State *L, int narg, const char *tname) -{ - const char *msg = lua_pushfstring(L, "%s expected, got %s", - tname, luaL_typename(L, narg)); - return luaL_argerror(L, narg, msg); -} - void luaA_init(xdgHandle *); bool luaA_parserc(xdgHandle *, const char *, bool); bool luaA_hasitem(lua_State *, const void *);