mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
cpp2ffi and generator: delete bad comments on functionD_re, repair split_comment
This commit is contained in:
@@ -116,7 +116,7 @@ end
|
|||||||
M.strsplit = strsplit
|
M.strsplit = strsplit
|
||||||
local function split_comment(line)
|
local function split_comment(line)
|
||||||
local comment = line:match("(%s*//.*)") --or ""
|
local comment = line:match("(%s*//.*)") --or ""
|
||||||
line = line:gsub("%s*//.*","")
|
line = line:gsub("%s*//[^\n]*","")
|
||||||
line = line:gsub("%s*$","")
|
line = line:gsub("%s*$","")
|
||||||
return line,comment
|
return line,comment
|
||||||
end
|
end
|
||||||
@@ -611,6 +611,7 @@ local function clean_functypedef(line)
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
local function parseFunction(self,stname,itt,namespace,locat)
|
local function parseFunction(self,stname,itt,namespace,locat)
|
||||||
|
|
||||||
local lineorig,comment = split_comment(itt.item)
|
local lineorig,comment = split_comment(itt.item)
|
||||||
line = clean_spaces(lineorig)
|
line = clean_spaces(lineorig)
|
||||||
--move *
|
--move *
|
||||||
@@ -1130,6 +1131,9 @@ function M.Parser()
|
|||||||
return par.skipped[def.ov_cimguiname] or par.skipped[def.cimguiname]
|
return par.skipped[def.ov_cimguiname] or par.skipped[def.cimguiname]
|
||||||
end
|
end
|
||||||
function par:take_lines(cmd_line,names,compiler)
|
function par:take_lines(cmd_line,names,compiler)
|
||||||
|
if self.COMMENTS_GENERATION then
|
||||||
|
cmd_line = cmd_line .. (compiler=="cl" and " /C " or " -C ")
|
||||||
|
end
|
||||||
local pipe,err = io.popen(cmd_line,"r")
|
local pipe,err = io.popen(cmd_line,"r")
|
||||||
if not pipe then
|
if not pipe then
|
||||||
error("could not execute COMPILER "..err)
|
error("could not execute COMPILER "..err)
|
||||||
@@ -1246,7 +1250,34 @@ function M.Parser()
|
|||||||
table.insert(cdefs2,cdef[1])
|
table.insert(cdefs2,cdef[1])
|
||||||
end
|
end
|
||||||
local txt = table.concat(cdefs2,"\n")
|
local txt = table.concat(cdefs2,"\n")
|
||||||
|
--clean bad positioned comments inside functionD_re
|
||||||
|
if self.COMMENTS_GENERATION then
|
||||||
|
print"cleaning comments inside functionD_re--------------"
|
||||||
|
---[[
|
||||||
|
local nn = 0
|
||||||
|
local txtclean = {}
|
||||||
|
local reg = "(\n[%w%s]-[%w]+%s*%b())(%s*//[^\n]*)([\n%s%w]*%b{}%s-;*)"
|
||||||
|
--reg = "^([^;{}]-%b()[\n%s%w]*%b{}%s-;*)"
|
||||||
|
local ini = 1
|
||||||
|
local i,e,a,b,c = txt:find(reg,ini)
|
||||||
|
while i do
|
||||||
|
print(i,e,#txt)
|
||||||
|
table.insert(txtclean,txt:sub(ini,i-1))
|
||||||
|
table.insert(txtclean,a)
|
||||||
|
print("a:",a)
|
||||||
|
print("b:",b)
|
||||||
|
print("c:",c)
|
||||||
|
c = c:gsub("(%s*//[^\n]*)","")
|
||||||
|
table.insert(txtclean,c)
|
||||||
|
nn = nn + 1
|
||||||
|
ini = e + 1
|
||||||
|
i,e,a,b,c = txt:find(reg,ini)
|
||||||
|
end
|
||||||
|
table.insert(txtclean,txt:sub(ini))
|
||||||
|
print("end cleaning ------------------------------",nn)
|
||||||
|
txt = table.concat(txtclean)
|
||||||
|
end
|
||||||
|
--]]
|
||||||
self.itemsarr = par:parseItemsR2(txt)
|
self.itemsarr = par:parseItemsR2(txt)
|
||||||
itemsarr = self.itemsarr
|
itemsarr = self.itemsarr
|
||||||
end
|
end
|
||||||
|
@@ -15,8 +15,8 @@ set PATH=%PATH%;C:\anima;C:\mingws\i686-7.2.0-release-posix-dwarf-rt_v5-rev1\min
|
|||||||
:: set PATH=%PATH%;C:\luaGL\sources\luajit-master\luajit-master\bin\mingw32;C:\mingw32\bin;
|
:: set PATH=%PATH%;C:\luaGL\sources\luajit-master\luajit-master\bin\mingw32;C:\mingw32\bin;
|
||||||
::process files
|
::process files
|
||||||
:: arg[1] compiler name gcc, clang or cl
|
:: arg[1] compiler name gcc, clang or cl
|
||||||
:: arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation
|
:: arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation, comments for comments generation
|
||||||
:: examples: "" "internal" "internal freetype"
|
:: examples: "" "internal" "internal freetype comments"
|
||||||
:: arg[3..n] name of implementations to generate and/or CFLAGS (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
|
:: arg[3..n] name of implementations to generate and/or CFLAGS (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
|
||||||
luajit ./generator.lua gcc "internal" glfw opengl3 opengl2 sdl
|
luajit ./generator.lua gcc "internal" glfw opengl3 opengl2 sdl
|
||||||
|
|
||||||
|
@@ -32,10 +32,10 @@ if FREETYPE_GENERATION then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if COMPILER == "gcc" or COMPILER == "clang" then
|
if COMPILER == "gcc" or COMPILER == "clang" then
|
||||||
CPRE = COMPILER..(COMMENTS_GENERATION and " -C " or "")..[[ -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]] .. CFLAGS
|
CPRE = COMPILER..[[ -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]] .. CFLAGS
|
||||||
CTEST = COMPILER.." --version"
|
CTEST = COMPILER.." --version"
|
||||||
elseif COMPILER == "cl" then
|
elseif COMPILER == "cl" then
|
||||||
CPRE = COMPILER..(COMMENTS_GENERATION and " /C " or "")..[[ /E /DIMGUI_DISABLE_OBSOLETE_FUNCTIONS /DIMGUI_DEBUG_PARANOID /DIMGUI_API="" /DIMGUI_IMPL_API="" ]] .. CFLAGS
|
CPRE = COMPILER..[[ /E /DIMGUI_DISABLE_OBSOLETE_FUNCTIONS /DIMGUI_DEBUG_PARANOID /DIMGUI_API="" /DIMGUI_IMPL_API="" ]] .. CFLAGS
|
||||||
CTEST = COMPILER
|
CTEST = COMPILER
|
||||||
else
|
else
|
||||||
print("Working without compiler ")
|
print("Working without compiler ")
|
||||||
@@ -352,7 +352,7 @@ local function parseImGuiHeader(header,names)
|
|||||||
parser.manuals = cimgui_manuals
|
parser.manuals = cimgui_manuals
|
||||||
parser.UDTs = {"ImVec2","ImVec4","ImColor","ImRect"}
|
parser.UDTs = {"ImVec2","ImVec4","ImColor","ImRect"}
|
||||||
--parser.gen_template_typedef = gen_template_typedef --use auto
|
--parser.gen_template_typedef = gen_template_typedef --use auto
|
||||||
|
parser.COMMENTS_GENERATION = COMMENTS_GENERATION
|
||||||
local defines = parser:take_lines(CPRE..header,names,COMPILER)
|
local defines = parser:take_lines(CPRE..header,names,COMPILER)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
Reference in New Issue
Block a user