cpp2ffi: add json parsing for typedef struct inside namespace (STB_TexteditState)

This commit is contained in:
Victor Bombi
2020-08-24 20:02:35 +02:00
parent c9921e9e0f
commit e2c64a1808

View File

@@ -951,6 +951,11 @@ function M.Parser()
if derived then print(stname,"derived from",derived) end
--try to get name from typedef structs
if not stname and stru:match("typedef struct") then
stname = stru:match("%b{}%s*(%S+)%s*;")
end
if not stname then
print(stru)
error"could not get stname"
@@ -1186,6 +1191,28 @@ function M.Parser()
end
end
end
--get structs in namespace
for i,it in ipairs(itemsarr) do
if it.re_name == "namespace_re" then
local nsp = it.item:match("%b{}"):sub(2,-2)
local namespace = it.item:match("namespace%s+(%S+)")
local nspparr,itemsnsp = parseItems(nsp, nil, it.locat )
for insp,itnsp in ipairs(nspparr) do
if itnsp.re_name == "struct_re" or itnsp.re_name == "typedef_st_re" then
local cleanst,structname,strtab = self:clean_struct(itnsp.item, itnsp.locat)
if structname and not self.typenames[structname] then
outtab.structs[structname] = {}
outtab.locations[structname] = itnsp.locat
self.order[structname]=i
for j=3,#strtab-1 do
self:parse_struct_line(strtab[j],outtab.structs[structname])
end
end
end
end
end
end
--inner_structs
for i,it in ipairs(self.inerstructs) do