diff --git a/generator/cpp2ffi.lua b/generator/cpp2ffi.lua index a15939a..2d0b686 100644 --- a/generator/cpp2ffi.lua +++ b/generator/cpp2ffi.lua @@ -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 diff --git a/generator/generator.lua b/generator/generator.lua index 0bc7152..6d60af0 100644 --- a/generator/generator.lua +++ b/generator/generator.lua @@ -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