aboutsummaryrefslogtreecommitdiffstats
path: root/alv
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2025-09-22 15:41:55 +0000
committers-ol <s+removethis@s-ol.nu>2025-09-22 15:41:55 +0000
commit5e09bd7d0801c44cff80df8755751aa0ef748eb9 (patch)
tree9fea18b18248895caa04a1a74531ad25238b5d43 /alv
parentlib/love: tsv-output preserves canvas unless name/size changed (diff)
downloadalive-5e09bd7d0801c44cff80df8755751aa0ef748eb9.tar.gz
alive-5e09bd7d0801c44cff80df8755751aa0ef748eb9.zip
global tag IDs
Diffstat (limited to 'alv')
-rw-r--r--alv/module.moon2
-rw-r--r--alv/registry.moon6
-rw-r--r--alv/tag.moon28
3 files changed, 24 insertions, 12 deletions
diff --git a/alv/module.moon b/alv/module.moon
index 6eeb10b..d3fa5e5 100644
--- a/alv/module.moon
+++ b/alv/module.moon
@@ -14,7 +14,7 @@ class Module
--- create a new Module.
-- @classmethod
new: =>
- @registry = Registry!
+ @registry = Registry @
--- check when the module source has last changed.
-- @function poll
diff --git a/alv/registry.moon b/alv/registry.moon
index b625c1f..77aae7d 100644
--- a/alv/registry.moon
+++ b/alv/registry.moon
@@ -100,12 +100,16 @@ class Registry
@last_map = {}
+ --- the module associated with this Registry
+ -- @tfield Module module
+
--- static functions
-- @section static
--- create a new Registry.
-- @classmethod
- new: =>
+ -- @tparam Module module
+ new: (@module) =>
@last_map = {}
{
diff --git a/alv/tag.moon b/alv/tag.moon
index 1ad9b28..070b0cd 100644
--- a/alv/tag.moon
+++ b/alv/tag.moon
@@ -37,6 +37,13 @@ class Tag
assert parent, "need parent to clone!"
ClonedTag @, parent
+ --- get a globally-unique identifier for this tag
+ --
+ -- prepends the module name to the tag string
+ --
+ -- @treturn string a unique string
+ ident: => "#{@registry.module\name!}:#{@}"
+
stringify: (depth=-1) => if @value and depth == -1 then "[#{@value}]" else ''
__tostring: => if @value then "#{@value}" else '?'
@@ -45,8 +52,8 @@ class Tag
new: (@value) =>
if COPILOT and "string" != type @value
- registry = COPILOT.active_module.registry
- @pending = registry\register @
+ @registry = COPILOT.active_module.registry
+ @pending = @registry\register @
--- get a unique index value for this Tag.
--
@@ -66,6 +73,12 @@ class Tag
assert either_or, "unexpected :set #{value} on #{@}"
@value = value
+ --- the Registry associated with this Tag
+ -- @tfield Registry registry
+
+ --- whether this Tag is newly assigned this tick
+ -- @tfield bool pending
+
--- static functions
-- @section static
@@ -80,8 +93,8 @@ class ClonedTag extends Tag
if 'string' == type @original.value
return
- registry = COPILOT.active_module.registry
- registry\register @
+ @registry = COPILOT.active_module.registry
+ @registry\register @
@pending = @original.pending or @parent.pending
@@ -96,12 +109,7 @@ class ClonedTag extends Tag
@original\set value
stringify: => error "cant stringify ClonedTag"
-
- __tostring: =>
- if @parent
- "#{@parent}.#{@original}"
- else
- tostring @original
+ __tostring: => "#{@parent}.#{@original}"
{
:Tag