comments to 10 multiples in structs and typedefs to begining

This commit is contained in:
sonoro1234
2018-06-15 17:54:19 +02:00
parent 102fb84147
commit 33489bbd79
2 changed files with 727 additions and 721 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -110,7 +110,10 @@ local function clean_spaces(cad)
cad = cad:gsub("%s*([%(%),=])%s*","%1") --not spaces with ( , ) cad = cad:gsub("%s*([%(%),=])%s*","%1") --not spaces with ( , )
return cad return cad
end end
local function split_comment(line)
local comment = line:match("(%s*//.*)") or ""
return line:gsub("%s*//.*",""),comment
end
local function get_manuals(def) local function get_manuals(def)
return cimgui_manuals[def.ov_cimguiname] or cimgui_manuals[def.cimguiname] return cimgui_manuals[def.ov_cimguiname] or cimgui_manuals[def.cimguiname]
end end
@@ -143,12 +146,11 @@ local function struct_parser()
--drop initial comments --drop initial comments
if line:match(initial_comment_re) then if line:match(initial_comment_re) then
--print("coment:",line)
return return
end end
local linecommented = line local line,comment = split_comment(line)
line = line:gsub("%s*//.*","") --local linecommented = line
--if in_function discard --if in_function discard
if in_functionst then if in_functionst then
@@ -174,9 +176,9 @@ local function struct_parser()
elseif line:match("public:") then elseif line:match("public:") then
--nothing --nothing
else else
local linea = linecommented:gsub("%S+",{class="struct",mutable=""}) local linea = line:gsub("%S+",{class="struct",mutable=""})
linea = linea:gsub("(%b<>)","/%*%1%*/") --comment template parameters linea = linea:gsub("(%b<>)","/%*%1%*/") --comment template parameters
table.insert(structcdefs,linea) table.insert(structcdefs,linea..comment)
--]] --]]
end end
return return
@@ -442,7 +444,7 @@ local function gen_structs_and_enums(cdefs)
local struct_op_close_re = "%b{}" local struct_op_close_re = "%b{}"
local structnames = {} local structnames = {}
local innerstructs = {} local innerstructs = {}
local typedefs_table = {}
local outtab = {} local outtab = {}
-- Output the file -- Output the file
table.insert(outtab,"/////////////// BEGIN AUTOGENERATED SEGMENT\n") table.insert(outtab,"/////////////// BEGIN AUTOGENERATED SEGMENT\n")
@@ -450,8 +452,12 @@ local function gen_structs_and_enums(cdefs)
for i,line in ipairs(cdefs) do for i,line in ipairs(cdefs) do
repeat -- simulating continue with break repeat -- simulating continue with break
local linecom = line -- separate comments from code and try to add them with same tab
line = line:gsub("%s*//.*","") local line, comment = split_comment(line)
local linelen = #line
local desired_linelen = math.max(math.ceil(linelen/10)*10,40)
local spaces_to_add = desired_linelen - linelen
local linecom = line..string.rep(" ",spaces_to_add)..comment
if line:match(namespace_re) then if line:match(namespace_re) then
in_namespace = true in_namespace = true
@@ -497,7 +503,7 @@ typedef struct ImVector ImVector;]])
table.insert(outtab,linecom.."\n") table.insert(outtab,linecom.."\n")
local struct_closed_name = line:match(struct_closed_re) local struct_closed_name = line:match(struct_closed_re)
if struct_closed_name then if struct_closed_name then
table.insert(outtab,"typedef struct "..struct_closed_name.." "..struct_closed_name..";\n") table.insert(typedefs_table,"typedef struct "..struct_closed_name.." "..struct_closed_name..";\n")
end end
end end
@@ -511,12 +517,14 @@ typedef struct ImVector ImVector;]])
st[#st + 1] = line st[#st + 1] = line
if line:match(struct_closing_re) and not line:match(struct_op_close_re) then if line:match(struct_closing_re) and not line:match(struct_op_close_re) then
local structname = structnames[#structnames] local structname = structnames[#structnames]
st[#st + 1] = string.format("typedef struct %s %s;\n",structname,structname) --st[#st + 1] = string.format("typedef struct %s %s;\n",structname,structname)
table.insert(typedefs_table,string.format("typedef struct %s %s;\n",structname,structname))
structnames[#structnames] = nil structnames[#structnames] = nil
end end
elseif line:match(struct_closing_re) and not line:match(struct_op_close_re) then elseif line:match(struct_closing_re) and not line:match(struct_op_close_re) then
local structname = structnames[#structnames] local structname = structnames[#structnames]
table.insert(outtab,"typedef struct "..structname.." "..structname..";\n") --table.insert(outtab,"typedef struct "..structname.." "..structname..";\n")
table.insert(typedefs_table,"typedef struct "..structname.." "..structname..";\n")
structnames[#structnames] = nil structnames[#structnames] = nil
end end
end end
@@ -529,9 +537,11 @@ typedef struct ImVector ImVector;]])
table.insert(outtab,line.."\n") table.insert(outtab,line.."\n")
end end
end end
--table.insert(outtab,"#endif //IMGUI_STRUCTS_INCLUDED\n")
table.insert(outtab,"//////////////// END AUTOGENERATED SEGMENT \n") table.insert(outtab,"//////////////// END AUTOGENERATED SEGMENT \n")
--hfile:close() for i,l in ipairs(typedefs_table) do
table.insert(outtab,2,l)
end
return outtab return outtab
end end