diff options
| author | s-ol <s+removethis@s-ol.nu> | 2021-05-03 16:03:59 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-02 14:24:49 +0000 |
| commit | 68120c4b2cf51659c5bad85c86e9154a2586e4d6 (patch) | |
| tree | 47533a8618d94014bee1124cbf02bbcf81425479 | |
| parent | move love main.lua to alv.copilot.love.main (diff) | |
| download | alive-68120c4b2cf51659c5bad85c86e9154a2586e4d6.tar.gz alive-68120c4b2cf51659c5bad85c86e9154a2586e4d6.zip | |
allow top-level input in Op.inputs
| -rw-r--r-- | alv/base/op.moon | 25 | ||||
| -rw-r--r-- | alv/util.moon | 8 |
2 files changed, 16 insertions, 17 deletions
diff --git a/alv/base/op.moon b/alv/base/op.moon index bb48b09..8cd2854 100644 --- a/alv/base/op.moon +++ b/alv/base/op.moon @@ -140,19 +140,18 @@ class Op new: (@out, @state) => do_setup = (old, cur) -> - for k, cur_val in pairs cur - old_val = old and old[k] - - -- are these inputs or nested tables? - cur_plain = cur_val and not cur_val.__class - old_plain = old_val and not old_val.__class - - if cur_plain - -- both are tables, recurse - do_setup old_val, cur_val - elseif not (cur_plain or old_plain) - -- both are streams (or nil), setup them - cur_val\setup old_val + -- are these inputs or nested tables? + old_plain = old and not old.__class + cur_plain = cur and not cur.__class + + if cur_plain + -- both are tables, recurse + for k, cur_nest in pairs cur + do_setup (old and old[k]), cur_nest + elseif cur and not (cur_plain or old_plain) + -- both are streams (or nil), setup them + cur\setup old + --- setup previous `inputs`, if any, with the new inputs, and write them to -- `inputs`. The `inputs` table can be nested with string or integer keys, -- but all leaf-entries must be `Input` instances. It must not contain loops diff --git a/alv/util.moon b/alv/util.moon index e175600..defca70 100644 --- a/alv/util.moon +++ b/alv/util.moon @@ -50,11 +50,11 @@ deep_map = (val, fn) -> --- yield all leaf values in a table deep_iter = (table) -> - for k, v in pairs table - if is_plain_table v + if is_plain_table table + for k, v in pairs table deep_iter v - else - coroutine.yield v + else + coroutine.yield table { :opairs |
