Skip to content

Commit 6d3217e

Browse files
committed
feat: add bit_or in evdev.util
1 parent 721061d commit 6d3217e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

evdev/util.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ local mod = {
4343
enum = enum,
4444
}
4545

46+
---@param bits number|number[]
47+
---@return number
48+
function mod.bit_or(bits)
49+
return type(bits) == "number" and bits or bit.bor(table.unpack(bits))
50+
end
51+
4652
---@param str_ptr ffi.cdata* pointer to string
4753
---@return string
4854
function mod.to_string(str_ptr)
@@ -53,7 +59,7 @@ end
5359
---@param flags number[]
5460
---@return number fd file descriptor
5561
function mod.open_file(pathname, flags)
56-
return open(pathname, bit.bor(table.unpack(flags)))
62+
return open(pathname, mod.bit_or(flags))
5763
end
5864

5965
---@param errnum number

0 commit comments

Comments
 (0)