From 9c18872bc69a713c038eb9626d42a81615b80d97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 14 Oct 2019 21:03:49 +0800 Subject: =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/core/field.lua | 34 ++++++++++++---------------------- server-beta/src/core/getfield.lua | 26 ++++++++++---------------- server-beta/src/core/getindex.lua | 26 ++++++++++---------------- server-beta/src/core/getmethod.lua | 26 ++++++++++---------------- server-beta/src/core/method.lua | 4 ++++ server-beta/src/core/setfield.lua | 26 ++++++++++---------------- server-beta/src/core/setindex.lua | 26 ++++++++++---------------- server-beta/src/core/setmethod.lua | 26 ++++++++++---------------- 8 files changed, 76 insertions(+), 118 deletions(-) (limited to 'server-beta/src') diff --git a/server-beta/src/core/field.lua b/server-beta/src/core/field.lua index 4d48bd93..e1e67c08 100644 --- a/server-beta/src/core/field.lua +++ b/server-beta/src/core/field.lua @@ -5,32 +5,22 @@ local m = {} function m:def(source, callback) local parent = source.parent - if parent.type == 'setfield' or parent.type == 'getfield' then - local node = parent.node - local key = guide.getKeyName(source) - self:eachField(node, key, function (src, mode) - if mode == 'set' then - callback(src, mode) - end - end) - elseif parent.type == 'tablefield' then - self:eachDef(parent.value, callback) - end + local key = guide.getKeyName(source) + self:eachField(parent, key, function (src, mode) + if mode == 'set' then + callback(src, mode) + end + end) end function m:ref(source, callback) local parent = source.parent - if parent.type == 'setfield' or parent.type == 'getfield' then - local node = parent.node - local key = guide.getKeyName(source) - self:eachField(node, key, function (src, mode) - if mode == 'set' or mode == 'get' then - callback(src, mode) - end - end) - elseif parent.type == 'tablefield' then - self:eachDef(parent.value, callback) - end + local key = guide.getKeyName(source) + self:eachField(parent, key, function (src, mode) + if mode == 'set' or mode == 'set' then + callback(src, mode) + end + end) end function m:field(source, key, callback) diff --git a/server-beta/src/core/getfield.lua b/server-beta/src/core/getfield.lua index 69c8a675..c76df24e 100644 --- a/server-beta/src/core/getfield.lua +++ b/server-beta/src/core/getfield.lua @@ -16,33 +16,27 @@ function m:field(source, key, callback) callback(source.field, 'get') end - self:eachField(node, myKey, function (src, mode) + self:eachField(node, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) self:eachValue(node, function (src) - self:eachField(src, myKey, function (src, mode) + self:eachField(src, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) end) diff --git a/server-beta/src/core/getindex.lua b/server-beta/src/core/getindex.lua index d66d06fe..28706589 100644 --- a/server-beta/src/core/getindex.lua +++ b/server-beta/src/core/getindex.lua @@ -16,33 +16,27 @@ function m:field(source, key, callback) callback(source.index, 'set') end - self:eachField(node, myKey, function (src, mode) + self:eachField(node, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) self:eachValue(node, function (src) - self:eachField(src, myKey, function (src, mode) + self:eachField(src, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) end) diff --git a/server-beta/src/core/getmethod.lua b/server-beta/src/core/getmethod.lua index fd5855c1..b743d384 100644 --- a/server-beta/src/core/getmethod.lua +++ b/server-beta/src/core/getmethod.lua @@ -16,33 +16,27 @@ function m:field(source, key, callback) callback(source.method, 'get') end - self:eachField(node, myKey, function (src, mode) + self:eachField(node, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) self:eachValue(node, function (src) - self:eachField(src, myKey, function (src, mode) + self:eachField(src, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) end) diff --git a/server-beta/src/core/method.lua b/server-beta/src/core/method.lua index 071e231a..c8ea61e1 100644 --- a/server-beta/src/core/method.lua +++ b/server-beta/src/core/method.lua @@ -22,6 +22,10 @@ function m:ref(source, callback) end) end +function m:field(source, key, callback) + self:eachField(source.parent, key, callback) +end + function m:value(source, callback) local parent = source.parent if parent.type == 'setmethod' then diff --git a/server-beta/src/core/setfield.lua b/server-beta/src/core/setfield.lua index 356b5eee..a9f76280 100644 --- a/server-beta/src/core/setfield.lua +++ b/server-beta/src/core/setfield.lua @@ -16,33 +16,27 @@ function m:field(source, key, callback) callback(source.field, 'set') end - self:eachField(node, myKey, function (src, mode) + self:eachField(node, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) self:eachValue(node, function (src) - self:eachField(src, myKey, function (src, mode) + self:eachField(src, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) end) diff --git a/server-beta/src/core/setindex.lua b/server-beta/src/core/setindex.lua index 895d48f5..87fe18de 100644 --- a/server-beta/src/core/setindex.lua +++ b/server-beta/src/core/setindex.lua @@ -16,33 +16,27 @@ function m:field(source, key, callback) callback(source.index, 'get') end - self:eachField(node, myKey, function (src, mode) + self:eachField(node, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) self:eachValue(node, function (src) - self:eachField(src, myKey, function (src, mode) + self:eachField(src, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) end) diff --git a/server-beta/src/core/setmethod.lua b/server-beta/src/core/setmethod.lua index 4140c2d5..e48cd6d1 100644 --- a/server-beta/src/core/setmethod.lua +++ b/server-beta/src/core/setmethod.lua @@ -16,33 +16,27 @@ function m:field(source, key, callback) callback(source.method, 'set') end - self:eachField(node, myKey, function (src, mode) + self:eachField(node, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) self:eachValue(node, function (src) - self:eachField(src, myKey, function (src, mode) + self:eachField(src, key, function (src, mode) if used[src] then return end used[src] = true - self:eachField(src, key, function (src, mode) - used[src] = true - if mode == 'set' then - callback(src, mode) - found = true - end - end) + if mode == 'set' then + callback(src, mode) + found = true + end end) end) -- cgit v1.2.3