diff options
| -rw-r--r-- | lbitlib.c | 23 | ||||
| -rw-r--r-- | luaconf.h | 7 |
2 files changed, 28 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbitlib.c,v 1.22 2013/07/09 18:31:01 roberto Exp roberto $ | 2 | ** $Id: lbitlib.c,v 1.23 2014/02/26 12:38:18 roberto Exp roberto $ |
| 3 | ** Standard library for bitwise operations | 3 | ** Standard library for bitwise operations |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -13,6 +13,9 @@ | |||
| 13 | #include "lualib.h" | 13 | #include "lualib.h" |
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | #if defined(LUA_COMPAT_BITLIB) /* { */ | ||
| 17 | |||
| 18 | |||
| 16 | /* number of bits to consider in a number */ | 19 | /* number of bits to consider in a number */ |
| 17 | #if !defined(LUA_NBITS) | 20 | #if !defined(LUA_NBITS) |
| 18 | #define LUA_NBITS 32 | 21 | #define LUA_NBITS 32 |
| @@ -213,3 +216,21 @@ LUAMOD_API int luaopen_bit32 (lua_State *L) { | |||
| 213 | return 1; | 216 | return 1; |
| 214 | } | 217 | } |
| 215 | 218 | ||
| 219 | |||
| 220 | #else /* }{ */ | ||
| 221 | |||
| 222 | static int b_err (lua_State *L) { | ||
| 223 | return luaL_error(L, "library 'bit32' is deprecated"); | ||
| 224 | } | ||
| 225 | |||
| 226 | |||
| 227 | LUAMOD_API int luaopen_bit32 (lua_State *L) { | ||
| 228 | lua_createtable(L, 0, 1); /* new table to represent the module */ | ||
| 229 | lua_pushvalue(L, -1); | ||
| 230 | lua_setmetatable(L, -2); /* set it as its own metatable */ | ||
| 231 | lua_pushcfunction(L, b_err); | ||
| 232 | lua_setfield(L, -2, "__index"); /* metatable.__index = b_errret */ | ||
| 233 | return 1; | ||
| 234 | } | ||
| 235 | |||
| 236 | #endif /* } */ | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.190 2014/02/26 15:27:56 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.191 2014/03/06 16:15:18 roberto Exp roberto $ |
| 3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -248,6 +248,11 @@ | |||
| 248 | #if defined(LUA_COMPAT_ALL) /* { */ | 248 | #if defined(LUA_COMPAT_ALL) /* { */ |
| 249 | 249 | ||
| 250 | /* | 250 | /* |
| 251 | @@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. | ||
| 252 | */ | ||
| 253 | #define LUA_COMPAT_BITLIB | ||
| 254 | |||
| 255 | /* | ||
| 251 | @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. | 256 | @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. |
| 252 | ** You can replace it with 'table.unpack'. | 257 | ** You can replace it with 'table.unpack'. |
| 253 | */ | 258 | */ |
