From aa17d5ab935f3963b6a24edb77860dc4f622e31c Mon Sep 17 00:00:00 2001 From: sumneko Date: Mon, 6 May 2019 20:03:02 +0800 Subject: =?UTF-8?q?alias=E6=94=AF=E6=8C=81=E5=AD=97=E9=9D=A2=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/emmy/alias.lua | 11 +++++++++++ server/src/emmy/manager.lua | 10 ++++++++++ 2 files changed, 21 insertions(+) (limited to 'server/src/emmy') diff --git a/server/src/emmy/alias.lua b/server/src/emmy/alias.lua index cec23b78..be47cb4f 100644 --- a/server/src/emmy/alias.lua +++ b/server/src/emmy/alias.lua @@ -21,11 +21,22 @@ function mt:bindType(type) 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 diff --git a/server/src/emmy/manager.lua b/server/src/emmy/manager.lua index 85f25bd1..cce1e0e4 100644 --- a/server/src/emmy/manager.lua +++ b/server/src/emmy/manager.lua @@ -128,6 +128,9 @@ function mt:addAlias(source, typeObj) aliasObj:bindType(typeObj) local list = self:getClass(aliasName) list[source.id] = aliasObj + for i = 3, #source do + aliasObj:addEnum(source[i][1]) + end return aliasObj end @@ -135,6 +138,13 @@ function mt:addParam(source, bind) local paramObj = newParam(self, source) if bind.type == 'emmy.type' then paramObj:bindType(bind) + self:eachClass(bind:getName(), function (class) + if class.type == 'emmy.alias' then + class:eachEnum(function (enum) + paramObj:addEnum(enum) + end) + end + end) elseif bind.type == 'emmy.generic' then paramObj:bindGeneric(bind) end -- cgit v1.2.3