diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-07-10 17:57:05 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-07-10 17:57:05 -0300 |
commit | fcf99bf7889ab33d8be84504378c32865f4a60f3 (patch) | |
tree | 388203563f4b179e71eaf14a775e020038172f1e | |
parent | 98d76cdcae713851872fa9ae1e76fcc09298d824 (diff) | |
download | lua-fcf99bf7889ab33d8be84504378c32865f4a60f3.tar.gz lua-fcf99bf7889ab33d8be84504378c32865f4a60f3.tar.bz2 lua-fcf99bf7889ab33d8be84504378c32865f4a60f3.zip |
'math.isfloat' replaced by 'debug.subtype'
-rw-r--r-- | ldblib.c | 35 | ||||
-rw-r--r-- | lmathlib.c | 10 |
2 files changed, 35 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.132 2012/01/19 20:14:44 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.133 2013/06/25 19:37:00 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -34,6 +34,38 @@ static int db_numbits (lua_State *L) { | |||
34 | } | 34 | } |
35 | 35 | ||
36 | 36 | ||
37 | static int db_subtype (lua_State *L) { | ||
38 | int tp = lua_type(L, 1); | ||
39 | switch (tp) { | ||
40 | case LUA_TNONE: | ||
41 | luaL_checkany(L, 1); | ||
42 | break; | ||
43 | case LUA_TNUMBER: | ||
44 | if (lua_isinteger(L, 1)) | ||
45 | lua_pushliteral(L, "integer"); | ||
46 | else | ||
47 | lua_pushliteral(L, "float"); | ||
48 | break; | ||
49 | case LUA_TFUNCTION: | ||
50 | if (lua_iscfunction(L, 1)) | ||
51 | lua_pushliteral(L, "Cfunction"); | ||
52 | else | ||
53 | lua_pushliteral(L, "Luafunction"); | ||
54 | break; | ||
55 | case LUA_TUSERDATA: | ||
56 | if (lua_islightuserdata(L, 1)) | ||
57 | lua_pushliteral(L, "lightudata"); | ||
58 | else | ||
59 | lua_pushliteral(L, "fulludata"); | ||
60 | break; | ||
61 | default: | ||
62 | lua_pushstring(L, lua_typename(L, tp)); | ||
63 | break; | ||
64 | } | ||
65 | return 1; | ||
66 | } | ||
67 | |||
68 | |||
37 | static int db_getregistry (lua_State *L) { | 69 | static int db_getregistry (lua_State *L) { |
38 | lua_pushvalue(L, LUA_REGISTRYINDEX); | 70 | lua_pushvalue(L, LUA_REGISTRYINDEX); |
39 | return 1; | 71 | return 1; |
@@ -399,6 +431,7 @@ static const luaL_Reg dblib[] = { | |||
399 | {"setlocal", db_setlocal}, | 431 | {"setlocal", db_setlocal}, |
400 | {"setmetatable", db_setmetatable}, | 432 | {"setmetatable", db_setmetatable}, |
401 | {"setupvalue", db_setupvalue}, | 433 | {"setupvalue", db_setupvalue}, |
434 | {"subtype", db_subtype}, | ||
402 | {"traceback", db_traceback}, | 435 | {"traceback", db_traceback}, |
403 | {NULL, NULL} | 436 | {NULL, NULL} |
404 | }; | 437 | }; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.89 2013/06/25 19:37:00 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.90 2013/07/03 17:23:19 roberto Exp roberto $ |
3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -251,13 +251,6 @@ static int math_randomseed (lua_State *L) { | |||
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | static int math_isfloat (lua_State *L) { | ||
255 | luaL_checkany(L, 1); | ||
256 | lua_pushboolean(L, (lua_type(L, 1) == LUA_TNUMBER && !lua_isinteger(L, 1))); | ||
257 | return 1; | ||
258 | } | ||
259 | |||
260 | |||
261 | static const luaL_Reg mathlib[] = { | 254 | static const luaL_Reg mathlib[] = { |
262 | {"abs", math_abs}, | 255 | {"abs", math_abs}, |
263 | {"acos", math_acos}, | 256 | {"acos", math_acos}, |
@@ -273,7 +266,6 @@ static const luaL_Reg mathlib[] = { | |||
273 | {"ifloor", math_ifloor}, | 266 | {"ifloor", math_ifloor}, |
274 | {"fmod", math_fmod}, | 267 | {"fmod", math_fmod}, |
275 | {"frexp", math_frexp}, | 268 | {"frexp", math_frexp}, |
276 | {"isfloat", math_isfloat}, | ||
277 | {"ldexp", math_ldexp}, | 269 | {"ldexp", math_ldexp}, |
278 | #if defined(LUA_COMPAT_LOG10) | 270 | #if defined(LUA_COMPAT_LOG10) |
279 | {"log10", math_log10}, | 271 | {"log10", math_log10}, |