lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Jan 17, 2011 at 2:42 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> By any chance, is there a Lua-5.2-compatible implementation of the
>> bit32 module written for Lua 5.1?
>
> The simple hack below seems to work (it does compile :) in a 32-bit Linux:
>
> 24c24,26
> <
> ---
>> typedef unsigned int lua_Unsigned;
>> #define luaL_checkunsigned (lua_Unsigned) luaL_checkinteger
>> #define lua_pushunsigned lua_pushinteger
> 159,160c161,162
> < LUAMOD_API int luaopen_bit32 (lua_State *L) {
> <   luaL_newlib(L, bitlib);
> ---
>> int luaopen_bit32 (lua_State *L) {
>>   luaL_register(L, "bit32", bitlib);

Thanks! Preliminary tests show it works fine. I also wrote a rockspec
for it called "bit32 5.2.0alpha" for Lua 5.1. After a few more testing
I'll post it to the LuaRocks repository.

-- Hisham