3
3
4
4
local ffi = require " ffi"
5
5
6
- local bitops = require " vips.bitops"
7
6
local verror = require " vips.verror"
8
7
local version = require " vips.version"
9
8
local log = require " vips.log"
10
9
local gvalue = require " vips.gvalue"
11
10
local vobject = require " vips.vobject"
12
11
local Image = require " vips.Image"
13
12
14
- local band = bitops .band
15
13
local type = type
16
14
local error = error
17
15
local pairs = pairs
@@ -30,6 +28,10 @@ local OUTPUT = 32
30
28
local DEPRECATED = 64
31
29
local MODIFY = 128
32
30
31
+ local function isbitset (a , b )
32
+ return ( (a - (a % b )) / b ) % 2 == 1
33
+ end
34
+
33
35
-- find the first image, and recurse
34
36
local function find_first_image (array , length )
35
37
length = length or # array
@@ -90,7 +92,7 @@ voperation.set = function(self, name, flags, match_image, value)
90
92
end
91
93
92
94
-- MODIFY args need to be copied before they are set
93
- if band (flags , MODIFY ) ~= 0 then
95
+ if isbitset (flags , MODIFY ) then
94
96
log .msg (" copying MODIFY arg" , name )
95
97
-- make sure we have a unique copy
96
98
value = value :copy ():copy_memory ()
@@ -167,9 +169,9 @@ voperation.call = function(name, string_options, ...)
167
169
local flag = flags [i ]
168
170
flags_from_name [names [i ]] = flag
169
171
170
- if band (flag , INPUT ) ~= 0 and
171
- band (flag , REQUIRED ) ~= 0 and
172
- band (flag , DEPRECATED ) == 0 then
172
+ if isbitset (flag , INPUT ) and
173
+ isbitset (flag , REQUIRED ) and
174
+ not isbitset (flag , DEPRECATED ) then
173
175
n_required = n_required + 1
174
176
end
175
177
end
@@ -207,9 +209,9 @@ voperation.call = function(name, string_options, ...)
207
209
for i = 1 , arguments_length do
208
210
local flag = flags [i ]
209
211
210
- if band (flag , INPUT ) ~= 0 and
211
- band (flag , REQUIRED ) ~= 0 and
212
- band (flag , DEPRECATED ) == 0 then
212
+ if isbitset (flag , INPUT ) and
213
+ isbitset (flag , REQUIRED ) and
214
+ not isbitset (flag , DEPRECATED ) then
213
215
n = n + 1
214
216
215
217
if not vop :set (names [i ], flag ,
@@ -247,17 +249,17 @@ voperation.call = function(name, string_options, ...)
247
249
for i = 1 , arguments_length do
248
250
local flag = flags [i ]
249
251
250
- if band (flag , OUTPUT ) ~= 0 and
251
- band (flag , REQUIRED ) ~= 0 and
252
- band (flag , DEPRECATED ) == 0 then
252
+ if isbitset (flag , OUTPUT ) and
253
+ isbitset (flag , REQUIRED ) and
254
+ not isbitset (flag , DEPRECATED ) then
253
255
result [n ] = vob :get (names [i ])
254
256
n = n + 1
255
257
end
256
258
257
259
-- MODIFY input args are returned .. this will get the copy we
258
260
-- made above
259
- if band (flag , INPUT ) ~= 0 and
260
- band (flag , MODIFY ) ~= 0 then
261
+ if isbitset (flag , INPUT ) and
262
+ isbitset (flag , MODIFY ) then
261
263
result [n ] = vob :get (names [i ])
262
264
n = n + 1
263
265
end
@@ -267,9 +269,9 @@ voperation.call = function(name, string_options, ...)
267
269
for i = 1 , arguments_length do
268
270
local flag = flags [i ]
269
271
270
- if band (flag , OUTPUT ) ~= 0 and
271
- band (flag , REQUIRED ) == 0 and
272
- band (flag , DEPRECATED ) == 0 then
272
+ if isbitset (flag , OUTPUT ) and
273
+ not isbitset (flag , REQUIRED ) and
274
+ not isbitset (flag , DEPRECATED ) then
273
275
result [n ] = vob :get (names [i ])
274
276
n = n + 1
275
277
end
0 commit comments