commit fcf99bf7889ab33d8be84504378c32865f4a60f3
parent 98d76cdcae713851872fa9ae1e76fcc09298d824
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 10 Jul 2013 17:56:40 -0300
'math.isfloat' replaced by 'debug.subtype'
Diffstat:
2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/ldblib.c b/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.132 2012/01/19 20:14:44 roberto Exp roberto $
+** $Id: ldblib.c,v 1.133 2013/06/25 19:37:00 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -34,6 +34,38 @@ static int db_numbits (lua_State *L) {
}
+static int db_subtype (lua_State *L) {
+ int tp = lua_type(L, 1);
+ switch (tp) {
+ case LUA_TNONE:
+ luaL_checkany(L, 1);
+ break;
+ case LUA_TNUMBER:
+ if (lua_isinteger(L, 1))
+ lua_pushliteral(L, "integer");
+ else
+ lua_pushliteral(L, "float");
+ break;
+ case LUA_TFUNCTION:
+ if (lua_iscfunction(L, 1))
+ lua_pushliteral(L, "Cfunction");
+ else
+ lua_pushliteral(L, "Luafunction");
+ break;
+ case LUA_TUSERDATA:
+ if (lua_islightuserdata(L, 1))
+ lua_pushliteral(L, "lightudata");
+ else
+ lua_pushliteral(L, "fulludata");
+ break;
+ default:
+ lua_pushstring(L, lua_typename(L, tp));
+ break;
+ }
+ return 1;
+}
+
+
static int db_getregistry (lua_State *L) {
lua_pushvalue(L, LUA_REGISTRYINDEX);
return 1;
@@ -399,6 +431,7 @@ static const luaL_Reg dblib[] = {
{"setlocal", db_setlocal},
{"setmetatable", db_setmetatable},
{"setupvalue", db_setupvalue},
+ {"subtype", db_subtype},
{"traceback", db_traceback},
{NULL, NULL}
};
diff --git a/lmathlib.c b/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.89 2013/06/25 19:37:00 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.90 2013/07/03 17:23:19 roberto Exp roberto $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -251,13 +251,6 @@ static int math_randomseed (lua_State *L) {
}
-static int math_isfloat (lua_State *L) {
- luaL_checkany(L, 1);
- lua_pushboolean(L, (lua_type(L, 1) == LUA_TNUMBER && !lua_isinteger(L, 1)));
- return 1;
-}
-
-
static const luaL_Reg mathlib[] = {
{"abs", math_abs},
{"acos", math_acos},
@@ -273,7 +266,6 @@ static const luaL_Reg mathlib[] = {
{"ifloor", math_ifloor},
{"fmod", math_fmod},
{"frexp", math_frexp},
- {"isfloat", math_isfloat},
{"ldexp", math_ldexp},
#if defined(LUA_COMPAT_LOG10)
{"log10", math_log10},