lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 282d67d8fcd3b06e21d27f3acb8f9efdd992c937
parent 114d10cbc599e848bd28f5b454ec4f8f823dce37
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Tue, 18 Mar 2014 15:26:43 -0300

bitlib has been deprecated

Diffstat:
Mlbitlib.c | 23++++++++++++++++++++++-
Mluaconf.h | 7++++++-
2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/lbitlib.c b/lbitlib.c @@ -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 ** See Copyright Notice in lua.h */ @@ -13,6 +13,9 @@ #include "lualib.h" +#if defined(LUA_COMPAT_BITLIB) /* { */ + + /* number of bits to consider in a number */ #if !defined(LUA_NBITS) #define LUA_NBITS 32 @@ -213,3 +216,21 @@ LUAMOD_API int luaopen_bit32 (lua_State *L) { 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 /* } */ diff --git a/luaconf.h b/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.190 2014/02/26 15:27:56 roberto Exp roberto $ +** $Id: luaconf.h,v 1.191 2014/03/06 16:15:18 roberto Exp roberto $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -248,6 +248,11 @@ #if defined(LUA_COMPAT_ALL) /* { */ /* +@@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. +*/ +#define LUA_COMPAT_BITLIB + +/* @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. ** You can replace it with 'table.unpack'. */