mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-14 13:38:31 +01:00
avoid excesive typedefs
This commit is contained in:
@@ -37,30 +37,11 @@ typedef unsigned long long ImU64;
|
|||||||
|
|
||||||
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||||
|
|
||||||
typedef struct ImFont ImFont;
|
|
||||||
typedef struct ImFontAtlas ImFontAtlas;
|
|
||||||
typedef struct CustomRect CustomRect;
|
typedef struct CustomRect CustomRect;
|
||||||
typedef struct GlyphRangesBuilder GlyphRangesBuilder;
|
typedef struct GlyphRangesBuilder GlyphRangesBuilder;
|
||||||
typedef struct ImFontGlyph ImFontGlyph;
|
typedef struct ImFontGlyph ImFontGlyph;
|
||||||
typedef struct ImFontConfig ImFontConfig;
|
|
||||||
typedef struct ImDrawData ImDrawData;
|
|
||||||
typedef struct ImDrawList ImDrawList;
|
|
||||||
typedef struct ImDrawChannel ImDrawChannel;
|
|
||||||
typedef struct ImDrawVert ImDrawVert;
|
|
||||||
typedef struct ImDrawCmd ImDrawCmd;
|
|
||||||
typedef struct ImGuiListClipper ImGuiListClipper;
|
|
||||||
typedef struct ImColor ImColor;
|
|
||||||
typedef struct ImGuiPayload ImGuiPayload;
|
|
||||||
typedef struct ImGuiSizeCallbackData ImGuiSizeCallbackData;
|
|
||||||
typedef struct ImGuiTextEditCallbackData ImGuiTextEditCallbackData;
|
|
||||||
typedef struct ImGuiStorage ImGuiStorage;
|
|
||||||
typedef struct Pair Pair;
|
typedef struct Pair Pair;
|
||||||
typedef struct ImGuiTextBuffer ImGuiTextBuffer;
|
|
||||||
typedef struct ImGuiTextFilter ImGuiTextFilter;
|
|
||||||
typedef struct TextRange TextRange;
|
typedef struct TextRange TextRange;
|
||||||
typedef struct ImGuiOnceUponAFrame ImGuiOnceUponAFrame;
|
|
||||||
typedef struct ImGuiIO ImGuiIO;
|
|
||||||
typedef struct ImGuiStyle ImGuiStyle;
|
|
||||||
typedef struct ImVec4 ImVec4;
|
typedef struct ImVec4 ImVec4;
|
||||||
typedef struct ImVec2 ImVec2;
|
typedef struct ImVec2 ImVec2;
|
||||||
typedef struct ImGuiContext ImGuiContext;
|
typedef struct ImGuiContext ImGuiContext;
|
||||||
|
@@ -36,29 +36,14 @@ typedef unsigned long long ImU64;
|
|||||||
//struct SDL_Window;
|
//struct SDL_Window;
|
||||||
|
|
||||||
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||||
typedef unsigned short ImDrawIdx;typedef struct ImFont ImFont;
|
typedef unsigned short ImDrawIdx;
|
||||||
typedef struct ImFontAtlas ImFontAtlas;
|
typedef void* ImTextureID;
|
||||||
|
// dear imgui, v1.62
|
||||||
typedef struct CustomRect CustomRect;
|
typedef struct CustomRect CustomRect;
|
||||||
typedef struct GlyphRangesBuilder GlyphRangesBuilder;
|
typedef struct GlyphRangesBuilder GlyphRangesBuilder;
|
||||||
typedef struct ImFontGlyph ImFontGlyph;
|
typedef struct ImFontGlyph ImFontGlyph;
|
||||||
typedef struct ImFontConfig ImFontConfig;
|
|
||||||
typedef struct ImDrawData ImDrawData;
|
|
||||||
typedef struct ImDrawList ImDrawList;
|
|
||||||
typedef struct ImDrawChannel ImDrawChannel;
|
|
||||||
typedef struct ImDrawCmd ImDrawCmd;
|
|
||||||
typedef struct ImGuiListClipper ImGuiListClipper;
|
|
||||||
typedef struct ImColor ImColor;
|
|
||||||
typedef struct ImGuiPayload ImGuiPayload;
|
|
||||||
typedef struct ImGuiSizeCallbackData ImGuiSizeCallbackData;
|
|
||||||
typedef struct ImGuiTextEditCallbackData ImGuiTextEditCallbackData;
|
|
||||||
typedef struct ImGuiStorage ImGuiStorage;
|
|
||||||
typedef struct Pair Pair;
|
typedef struct Pair Pair;
|
||||||
typedef struct ImGuiTextBuffer ImGuiTextBuffer;
|
|
||||||
typedef struct ImGuiTextFilter ImGuiTextFilter;
|
|
||||||
typedef struct TextRange TextRange;
|
typedef struct TextRange TextRange;
|
||||||
typedef struct ImGuiOnceUponAFrame ImGuiOnceUponAFrame;
|
|
||||||
typedef struct ImGuiIO ImGuiIO;
|
|
||||||
typedef struct ImGuiStyle ImGuiStyle;
|
|
||||||
typedef struct ImVec4 ImVec4;
|
typedef struct ImVec4 ImVec4;
|
||||||
typedef struct ImVec2 ImVec2;
|
typedef struct ImVec2 ImVec2;
|
||||||
typedef struct ImGuiContext ImGuiContext;
|
typedef struct ImGuiContext ImGuiContext;
|
||||||
@@ -82,7 +67,6 @@ typedef struct ImDrawList ImDrawList;
|
|||||||
typedef struct ImDrawData ImDrawData;
|
typedef struct ImDrawData ImDrawData;
|
||||||
typedef struct ImDrawCmd ImDrawCmd;
|
typedef struct ImDrawCmd ImDrawCmd;
|
||||||
typedef struct ImDrawChannel ImDrawChannel;
|
typedef struct ImDrawChannel ImDrawChannel;
|
||||||
typedef void* ImTextureID;// dear imgui, v1.62
|
|
||||||
// (headers)
|
// (headers)
|
||||||
// See imgui.cpp file for documentation.
|
// See imgui.cpp file for documentation.
|
||||||
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
||||||
|
@@ -37,30 +37,11 @@ typedef unsigned long long ImU64;
|
|||||||
|
|
||||||
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||||
|
|
||||||
typedef struct ImFont ImFont;
|
|
||||||
typedef struct ImFontAtlas ImFontAtlas;
|
|
||||||
typedef struct CustomRect CustomRect;
|
typedef struct CustomRect CustomRect;
|
||||||
typedef struct GlyphRangesBuilder GlyphRangesBuilder;
|
typedef struct GlyphRangesBuilder GlyphRangesBuilder;
|
||||||
typedef struct ImFontGlyph ImFontGlyph;
|
typedef struct ImFontGlyph ImFontGlyph;
|
||||||
typedef struct ImFontConfig ImFontConfig;
|
|
||||||
typedef struct ImDrawData ImDrawData;
|
|
||||||
typedef struct ImDrawList ImDrawList;
|
|
||||||
typedef struct ImDrawChannel ImDrawChannel;
|
|
||||||
typedef struct ImDrawVert ImDrawVert;
|
|
||||||
typedef struct ImDrawCmd ImDrawCmd;
|
|
||||||
typedef struct ImGuiListClipper ImGuiListClipper;
|
|
||||||
typedef struct ImColor ImColor;
|
|
||||||
typedef struct ImGuiPayload ImGuiPayload;
|
|
||||||
typedef struct ImGuiSizeCallbackData ImGuiSizeCallbackData;
|
|
||||||
typedef struct ImGuiTextEditCallbackData ImGuiTextEditCallbackData;
|
|
||||||
typedef struct ImGuiStorage ImGuiStorage;
|
|
||||||
typedef struct Pair Pair;
|
typedef struct Pair Pair;
|
||||||
typedef struct ImGuiTextBuffer ImGuiTextBuffer;
|
|
||||||
typedef struct ImGuiTextFilter ImGuiTextFilter;
|
|
||||||
typedef struct TextRange TextRange;
|
typedef struct TextRange TextRange;
|
||||||
typedef struct ImGuiOnceUponAFrame ImGuiOnceUponAFrame;
|
|
||||||
typedef struct ImGuiIO ImGuiIO;
|
|
||||||
typedef struct ImGuiStyle ImGuiStyle;
|
|
||||||
typedef struct ImVec4 ImVec4;
|
typedef struct ImVec4 ImVec4;
|
||||||
typedef struct ImVec2 ImVec2;
|
typedef struct ImVec2 ImVec2;
|
||||||
typedef struct ImGuiContext ImGuiContext;
|
typedef struct ImGuiContext ImGuiContext;
|
||||||
|
@@ -620,7 +620,7 @@ local function gen_structs_and_enums_table(cdefs)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function gen_structs_and_enums(cdefs,addextra)
|
local function gen_structs_and_enums(cdefs)
|
||||||
local function_closing_re = "}"
|
local function_closing_re = "}"
|
||||||
local namespace_re = "namespace"
|
local namespace_re = "namespace"
|
||||||
local in_namespace = false
|
local in_namespace = false
|
||||||
@@ -634,10 +634,7 @@ local function gen_structs_and_enums(cdefs,addextra)
|
|||||||
local outtab = {}
|
local outtab = {}
|
||||||
-- Output the file
|
-- Output the file
|
||||||
--table.insert(outtab,"/////////////// BEGIN AUTOGENERATED SEGMENT\n")
|
--table.insert(outtab,"/////////////// BEGIN AUTOGENERATED SEGMENT\n")
|
||||||
if addextra then
|
|
||||||
table.insert(outtab,[[typedef unsigned short ImDrawIdx;]])
|
|
||||||
table.insert(outtab,[[typedef void* ImTextureID;]])
|
|
||||||
end
|
|
||||||
for i,line in ipairs(cdefs) do
|
for i,line in ipairs(cdefs) do
|
||||||
repeat -- simulating continue with break
|
repeat -- simulating continue with break
|
||||||
-- separate comments from code and try to add them with same tab
|
-- separate comments from code and try to add them with same tab
|
||||||
@@ -659,6 +656,7 @@ local function gen_structs_and_enums(cdefs,addextra)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ImVector special treatment
|
||||||
if structnames[#structnames] == "ImVector" then
|
if structnames[#structnames] == "ImVector" then
|
||||||
if line:match(struct_closing_re) then
|
if line:match(struct_closing_re) then
|
||||||
table.insert(outtab,[[struct ImVector
|
table.insert(outtab,[[struct ImVector
|
||||||
@@ -727,9 +725,13 @@ typedef struct ImVector ImVector;]])
|
|||||||
end
|
end
|
||||||
|
|
||||||
--table.insert(outtab,"//////////////// END AUTOGENERATED SEGMENT \n")
|
--table.insert(outtab,"//////////////// END AUTOGENERATED SEGMENT \n")
|
||||||
|
local uniques = {}
|
||||||
for i,l in ipairs(typedefs_table) do
|
for i,l in ipairs(typedefs_table) do
|
||||||
|
if not uniques[l] then
|
||||||
|
uniques[l] = true
|
||||||
table.insert(outtab,2,l)
|
table.insert(outtab,2,l)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
local cstructsstr = table.concat(outtab)
|
local cstructsstr = table.concat(outtab)
|
||||||
cstructsstr = cstructsstr:gsub("\n+","\n") --several empty lines to one empty line
|
cstructsstr = cstructsstr:gsub("\n+","\n") --several empty lines to one empty line
|
||||||
return cstructsstr
|
return cstructsstr
|
||||||
@@ -863,13 +865,18 @@ local function func_implementation(FP)
|
|||||||
--cppfile:close()
|
--cppfile:close()
|
||||||
return table.concat(outtab)
|
return table.concat(outtab)
|
||||||
end
|
end
|
||||||
|
|
||||||
--generate cimgui.cpp cimgui.h and auto versions depending on postfix
|
--generate cimgui.cpp cimgui.h and auto versions depending on postfix
|
||||||
local function cimgui_generation(postfix,STP,FP)
|
local function cimgui_generation(postfix,STP,FP)
|
||||||
--merge it in cimgui_template.h to cimgui.h
|
--merge it in cimgui_template.h to cimgui.h
|
||||||
local hfile = io.open("./cimgui_template.h","r")
|
local hfile = io.open("./cimgui_template.h","r")
|
||||||
local hstrfile = hfile:read"*a"
|
local hstrfile = hfile:read"*a"
|
||||||
hfile:close()
|
hfile:close()
|
||||||
local cstructsstr = gen_structs_and_enums(STP.lines,postfix=="")
|
local cstructsstr = gen_structs_and_enums(STP.lines)
|
||||||
|
--for not gcc parsing
|
||||||
|
if postfix == "" then
|
||||||
|
cstructsstr = "typedef unsigned short ImDrawIdx;\ntypedef void* ImTextureID;\n"..cstructsstr
|
||||||
|
end
|
||||||
hstrfile = hstrfile:gsub([[#include "imgui_structs%.h"]],cstructsstr)
|
hstrfile = hstrfile:gsub([[#include "imgui_structs%.h"]],cstructsstr)
|
||||||
local cfuncsstr = func_header_generate(FP)
|
local cfuncsstr = func_header_generate(FP)
|
||||||
hstrfile = hstrfile:gsub([[#include "auto_funcs%.h"]],cfuncsstr)
|
hstrfile = hstrfile:gsub([[#include "auto_funcs%.h"]],cfuncsstr)
|
||||||
@@ -907,6 +914,8 @@ FP:compute_overloads()
|
|||||||
cimgui_generation("",STP,FP)
|
cimgui_generation("",STP,FP)
|
||||||
|
|
||||||
--then gcc
|
--then gcc
|
||||||
|
local pFP,pSTP
|
||||||
|
|
||||||
if HAVE_GCC then
|
if HAVE_GCC then
|
||||||
local pipe,err = io.popen([[gcc -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h]],"r")
|
local pipe,err = io.popen([[gcc -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h]],"r")
|
||||||
|
|
||||||
@@ -914,26 +923,26 @@ if not pipe then
|
|||||||
error("could not execute gcc "..err)
|
error("could not execute gcc "..err)
|
||||||
end
|
end
|
||||||
|
|
||||||
STP = struct_parser() --overwrite
|
pSTP = struct_parser() --overwrite
|
||||||
FP = func_parser() --overwrite
|
pFP = func_parser() --overwrite
|
||||||
|
|
||||||
for line in location(pipe,{"imgui"}) do
|
for line in location(pipe,{"imgui"}) do
|
||||||
local line, comment = split_comment(line)
|
local line, comment = split_comment(line)
|
||||||
STP.insert(line,comment)
|
pSTP.insert(line,comment)
|
||||||
FP.insert(line,comment)
|
pFP.insert(line,comment)
|
||||||
end
|
end
|
||||||
pipe:close()
|
pipe:close()
|
||||||
local ovstr = FP:compute_overloads()
|
local ovstr = pFP:compute_overloads()
|
||||||
save_data("./generated/overloads.txt",ovstr)
|
save_data("./generated/overloads.txt",ovstr)
|
||||||
cimgui_generation("_auto",STP,FP)
|
cimgui_generation("_auto",pSTP,pFP)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
----------save fundefs in definitions.lua for using in bindings
|
----------save fundefs in definitions.lua for using in bindings
|
||||||
save_data("./generated/definitions.lua",serializeTable("defs",FP.defsT),"\nreturn defs")
|
save_data("./generated/definitions.lua",serializeTable("defs",pFP.defsT),"\nreturn defs")
|
||||||
|
|
||||||
----------save struct and enums lua table in structs_and_enums.lua for using in bindings
|
----------save struct and enums lua table in structs_and_enums.lua for using in bindings
|
||||||
local structs_and_enums_table = gen_structs_and_enums_table(STP.lines)
|
local structs_and_enums_table = gen_structs_and_enums_table(pSTP.lines)
|
||||||
save_data("./generated/structs_and_enums.lua",serializeTable("defs",structs_and_enums_table),"\nreturn defs")
|
save_data("./generated/structs_and_enums.lua",serializeTable("defs",structs_and_enums_table),"\nreturn defs")
|
||||||
|
|
||||||
--=================================Now implementations
|
--=================================Now implementations
|
||||||
@@ -993,7 +1002,7 @@ local function json_prepare(defs)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local json = require"json"
|
local json = require"json"
|
||||||
save_data("./generated/definitions.json",json.encode(json_prepare(FP.defsT)))
|
save_data("./generated/definitions.json",json.encode(json_prepare(pFP.defsT)))
|
||||||
save_data("./generated/structs_and_enums.json",json.encode(structs_and_enums_table))
|
save_data("./generated/structs_and_enums.json",json.encode(structs_and_enums_table))
|
||||||
if iFP then
|
if iFP then
|
||||||
save_data("./generated/impl_definitions.json",json.encode(json_prepare(iFP.defsT)))
|
save_data("./generated/impl_definitions.json",json.encode(json_prepare(iFP.defsT)))
|
||||||
|
Reference in New Issue
Block a user