Update LuaBitOp to 1.0.2

This commit is contained in:
gocha 2012-08-31 06:59:00 +09:00
parent b7b749af3f
commit 81c078eba8
1 changed files with 16 additions and 4 deletions

View File

@ -1129,14 +1129,14 @@ DEFINE_LUA_FUNCTION(addressof, "table_or_function")
return 1;
}
// the following bit operations are ported from LuaBitOp 1.0.1,
// the following bit operations are ported from LuaBitOp 1.0.12
// because it can handle the sign bit (bit 31) correctly.
/*
** Lua BitOp -- a bit operations library for Lua 5.1.
** Lua BitOp -- a bit operations library for Lua 5.1/5.2.
** http://bitop.luajit.org/
**
** Copyright (C) 2008-2009 Mike Pall. All rights reserved.
** Copyright (C) 2008-2012 Mike Pall. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
@ -1186,7 +1186,11 @@ static UBits barg(lua_State *L, int idx)
{
BitNum bn;
UBits b;
#if LUA_VERSION_NUM < 502
bn.n = lua_tonumber(L, idx);
#else
bn.n = luaL_checknumber(L, idx);
#endif
#if defined(LUA_NUMBER_DOUBLE)
bn.n += 6755399441055744.0; /* 2^52+2^51 */
#ifdef SWAPPED_DOUBLE
@ -1206,8 +1210,11 @@ static UBits barg(lua_State *L, int idx)
#else
#error "Unknown number type, check LUA_NUMBER_* in luaconf.h"
#endif
if (b == 0 && !lua_isnumber(L, idx))
#if LUA_VERSION_NUM < 502
if (b == 0 && !lua_isnumber(L, idx)) {
luaL_typerror(L, idx, "number");
}
#endif
return b;
}
@ -1301,6 +1308,11 @@ bool luabitop_validate(lua_State *L) // originally named as luaopen_bit
luaL_error(L, "bit library self-test failed (%s)", msg);
return false;
}
#if LUA_VERSION_NUM < 502
luaL_register(L, "bit", bit_funcs);
#else
luaL_newlib(L, bit_funcs);
#endif
return true;
}