diff --git a/cimgui.h b/cimgui.h index ae2dbae..ede29c1 100644 --- a/cimgui.h +++ b/cimgui.h @@ -3820,23 +3820,14 @@ typedef union SDL_Event SDL_Event; #ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS -typedef struct ImColor_c ImColor; -typedef struct ImRect_c ImRect; typedef struct ImTextureRef_c ImTextureRef; typedef struct ImVec2_c ImVec2; typedef struct ImVec2i_c ImVec2i; typedef struct ImVec4_c ImVec4; +typedef struct ImColor_c ImColor; +typedef struct ImRect_c ImRect; #endif #ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS -typedef struct ImColor_c ImColor_c; -struct ImColor_c { - ImVec4 Value; -}; -typedef struct ImRect_c ImRect_c; -struct ImRect_c { - ImVec2 Min; - ImVec2 Max; -}; typedef struct ImTextureRef_c ImTextureRef_c; struct ImTextureRef_c { ImTextureData* _TexData; @@ -3859,6 +3850,15 @@ struct ImVec4_c { float z; float w; }; +typedef struct ImColor_c ImColor_c; +struct ImColor_c { + ImVec4_c Value; +}; +typedef struct ImRect_c ImRect_c; +struct ImRect_c { + ImVec2_c Min; + ImVec2_c Max; +}; #endif #ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS typedef struct ImGuiTextFilter::ImGuiTextRange ImGuiTextRange; diff --git a/generator/cpp2ffi.lua b/generator/cpp2ffi.lua index 850db68..fdd1968 100644 --- a/generator/cpp2ffi.lua +++ b/generator/cpp2ffi.lua @@ -1103,22 +1103,53 @@ local function get_nonPOD(FP) FP.structs_and_enums_table.nonPOD = nonPOD return nonPOD end -M.get_nonPOD = get_nonPOD +local function recur_calc_depth(FP, structs, k,n) + local struct = structs[k] + local n1 = n + for i,field in ipairs(struct) do + local typ = field.type:gsub("const ","") + typ = typ:gsub("*","") + if FP.nP_used[typ] then + n1 = math.max(n1,recur_calc_depth(FP, structs, typ,n+1)) + end + end + return n1 +end local function gen_structs_c(FP) local structs = FP.structs_and_enums_table.structs + --sort nP_used by dependencies and name + nP_used_sorted = {} + for k,v in pairs(FP.nP_used) do + nP_used_sorted[k] = recur_calc_depth(FP, structs, k, 1) + end + --M.prtable(nP_used_sorted) + local npsorted ={} + for k,n in pairs(nP_used_sorted) do insert(npsorted,k) end + table.sort(npsorted, function(a,b) return (nP_used_sorted[a] < nP_used_sorted[b]) or ((nP_used_sorted[a] == nP_used_sorted[b]) and (a 0 then insert(tabs,1,"#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS") insert(tabs,"#endif")