summaryrefslogtreecommitdiff
path: root/src/ldblib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ldblib.c')
-rw-r--r--src/ldblib.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ldblib.c b/src/ldblib.c
index c0226945..30499a62 100644
--- a/src/ldblib.c
+++ b/src/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.132 2012/01/19 20:14:44 roberto Exp $
+** $Id: ldblib.c,v 1.133 2013/06/25 19:37:00 roberto Exp $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -22,6 +22,18 @@
+static int db_numbits (lua_State *L) {
+ const char *s = luaL_checkstring(L, 1);
+ if (*s == 'i')
+ lua_pushinteger(L, sizeof(lua_Integer) * CHAR_BIT);
+ else if (*s == 'f')
+ lua_pushinteger(L, sizeof(lua_Number) * CHAR_BIT);
+ else
+ luaL_argerror(L, 1, lua_pushfstring(L, "invalid option '%s'", s));
+ return 1;
+}
+
+
static int db_getregistry (lua_State *L) {
lua_pushvalue(L, LUA_REGISTRYINDEX);
return 1;
@@ -379,6 +391,7 @@ static const luaL_Reg dblib[] = {
{"getregistry", db_getregistry},
{"getmetatable", db_getmetatable},
{"getupvalue", db_getupvalue},
+ {"numbits", db_numbits},
{"upvaluejoin", db_upvaluejoin},
{"upvalueid", db_upvalueid},
{"setuservalue", db_setuservalue},