14 Commits

Author SHA1 Message Date
BlackMATov
59fb4d8ea4 update readme 2025-09-01 16:09:35 +07:00
BlackMATov
001e6f2956 Merge branch 'feature/pairs' into dev 2025-09-01 15:49:46 +07:00
BlackMATov
fb6d13ca74 temp remove pairs to merge other changes to dev 2025-09-01 15:34:03 +07:00
BlackMATov
8f61a14db6 update pairs todos 2025-09-01 15:09:29 +07:00
BlackMATov
0c016f1b67 return xxx_set debug mode 2025-09-01 01:59:00 +07:00
BlackMATov
26bf586140 primary/secondary functon set doesn't work with pairs as entity now 2025-09-01 01:53:29 +07:00
BlackMATov
46f1516a55 style fixes 2025-09-01 01:10:17 +07:00
BlackMATov
4cd8393546 public api works only with non-pair ids in has/get functions 2025-09-01 00:33:10 +07:00
BlackMATov
22302cee75 primary/secondary iterators for pair entities 2025-08-29 18:19:19 +07:00
BlackMATov
d4a7c7b77c more pair checks 2025-08-29 05:56:23 +07:00
BlackMATov
12beee6eec debug mode for pack/unpack and pair/unpair 2025-08-26 05:42:04 +07:00
BlackMATov
71a7d382c1 more type annots 2025-08-26 04:13:50 +07:00
BlackMATov
f2a8ee5b83 little style fixes 2025-08-24 16:14:26 +07:00
BlackMATov
81bf1d91e9 Revert "temp remove pairs to merge other changes to dev" 2025-08-20 23:27:08 +07:00
5 changed files with 270 additions and 250 deletions

View File

@@ -147,16 +147,15 @@ function evolved.alive_any(...) end
Sometimes (for debugging purposes, for example), it is necessary to extract the index and version from an identifier or to pack them back into an identifier. The [`evolved.pack`](#evolvedpack) and [`evolved.unpack`](#evolvedunpack) functions can be used for this purpose.
```lua
---@param primary integer
---@param secondary integer
---@param index integer
---@param version integer
---@return evolved.id id
---@nodiscard
function evolved.pack(primary, secondary) end
function evolved.pack(index, version) end
---@param id evolved.id
---@return integer primary
---@return integer secondary
---@return integer options
---@nodiscard
function evolved.unpack(id) end
```
@@ -1098,7 +1097,7 @@ id :: integer? -> id...
name :: id... -> string...
pack :: integer, integer -> id
unpack :: id -> integer, integer, integer
unpack :: id -> integer, integer
defer :: boolean
commit :: boolean
@@ -1304,11 +1303,11 @@ function evolved.name(...) end
### `evolved.pack`
```lua
---@param primary integer
---@param secondary integer
---@param index integer
---@param version integer
---@return evolved.id id
---@nodiscard
function evolved.pack(primary, secondary) end
function evolved.pack(index, version) end
```
### `evolved.unpack`
@@ -1317,7 +1316,6 @@ function evolved.pack(primary, secondary) end
---@param id evolved.id
---@return integer primary
---@return integer secondary
---@return integer options
---@nodiscard
function evolved.unpack(id) end
```

View File

@@ -11,7 +11,6 @@
- add INDEX fragment trait
- use compact prefix-tree for chunks
- optional ffi component storages
- add EXCLUSIVE fragment trait
## Thoughts

View File

@@ -13,21 +13,8 @@ for _ = 1, 1000 do
local initial_secondary = math.random(1, 2 ^ 20 - 1)
local packed_id = evo.pack(initial_primary, initial_secondary)
local unpacked_primary, unpacked_secondary, unpacked_options = evo.unpack(packed_id)
local unpacked_primary, unpacked_secondary = evo.unpack(packed_id)
assert(initial_primary == unpacked_primary)
assert(initial_secondary == unpacked_secondary)
assert(0 == unpacked_options)
end
for _ = 1, 1000 do
local initial_primary = math.random(1, 2 ^ 31 - 1)
local initial_secondary = math.random(1, 2 ^ 31 - 1)
local packed_id = evo.pack(initial_primary, initial_secondary)
local unpacked_primary, unpacked_secondary, unpacked_options = evo.unpack(packed_id)
assert(initial_primary % 2 ^ 20 == unpacked_primary)
assert(initial_secondary % 2 ^ 20 == unpacked_secondary)
assert(0 == unpacked_options)
end

View File

@@ -3,8 +3,8 @@ local evo = require 'evolved'
do
local id = evo.id()
local index, version, options = evo.unpack(id)
assert(evo.name(id) == string.format('$%d#%d:%d:%d', id, index, version, options))
local index, version = evo.unpack(id)
assert(evo.name(id) == string.format('$%d#%d:%d', id, index, version))
evo.set(id, evo.NAME, 'hello')
assert(evo.name(id) == 'hello')
@@ -13,7 +13,7 @@ do
assert(evo.name(id) == 'world')
evo.destroy(id)
assert(evo.name(id) == string.format('$%d#%d:%d:%d', id, index, version, options))
assert(evo.name(id) == string.format('$%d#%d:%d', id, index, version))
end
do

File diff suppressed because it is too large Load Diff