diff --git a/CMakeLists.txt b/CMakeLists.txt index 6268c16..1008e41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ endif (IMGUI_STATIC) target_compile_definitions(cimgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1) if (WIN32) target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API=extern\t\"C\"\t__declspec\(dllexport\)) + list(APPEND IMGUI_LIBRARIES imm32) else (WIN32) target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API=extern\t\"C\"\t) endif (WIN32) diff --git a/backend_test/main.c b/backend_test/main.c index 6ad52df..8e5a6d4 100644 --- a/backend_test/main.c +++ b/backend_test/main.c @@ -12,11 +12,11 @@ #include #ifdef IMGUI_HAS_IMSTR -#define igBegin SigBegin -#define igSliderFloat SigSliderFloat -#define igCheckbox SigCheckbox -#define igColorEdit3 SigColorEdit3 -#define igButton SigButton +#define igBegin igBegin_Strv +#define igSliderFloat igSliderFloat_Strv +#define igCheckbox igCheckbox_Strv +#define igColorEdit3 igColorEdit3_Strv +#define igButton igButton_Strv #endif SDL_Window *window = NULL; diff --git a/generator/cpp2ffi.lua b/generator/cpp2ffi.lua index fd3cf77..4be365f 100644 --- a/generator/cpp2ffi.lua +++ b/generator/cpp2ffi.lua @@ -503,7 +503,7 @@ local function typetoStr(typ) typ = typ:gsub("float","Float") typ = typ:gsub("uInt","Uint") typ = typ:gsub("ImGui","") - typ = typ:gsub("ImStr","STR") + --typ = typ:gsub("ImStr","STR") typ = typ:gsub("Im","") typ = typ:gsub("[<>]","") return typ @@ -792,7 +792,7 @@ local function ADDIMSTR_S(FP) --if isIMSTR return generate _S version local isIMSTR = false for i,arg in ipairs(defT.argsT) do - if arg.type == "ImStr" then isIMSTR=true;break end + if arg.type == "ImStrv" then isIMSTR=true;break end end --if defT.ret=="ImVec2" or defT.ret=="ImVec4" or defT.ret=="ImColor" then --if isIMSTR then print(t.cimguiname,defT.ov_cimguiname,defT.argsoriginal,"isIMSTR") end @@ -806,7 +806,7 @@ local function ADDIMSTR_S(FP) --then argsT table defT2.argsT = {} for k,v in ipairs(defT.argsT) do - local typ = v.type == "ImStr" and "const char*" or v.type + local typ = v.type == "ImStrv" and "const char*" or v.type table.insert(defT2.argsT,{type=typ,name=v.name}) end --defaults table @@ -814,13 +814,13 @@ local function ADDIMSTR_S(FP) for k,v in pairs(defT.defaults) do defT2.defaults[k] = v end - defT2.args = defT2.args:gsub("ImStr","const char*") - --recreate call_args for wrapping into ImStr + defT2.args = defT2.args:gsub("ImStrv","const char*") + --recreate call_args for wrapping into ImStrv local caar if #defT.argsT > 0 then caar = "(" for i,v in ipairs(defT.argsT) do - local name = v.name --v.type == "ImStr" and "ImStr("..v.name..")" or v.name --wrap + local name = v.name if v.ret then --function pointer caar = caar .. name .. "," else @@ -832,9 +832,9 @@ local function ADDIMSTR_S(FP) else caar = "()" end - defT2.call_args = caar --:gsub("ImStr%(([^%(%)]+)%)","%1") --unwrap + defT2.call_args = caar ------------------ - defT2.signature = defT.signature:gsub("ImStr","const char*") --.."_S" + defT2.signature = defT.signature:gsub("ImStrv","const char*") --.."_S" defT2.ov_cimguiname = defT2.ov_cimguiname .. "_Strv" defT2.isIMSTR_S = 1 -- check there is not an equal version in imgui_stname diff --git a/test/main.c b/test/main.c index 468835f..51bd6af 100644 --- a/test/main.c +++ b/test/main.c @@ -3,11 +3,11 @@ #include "../cimgui.h" #ifdef IMGUI_HAS_IMSTR -#define igBegin SigBegin -#define igSliderFloat SigSliderFloat -#define igCheckbox SigCheckbox -#define igColorEdit3 SigColorEdit3 -#define igButton SigButton +#define igBegin igBegin_Strv +#define igSliderFloat igSliderFloat_Strv +#define igCheckbox igCheckbox_Strv +#define igColorEdit3 igColorEdit3_Strv +#define igButton igButton_Strv #endif int main(void)