rename include/exclude_list to includes/excludes

This commit is contained in:
BlackMATov
2025-01-06 14:55:01 +07:00
parent 6130ba3897
commit f7b8f5879b
3 changed files with 85 additions and 85 deletions

View File

@@ -26,13 +26,13 @@ TAG :: fragment
DEFAULT :: fragment DEFAULT :: fragment
CONSTRUCT :: fragment CONSTRUCT :: fragment
INCLUDES :: fragment
EXCLUDES :: fragment
ON_SET :: fragment ON_SET :: fragment
ON_ASSIGN :: fragment ON_ASSIGN :: fragment
ON_INSERT :: fragment ON_INSERT :: fragment
ON_REMOVE :: fragment ON_REMOVE :: fragment
INCLUDE_LIST :: fragment
EXCLUDE_LIST :: fragment
``` ```
## Functions ## Functions

View File

@@ -826,7 +826,7 @@ do
assert(evo.insert(e5, f4, 53)) assert(evo.insert(e5, f4, 53))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f1, f2) evo.insert(q, evo.INCLUDES, f1, f2)
assert(evo.batch_assign(q, f1, 60) == 3) assert(evo.batch_assign(q, f1, 60) == 3)
@@ -886,7 +886,7 @@ do
assert(evo.insert(e5, f4, 53)) assert(evo.insert(e5, f4, 53))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f1, f2) evo.insert(q, evo.INCLUDES, f1, f2)
assert(evo.batch_assign(q, f1, 60) == 3) assert(evo.batch_assign(q, f1, 60) == 3)
@@ -944,7 +944,7 @@ do
assert(evo.insert(e5, f4, 53)) assert(evo.insert(e5, f4, 53))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f1, f2) evo.insert(q, evo.INCLUDES, f1, f2)
assert(evo.batch_clear(q) == 3) assert(evo.batch_clear(q) == 3)
@@ -1014,7 +1014,7 @@ do
assert(evo.insert(e5, f4, 53)) assert(evo.insert(e5, f4, 53))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f1, f2) evo.insert(q, evo.INCLUDES, f1, f2)
assert(evo.batch_clear(q) == 3) assert(evo.batch_clear(q) == 3)
assert(entity_sum == e2 * 2 + e3 * 3 + e4 * 4) assert(entity_sum == e2 * 2 + e3 * 3 + e4 * 4)
@@ -1062,7 +1062,7 @@ do
assert(evo.insert(e5, f4, 53)) assert(evo.insert(e5, f4, 53))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f1, f2) evo.insert(q, evo.INCLUDES, f1, f2)
assert(evo.batch_destroy(q) == 3) assert(evo.batch_destroy(q) == 3)
@@ -1132,7 +1132,7 @@ do
assert(evo.insert(e5, f4, 53)) assert(evo.insert(e5, f4, 53))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f1, f2) evo.insert(q, evo.INCLUDES, f1, f2)
assert(evo.batch_destroy(q) == 3) assert(evo.batch_destroy(q) == 3)
assert(entity_sum == e2 * 2 + e3 * 3 + e4 * 4) assert(entity_sum == e2 * 2 + e3 * 3 + e4 * 4)
@@ -1180,7 +1180,7 @@ do
assert(evo.insert(e5, f4, 53)) assert(evo.insert(e5, f4, 53))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f1, f2) evo.insert(q, evo.INCLUDES, f1, f2)
assert(evo.batch_remove(q, f2, f3) == 3) assert(evo.batch_remove(q, f2, f3) == 3)
@@ -1253,7 +1253,7 @@ do
assert(evo.insert(e5, f4, 53)) assert(evo.insert(e5, f4, 53))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f1, f2) evo.insert(q, evo.INCLUDES, f1, f2)
assert(evo.batch_remove(q, f2, f3) == 3) assert(evo.batch_remove(q, f2, f3) == 3)
assert(entity_sum == e2 + e3 * 2 + e4 * 2) assert(entity_sum == e2 + e3 * 2 + e4 * 2)
@@ -1289,7 +1289,7 @@ do
assert(evo.insert(e4, f4, 50)) assert(evo.insert(e4, f4, 50))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f2) evo.insert(q, evo.INCLUDES, f2)
assert(evo.batch_insert(q, f1, 60) == 1) assert(evo.batch_insert(q, f1, 60) == 1)
@@ -1334,7 +1334,7 @@ do
assert(evo.insert(e4, f4, 50)) assert(evo.insert(e4, f4, 50))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f2) evo.insert(q, evo.INCLUDES, f2)
entity_sum = 0 entity_sum = 0
component_sum = 0 component_sum = 0
@@ -1377,7 +1377,7 @@ do
assert(evo.insert(e4, f4, 50)) assert(evo.insert(e4, f4, 50))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f2) evo.insert(q, evo.INCLUDES, f2)
assert(evo.batch_set(q, f1, 60) == 3) assert(evo.batch_set(q, f1, 60) == 3)
@@ -1422,7 +1422,7 @@ do
assert(evo.insert(e4, f4, 50)) assert(evo.insert(e4, f4, 50))
local q = evo.id() local q = evo.id()
evo.insert(q, evo.INCLUDE_LIST, f2) evo.insert(q, evo.INCLUDES, f2)
entity_sum = 0 entity_sum = 0
component_sum = 0 component_sum = 0
@@ -1815,12 +1815,12 @@ do
do do
do do
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
evo.batch_destroy(q) evo.batch_destroy(q)
end end
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1, f2) evo.set(q, evo.INCLUDES, f1, f2)
do do
local e = evo.id() local e = evo.id()
@@ -1865,12 +1865,12 @@ do
do do
do do
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
evo.batch_destroy(q) evo.batch_destroy(q)
end end
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1, f2) evo.set(q, evo.INCLUDES, f1, f2)
do do
local e1 = evo.id() local e1 = evo.id()
@@ -1912,12 +1912,12 @@ do
do do
do do
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
evo.batch_destroy(q) evo.batch_destroy(q)
end end
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1, f2) evo.set(q, evo.INCLUDES, f1, f2)
do do
local e1 = evo.id() local e1 = evo.id()
@@ -1963,12 +1963,12 @@ do
do do
do do
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
evo.batch_destroy(q) evo.batch_destroy(q)
end end
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1, f2) evo.set(q, evo.INCLUDES, f1, f2)
do do
local e1 = evo.id() local e1 = evo.id()
@@ -2008,12 +2008,12 @@ do
do do
do do
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
evo.batch_destroy(q) evo.batch_destroy(q)
end end
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1, f2) evo.set(q, evo.INCLUDES, f1, f2)
do do
local e1 = evo.id() local e1 = evo.id()
@@ -2055,7 +2055,7 @@ do
local f1, f2 = evo.id(2) local f1, f2 = evo.id(2)
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
local e1 = evo.id() local e1 = evo.id()
assert(evo.insert(e1, f1, 41)) assert(evo.insert(e1, f1, 41))
@@ -2091,7 +2091,7 @@ do
local f1, f2 = evo.id(2) local f1, f2 = evo.id(2)
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
local e1 = evo.id() local e1 = evo.id()
assert(evo.insert(e1, f1, 41)) assert(evo.insert(e1, f1, 41))
@@ -2127,7 +2127,7 @@ do
local f1, f2 = evo.id(2) local f1, f2 = evo.id(2)
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
local e1 = evo.id() local e1 = evo.id()
assert(evo.insert(e1, f1, 41)) assert(evo.insert(e1, f1, 41))
@@ -2163,7 +2163,7 @@ do
local f1 = evo.id(1) local f1 = evo.id(1)
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
local e1 = evo.id() local e1 = evo.id()
assert(evo.insert(e1, f1, 41)) assert(evo.insert(e1, f1, 41))
@@ -2186,7 +2186,7 @@ do
local f1 = evo.id(1) local f1 = evo.id(1)
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
local e1 = evo.id() local e1 = evo.id()
assert(evo.insert(e1, f1, 41)) assert(evo.insert(e1, f1, 41))
@@ -2211,7 +2211,7 @@ do
local f1 = evo.id(1) local f1 = evo.id(1)
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
local e1 = evo.id() local e1 = evo.id()
assert(evo.insert(e1, f1, 41)) assert(evo.insert(e1, f1, 41))
@@ -2236,8 +2236,8 @@ do
local f1, f2 = evo.id(2) local f1, f2 = evo.id(2)
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
evo.set(q, evo.INCLUDE_LIST, f2) evo.set(q, evo.INCLUDES, f2)
local e1 = evo.id() local e1 = evo.id()
assert(evo.insert(e1, f1, 41)) assert(evo.insert(e1, f1, 41))
@@ -2253,7 +2253,7 @@ do
assert(entities and entities[1] == e2) assert(entities and entities[1] == e2)
end end
evo.set(q, evo.INCLUDE_LIST) evo.set(q, evo.INCLUDES)
do do
local iter, state = evo.execute(q) local iter, state = evo.execute(q)
@@ -2268,7 +2268,7 @@ do
local f1, f2, f3 = evo.id(3) local f1, f2, f3 = evo.id(3)
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
local e1 = evo.id() local e1 = evo.id()
assert(evo.insert(e1, f1, 41)) assert(evo.insert(e1, f1, 41))
@@ -2296,10 +2296,10 @@ do
local f1, f2 = evo.id(2) local f1, f2 = evo.id(2)
local q = evo.id() local q = evo.id()
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
evo.set(q, evo.EXCLUDE_LIST, f1) evo.set(q, evo.EXCLUDES, f1)
evo.set(q, evo.EXCLUDE_LIST, f2) evo.set(q, evo.EXCLUDES, f2)
local e1 = evo.id() local e1 = evo.id()
assert(evo.insert(e1, f1, 41)) assert(evo.insert(e1, f1, 41))
@@ -2319,7 +2319,7 @@ do
assert(not entities) assert(not entities)
end end
evo.set(q, evo.EXCLUDE_LIST) evo.set(q, evo.EXCLUDES)
do do
local iter, state = evo.execute(q) local iter, state = evo.execute(q)
@@ -2355,7 +2355,7 @@ do
assert(not chunk and not entities) assert(not chunk and not entities)
end end
evo.set(q, evo.EXCLUDE_LIST, f2) evo.set(q, evo.EXCLUDES, f2)
do do
local iter, state = evo.execute(q) local iter, state = evo.execute(q)
@@ -2363,7 +2363,7 @@ do
assert(not chunk and not entities) assert(not chunk and not entities)
end end
evo.set(q, evo.INCLUDE_LIST, f1) evo.set(q, evo.INCLUDES, f1)
do do
local iter, state = evo.execute(q) local iter, state = evo.execute(q)

View File

@@ -339,13 +339,39 @@ evolved.TAG = __acquire_id()
evolved.DEFAULT = __acquire_id() evolved.DEFAULT = __acquire_id()
evolved.CONSTRUCT = __acquire_id() evolved.CONSTRUCT = __acquire_id()
evolved.INCLUDES = __acquire_id()
evolved.EXCLUDES = __acquire_id()
evolved.ON_SET = __acquire_id() evolved.ON_SET = __acquire_id()
evolved.ON_ASSIGN = __acquire_id() evolved.ON_ASSIGN = __acquire_id()
evolved.ON_INSERT = __acquire_id() evolved.ON_INSERT = __acquire_id()
evolved.ON_REMOVE = __acquire_id() evolved.ON_REMOVE = __acquire_id()
evolved.INCLUDE_LIST = __acquire_id() ---
evolved.EXCLUDE_LIST = __acquire_id() ---
---
---
---
local __INCLUDE_SET = __acquire_id()
local __EXCLUDE_SET = __acquire_id()
local __SORTED_INCLUDE_LIST = __acquire_id()
local __SORTED_EXCLUDE_LIST = __acquire_id()
---@type table<evolved.fragment, boolean>
local __EMPTY_FRAGMENT_SET = setmetatable({}, {
__newindex = function() error('attempt to modify empty fragment set') end
})
---@type evolved.fragment[]
local __EMPTY_FRAGMENT_LIST = setmetatable({}, {
__newindex = function() error('attempt to modify empty fragment list') end
})
---@type evolved.component[]
local __EMPTY_COMPONENT_STORAGE = setmetatable({}, {
__newindex = function() error('attempt to modify empty component storage') end
})
--- ---
--- ---
@@ -2448,15 +2474,10 @@ end
--- ---
--- ---
local __INCLUDE_SET = __acquire_id()
local __EXCLUDE_SET = __acquire_id()
local __SORTED_INCLUDE_LIST = __acquire_id()
local __SORTED_EXCLUDE_LIST = __acquire_id()
evolved.set(evolved.TAG, evolved.TAG) evolved.set(evolved.TAG, evolved.TAG)
---@param ... evolved.fragment ---@param ... evolved.fragment
evolved.set(evolved.INCLUDE_LIST, evolved.CONSTRUCT, function(_, _, ...) evolved.set(evolved.INCLUDES, evolved.CONSTRUCT, function(_, _, ...)
local fragment_count = select('#', ...) local fragment_count = select('#', ...)
if fragment_count == 0 then if fragment_count == 0 then
@@ -2475,7 +2496,7 @@ end)
---@param query evolved.query ---@param query evolved.query
---@param include_list evolved.fragment[] ---@param include_list evolved.fragment[]
evolved.set(evolved.INCLUDE_LIST, evolved.ON_SET, function(query, _, include_list) evolved.set(evolved.INCLUDES, evolved.ON_SET, function(query, _, include_list)
local include_list_size = #include_list local include_list_size = #include_list
---@type table<evolved.fragment, boolean> ---@type table<evolved.fragment, boolean>
@@ -2500,12 +2521,12 @@ evolved.set(evolved.INCLUDE_LIST, evolved.ON_SET, function(query, _, include_lis
evolved.set(query, __SORTED_INCLUDE_LIST, sorted_include_list) evolved.set(query, __SORTED_INCLUDE_LIST, sorted_include_list)
end) end)
evolved.set(evolved.INCLUDE_LIST, evolved.ON_REMOVE, function(query) evolved.set(evolved.INCLUDES, evolved.ON_REMOVE, function(query)
evolved.remove(query, __INCLUDE_SET, __SORTED_INCLUDE_LIST) evolved.remove(query, __INCLUDE_SET, __SORTED_INCLUDE_LIST)
end) end)
---@param ... evolved.fragment ---@param ... evolved.fragment
evolved.set(evolved.EXCLUDE_LIST, evolved.CONSTRUCT, function(_, _, ...) evolved.set(evolved.EXCLUDES, evolved.CONSTRUCT, function(_, _, ...)
local fragment_count = select('#', ...) local fragment_count = select('#', ...)
if fragment_count == 0 then if fragment_count == 0 then
@@ -2524,7 +2545,7 @@ end)
---@param query evolved.query ---@param query evolved.query
---@param exclude_list evolved.fragment[] ---@param exclude_list evolved.fragment[]
evolved.set(evolved.EXCLUDE_LIST, evolved.ON_SET, function(query, _, exclude_list) evolved.set(evolved.EXCLUDES, evolved.ON_SET, function(query, _, exclude_list)
local exclude_list_size = #exclude_list local exclude_list_size = #exclude_list
---@type table<evolved.fragment, boolean> ---@type table<evolved.fragment, boolean>
@@ -2549,7 +2570,7 @@ evolved.set(evolved.EXCLUDE_LIST, evolved.ON_SET, function(query, _, exclude_lis
evolved.set(query, __SORTED_EXCLUDE_LIST, sorted_exclude_list) evolved.set(query, __SORTED_EXCLUDE_LIST, sorted_exclude_list)
end) end)
evolved.set(evolved.EXCLUDE_LIST, evolved.ON_REMOVE, function(query) evolved.set(evolved.EXCLUDES, evolved.ON_REMOVE, function(query)
evolved.remove(query, __EXCLUDE_SET, __SORTED_EXCLUDE_LIST) evolved.remove(query, __EXCLUDE_SET, __SORTED_EXCLUDE_LIST)
end) end)
@@ -2559,27 +2580,6 @@ end)
--- ---
--- ---
---@type table<evolved.fragment, boolean>
local __EMPTY_FRAGMENT_SET = setmetatable({}, {
__newindex = function() error('attempt to modify empty fragment set') end
})
---@type evolved.fragment[]
local __EMPTY_FRAGMENT_LIST = setmetatable({}, {
__newindex = function() error('attempt to modify empty fragment list') end
})
---@type evolved.component[]
local __EMPTY_COMPONENT_STORAGE = setmetatable({}, {
__newindex = function() error('attempt to modify empty component storage') end
})
---
---
---
---
---
---@param ... evolved.fragment fragments ---@param ... evolved.fragment fragments
---@return evolved.chunk?, evolved.entity[]? ---@return evolved.chunk?, evolved.entity[]?
function evolved.chunk(...) function evolved.chunk(...)
@@ -2637,39 +2637,39 @@ function evolved.select(chunk, ...)
local indices = chunk.__component_indices local indices = chunk.__component_indices
local storages = chunk.__component_storages local storages = chunk.__component_storages
local EMPTY_COMPONENT_STORAGE = __EMPTY_COMPONENT_STORAGE local empty_component_storage = __EMPTY_COMPONENT_STORAGE
if fragment_count == 1 then if fragment_count == 1 then
local f1 = ... local f1 = ...
local i1 = indices[f1] local i1 = indices[f1]
return return
i1 and storages[i1] or EMPTY_COMPONENT_STORAGE i1 and storages[i1] or empty_component_storage
end end
if fragment_count == 2 then if fragment_count == 2 then
local f1, f2 = ... local f1, f2 = ...
local i1, i2 = indices[f1], indices[f2] local i1, i2 = indices[f1], indices[f2]
return return
i1 and storages[i1] or EMPTY_COMPONENT_STORAGE, i1 and storages[i1] or empty_component_storage,
i2 and storages[i2] or EMPTY_COMPONENT_STORAGE i2 and storages[i2] or empty_component_storage
end end
if fragment_count == 3 then if fragment_count == 3 then
local f1, f2, f3 = ... local f1, f2, f3 = ...
local i1, i2, i3 = indices[f1], indices[f2], indices[f3] local i1, i2, i3 = indices[f1], indices[f2], indices[f3]
return return
i1 and storages[i1] or EMPTY_COMPONENT_STORAGE, i1 and storages[i1] or empty_component_storage,
i2 and storages[i2] or EMPTY_COMPONENT_STORAGE, i2 and storages[i2] or empty_component_storage,
i3 and storages[i3] or EMPTY_COMPONENT_STORAGE i3 and storages[i3] or empty_component_storage
end end
do do
local f1, f2, f3 = ... local f1, f2, f3 = ...
local i1, i2, i3 = indices[f1], indices[f2], indices[f3] local i1, i2, i3 = indices[f1], indices[f2], indices[f3]
return return
i1 and storages[i1] or EMPTY_COMPONENT_STORAGE, i1 and storages[i1] or empty_component_storage,
i2 and storages[i2] or EMPTY_COMPONENT_STORAGE, i2 and storages[i2] or empty_component_storage,
i3 and storages[i3] or EMPTY_COMPONENT_STORAGE, i3 and storages[i3] or empty_component_storage,
evolved.select(chunk, select(4, ...)) evolved.select(chunk, select(4, ...))
end end
end end