From c17ee4027a2a4b3b62992c9f9b1381a80626962a Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Mon, 15 Aug 2016 13:48:13 +0100 Subject: [PATCH] docs: abstract away object scope enum --- src/scripts/elua/apps/docgen/doctree.lua | 5 +++++ src/scripts/elua/apps/gendoc.lua | 20 +++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua index 35b1ee5..f794669 100644 --- a/src/scripts/elua/apps/docgen/doctree.lua +++ b/src/scripts/elua/apps/docgen/doctree.lua @@ -10,6 +10,11 @@ local writer local M = {} local Node = util.Object:clone { + scope = { + PUBLIC = eolian.object_scope.PUBLIC, + PRIVATE = eolian.object_scope.PRIVATE, + PROTECTED = eolian.object_scope.PROTECTED + } } local gen_doc_refd = function(str) diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua index bebfac2..0cffab2 100644 --- a/src/scripts/elua/apps/gendoc.lua +++ b/src/scripts/elua/apps/gendoc.lua @@ -106,14 +106,13 @@ local gen_func_namesig = function(fn, cl, buf, isprop, isget, isset) buf[#buf + 1] = "." buf[#buf + 1] = fn:name_get() buf[#buf + 1] = " " - local obs = eolian.object_scope if not isprop then - if fn:scope_get(fn.METHOD) == obs.PROTECTED then + if fn:scope_get(fn.METHOD) == fn.scope.PROTECTED then buf[#buf + 1] = "@protected " end elseif isget and isset then - if fn:scope_get(fn.PROP_GET) == obs.PROTECTED and - fn:scope_get(fn.PROP_SET) == obs.PROTECTED then + if fn:scope_get(fn.PROP_GET) == fn.scope.PROTECTED and + fn:scope_get(fn.PROP_SET) == fn.scope.PROTECTED then buf[#buf + 1] = "@protected " end end @@ -231,7 +230,6 @@ end local gen_prop_sig = function(fn, cl) local buf = {} local fnt = fn:type_get() - local obs = eolian.object_scope local isget = (fnt == fn.PROPERTY or fnt == fn.PROP_GET) local isset = (fnt == fn.PROPERTY or fnt == fn.PROP_SET) gen_func_namesig(fn, cl, buf, true, isget, isset) @@ -257,8 +255,8 @@ local gen_prop_sig = function(fn, cl) if isget then buf[#buf + 1] = " get " - if fn:scope_get(fn.PROP_GET) == obs.PROTECTED and - fn:scope_get(fn.PROP_SET) ~= obs.PROTECTED then + if fn:scope_get(fn.PROP_GET) == fn.scope.PROTECTED and + fn:scope_get(fn.PROP_SET) ~= fn.scope.PROTECTED then buf[#buf + 1] = "@protected " end buf[#buf + 1] = "{" @@ -278,8 +276,8 @@ local gen_prop_sig = function(fn, cl) if isset then buf[#buf + 1] = " set " - if fn:scope_get(fn.PROP_SET) == obs.PROTECTED and - fn:scope_get(fn.PROP_GET) ~= obs.PROTECTED then + if fn:scope_get(fn.PROP_SET) == fn.scope.PROTECTED and + fn:scope_get(fn.PROP_GET) ~= fn.scope.PROTECTED then buf[#buf + 1] = "@protected " end buf[#buf + 1] = "{" @@ -1012,9 +1010,9 @@ build_event = function(ev, cl) f:write_h("Signature", 3) local buf = { ev:name_get() } - if ev:scope_get() == eolian.object_scope.PRIVATE then + if ev:scope_get() == ev.scope.PRIVATE then buf[#buf + 1] = " @private" - elseif ev:scope_get() == eolian.object_scope.PROTECTED then + elseif ev:scope_get() == ev.scope.PROTECTED then buf[#buf + 1] = " @protected" end -- 2.7.4