mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
cpp2ffi: simplify gen_template_typedef
This commit is contained in:
@@ -1629,7 +1629,7 @@ function M.Parser()
|
||||
for j=3,#strtab-1 do
|
||||
self:parse_struct_line(strtab[j],self.templated_structs[structname],comstab[j])
|
||||
end
|
||||
M.prtable(self.templated_structs[structname])
|
||||
--M.prtable(self.templated_structs[structname])
|
||||
else
|
||||
print("skipped unnamed struct",structname)
|
||||
end
|
||||
@@ -1848,6 +1848,15 @@ function M.Parser()
|
||||
table.insert(self.funcdefs,v)
|
||||
end
|
||||
end
|
||||
function par:gentemplatetypedef(ttype,te,newte)
|
||||
--print("gentemplatetypedef",ttype,te,newte)
|
||||
if not newte then return "" end
|
||||
self.templates_done = self.templates_done or {}
|
||||
self.templates_done[ttype] = self.templates_done[ttype] or {}
|
||||
if self.templates_done[ttype][te] then return "" end
|
||||
self.templates_done[ttype][te] = true
|
||||
return self:gen_template_typedef(ttype,te,newte) --given by user
|
||||
end
|
||||
return par
|
||||
end
|
||||
|
||||
|
@@ -250,14 +250,8 @@ end
|
||||
|
||||
----------custom ImVector templates
|
||||
local table_do_sorted = cpp2ffi.table_do_sorted
|
||||
local function gentemplatetypedef(self,ttype,te,newte)
|
||||
local function gen_template_typedef(self,ttype,te,newte)
|
||||
local code = {}
|
||||
--print("gentemplatetypedef",ttype,te,newte)
|
||||
if not newte then return "" end
|
||||
self.templates_done = self.templates_done or {}
|
||||
self.templates_done[ttype] = self.templates_done[ttype] or {}
|
||||
if self.templates_done[ttype][te] then return "" end
|
||||
self.templates_done[ttype][te] = true
|
||||
if ttype == "ImVector" then
|
||||
table.insert(code,"typedef struct ImVector_"..newte.." {int Size;int Capacity;"..te.."* Data;} ImVector_"..newte..";\n")
|
||||
elseif ttype == "ImPool" then
|
||||
@@ -379,7 +373,7 @@ local function parseImGuiHeader(header,names)
|
||||
parser.cname_overloads = cimgui_overloads
|
||||
parser.manuals = cimgui_manuals
|
||||
parser.UDTs = {"ImVec2","ImVec4","ImColor","ImRect"}
|
||||
parser.gentemplatetypedef = gentemplatetypedef
|
||||
parser.gen_template_typedef = gen_template_typedef
|
||||
|
||||
local defines = parser:take_lines(CPRE..header,names,COMPILER)
|
||||
|
||||
|
Reference in New Issue
Block a user