cpp2ffi: add COMPILER argument to location iterator

This commit is contained in:
sonoro1234
2020-01-23 12:15:14 +01:00
parent fa9538889b
commit 677678af07
2 changed files with 13 additions and 3 deletions

View File

@@ -1290,7 +1290,7 @@ M.serializeTableF = function(t)
return M.serializeTable("defs",t).."\nreturn defs"
end
--iterates lines from a gcc/clang -E in a specific location
local function location(file,locpathT,defines)
local function location(file,locpathT,defines,COMPILER)
local define_re = "^#define%s+([^%s]+)%s+([^%s]+)$"
local number_re = "^-?[0-9]+u*$"
local hex_re = "0x[0-9a-fA-F]+u*$"
@@ -1300,6 +1300,7 @@ local function location(file,locpathT,defines)
else --gcc, clang
location_re = '^# (%d+) "([^"]*)"'
end
local path_reT = {}
for i,locpath in ipairs(locpathT) do
table.insert(path_reT,'^.*[\\/]('..locpath..')%.h$')
@@ -1325,6 +1326,7 @@ local function location(file,locpathT,defines)
if #line==0 then --nothing on emptyline
elseif not line:match("%S") then --nothing if only spaces
elseif line:sub(1,1) == "#" then
--elseif line:match"^%s*#" then
-- Is this a location pragma?
local loc_num_t,location_match = line:match(location_re)
if location_match then

View File

@@ -553,7 +553,15 @@ local function parseImGuiHeader(header,names)
local iterator = (HAVE_COMPILER and cpp2ffi.location) or filelines
local tableo = {}
for line,loca,loca2 in iterator(pipe,names,{}) do
--[[
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)
--table.insert(tableo,line)
--print(loca,loca2)
@@ -719,7 +727,7 @@ if #implementations > 0 then
local iterator = (HAVE_COMPILER and cpp2ffi.location) or filelines
for line,locat in iterator(pipe,{locati},{}) do
for line,locat in iterator(pipe,{locati},{},COMPILER) do
--local line, comment = split_comment(line)
parser2:insert(line)
end