From 8ad6a7f955182955aec1fff0ed367f564f31e46a Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 19 May 2018 09:15:28 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AA=97=E5=8F=A3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/3rdparty/luax/luax.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/3rdparty/luax/luax.h') diff --git a/src/3rdparty/luax/luax.h b/src/3rdparty/luax/luax.h index 49036b9..b5ef0f4 100644 --- a/src/3rdparty/luax/luax.h +++ b/src/3rdparty/luax/luax.h @@ -50,6 +50,8 @@ */ #define luax_gettop lua_gettop +#define luax_gettable lua_gettable + /** * Check userdata type. */ @@ -57,6 +59,20 @@ #define luax_checknumber luaL_checknumber #define luax_checkinteger luaL_checkinteger #define luax_checkstring luaL_checkstring +#define luax_checkbool luaL_checkinteger +//bool luax_checkbool(lua_State *L, int numArg) +//{ +// bool b = false; +// if (lua_type(L, numArg) == LUA_TBOOLEAN) +// { +// b = lua_toboolean(L, numArg); +// } +// else +// { +// luaL_typerror(L, numArg, lua_typename(L, LUA_TBOOLEAN)); +// } +// return b; +//} /** * Oprating tables. @@ -103,6 +119,30 @@ * If nosuch field push a nil at the top of stack. */ #define luax_getfield(L, I, N) lua_getfield(L, I, N) +inline float luax_getfield_number(lua_State* L, int I, const char* N) +{ + luax_getfield(L, I, N); + float n = luax_checknumber(L, -1); + return n; +} +inline int luax_getfield_integer(lua_State* L, int I, const char* N) +{ + luax_getfield(L, I, N); + int bin = luax_checkinteger(L, -1); + return bin; +} +inline const char* luax_getfield_string(lua_State* L, int I, const char* N) +{ + luax_getfield(L, I, N); + const char* str = luax_checkstring(L, -1); + return str; +} +inline char luax_getfield_bool(lua_State* L, int I, const char* N) +{ + luax_getfield(L, I, N); + char bin = lua_toboolean(L, -1); + return bin; +} /** * Set raw -- cgit v1.1-26-g67d0