From fedb6d334a062705ec8f34ede1aff9409da406b1 Mon Sep 17 00:00:00 2001 From: sonoro1234 Date: Mon, 3 Aug 2026 22:06:54 +0200 Subject: [PATCH] cpp2ffi: test all overloads for varargs --- cimgui.cpp | 2 +- generator/cimgui_template.cpp | 2 +- generator/cpp2ffi.lua | 32 +++++---- generator/output/definitions.json | 116 ++++++++++++++++++++++++++++++ generator/output/definitions.lua | 96 +++++++++++++++++++++++++ 5 files changed, 231 insertions(+), 17 deletions(-) diff --git a/cimgui.cpp b/cimgui.cpp index 96d8e65..2e14754 100644 --- a/cimgui.cpp +++ b/cimgui.cpp @@ -6635,7 +6635,7 @@ CIMGUI_API void ImGuiTextBuffer_appendf(ImGuiTextBuffer *self, const char *fmt, #ifdef CIMGUI_VARGS0 CIMGUI_API void ImGuiTextBuffer_appendf0(ImGuiTextBuffer *self, const char *fmt) { - ImGuiTextBuffer_appendf(self,fmd) + ImGuiTextBuffer_appendf(self,fmt) } #endif diff --git a/generator/cimgui_template.cpp b/generator/cimgui_template.cpp index da4a16f..75d67e5 100644 --- a/generator/cimgui_template.cpp +++ b/generator/cimgui_template.cpp @@ -20,7 +20,7 @@ CIMGUI_API void ImGuiTextBuffer_appendf(ImGuiTextBuffer *self, const char *fmt, #ifdef CIMGUI_VARGS0 CIMGUI_API void ImGuiTextBuffer_appendf0(ImGuiTextBuffer *self, const char *fmt) { - ImGuiTextBuffer_appendf(self,fmd) + ImGuiTextBuffer_appendf(self,fmt) } #endif diff --git a/generator/cpp2ffi.lua b/generator/cpp2ffi.lua index e690491..fbac6b2 100644 --- a/generator/cpp2ffi.lua +++ b/generator/cpp2ffi.lua @@ -1846,21 +1846,23 @@ end local function save_output(self) --add VARGS0 local defsVARG = {} - for k,def in pairs(self.defsT) do - if def[1].isvararg then - assert(#def==1,"varargs in overloads still not worked") - --print("vararg",k,#def) - local def1 = deepcopy(def[1]) - def1.isvararg = nil - def1.isVARG0 = true - def1.argsT[#def1.argsT] = nil - def1.args = paramListWithoutDots(def1.args) - def1.call_args_old = paramListWithoutDots(def1.call_args_old) - def1.call_args = paramListWithoutDots(def1.call_args) - def1.signature = paramListWithoutDots(def1.signature) - def1.cimguiname = def1.cimguiname.."0" - def1.ov_cimguiname = def1.ov_cimguiname.."0" - defsVARG[k.."0"] = {def1} + for k,defs in pairs(self.defsT) do + for i, def in ipairs(defs) do + if def.isvararg then + --print("vararg",k,#def) + local def1 = deepcopy(def) + def1.isvararg = nil + def1.isVARG0 = true + def1.argsT[#def1.argsT] = nil + def1.args = paramListWithoutDots(def1.args) + def1.call_args_old = paramListWithoutDots(def1.call_args_old) + def1.call_args = paramListWithoutDots(def1.call_args) + def1.signature = paramListWithoutDots(def1.signature) + def1.cimguiname = def1.cimguiname.."0" + def1.ov_cimguiname = def1.ov_cimguiname.."0" + defsVARG[k.."0"] = defsVARG[k.."0"] or {} + table.insert(defsVARG[k.."0"], def1) + end end end for k,def in pairs(defsVARG) do diff --git a/generator/output/definitions.json b/generator/output/definitions.json index 9325172..68185da 100644 --- a/generator/output/definitions.json +++ b/generator/output/definitions.json @@ -44651,6 +44651,60 @@ "stname": "" } ], + "igTreeNode0": [ + { + "args": "(const char* str_id,const char* fmt)", + "argsT": [ + { + "name": "str_id", + "type": "const char*" + }, + { + "name": "fmt", + "type": "const char*" + } + ], + "argsoriginal": "(const char* str_id,const char* fmt,...)", + "call_args": "(str_id,fmt)", + "call_args_old": "(str_id,fmt)", + "cimguiname": "igTreeNode0", + "defaults": {}, + "funcname": "TreeNode", + "isVARG0": true, + "location": "imgui:752", + "namespace": "ImGui", + "ov_cimguiname": "igTreeNode_StrStr0", + "ret": "bool", + "signature": "(const char*,const char*)", + "stname": "" + }, + { + "args": "(const void* ptr_id,const char* fmt)", + "argsT": [ + { + "name": "ptr_id", + "type": "const void*" + }, + { + "name": "fmt", + "type": "const char*" + } + ], + "argsoriginal": "(const void* ptr_id,const char* fmt,...)", + "call_args": "(ptr_id,fmt)", + "call_args_old": "(ptr_id,fmt)", + "cimguiname": "igTreeNode0", + "defaults": {}, + "funcname": "TreeNode", + "isVARG0": true, + "location": "imgui:753", + "namespace": "ImGui", + "ov_cimguiname": "igTreeNode_Ptr0", + "ret": "bool", + "signature": "(const void*,const char*)", + "stname": "" + } + ], "igTreeNodeBehavior": [ { "args": "(ImGuiID id,ImGuiTreeNodeFlags flags,const char* label,const char* label_end)", @@ -44831,6 +44885,68 @@ "stname": "" } ], + "igTreeNodeEx0": [ + { + "args": "(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt)", + "argsT": [ + { + "name": "str_id", + "type": "const char*" + }, + { + "name": "flags", + "type": "ImGuiTreeNodeFlags" + }, + { + "name": "fmt", + "type": "const char*" + } + ], + "argsoriginal": "(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,...)", + "call_args": "(str_id,flags,fmt)", + "call_args_old": "(str_id,flags,fmt)", + "cimguiname": "igTreeNodeEx0", + "defaults": {}, + "funcname": "TreeNodeEx", + "isVARG0": true, + "location": "imgui:757", + "namespace": "ImGui", + "ov_cimguiname": "igTreeNodeEx_StrStr0", + "ret": "bool", + "signature": "(const char*,ImGuiTreeNodeFlags,const char*)", + "stname": "" + }, + { + "args": "(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt)", + "argsT": [ + { + "name": "ptr_id", + "type": "const void*" + }, + { + "name": "flags", + "type": "ImGuiTreeNodeFlags" + }, + { + "name": "fmt", + "type": "const char*" + } + ], + "argsoriginal": "(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt,...)", + "call_args": "(ptr_id,flags,fmt)", + "call_args_old": "(ptr_id,flags,fmt)", + "cimguiname": "igTreeNodeEx0", + "defaults": {}, + "funcname": "TreeNodeEx", + "isVARG0": true, + "location": "imgui:758", + "namespace": "ImGui", + "ov_cimguiname": "igTreeNodeEx_Ptr0", + "ret": "bool", + "signature": "(const void*,ImGuiTreeNodeFlags,const char*)", + "stname": "" + } + ], "igTreeNodeExV": [ { "args": "(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,va_list args)", diff --git a/generator/output/definitions.lua b/generator/output/definitions.lua index 24b1aef..c20eb04 100644 --- a/generator/output/definitions.lua +++ b/generator/output/definitions.lua @@ -38184,6 +38184,51 @@ local t={ ["(const char*)"]=nil, ["(const char*,const char*,...)"]=nil, ["(const void*,const char*,...)"]=nil}, + igTreeNode0={ + [1]={ + args="(const char* str_id,const char* fmt)", + argsT={ + [1]={ + name="str_id", + type="const char*"}, + [2]={ + name="fmt", + type="const char*"}}, + argsoriginal="(const char* str_id,const char* fmt,...)", + call_args="(str_id,fmt)", + call_args_old="(str_id,fmt)", + cimguiname="igTreeNode0", + defaults={}, + funcname="TreeNode", + isVARG0=true, + location="imgui:752", + namespace="ImGui", + ov_cimguiname="igTreeNode_StrStr0", + ret="bool", + signature="(const char*,const char*)", + stname=""}, + [2]={ + args="(const void* ptr_id,const char* fmt)", + argsT={ + [1]={ + name="ptr_id", + type="const void*"}, + [2]={ + name="fmt", + type="const char*"}}, + argsoriginal="(const void* ptr_id,const char* fmt,...)", + call_args="(ptr_id,fmt)", + call_args_old="(ptr_id,fmt)", + cimguiname="igTreeNode0", + defaults={}, + funcname="TreeNode", + isVARG0=true, + location="imgui:753", + namespace="ImGui", + ov_cimguiname="igTreeNode_Ptr0", + ret="bool", + signature="(const void*,const char*)", + stname=""}}, igTreeNodeBehavior={ [1]={ args="(ImGuiID id,ImGuiTreeNodeFlags flags,const char* label,const char* label_end)", @@ -38336,6 +38381,57 @@ local t={ ["(const char*,ImGuiTreeNodeFlags)"]=nil, ["(const char*,ImGuiTreeNodeFlags,const char*,...)"]=nil, ["(const void*,ImGuiTreeNodeFlags,const char*,...)"]=nil}, + igTreeNodeEx0={ + [1]={ + args="(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt)", + argsT={ + [1]={ + name="str_id", + type="const char*"}, + [2]={ + name="flags", + type="ImGuiTreeNodeFlags"}, + [3]={ + name="fmt", + type="const char*"}}, + argsoriginal="(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,...)", + call_args="(str_id,flags,fmt)", + call_args_old="(str_id,flags,fmt)", + cimguiname="igTreeNodeEx0", + defaults={}, + funcname="TreeNodeEx", + isVARG0=true, + location="imgui:757", + namespace="ImGui", + ov_cimguiname="igTreeNodeEx_StrStr0", + ret="bool", + signature="(const char*,ImGuiTreeNodeFlags,const char*)", + stname=""}, + [2]={ + args="(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt)", + argsT={ + [1]={ + name="ptr_id", + type="const void*"}, + [2]={ + name="flags", + type="ImGuiTreeNodeFlags"}, + [3]={ + name="fmt", + type="const char*"}}, + argsoriginal="(const void* ptr_id,ImGuiTreeNodeFlags flags,const char* fmt,...)", + call_args="(ptr_id,flags,fmt)", + call_args_old="(ptr_id,flags,fmt)", + cimguiname="igTreeNodeEx0", + defaults={}, + funcname="TreeNodeEx", + isVARG0=true, + location="imgui:758", + namespace="ImGui", + ov_cimguiname="igTreeNodeEx_Ptr0", + ret="bool", + signature="(const void*,ImGuiTreeNodeFlags,const char*)", + stname=""}}, igTreeNodeExV={ [1]={ args="(const char* str_id,ImGuiTreeNodeFlags flags,const char* fmt,va_list args)",