new generator move embeded_structs detection to gen_structs_and_enums

This commit is contained in:
Victor Bombi
2020-09-03 20:25:38 +02:00
parent 8ba8ced1f5
commit 8fee1a6fe7

View File

@@ -958,10 +958,7 @@ function M.Parser()
if itnsp.re_name == "function_re" or itnsp.re_name == "functionD_re" then if itnsp.re_name == "function_re" or itnsp.re_name == "functionD_re" then
self:parseFunction(stname,itnsp.item,nil,itnsp.locat) self:parseFunction(stname,itnsp.item,nil,itnsp.locat)
elseif itnsp.re_name == "struct_re" then elseif itnsp.re_name == "struct_re" then
--get embeded_structs
local embededst = itnsp.item:match("struct%s+(%S+)") local embededst = itnsp.item:match("struct%s+(%S+)")
self.embeded_structs[embededst] = stname.."::"..embededst
print("embeded_structs",embededst)
local itemsemarr = itnsp.childs local itemsemarr = itnsp.childs
--assert(not itemsem.struct_re,"two level embed struct") --assert(not itemsem.struct_re,"two level embed struct")
for iemb,itemb in ipairs(itemsemarr) do for iemb,itemb in ipairs(itemsemarr) do
@@ -1082,9 +1079,15 @@ function M.Parser()
if not structname then print("NO NAME",cleanst,it.item) end if not structname then print("NO NAME",cleanst,it.item) end
--if not void stname or templated --if not void stname or templated
if structname and not self.typenames[structname] then if structname and not self.typenames[structname] then
table.insert(outtab,cleanst) table.insert(outtab,cleanst)
table.insert(typedefs_table,"typedef struct "..structname.." "..structname..";\n") table.insert(typedefs_table,"typedef struct "..structname.." "..structname..";\n")
self.typedefs_dict[structname]="struct "..structname self.typedefs_dict[structname]="struct "..structname
end
if it.parent and it.parent.re_name == "struct_re" then
--TODO nesting more levels and namespace
local stname = it.parent.item:match("struct%s+(%S+)")
local embededst = it.item:match("struct%s+(%S+)")
self.embeded_structs[embededst] = stname.."::"..embededst
end end
elseif it.re_name == "namespace_re" or it.re_name == "union_re" or it.re_name == "functype_re" then elseif it.re_name == "namespace_re" or it.re_name == "union_re" or it.re_name == "functype_re" then
--nop --nop