diff options
| -rw-r--r-- | ldblib.c | 30 |
1 files changed, 1 insertions, 29 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldblib.c,v 1.141 2014/08/22 16:22:42 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.142 2014/10/01 11:54:56 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 | */ |
| @@ -21,33 +21,6 @@ | |||
| 21 | #define HOOKKEY "_HKEY" | 21 | #define HOOKKEY "_HKEY" |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | static int db_Csize (lua_State *L) { | ||
| 25 | static struct { | ||
| 26 | char c; | ||
| 27 | unsigned char sz; | ||
| 28 | } sizes[] = { | ||
| 29 | {'I', sizeof(lua_Integer)}, | ||
| 30 | {'F', sizeof(lua_Number)}, | ||
| 31 | {'h', sizeof(short)}, | ||
| 32 | {'i', sizeof(int)}, | ||
| 33 | {'l', sizeof(long)}, | ||
| 34 | {'z', sizeof(size_t)}, | ||
| 35 | {'f', sizeof(float)}, | ||
| 36 | {'d', sizeof(double)}, | ||
| 37 | {'p', sizeof(void*)} | ||
| 38 | }; | ||
| 39 | const char *s = luaL_checkstring(L, 1); | ||
| 40 | int i; | ||
| 41 | for (i = 0; i < (int)(sizeof(sizes)/sizeof(sizes[0])); i++) { | ||
| 42 | if (*s == sizes[i].c) { | ||
| 43 | lua_pushinteger(L, sizes[i].sz); | ||
| 44 | return 1; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | return luaL_argerror(L, 1, lua_pushfstring(L, "invalid option '%c'", *s)); | ||
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | static int db_getregistry (lua_State *L) { | 24 | static int db_getregistry (lua_State *L) { |
| 52 | lua_pushvalue(L, LUA_REGISTRYINDEX); | 25 | lua_pushvalue(L, LUA_REGISTRYINDEX); |
| 53 | return 1; | 26 | return 1; |
| @@ -428,7 +401,6 @@ static int db_traceback (lua_State *L) { | |||
| 428 | 401 | ||
| 429 | 402 | ||
| 430 | static const luaL_Reg dblib[] = { | 403 | static const luaL_Reg dblib[] = { |
| 431 | {"sizeof", db_Csize}, | ||
| 432 | {"debug", db_debug}, | 404 | {"debug", db_debug}, |
| 433 | {"getuservalue", db_getuservalue}, | 405 | {"getuservalue", db_getuservalue}, |
| 434 | {"gethook", db_gethook}, | 406 | {"gethook", db_gethook}, |
