mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
comments to 10 multiples in structs and typedefs to begining
This commit is contained in:
1408
cimgui/cimgui.h
1408
cimgui/cimgui.h
File diff suppressed because it is too large
Load Diff
@@ -110,7 +110,10 @@ local function clean_spaces(cad)
|
||||
cad = cad:gsub("%s*([%(%),=])%s*","%1") --not spaces with ( , )
|
||||
return cad
|
||||
end
|
||||
|
||||
local function split_comment(line)
|
||||
local comment = line:match("(%s*//.*)") or ""
|
||||
return line:gsub("%s*//.*",""),comment
|
||||
end
|
||||
local function get_manuals(def)
|
||||
return cimgui_manuals[def.ov_cimguiname] or cimgui_manuals[def.cimguiname]
|
||||
end
|
||||
@@ -140,15 +143,14 @@ local function struct_parser()
|
||||
local STP = {}
|
||||
STP.lines = structcdefs
|
||||
function STP.insert(line)
|
||||
|
||||
|
||||
--drop initial comments
|
||||
if line:match(initial_comment_re) then
|
||||
--print("coment:",line)
|
||||
return
|
||||
end
|
||||
|
||||
local linecommented = line
|
||||
line = line:gsub("%s*//.*","")
|
||||
local line,comment = split_comment(line)
|
||||
--local linecommented = line
|
||||
|
||||
--if in_function discard
|
||||
if in_functionst then
|
||||
@@ -174,9 +176,9 @@ local function struct_parser()
|
||||
elseif line:match("public:") then
|
||||
--nothing
|
||||
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
|
||||
table.insert(structcdefs,linea)
|
||||
table.insert(structcdefs,linea..comment)
|
||||
--]]
|
||||
end
|
||||
return
|
||||
@@ -442,7 +444,7 @@ local function gen_structs_and_enums(cdefs)
|
||||
local struct_op_close_re = "%b{}"
|
||||
local structnames = {}
|
||||
local innerstructs = {}
|
||||
|
||||
local typedefs_table = {}
|
||||
local outtab = {}
|
||||
-- Output the file
|
||||
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
|
||||
repeat -- simulating continue with break
|
||||
local linecom = line
|
||||
line = line:gsub("%s*//.*","")
|
||||
-- separate comments from code and try to add them with same tab
|
||||
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
|
||||
in_namespace = true
|
||||
@@ -497,7 +503,7 @@ typedef struct ImVector ImVector;]])
|
||||
table.insert(outtab,linecom.."\n")
|
||||
local struct_closed_name = line:match(struct_closed_re)
|
||||
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
|
||||
|
||||
@@ -511,12 +517,14 @@ typedef struct ImVector ImVector;]])
|
||||
st[#st + 1] = line
|
||||
if line:match(struct_closing_re) and not line:match(struct_op_close_re) then
|
||||
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
|
||||
end
|
||||
elseif line:match(struct_closing_re) and not line:match(struct_op_close_re) then
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -529,9 +537,11 @@ typedef struct ImVector ImVector;]])
|
||||
table.insert(outtab,line.."\n")
|
||||
end
|
||||
end
|
||||
--table.insert(outtab,"#endif //IMGUI_STRUCTS_INCLUDED\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
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user