docs: move type cstr retrieval to doctree
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Wed, 17 Aug 2016 12:34:20 +0000 (13:34 +0100)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Wed, 17 Aug 2016 12:34:20 +0000 (13:34 +0100)
src/scripts/elua/apps/docgen/doctree.lua
src/scripts/elua/apps/docgen/serializers.lua
src/scripts/elua/apps/gendoc.lua

index 5a7077a..ef412fa 100644 (file)
@@ -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,
index b480a50..c82de93 100644 (file)
@@ -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
index 9b619e4..9755e71 100644 (file)
@@ -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)