Skip to content
Merged

Dev #33

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lua5.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v11
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/lua5.2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: lua5.2

on: [push, pull_request]

jobs:
build:
runs-on: ${{matrix.operating_system}}
strategy:
fail-fast: false
matrix:
lua_version: ["5.2"]
operating_system: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: ${{matrix.operating_system}}-${{matrix.lua_version}}
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
lua ./develop/all.lua
21 changes: 21 additions & 0 deletions .github/workflows/lua5.3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: lua5.3

on: [push, pull_request]

jobs:
build:
runs-on: ${{matrix.operating_system}}
strategy:
fail-fast: false
matrix:
lua_version: ["5.3"]
operating_system: ["ubuntu-latest", "macos-latest", "windows-latest"]
name: ${{matrix.operating_system}}-${{matrix.lua_version}}
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
lua ./develop/all.lua
2 changes: 1 addition & 1 deletion .github/workflows/lua5.4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v11
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/luajit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- uses: leafo/gh-actions-lua@v11
- uses: leafo/gh-actions-lua@v12
with:
luaVersion: ${{matrix.lua_version}}
- run: |
Expand Down
27 changes: 27 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
"file": "${workspaceFolder}/develop/all.lua"
}
},
{
"name": "Launch Evolved All (lua5.2)",
"type": "lua-local",
"request": "launch",
"program": {
"lua": "lua5.2",
"file": "${workspaceFolder}/develop/all.lua"
}
},
{
"name": "Launch Evolved All (lua5.3)",
"type": "lua-local",
"request": "launch",
"program": {
"lua": "lua5.3",
"file": "${workspaceFolder}/develop/all.lua"
}
},
{
"name": "Launch Evolved All (lua5.4)",
"type": "lua-local",
Expand All @@ -19,6 +37,15 @@
"file": "${workspaceFolder}/develop/all.lua"
}
},
{
"name": "Launch Evolved All (lua5.5)",
"type": "lua-local",
"request": "launch",
"program": {
"lua": "lua5.5",
"file": "${workspaceFolder}/develop/all.lua"
}
},
{
"name": "Launch Evolved All (luajit)",
"type": "lua-local",
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
- [Chunk](#chunk)
- [Builder](#builder)
- [Changelog](#changelog)
- [v1.6.0](#v160)
- [v1.5.0](#v150)
- [v1.4.0](#v140)
- [v1.3.0](#v130)
Expand Down Expand Up @@ -643,14 +644,18 @@ Now we know that structural changes are not allowed during iteration, but what i
---@return boolean started
function evolved.defer() end

---@return integer depth
---@nodiscard
function evolved.depth() end

---@return boolean committed
function evolved.commit() end

---@return boolean cancelled
function evolved.cancel() end
```

The [`evolved.defer`](#evolveddefer) function starts a deferred scope. This means that all changes made inside the scope will be queued and applied after leaving the scope. The [`evolved.commit`](#evolvedcommit) function closes the last deferred scope and applies all queued changes. These functions can be nested, so you can start a new deferred scope inside an existing one. The [`evolved.commit`](#evolvedcommit) function will apply all queued changes only when the last deferred scope is closed.
The [`evolved.defer`](#evolveddefer) function starts a deferred scope. This means that all changes made inside the scope will be queued and applied after leaving the scope. The [`evolved.commit`](#evolvedcommit) function closes the last deferred scope and applies all queued changes. These functions can be nested, so you can start a new deferred scope inside an existing one. The [`evolved.commit`](#evolvedcommit) function will apply all queued changes only when the last deferred scope is closed. The [`evolved.depth`](#evolveddepth) function returns the current depth of deferred scopes. If there are no deferred scopes, it returns `0`.

```lua
local evolved = require 'evolved'
Expand Down Expand Up @@ -1184,6 +1189,7 @@ pack :: integer, integer -> id
unpack :: id -> integer, integer

defer :: boolean
depth :: integer
commit :: boolean
cancel :: boolean

Expand Down Expand Up @@ -1306,11 +1312,16 @@ builder_mt:destruction_policy :: id -> builder

## Changelog

### v1.6.0

- Significant performance improvements of the [`evolved.REQUIRES`](#evolvedrequires) fragment trait
- Added the new [`evolved.depth`](#evolveddepth) function that returns the current depth of deferred scopes

### v1.5.0

- Added a little [LÖVE](https://love2d.org) example;
- The spawn and clone operations with defaults have been significantly optimized;
- Added basic [Teal](https://github.com/teal-language) type definitions, thanks to [@p0sel0k](https://github.com/p0sel0k).
- Added a little [LÖVE](https://love2d.org) example
- The spawn and clone operations with defaults have been significantly optimized
- Added basic [Teal](https://github.com/teal-language) type definitions, thanks to [@p0sel0k](https://github.com/p0sel0k)

### v1.4.0

Expand Down Expand Up @@ -1446,6 +1457,14 @@ function evolved.unpack(id) end
function evolved.defer() end
```

### `evolved.depth`

```lua
---@return integer depth
---@nodiscard
function evolved.depth() end
```

### `evolved.commit`

```lua
Expand Down
7 changes: 4 additions & 3 deletions develop/GUIDES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
1. Insert the new function into the `evolved` table in `evolved.lua`.
2. Create tests for the function in `develop/testing/function_name_tests.lua`.
3. Add the new test to `develop/all.lua`.
4. Document the function in the **Cheat Sheet** and **API Reference** sections of `README.md`.
5. Provide a description in the **Overview** section of `README.md`.
6. Describe the update in the **Changelog** section of `README.md`.
4. Update the Teal type definitions in `evolved.d.tl`.
5. Document the function in the **Cheat Sheet** and **API Reference** sections of `README.md`.
6. Provide a description in the **Overview** section of `README.md`.
7. Describe the update in the **Changelog** section of `README.md`.
4 changes: 1 addition & 3 deletions develop/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

## Thoughts

- We can return deferred status from modifying operations and spawn/clone methods.
- We should have a way to not copy components on deferred spawn/clone.
- We should have a way to not copy components on deferred spawn/clone

## Known Issues

- Required fragments are slower than they should be
- Errors in hooks are cannot be handled properly right now
2 changes: 2 additions & 0 deletions develop/all.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'develop.testing.build_tests'
require 'develop.testing.cancel_tests'
require 'develop.testing.clone_tests'
require 'develop.testing.depth_tests'
require 'develop.testing.destroy_tests'
require 'develop.testing.locate_tests'
require 'develop.testing.main_tests'
require 'develop.testing.multi_spawn_tests'
Expand Down
3 changes: 3 additions & 0 deletions develop/benchmarks/clone_bmarks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ basics.describe_bench(
local clone = evo.clone

local prefab = evo.spawn { [RF1] = true }
evo.remove(prefab, F1)

for _ = 1, N do
clone(prefab)
Expand Down Expand Up @@ -217,6 +218,7 @@ basics.describe_bench(
local clone = evo.clone

local prefab = evo.spawn { [RF123] = true }
evo.remove(prefab, F1, F2, F3)

for _ = 1, N do
clone(prefab)
Expand Down Expand Up @@ -261,6 +263,7 @@ basics.describe_bench(
local clone = evo.clone

local prefab = evo.spawn { [RF12345] = true }
evo.remove(prefab, F1, F2, F3, F4, F5)

for _ = 1, N do
clone(prefab)
Expand Down
65 changes: 65 additions & 0 deletions develop/testing/depth_tests.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
local evo = require 'evolved'

do
assert(evo.depth() == 0)

assert(evo.defer())
assert(evo.depth() == 1)

assert(not evo.defer())
assert(evo.depth() == 2)

assert(not evo.cancel())
assert(evo.depth() == 1)

assert(evo.cancel())
assert(evo.depth() == 0)
end

do
assert(evo.depth() == 0)

assert(evo.defer())
assert(evo.depth() == 1)

assert(not evo.defer())
assert(evo.depth() == 2)

assert(not evo.commit())
assert(evo.depth() == 1)

assert(evo.commit())
assert(evo.depth() == 0)
end

do
assert(evo.depth() == 0)

assert(evo.defer())
assert(evo.depth() == 1)

assert(not evo.defer())
assert(evo.depth() == 2)

assert(not evo.cancel())
assert(evo.depth() == 1)

assert(evo.commit())
assert(evo.depth() == 0)
end

do
assert(evo.depth() == 0)

assert(evo.defer())
assert(evo.depth() == 1)

assert(not evo.defer())
assert(evo.depth() == 2)

assert(not evo.commit())
assert(evo.depth() == 1)

assert(evo.cancel())
assert(evo.depth() == 0)
end
Loading
Loading