Software /
code /
prosody
Annotate
util/bitcompat.lua @ 13204:c9ef35fab0b1
core.moduleapi: Add :get_option_period for parsing time intervals
E.g. for use in mod_mam and others that take an amount of time before
some (usually cleanup) action is taken.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 16 Jul 2023 19:49:12 +0200 |
parent | 12975:d10957394a3c |
rev | line source |
---|---|
10241
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- Compatibility layer for bitwise operations |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 -- First try the bit32 lib |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 -- Lua 5.3 has it with compat enabled |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 -- Lua 5.2 has it by default |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 if _G.bit32 then |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 return _G.bit32; |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 end |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 do |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 -- Lua 5.3 and 5.4 would be able to use native infix operators |
12975
d10957394a3c
util: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
12573
diff
changeset
|
12 local ok, bitop = pcall(require, "prosody.util.bit53") |
10241
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 if ok then |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 return bitop; |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 end |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 end |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 |
48f7cda4174d
util.bitops: Library to find appropriate bitwise library (closes #1395)
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 error "No bit module found. See https://prosody.im/doc/depends#bitop"; |