|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
-** $Id: lbitlib.c,v 1.22 2013/07/09 18:31:01 roberto Exp roberto $
|
|
|
|
|
|
+** $Id: lbitlib.c,v 1.23 2014/02/26 12:38:18 roberto Exp roberto $
|
|
** Standard library for bitwise operations
|
|
** Standard library for bitwise operations
|
|
** See Copyright Notice in lua.h
|
|
** See Copyright Notice in lua.h
|
|
*/
|
|
*/
|
|
@@ -13,6 +13,9 @@
|
|
#include "lualib.h"
|
|
#include "lualib.h"
|
|
|
|
|
|
|
|
|
|
|
|
+#if defined(LUA_COMPAT_BITLIB) /* { */
|
|
|
|
+
|
|
|
|
+
|
|
/* number of bits to consider in a number */
|
|
/* number of bits to consider in a number */
|
|
#if !defined(LUA_NBITS)
|
|
#if !defined(LUA_NBITS)
|
|
#define LUA_NBITS 32
|
|
#define LUA_NBITS 32
|
|
@@ -213,3 +216,21 @@ LUAMOD_API int luaopen_bit32 (lua_State *L) {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+#else /* }{ */
|
|
|
|
+
|
|
|
|
+static int b_err (lua_State *L) {
|
|
|
|
+ return luaL_error(L, "library 'bit32' is deprecated");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+LUAMOD_API int luaopen_bit32 (lua_State *L) {
|
|
|
|
+ lua_createtable(L, 0, 1); /* new table to represent the module */
|
|
|
|
+ lua_pushvalue(L, -1);
|
|
|
|
+ lua_setmetatable(L, -2); /* set it as its own metatable */
|
|
|
|
+ lua_pushcfunction(L, b_err);
|
|
|
|
+ lua_setfield(L, -2, "__index"); /* metatable.__index = b_errret */
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#endif /* } */
|