mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
cpp2ffi: take care of template different of typename, generator: ImSpan template generation
This commit is contained in:
@@ -1017,12 +1017,16 @@ function M.Parser()
|
|||||||
child.parent = it
|
child.parent = it
|
||||||
end
|
end
|
||||||
if it.re_name == "struct_re" then
|
if it.re_name == "struct_re" then
|
||||||
local typename = it.item:match("%s*template%s*<%s*typename%s*(%S+)%s*>")
|
local typename = it.item:match("^%s*template%s*<%s*typename%s*(%S+)%s*>")
|
||||||
local stname = it.item:match("struct%s+(%S+)")
|
local stname = it.item:match("struct%s+(%S+)")
|
||||||
it.name = stname
|
it.name = stname
|
||||||
if typename then -- it is a struct template
|
|
||||||
|
local templa1,templa2 = it.item:match("^%s*template%s*<%s*(%S+)%s*(%S+)%s*>")
|
||||||
|
if templa1 or templa2 then print("template found",stname,templa1,templa2,"typename",typename) end
|
||||||
|
|
||||||
|
if typename or templa2 then -- it is a struct template
|
||||||
self.typenames = self.typenames or {}
|
self.typenames = self.typenames or {}
|
||||||
self.typenames[stname] = typename
|
self.typenames[stname] = typename or templa2
|
||||||
end
|
end
|
||||||
elseif it.re_name == "namespace_re" then
|
elseif it.re_name == "namespace_re" then
|
||||||
it.name = it.item:match("namespace%s+(%S+)")
|
it.name = it.item:match("namespace%s+(%S+)")
|
||||||
@@ -1414,7 +1418,11 @@ function M.Parser()
|
|||||||
f()
|
f()
|
||||||
t.size = estevalor
|
t.size = estevalor
|
||||||
end
|
end
|
||||||
assert(t.size,val)
|
--assert(t.size,val)
|
||||||
|
if not t.size then
|
||||||
|
print("not t.size for",val,"in",t.name)
|
||||||
|
error"not t.size"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -244,6 +244,13 @@ local function generate_templates(code,codeimpool,templates)
|
|||||||
table.insert(code,"typedef struct ImVector_"..newte.." {int Size;int Capacity;"..te.."* Data;} ImVector_"..newte..";\n")
|
table.insert(code,"typedef struct ImVector_"..newte.." {int Size;int Capacity;"..te.."* Data;} ImVector_"..newte..";\n")
|
||||||
table.insert(code,"typedef struct ImChunkStream_"..newte.." {ImVector_"..te.." Buf;} ImChunkStream_"..newte..";\n")
|
table.insert(code,"typedef struct ImChunkStream_"..newte.." {ImVector_"..te.." Buf;} ImChunkStream_"..newte..";\n")
|
||||||
end)
|
end)
|
||||||
|
elseif ttype == "ImSpan" then
|
||||||
|
table_do_sorted(v, function(te,newte)
|
||||||
|
table.insert(code,"typedef struct ImSpan_"..newte.." {"..te.."* Data;" ..te.."* DataEnd;} ImSpan_"..newte..";\n")
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
print("generate_templates ttype not done",ttype)
|
||||||
|
error"generate templates"
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user