comparison util/bitcompat.lua @ 13624:de902cc0d46c

util.bitcompat: Avoid potential noise from global metatable If this module is require'd from a plugin on a Lua version without the global bit32 library, it may trip a warning about accessing globals.
author Kim Alvefur <zash@zash.se>
date Wed, 15 Jan 2025 09:55:28 +0100
parents d10957394a3c
children
comparison
equal deleted inserted replaced
13623:e226f9632a48 13624:de902cc0d46c
1 -- Compatibility layer for bitwise operations 1 -- Compatibility layer for bitwise operations
2 2
3 -- First try the bit32 lib 3 -- First try the bit32 lib
4 -- Lua 5.3 has it with compat enabled 4 -- Lua 5.3 has it with compat enabled
5 -- Lua 5.2 has it by default 5 -- Lua 5.2 has it by default
6 if _G.bit32 then 6 if rawget(_G, "bit32") then
7 return _G.bit32; 7 return _G.bit32;
8 end 8 end
9 9
10 do 10 do
11 -- Lua 5.3 and 5.4 would be able to use native infix operators 11 -- Lua 5.3 and 5.4 would be able to use native infix operators