Compare commits

...

5 Commits

Author SHA1 Message Date
sonoro1234
140d107be5 improve customization (see PR #290) 2025-03-18 13:20:46 +01:00
sonoro1234
c32d1c0c9b dont name igGetIO overload as the generic name of function (C++ name) solves issue #289 2025-03-15 17:51:30 +01:00
sonoro1234
3530b937f1 generation 2025-03-15 17:03:47 +01:00
Victor Bombi
bb6f212993 Merge pull request #288 from spencercw/vulkan
generator.lua: fix missing void in Vulkan function generation
2025-03-15 16:57:30 +01:00
Chris Spencer
e3af31fb9c generator.lua: fix missing void in Vulkan function generation 2025-03-15 11:57:14 +00:00
16 changed files with 71 additions and 47 deletions

View File

@@ -24,6 +24,8 @@
#define igButton igButton_Str
#endif
#define igGetIO igGetIO_Nil
GLFWwindow *window;
// Data

View File

@@ -17,6 +17,8 @@
#define igButton igButton_Str
#endif
#define igGetIO igGetIO_Nil
GLFWwindow *window;
int main(int argc, char *argv[])

View File

@@ -18,6 +18,8 @@
#define igButton igButton_Str
#endif
#define igGetIO igGetIO_Nil
SDL_Window *window = NULL;
int main(int argc, char* argv[])

View File

@@ -26,6 +26,8 @@
#define igButton igButton_Str
#endif
#define igGetIO igGetIO_Nil
#define IM_UNUSED(_VAR) ((void)(_VAR))
#define IM_ASSERT(_EXPR) assert(_EXPR)
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR))))

View File

@@ -53,7 +53,7 @@ CIMGUI_API void igSetCurrentContext(ImGuiContext* ctx)
{
return ImGui::SetCurrentContext(ctx);
}
CIMGUI_API ImGuiIO* igGetIO()
CIMGUI_API ImGuiIO* igGetIO_Nil()
{
return &ImGui::GetIO();
}
@@ -3999,7 +3999,7 @@ CIMGUI_API ImGuiTableColumnSettings* ImGuiTableSettings_GetColumnSettings(ImGuiT
{
return self->GetColumnSettings();
}
CIMGUI_API ImGuiIO* igGetIOEx(ImGuiContext* ctx)
CIMGUI_API ImGuiIO* igGetIO_ContextPtr(ImGuiContext* ctx)
{
return &ImGui::GetIO(ctx);
}

View File

@@ -3633,7 +3633,7 @@ CIMGUI_API ImGuiContext* igCreateContext(ImFontAtlas* shared_font_atlas);
CIMGUI_API void igDestroyContext(ImGuiContext* ctx);
CIMGUI_API ImGuiContext* igGetCurrentContext(void);
CIMGUI_API void igSetCurrentContext(ImGuiContext* ctx);
CIMGUI_API ImGuiIO* igGetIO(void);
CIMGUI_API ImGuiIO* igGetIO_Nil(void);
CIMGUI_API ImGuiPlatformIO* igGetPlatformIO_Nil(void);
CIMGUI_API ImGuiStyle* igGetStyle(void);
CIMGUI_API void igNewFrame(void);
@@ -4607,7 +4607,7 @@ CIMGUI_API void ImGuiTableColumnSettings_destroy(ImGuiTableColumnSettings* self)
CIMGUI_API ImGuiTableSettings* ImGuiTableSettings_ImGuiTableSettings(void);
CIMGUI_API void ImGuiTableSettings_destroy(ImGuiTableSettings* self);
CIMGUI_API ImGuiTableColumnSettings* ImGuiTableSettings_GetColumnSettings(ImGuiTableSettings* self);
CIMGUI_API ImGuiIO* igGetIOEx(ImGuiContext* ctx);
CIMGUI_API ImGuiIO* igGetIO_ContextPtr(ImGuiContext* ctx);
CIMGUI_API ImGuiPlatformIO* igGetPlatformIO_ContextPtr(ImGuiContext* ctx);
CIMGUI_API ImGuiWindow* igGetCurrentWindowRead(void);
CIMGUI_API ImGuiWindow* igGetCurrentWindow(void);

View File

@@ -5,34 +5,19 @@
#include "./imgui/imgui_internal.h"
#include "cimgui.h"
#ifdef CIMGUI_USE_DX9
#include "imgui_impl_dx9.h"
#endif
#ifdef CIMGUI_USE_DX10
#include "imgui_impl_dx10.h"
#endif
#ifdef CIMGUI_USE_DX11
#include "imgui_impl_dx11.h"
#endif
#ifdef CIMGUI_USE_DX12
#include "imgui_impl_dx12.h"
#endif
#ifdef CIMGUI_USE_GLFW
#include "imgui_impl_glfw.h"
#endif
#ifdef CIMGUI_USE_OPENGL2
#include "imgui_impl_opengl2.h"
#endif
#ifdef CIMGUI_USE_OPENGL3
#include "imgui_impl_opengl3.h"
#endif
#ifdef CIMGUI_USE_OPENGL2
#include "imgui_impl_opengl2.h"
#endif
#ifdef CIMGUI_USE_SDL2
#include "imgui_impl_sdl2.h"
#endif
@@ -45,10 +30,6 @@
#include "imgui_impl_vulkan.h"
#endif
#ifdef CIMGUI_USE_WIN32
#include "imgui_impl_win32.h"
#endif
#include "cimgui_impl.h"
#ifdef CIMGUI_USE_VULKAN

View File

@@ -193,6 +193,6 @@ CIMGUI_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice
CIMGUI_API VkPhysicalDevice ImGui_ImplVulkanH_SelectPhysicalDevice(VkInstance instance);
CIMGUI_API uint32_t ImGui_ImplVulkanH_SelectQueueFamilyIndex(VkPhysicalDevice physical_device);
CIMGUI_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
CIMGUI_API ImGui_ImplVulkanH_Window* ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window();
CIMGUI_API ImGui_ImplVulkanH_Window* ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window(void);
#endif

View File

@@ -0,0 +1,23 @@
#include "./imgui/imgui.h"
#ifdef IMGUI_ENABLE_FREETYPE
#include "./imgui/misc/freetype/imgui_freetype.h"
#endif
#include "./imgui/imgui_internal.h"
#include "cimgui.h"
GENERATED_PLACEHOLDER
#include "cimgui_impl.h"
#ifdef CIMGUI_USE_VULKAN
CIMGUI_API ImGui_ImplVulkanH_Window* ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window()
{
return IM_NEW(ImGui_ImplVulkanH_Window)();
}
CIMGUI_API void ImGui_ImplVulkanH_Window_Construct(ImGui_ImplVulkanH_Window* self)
{
IM_PLACEMENT_NEW(self) ImGui_ImplVulkanH_Window();
}
#endif

View File

@@ -20,7 +20,7 @@ set PATH=%PATH%;C:\anima;C:\mingws\i686-7.2.0-release-posix-dwarf-rt_v5-rev1\min
:: examples: "" "internal" "internal comments"
:: arg[3..n] name of implementations to generate and/or CFLAGS (e.g. -DIMGUI_USER_CONFIG)
::-DIMGUI_USE_WCHAR32 should not be used (is discarded)
luajit ./generator.lua gcc "internal noimstrv" glfw opengl3 opengl2 sdl2 sdl3 vulkan -DIMGUI_USE_WCHAR32 %*
luajit ./generator.lua gcc "internal noimstrv" glfw opengl3 opengl2 sdl2 sdl3 vulkan %*
::leave console open
cmd /k

View File

@@ -13,6 +13,7 @@ local CONSTRUCTORS_GENERATION = script_args[2]:match("constructors") and true or
local NOCHAR = script_args[2]:match("nochar") and true or false
local NOIMSTRV = script_args[2]:match("noimstrv") and true or false
local IMGUI_PATH = os.getenv"IMGUI_PATH" or "../imgui"
local CONFIG_GENERATOR_PATH = os.getenv"CONFIG_GENERATOR_PATH" or "./config_generator.lua"
local CFLAGS = ""
local CPRE,CTEST
--get implementations
@@ -91,10 +92,10 @@ local cimgui_skipped = {
--desired name
---------------------------------------------------------------------------
local cimgui_overloads = {
igGetIO = {
["()"] = "igGetIO",
["(ImGuiContext*)"] = "igGetIOEx",
},
-- igGetIO = {
-- ["()"] = "igGetIO",
-- ["(ImGuiContext*)"] = "igGetIOEx",
-- },
--igPushID = {
--["(const char*)"] = "igPushIDStr",
--["(const char*,const char*)"] = "igPushIDRange",
@@ -128,6 +129,7 @@ local function func_header_impl_generate(FP)
local cimf = FP.defsT[t.cimguiname]
local def = cimf[t.signature]
local addcoment = def.comment or ""
local empty = def.args:match("^%(%)") --no args
if def.constructor then
-- only vulkan is manually created
assert(def.ov_cimguiname=="ImGui_ImplVulkanH_Window_ImGui_ImplVulkanH_Window" or
@@ -139,7 +141,6 @@ local function func_header_impl_generate(FP)
else
if def.stname == "" then --ImGui namespace or top level
local empty = def.args:match("^%(%)") --no args
table.insert(outtab,"CIMGUI_API".." "..def.ret.." "..def.ov_cimguiname..(empty and "(void)" or def.args)..";"..addcoment.."\n")
else
cpp2ffi.prtable(def)
@@ -454,11 +455,18 @@ local parser2
if #implementations > 0 then
print("------------------implementations generation with "..COMPILER.."------------------------")
--parser2 for function defs
--parser3 for separated structs and enums in cimgui_impl.h
parser2 = cpp2ffi.Parser()
local config = require"config_generator"
local config = dofile(CONFIG_GENERATOR_PATH) --"./config_generator.lua"
local impl_str = ""
local impl_str_cpp = {}
for i,impl in ipairs(implementations) do
table.insert(impl_str_cpp, "\n#ifdef CIMGUI_USE_" .. string.upper(impl))
table.insert(impl_str_cpp, [[#include "imgui_impl_]]..impl..[[.h"]])
table.insert(impl_str_cpp, "#endif")
local source = backends_folder .. [[imgui_impl_]].. impl .. ".h "
local locati = [[imgui_impl_]].. impl
@@ -495,15 +503,15 @@ if #implementations > 0 then
end
parser2:do_parse()
-- save ./cimgui_impl.h
--local cfuncsstr = func_header_impl_generate(parser2)
--local cstructstr1,cstructstr2 = parser2.structs_and_enums[1], parser2.structs_and_enums[2]
--save_data("./output/cimgui_impl.h",cstructstr1,cstructstr2,cfuncsstr)
save_data("./output/cimgui_impl.h",impl_str)
----------save fundefs in impl_definitions.lua for using in bindings
save_data("./output/impl_definitions.lua",serializeTableF(parser2.defsT))
--impl cpp
impl_str_cpp = table.concat(impl_str_cpp, "\n")
local cppstr = read_data"./cimgui_impl_template.cpp"
cppstr = cppstr:gsub("GENERATED_PLACEHOLDER", impl_str_cpp)
save_data("./output/cimgui_impl.cpp",cppstr)
end -- #implementations > 0 then
@@ -536,8 +544,10 @@ end
-------------------copy C files to repo root
copyfile("./output/cimgui.h", "../cimgui.h")
copyfile("./output/cimgui_impl.h", "../cimgui_impl.h")
copyfile("./output/cimgui_impl.cpp", "../cimgui_impl.cpp")
copyfile("./output/cimgui.cpp", "../cimgui.cpp")
os.remove("./output/cimgui.h")
os.remove("./output/cimgui_impl.h")
os.remove("./output/cimgui_impl.cpp")
os.remove("./output/cimgui.cpp")
print"all done!!"

View File

@@ -25,7 +25,7 @@
POSITIONAL_ARGS=()
TARGETS="internal noimstrv"
CFLAGS="glfw opengl3 opengl2 sdl2 sdl3"
CFLAGS="glfw opengl3 opengl2 sdl2 sdl3 vulkan"
help() {
cat <<EOF

View File

@@ -21987,7 +21987,7 @@
"funcname": "GetIO",
"location": "imgui:340",
"namespace": "ImGui",
"ov_cimguiname": "igGetIO",
"ov_cimguiname": "igGetIO_Nil",
"ret": "ImGuiIO*",
"retref": "&",
"signature": "()",
@@ -22008,7 +22008,7 @@
"funcname": "GetIO",
"location": "imgui_internal:3238",
"namespace": "ImGui",
"ov_cimguiname": "igGetIOEx",
"ov_cimguiname": "igGetIO_ContextPtr",
"ret": "ImGuiIO*",
"retref": "&",
"signature": "(ImGuiContext*)",

View File

@@ -18663,7 +18663,7 @@ local t={
funcname="GetIO",
location="imgui:340",
namespace="ImGui",
ov_cimguiname="igGetIO",
ov_cimguiname="igGetIO_Nil",
ret="ImGuiIO*",
retref="&",
signature="()",
@@ -18681,7 +18681,7 @@ local t={
funcname="GetIO",
location="imgui_internal:3238",
namespace="ImGui",
ov_cimguiname="igGetIOEx",
ov_cimguiname="igGetIO_ContextPtr",
ret="ImGuiIO*",
retref="&",
signature="(ImGuiContext*)",

View File

@@ -124,8 +124,8 @@ igGetIDWithSeed 2
1 ImGuiID igGetIDWithSeed_Str (const char*,const char*,ImGuiID)
2 ImGuiID igGetIDWithSeed_Int (int,ImGuiID)
igGetIO 2
1 ImGuiIO* igGetIO ()
2 ImGuiIO* igGetIOEx (ImGuiContext*)
1 ImGuiIO* igGetIO_Nil ()
2 ImGuiIO* igGetIO_ContextPtr (ImGuiContext*)
igGetKeyData 2
1 ImGuiKeyData* igGetKeyData_ContextPtr (ImGuiContext*,ImGuiKey)
2 ImGuiKeyData* igGetKeyData_Key (ImGuiKey)

View File

@@ -11,6 +11,8 @@
#define igDebugCheckVersionAndDataLayout igDebugCheckVersionAndDataLayout_Str
#endif
#define igGetIO igGetIO_Nil
int main(void)
{
assert(igDebugCheckVersionAndDataLayout(igGetVersion(), sizeof(ImGuiIO), sizeof(ImGuiStyle),