summaryrefslogtreecommitdiff
path: root/server/src/emmy/manager.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/emmy/manager.lua')
-rw-r--r--server/src/emmy/manager.lua26
1 files changed, 24 insertions, 2 deletions
diff --git a/server/src/emmy/manager.lua b/server/src/emmy/manager.lua
index 99b46420..a3de42df 100644
--- a/server/src/emmy/manager.lua
+++ b/server/src/emmy/manager.lua
@@ -1,5 +1,6 @@
local listMgr = require 'vm.list'
local newClass = require 'emmy.class'
+local newType = require 'emmy.type'
local mt = {}
mt.__index = mt
@@ -26,7 +27,7 @@ function mt:flushClass(name)
list.version = version
end
-function mt:eachClass(name, callback)
+function mt:eachClassByName(name, callback)
self:flushClass(name)
local list = self._class[name]
if not list then
@@ -42,6 +43,22 @@ function mt:eachClass(name, callback)
end
end
+function mt:eachClass(...)
+ local n = select('#', ...)
+ if n == 1 then
+ local callback = ...
+ for name in pairs(self._class) do
+ local res = self:eachClassByName(name, callback)
+ if res ~= nil then
+ return res
+ end
+ end
+ else
+ local name, callback = ...
+ return self:eachClassByName(name, callback)
+ end
+end
+
function mt:addClass(source)
local className = source[1][1]
self:flushClass(className)
@@ -53,14 +70,19 @@ function mt:addClass(source)
}
self._class[className] = list
end
- list[source.id] = newClass(source)
+ list[source.id] = newClass(self, source)
return list[source.id]
end
+function mt:createType(source)
+ return newType(self, source)
+end
+
function mt:remove()
end
return function ()
+ ---@class emmyMgr
local self = setmetatable({
_class = {},
}, mt)