mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
cpp2ffi and generator: add parser:take_lines and use it
This commit is contained in:
@@ -936,6 +936,18 @@ function M.Parser()
|
|||||||
function par.get_manuals(def)
|
function par.get_manuals(def)
|
||||||
return par.manuals[def.ov_cimguiname] or par.manuals[def.cimguiname]
|
return par.manuals[def.ov_cimguiname] or par.manuals[def.cimguiname]
|
||||||
end
|
end
|
||||||
|
function par:take_lines(cmd_line,names,compiler)
|
||||||
|
local pipe,err = io.popen(cmd_line,"r")
|
||||||
|
if not pipe then
|
||||||
|
error("could not execute COMPILER "..err)
|
||||||
|
end
|
||||||
|
local defines = {}
|
||||||
|
for line,loca,loca2 in M.location(pipe,names,defines,compiler) do
|
||||||
|
self:insert(line, tostring(loca)..":"..tostring(loca2))
|
||||||
|
end
|
||||||
|
pipe:close()
|
||||||
|
return defines
|
||||||
|
end
|
||||||
function par:do_parse()
|
function par:do_parse()
|
||||||
self:parseItems()
|
self:parseItems()
|
||||||
self:gen_structs_and_enums()
|
self:gen_structs_and_enums()
|
||||||
|
@@ -367,30 +367,8 @@ 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"}
|
||||||
|
|
||||||
local pipe,err = io.popen(CPRE..header,"r")
|
local defines = parser:take_lines(CPRE..header,names,COMPILER)
|
||||||
|
|
||||||
if not pipe then
|
|
||||||
error("could not execute COMPILER "..err)
|
|
||||||
end
|
|
||||||
|
|
||||||
local iterator = cpp2ffi.location
|
|
||||||
|
|
||||||
--[[
|
|
||||||
local tableo = {}
|
|
||||||
local line
|
|
||||||
repeat
|
|
||||||
line =pipe:read"*l"
|
|
||||||
table.insert(tableo,line)
|
|
||||||
until not line
|
|
||||||
cpp2ffi.save_data("cdefs1.lua",table.concat(tableo,"\n"))
|
|
||||||
--]]
|
|
||||||
for line,loca,loca2 in iterator(pipe,names,{},COMPILER) do
|
|
||||||
parser:insert(line, tostring(loca)..":"..tostring(loca2))
|
|
||||||
--table.insert(tableo,line)
|
|
||||||
--print(loca,loca2)
|
|
||||||
end
|
|
||||||
--cpp2ffi.save_data("cdefs1.lua",table.concat(tableo))
|
|
||||||
pipe:close()
|
|
||||||
return parser
|
return parser
|
||||||
end
|
end
|
||||||
--generation
|
--generation
|
||||||
@@ -465,19 +443,8 @@ if #implementations > 0 then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local pipe,err = io.popen(CPRE..extra_defines..extra_includes..source,"r")
|
local defines = parser2:take_lines(CPRE..extra_defines..extra_includes..source, {locati}, COMPILER)
|
||||||
|
|
||||||
if not pipe then
|
|
||||||
error("could not get file: "..err)
|
|
||||||
end
|
|
||||||
|
|
||||||
local iterator = cpp2ffi.location
|
|
||||||
|
|
||||||
for line,locat,linenum in iterator(pipe,{locati},{},COMPILER) do
|
|
||||||
--local line, comment = split_comment(line)
|
|
||||||
parser2:insert(line,tostring(locat)..":"..tostring(linenum))
|
|
||||||
end
|
|
||||||
pipe:close()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
parser2:do_parse()
|
parser2:do_parse()
|
||||||
|
Reference in New Issue
Block a user