q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=066a2f9fd7e886ce25f36857217c8bccb1f93aff
commit 066a2f9fd7e886ce25f36857217c8bccb1f93aff Author: Daniel Kolesa <[email protected]> Date: Wed Aug 17 13:34:20 2016 +0100 docs: move type cstr retrieval to doctree --- src/scripts/elua/apps/docgen/doctree.lua | 13 +++++++++++++ src/scripts/elua/apps/docgen/serializers.lua | 17 ++--------------- src/scripts/elua/apps/gendoc.lua | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/scripts/elua/apps/docgen/doctree.lua b/src/scripts/elua/apps/docgen/doctree.lua index 5a7077a..ef412fa 100644 --- a/src/scripts/elua/apps/docgen/doctree.lua +++ b/src/scripts/elua/apps/docgen/doctree.lua @@ -670,6 +670,19 @@ M.Type = Node:clone { end } +M.type_cstr_get = function(tp, suffix) + tp = tp or "void" + local ct = (type(tp) == "string") and tp or tp:c_type_get() + if not suffix then + return ct + end + if ct:sub(#ct) == "*" then + return ct .. suffix + else + return ct .. " " .. suffix + end +end + M.Typedecl = Node:clone { UNKNOWN = eolian.typedecl_type.UNKNOWN, STRUCT = eolian.typedecl_type.STRUCT, diff --git a/src/scripts/elua/apps/docgen/serializers.lua b/src/scripts/elua/apps/docgen/serializers.lua index b480a50..c82de93 100644 --- a/src/scripts/elua/apps/docgen/serializers.lua +++ b/src/scripts/elua/apps/docgen/serializers.lua @@ -3,19 +3,6 @@ local dtree = require("docgen.doctree") local M = {} -M.get_ctype_str = function(tp, suffix) - tp = tp or "void" - local ct = (type(tp) == "string") and tp or tp:c_type_get() - if not suffix then - return ct - end - if ct:sub(#ct) == "*" then - return ct .. suffix - else - return ct .. " " .. suffix - end -end - local wrap_type_attrs = function(tp, str) if tp:is_const() then str = "const(" .. str .. ")" @@ -170,7 +157,7 @@ M.get_typedecl_cstr = function(tp) buf[#buf + 1] = " {\n" for i, fld in ipairs(fields) do buf[#buf + 1] = " " - buf[#buf + 1] = M.get_ctype_str(fld:type_get(), fld:name_get()) + buf[#buf + 1] = dtree.type_cstr_get(fld:type_get(), fld:name_get()) buf[#buf + 1] = ";\n" end buf[#buf + 1] = "} " .. fulln .. ";" @@ -212,7 +199,7 @@ M.get_typedecl_cstr = function(tp) elseif tpt == dtree.Typedecl.ALIAS then local fulln = tp:full_name_get():gsub("%.", "_"); keyref.add(fulln, "c") - return "typedef " .. M.get_ctype_str(tp:base_type_get(), fulln) .. ";" + return "typedef " .. dtree.type_cstr_get(tp:base_type_get(), fulln) .. ";" end error("unhandled typedecl type: " .. tpt) end diff --git a/src/scripts/elua/apps/gendoc.lua b/src/scripts/elua/apps/gendoc.lua index 9b619e4..9755e71 100644 --- a/src/scripts/elua/apps/gendoc.lua +++ b/src/scripts/elua/apps/gendoc.lua @@ -20,16 +20,16 @@ local gen_cparam = function(par, out) out = out or (par:direction_get() == par.OUT) local tstr = part:c_type_get() if out then - tstr = ser.get_ctype_str(tstr, "*") + tstr = dtree.type_cstr_get(tstr, "*") end - return ser.get_ctype_str(tstr, par:name_get()) + return dtree.type_cstr_get(tstr, par:name_get()) end local get_func_csig_part = function(cn, tp) if not tp then return "void " .. cn end - return ser.get_ctype_str(tp, cn) + return dtree.type_cstr_get(tp, cn) end local gen_func_csig = function(f, ftype) @@ -1035,7 +1035,7 @@ build_event = function(ev, cl) f:write_h("C signature", 3) local cn = ev:c_name_get() keyref.add(cn, "c") - f:write_code(ser.get_ctype_str(etp, cn) .. ";", "c") + f:write_code(dtree.type_cstr_get(etp, cn) .. ";", "c") f:write_nl() f:write_h("Description", 3) --
