diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-18 15:27:08 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-18 15:27:08 -0300 |
| commit | 282d67d8fcd3b06e21d27f3acb8f9efdd992c937 (patch) | |
| tree | 916818b041a6e81dcbca30a504b12890be3eee97 /lbitlib.c | |
| parent | 114d10cbc599e848bd28f5b454ec4f8f823dce37 (diff) | |
| download | lua-282d67d8fcd3b06e21d27f3acb8f9efdd992c937.tar.gz lua-282d67d8fcd3b06e21d27f3acb8f9efdd992c937.tar.bz2 lua-282d67d8fcd3b06e21d27f3acb8f9efdd992c937.zip | |
bitlib has been deprecated
Diffstat (limited to 'lbitlib.c')
| -rw-r--r-- | lbitlib.c | 23 |
1 files changed, 22 insertions, 1 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 /* } */ | ||
