File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ build = {
24
24
type = " builtin" ,
25
25
modules = {
26
26
vips = " src/vips.lua" ,
27
+ [" vips.bitops" ] = " src/vips/bitops.lua" ,
27
28
[" vips.cdefs" ] = " src/vips/cdefs.lua" ,
28
29
[" vips.verror" ] = " src/vips/verror.lua" ,
29
30
[" vips.version" ] = " src/vips/version.lua" ,
Original file line number Diff line number Diff line change
1
+ local hasbit , bit = pcall (require , " bit" )
2
+ local bitops = {}
3
+
4
+ if hasbit then -- Lua 5.1, 5.2 with luabitop or LuaJIT
5
+ bitops .band = bit .band
6
+ elseif (_VERSION == " Lua 5.1" or _VERSION == " Lua 5.2" ) then
7
+ error (" Bit operations missing. Please install 'luabitop'" )
8
+ else -- Lua >= 5.3
9
+ local band , err = load (" return function(a, b) return a & b end" )
10
+ if band then
11
+ local ok
12
+ ok , bitops .band = pcall (band )
13
+ if not ok then
14
+ error (" Execution error" )
15
+ end
16
+ else
17
+ error (" Compilation error" .. err )
18
+ end
19
+ end
20
+
21
+ return bitops
Original file line number Diff line number Diff line change 2
2
-- lookup and call operations
3
3
4
4
local ffi = require " ffi"
5
- local bit = require " bit"
6
5
6
+ local bitops = require " vips.bitops"
7
7
local verror = require " vips.verror"
8
8
local version = require " vips.version"
9
9
local log = require " vips.log"
10
10
local gvalue = require " vips.gvalue"
11
11
local vobject = require " vips.vobject"
12
12
local Image = require " vips.Image"
13
13
14
- local band = bit .band
14
+ local band = bitops .band
15
15
local type = type
16
16
local error = error
17
17
local pairs = pairs
You can’t perform that action at this time.
0 commit comments