Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix change all uses "bit32" for "bit" #43

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/corelib/base64.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
base64 -- v1.5.1 public domain Lua base64 encoder/decoder
no warranty implied; use at your own risk
Needs bit32.extract function. If not present it's implemented using BitOp
Needs bit.extract function. If not present it's implemented using BitOp
or Lua 5.3 native bit operators. For Lua 5.1 fallbacks to pure Lua
implementation inspired by Rici Lake's post:
http://ricilake.blogspot.co.uk/2007/10/iterating-bits-in-lua.html
Expand All @@ -24,7 +24,7 @@

base64 = {}

local extract = _G.bit32 and _G.bit32.extract
local extract = _G.bit and _G.bit.extract
if not extract then
if _G.bit then
local shl, shr, band = _G.bit.lshift, _G.bit.rshift, _G.bit.band
Expand Down
6 changes: 3 additions & 3 deletions modules/corelib/keyboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ function g_keyboard.isInUse()
end

function g_keyboard.isCtrlPressed()
return bit32.band(g_window.getKeyboardModifiers(), KeyboardCtrlModifier) ~= 0
return bit.band(g_window.getKeyboardModifiers(), KeyboardCtrlModifier) ~= 0
end

function g_keyboard.isAltPressed()
return bit32.band(g_window.getKeyboardModifiers(), KeyboardAltModifier) ~= 0
return bit.band(g_window.getKeyboardModifiers(), KeyboardAltModifier) ~= 0
end

function g_keyboard.isShiftPressed()
return bit32.band(g_window.getKeyboardModifiers(), KeyboardShiftModifier) ~= 0
return bit.band(g_window.getKeyboardModifiers(), KeyboardShiftModifier) ~= 0
end
1 change: 0 additions & 1 deletion modules/game_bot/executor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo

-- basic functions & classes
context.print = print
context.bit32 = bit32
context.bit = bit
context.pairs = pairs
context.ipairs = ipairs
Expand Down
4 changes: 2 additions & 2 deletions modules/game_healthinfo/healthinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ end
function onStatesChange(localPlayer, now, old)
if now == old then return end

local bitsChanged = bit32.bxor(now, old)
local bitsChanged = bit.bxor(now, old)
for i = 1, 32 do
local pow = math.pow(2, i-1)
if pow > bitsChanged then break end
local bitChanged = bit32.band(bitsChanged, pow)
local bitChanged = bit.band(bitsChanged, pow)
if bitChanged ~= 0 then
toggleIcon(bitChanged)
end
Expand Down
4 changes: 2 additions & 2 deletions modules/game_inventory/inventory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,11 @@ end

function onStatesChange(localPlayer, now, old)
if now == old then return end
local bitsChanged = bit32.bxor(now, old)
local bitsChanged = bit.bxor(now, old)
for i = 1, 32 do
local pow = math.pow(2, i-1)
if pow > bitsChanged then break end
local bitChanged = bit32.band(bitsChanged, pow)
local bitChanged = bit.band(bitsChanged, pow)
if bitChanged ~= 0 then
toggleIcon(bitChanged)
end
Expand Down
2 changes: 1 addition & 1 deletion modules/game_ruleviolation/ruleviolation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function onSelectReason(reasonLabel, focused)
actionsTextList:destroyChildren()
for actionBaseFlag = 0, #rvactions do
local actionFlagString = rvactions[actionBaseFlag]
if bit32.band(reasonLabel.actionFlags, math.pow(2, actionBaseFlag)) > 0 then
if bit.band(reasonLabel.actionFlags, math.pow(2, actionBaseFlag)) > 0 then
local label = g_ui.createWidget('RVListLabel', actionsTextList)
label:setText(actionFlagString)
label.actionId = actionBaseFlag
Expand Down
4 changes: 2 additions & 2 deletions modules/game_topbar/topbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ end
function onStatesChange(localPlayer, now, old)
if now == old then return end

local bitsChanged = bit32.bxor(now, old)
local bitsChanged = bit.bxor(now, old)
for i = 1, 32 do
local pow = math.pow(2, i - 1)
if pow > bitsChanged then break end
local bitChanged = bit32.band(bitsChanged, pow)
local bitChanged = bit.band(bitsChanged, pow)
if bitChanged ~= 0 then toggleIcon(bitChanged) end
end
end
Expand Down
2 changes: 1 addition & 1 deletion modules/gamelib/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Player:hasState(state, states)
local pow = math.pow(2, i-1)
if pow > states then break end

local states = bit32.band(states, pow)
local states = bit.band(states, pow)
if states == state then
return true
end
Expand Down
8 changes: 4 additions & 4 deletions src/framework/luaengine/lbitlib.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This is the bit32 library from lua 5.2.0, backported to
* This is the bit library from lua 5.2.0, backported to
* lua 5.1.4.
*
* version 5.2.0-backport4
Expand Down Expand Up @@ -164,9 +164,9 @@ static lua_Unsigned luaL_checkunsigned (lua_State *L, int arg) {
/* ----- Lua 5.2 luaL_newlib() compatibility: ----- */

#define LUAMOD_API LUALIB_API
#define LUA_BIT32LIBNAME "bit32"
#define LUA_BITLIBNAME "bit"
#ifndef luaL_newlib
#define luaL_newlib(x, y) luaL_register(x, LUA_BIT32LIBNAME, y)
#define luaL_newlib(x, y) luaL_register(x, LUA_BITLIBNAME, y)
#endif

/* ----- avoid a 'symbol redefined' warning below ----- */
Expand Down Expand Up @@ -372,7 +372,7 @@ static const luaL_Reg bitlib[] = {
{NULL, NULL}
};

int luaopen_bit32 (lua_State *L) {
int luaopen_bit (lua_State *L) {
luaL_newlib(L, bitlib);
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/framework/luaengine/lbitlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@

struct lua_State;

int luaopen_bit32 (lua_State *L);
int luaopen_bit (lua_State *L);

#endif
4 changes: 2 additions & 2 deletions src/framework/luaengine/luainterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,8 @@ void LuaInterface::createLuaState()
// load lua standard libraries
luaL_openlibs(L);

// load bit32 lib for bitwise operations
luaopen_bit32(L);
// load bit lib for bitwise operations
luaopen_bit(L);

// creates weak table
newTable();
Expand Down
Loading