Skip to content

Commit 24e7485

Browse files
RiskoZoSlovenskarolandlo
authored andcommitted
Replace bitops module with custom isbitset function
1 parent 1364a52 commit 24e7485

File tree

5 files changed

+20
-51
lines changed

5 files changed

+20
-51
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ jobs:
3333
run: |
3434
make dev
3535
if [[ ${{ matrix.luaVersion }} == 5.* ]]; then make ffi; fi
36-
if [[ ${{ matrix.luaVersion }} == 5.1 ]] || [[ ${{ matrix.luaVersion }} == 5.2 ]]; then
37-
make bit
38-
fi
3936
4037
- name: Lint with luacheck
4138
run: |
@@ -79,11 +76,6 @@ jobs:
7976
mingw-w64-x86_64-lua-luarocks
8077
mingw-w64-x86_64-${{ matrix.lua.name }}
8178

82-
- if: matrix.lua.name == 'lua51'
83-
name: Install bitop
84-
run: |
85-
pacman --noconfirm -S mingw-w64-x86_64-lua51-bitop
86-
8779
- name: Lua dependencies
8880
run: |
8981
if [[ ${{ matrix.lua.exe }} == lua5.3 ]]; then

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
DEV_ROCKS = "busted 2.2.0" "luacheck 1.1.2"
22

3-
.PHONY: dev ffi bit
3+
.PHONY: dev ffi
44

55
dev:
66
@for rock in $(DEV_ROCKS) ; do \
@@ -14,6 +14,3 @@ dev:
1414

1515
ffi:
1616
@luarocks install luaffi-tkl
17-
18-
bit:
19-
@luarocks install luabitop

lua-vips-1.1-10.rockspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ build = {
2424
type = "builtin",
2525
modules = {
2626
vips = "src/vips.lua",
27-
["vips.bitops"] = "src/vips/bitops.lua",
2827
["vips.cdefs"] = "src/vips/cdefs.lua",
2928
["vips.verror"] = "src/vips/verror.lua",
3029
["vips.version"] = "src/vips/version.lua",

src/vips/bitops.lua

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/vips/voperation.lua

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33

44
local ffi = require "ffi"
55

6-
local bitops = require "vips.bitops"
76
local verror = require "vips.verror"
87
local version = require "vips.version"
98
local log = require "vips.log"
109
local gvalue = require "vips.gvalue"
1110
local vobject = require "vips.vobject"
1211
local Image = require "vips.Image"
1312

14-
local band = bitops.band
1513
local type = type
1614
local error = error
1715
local pairs = pairs
@@ -30,6 +28,10 @@ local OUTPUT = 32
3028
local DEPRECATED = 64
3129
local MODIFY = 128
3230

31+
local function isbitset(a, b)
32+
return ( (a - (a % b)) / b ) % 2 == 1
33+
end
34+
3335
-- find the first image, and recurse
3436
local function find_first_image(array, length)
3537
length = length or #array
@@ -90,7 +92,7 @@ voperation.set = function(self, name, flags, match_image, value)
9092
end
9193

9294
-- MODIFY args need to be copied before they are set
93-
if band(flags, MODIFY) ~= 0 then
95+
if isbitset(flags, MODIFY) then
9496
log.msg("copying MODIFY arg", name)
9597
-- make sure we have a unique copy
9698
value = value:copy():copy_memory()
@@ -167,9 +169,9 @@ voperation.call = function(name, string_options, ...)
167169
local flag = flags[i]
168170
flags_from_name[names[i]] = flag
169171

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
173175
n_required = n_required + 1
174176
end
175177
end
@@ -207,9 +209,9 @@ voperation.call = function(name, string_options, ...)
207209
for i = 1, arguments_length do
208210
local flag = flags[i]
209211

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
213215
n = n + 1
214216

215217
if not vop:set(names[i], flag,
@@ -247,17 +249,17 @@ voperation.call = function(name, string_options, ...)
247249
for i = 1, arguments_length do
248250
local flag = flags[i]
249251

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
253255
result[n] = vob:get(names[i])
254256
n = n + 1
255257
end
256258

257259
-- MODIFY input args are returned .. this will get the copy we
258260
-- 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
261263
result[n] = vob:get(names[i])
262264
n = n + 1
263265
end
@@ -267,9 +269,9 @@ voperation.call = function(name, string_options, ...)
267269
for i = 1, arguments_length do
268270
local flag = flags[i]
269271

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
273275
result[n] = vob:get(names[i])
274276
n = n + 1
275277
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy