diff options
author | Diego Nehab <diego.nehab@gmail.com> | 2012-04-16 20:41:48 +0800 |
---|---|---|
committer | Diego Nehab <diego.nehab@gmail.com> | 2012-04-16 20:41:48 +0800 |
commit | b3c4f46179ed5b27ca76a824f8730fa50dbaae0b (patch) | |
tree | b5056d95f3307c49d942262387bba2ec3c949451 /src/auxiliar.c | |
parent | 4b671f4551e98ac9e1d9a7407d3dffdd7eb1d3dc (diff) | |
download | luasocket-b3c4f46179ed5b27ca76a824f8730fa50dbaae0b.tar.gz luasocket-b3c4f46179ed5b27ca76a824f8730fa50dbaae0b.tar.bz2 luasocket-b3c4f46179ed5b27ca76a824f8730fa50dbaae0b.zip |
merged lua_typerrror.{c,h} into auxiliar.{c,h}
Diffstat (limited to 'src/auxiliar.c')
-rw-r--r-- | src/auxiliar.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/auxiliar.c b/src/auxiliar.c index 3396fc1..c4e5260 100644 --- a/src/auxiliar.c +++ b/src/auxiliar.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | 9 | ||
10 | #include "auxiliar.h" | 10 | #include "auxiliar.h" |
11 | #include "lua_typeerror.h" | ||
12 | 11 | ||
13 | /*=========================================================================*\ | 12 | /*=========================================================================*\ |
14 | * Exported functions | 13 | * Exported functions |
@@ -82,7 +81,7 @@ void auxiliar_add2group(lua_State *L, const char *classname, const char *groupna | |||
82 | \*-------------------------------------------------------------------------*/ | 81 | \*-------------------------------------------------------------------------*/ |
83 | int auxiliar_checkboolean(lua_State *L, int objidx) { | 82 | int auxiliar_checkboolean(lua_State *L, int objidx) { |
84 | if (!lua_isboolean(L, objidx)) | 83 | if (!lua_isboolean(L, objidx)) |
85 | luaL_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); | 84 | auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); |
86 | return lua_toboolean(L, objidx); | 85 | return lua_toboolean(L, objidx); |
87 | } | 86 | } |
88 | 87 | ||
@@ -148,3 +147,14 @@ void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { | |||
148 | void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { | 147 | void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { |
149 | return luaL_checkudata(L, objidx, classname); | 148 | return luaL_checkudata(L, objidx, classname); |
150 | } | 149 | } |
150 | |||
151 | /*-------------------------------------------------------------------------*\ | ||
152 | * Throws error when argument does not have correct type. | ||
153 | * Used to be part of lauxlib in Lua 5.1, was dropped from 5.2. | ||
154 | \*-------------------------------------------------------------------------*/ | ||
155 | int auxiliar_typeerror (lua_State *L, int narg, const char *tname) { | ||
156 | const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, | ||
157 | luaL_typename(L, narg)); | ||
158 | return luaL_argerror(L, narg, msg); | ||
159 | } | ||
160 | |||