Pārlūkot izejas kodu

[lua] Modify default lua native bitops library from bit to bit32 (#10923)

* Update _hx_bit.lua

Modify default lua native bitops library from bit to bit32

* Update _hx_bit.lua
inklit 2 gadi atpakaļ
vecāks
revīzija
39d98a4cb0
1 mainītis faili ar 8 papildinājumiem un 7 dzēšanām
  1. 8 7
      std/lua/_lua/_hx_bit.lua

+ 8 - 7
std/lua/_lua/_hx_bit.lua

@@ -1,15 +1,16 @@
--- require this for lua 5.1
-pcall(require, 'bit')
-if bit then
-  _hx_bit_raw = bit
-  _hx_bit = setmetatable({}, { __index = _hx_bit_raw });
-else
-  _hx_bit_raw = _G.require('bit32')
+if pcall(require, 'bit32') then --if we are on Lua 5.1, bit32 will be the default. 
+  _hx_bit_raw = bit32
   _hx_bit = setmetatable({}, { __index = _hx_bit_raw });
   -- lua 5.2 weirdness
   _hx_bit.bnot = function(...) return _hx_bit_clamp(_hx_bit_raw.bnot(...)) end;
   _hx_bit.bxor = function(...) return _hx_bit_clamp(_hx_bit_raw.bxor(...)) end;
+else
+  --If we do not have bit32, fallback to 'bit'
+  pcall(require, 'bit')
+  _hx_bit_raw = bit
+  _hx_bit = setmetatable({}, { __index = _hx_bit_raw });
 end
+
 -- see https://github.com/HaxeFoundation/haxe/issues/8849
 _hx_bit.bor = function(...) return _hx_bit_clamp(_hx_bit_raw.bor(...)) end;
 _hx_bit.band = function(...) return _hx_bit_clamp(_hx_bit_raw.band(...)) end;