diff --git a/cimgui.h b/cimgui.h index b9b33ee..ac28f6f 100644 --- a/cimgui.h +++ b/cimgui.h @@ -240,8 +240,6 @@ typedef struct ImVector_ImDrawIdx {int Size;int Capacity;ImDrawIdx* Data;} ImVec typedef struct ImVector_unsigned_char {int Size;int Capacity;unsigned char* Data;} ImVector_unsigned_char; typedef struct ImVector_ImGuiWindowSettings {int Size;int Capacity;ImGuiWindowSettings* Data;} ImVector_ImGuiWindowSettings; typedef struct ImChunkStream_ImGuiWindowSettings {ImVector_ImGuiWindowSettings Buf;} ImChunkStream_ImGuiWindowSettings; -typedef struct ImVector_ImGuiTabBar {int Size;int Capacity;ImGuiTabBar* Data;} ImVector_ImGuiTabBar; -typedef struct ImPool_ImGuiTabBar {ImVector_ImGuiTabBar Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_ImGuiTabBar; typedef struct { @@ -822,6 +820,8 @@ struct ImGuiStorage { ImVector_ImGuiStoragePair Data; }; +typedef struct ImVector_ImGuiTabBar {int Size;int Capacity;ImGuiTabBar* Data;} ImVector_ImGuiTabBar; +typedef struct ImPool_ImGuiTabBar {ImVector_ImGuiTabBar Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_ImGuiTabBar; struct ImGuiListClipper { int DisplayStart, DisplayEnd; diff --git a/generator/generator.lua b/generator/generator.lua index 84ce28d..f236a7f 100644 --- a/generator/generator.lua +++ b/generator/generator.lua @@ -458,7 +458,7 @@ end ----------custom ImVector templates -local function generate_templates(code,templates) +local function generate_templates(code,codeimpool,templates) table.insert(code,"\n"..[[typedef struct ImVector{int Size;int Capacity;void* Data;} ImVector;]].."\n") for ttype,v in pairs(templates) do --local te = k:gsub("%s","_") @@ -470,8 +470,8 @@ local function generate_templates(code,templates) elseif ttype == "ImPool" then --declare ImGuiStorage for te,newte in pairs(v) do - table.insert(code,"typedef struct ImVector_"..newte.." {int Size;int Capacity;"..te.."* Data;} ImVector_"..newte..";\n") - table.insert(code,"typedef struct ImPool_"..newte.." {ImVector_"..te.." Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_"..newte..";\n") + table.insert(codeimpool,"typedef struct ImVector_"..newte.." {int Size;int Capacity;"..te.."* Data;} ImVector_"..newte..";\n") + table.insert(codeimpool,"typedef struct ImPool_"..newte.." {ImVector_"..te.." Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_"..newte..";\n") end elseif ttype == "ImChunkStream" then for te,newte in pairs(v) do @@ -513,9 +513,14 @@ local function cimgui_generation(parser) cpp2ffi.prtable(parser.typenames) local outtab = {} - generate_templates(outtab,parser.templates) + local outtabpool = {} + generate_templates(outtab, outtabpool, parser.templates) + + --move outtabpool after ImGuiStorage definition + local outpost1, outpost2 = outpost:match("^(.+struct ImGuiStorage%s*\n%b{};\n)(.+)$") + outpost = outpost1..table.concat(outtabpool)..outpost2 - local cstructsstr = outpre..table.concat(outtab,"")..outpost..(extra or "") + local cstructsstr = outpre..table.concat(outtab,"")..outpost --..(extra or "") hstrfile = hstrfile:gsub([[#include "imgui_structs%.h"]],cstructsstr) local cfuncsstr = func_header_generate(parser) diff --git a/generator/output/cimgui.h b/generator/output/cimgui.h index b9b33ee..ac28f6f 100644 --- a/generator/output/cimgui.h +++ b/generator/output/cimgui.h @@ -240,8 +240,6 @@ typedef struct ImVector_ImDrawIdx {int Size;int Capacity;ImDrawIdx* Data;} ImVec typedef struct ImVector_unsigned_char {int Size;int Capacity;unsigned char* Data;} ImVector_unsigned_char; typedef struct ImVector_ImGuiWindowSettings {int Size;int Capacity;ImGuiWindowSettings* Data;} ImVector_ImGuiWindowSettings; typedef struct ImChunkStream_ImGuiWindowSettings {ImVector_ImGuiWindowSettings Buf;} ImChunkStream_ImGuiWindowSettings; -typedef struct ImVector_ImGuiTabBar {int Size;int Capacity;ImGuiTabBar* Data;} ImVector_ImGuiTabBar; -typedef struct ImPool_ImGuiTabBar {ImVector_ImGuiTabBar Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_ImGuiTabBar; typedef struct { @@ -822,6 +820,8 @@ struct ImGuiStorage { ImVector_ImGuiStoragePair Data; }; +typedef struct ImVector_ImGuiTabBar {int Size;int Capacity;ImGuiTabBar* Data;} ImVector_ImGuiTabBar; +typedef struct ImPool_ImGuiTabBar {ImVector_ImGuiTabBar Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_ImGuiTabBar; struct ImGuiListClipper { int DisplayStart, DisplayEnd;