diff --git a/generator/cpp2ffi.lua b/generator/cpp2ffi.lua index 7a454d9..83b5084 100644 --- a/generator/cpp2ffi.lua +++ b/generator/cpp2ffi.lua @@ -1017,12 +1017,16 @@ function M.Parser() child.parent = it end 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+)") 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[stname] = typename + self.typenames[stname] = typename or templa2 end elseif it.re_name == "namespace_re" then it.name = it.item:match("namespace%s+(%S+)") @@ -1414,7 +1418,11 @@ function M.Parser() f() t.size = estevalor 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 diff --git a/generator/generator.lua b/generator/generator.lua index 143b210..fbcd309 100644 --- a/generator/generator.lua +++ b/generator/generator.lua @@ -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 ImChunkStream_"..newte.." {ImVector_"..te.." Buf;} ImChunkStream_"..newte..";\n") 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