summaryrefslogtreecommitdiff
path: root/script/emmy/alias.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/emmy/alias.lua')
-rw-r--r--script/emmy/alias.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/script/emmy/alias.lua b/script/emmy/alias.lua
new file mode 100644
index 00000000..be47cb4f
--- /dev/null
+++ b/script/emmy/alias.lua
@@ -0,0 +1,42 @@
+local listMgr = require 'vm.list'
+
+---@class EmmyAlias
+local mt = {}
+mt.__index = mt
+mt.type = 'emmy.alias'
+
+function mt:getName()
+ return self.name
+end
+
+function mt:getSource()
+ return listMgr.get(self.source)
+end
+
+function mt:bindType(type)
+ if type then
+ self._bindType = type
+ else
+ return self._bindType
+ end
+end
+
+function mt:addEnum(enum)
+ self._enum[#self._enum+1] = enum
+end
+
+function mt:eachEnum(callback)
+ for _, enum in ipairs(self._enum) do
+ callback(enum)
+ end
+end
+
+return function (manager, source)
+ local self = setmetatable({
+ name = source[1][1],
+ source = source.id,
+ _manager = manager,
+ _enum = {},
+ }, mt)
+ return self
+end