merged lua_typerrror.{c,h} into auxiliar.{c,h}

This commit is contained in:
Diego Nehab
2012-04-16 20:41:48 +08:00
parent 4b671f4551
commit b3c4f46179
7 changed files with 58 additions and 30 deletions

View File

@ -8,7 +8,6 @@
#include <stdio.h>
#include "auxiliar.h"
#include "lua_typeerror.h"
/*=========================================================================*\
* Exported functions
@ -82,7 +81,7 @@ void auxiliar_add2group(lua_State *L, const char *classname, const char *groupna
\*-------------------------------------------------------------------------*/
int auxiliar_checkboolean(lua_State *L, int objidx) {
if (!lua_isboolean(L, objidx))
luaL_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
return lua_toboolean(L, objidx);
}
@ -148,3 +147,14 @@ void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) {
void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) {
return luaL_checkudata(L, objidx, classname);
}
/*-------------------------------------------------------------------------*\
* Throws error when argument does not have correct type.
* Used to be part of lauxlib in Lua 5.1, was dropped from 5.2.
\*-------------------------------------------------------------------------*/
int auxiliar_typeerror (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);
}