add ImVector template types

This commit is contained in:
sonoro1234
2018-10-18 13:05:57 +02:00
parent 7a54d1276d
commit aca412fe7a
4 changed files with 168 additions and 89 deletions

View File

@@ -40,12 +40,30 @@ typedef struct ImColor_Simple { ImVec4_Simple Value;} ImColor_Simple;
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS #ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
struct ImDrawChannel;
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 unsigned short ImDrawIdx;;
typedef struct Pair Pair; typedef struct Pair Pair;
typedef struct TextRange TextRange; typedef struct TextRange TextRange;
typedef struct ImVector_ImVec2 ImVector_ImVec2;
typedef struct ImVector_ImDrawIdx ImVector_ImDrawIdx;
typedef struct ImVector_ImVec4 ImVector_ImVec4;
typedef struct ImVector_TextRange ImVector_TextRange;
typedef struct ImVector_ImFontPtr ImVector_ImFontPtr;
typedef struct ImVector_ImDrawCmd ImVector_ImDrawCmd;
typedef struct ImVector_ImDrawVert ImVector_ImDrawVert;
typedef struct ImVector_unsigned_short ImVector_unsigned_short;
typedef struct ImVector_ImTextureID ImVector_ImTextureID;
typedef struct ImVector_char ImVector_char;
typedef struct ImVector_ImDrawChannel ImVector_ImDrawChannel;
typedef struct ImVector_CustomRect ImVector_CustomRect;
typedef struct ImVector_Pair ImVector_Pair;
typedef struct ImVector_unsigned_char ImVector_unsigned_char;
typedef struct ImVector_ImFontGlyph ImVector_ImFontGlyph;
typedef struct ImVector_ImFontConfig ImVector_ImFontConfig;
typedef struct ImVector_ImWchar ImVector_ImWchar;
typedef struct ImVector_float ImVector_float;
typedef struct ImVec4 ImVec4; typedef struct ImVec4 ImVec4;
typedef struct ImVec2 ImVec2; typedef struct ImVec2 ImVec2;
typedef struct ImGuiTextBuffer ImGuiTextBuffer; typedef struct ImGuiTextBuffer ImGuiTextBuffer;
@@ -69,6 +87,7 @@ 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;
struct ImDrawChannel;
struct ImDrawCmd; struct ImDrawCmd;
struct ImDrawData; struct ImDrawData;
struct ImDrawList; struct ImDrawList;
@@ -568,13 +587,25 @@ struct ImGuiIO
float NavInputsDownDuration[ImGuiNavInput_COUNT]; float NavInputsDownDuration[ImGuiNavInput_COUNT];
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT]; float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
}; };
struct ImVector typedef struct ImVector{int Size;int Capacity;void* Data;} ImVector;
{ struct ImVector_float {int Size;int Capacity;float* Data;} ImVector_float;
int Size; struct ImVector_ImWchar {int Size;int Capacity;ImWchar* Data;} ImVector_ImWchar;
int Capacity; struct ImVector_ImFontConfig {int Size;int Capacity;ImFontConfig* Data;} ImVector_ImFontConfig;
void* Data; struct ImVector_ImFontGlyph {int Size;int Capacity;ImFontGlyph* Data;} ImVector_ImFontGlyph;
}; struct ImVector_unsigned_char {int Size;int Capacity;unsigned char* Data;} ImVector_unsigned_char;
typedef struct ImVector ImVector; struct ImVector_Pair {int Size;int Capacity;Pair* Data;} ImVector_Pair;
struct ImVector_CustomRect {int Size;int Capacity;CustomRect* Data;} ImVector_CustomRect;
struct ImVector_ImDrawChannel {int Size;int Capacity;ImDrawChannel* Data;} ImVector_ImDrawChannel;
struct ImVector_char {int Size;int Capacity;char* Data;} ImVector_char;
struct ImVector_ImTextureID {int Size;int Capacity;ImTextureID* Data;} ImVector_ImTextureID;
struct ImVector_unsigned_short {int Size;int Capacity;unsigned short* Data;} ImVector_unsigned_short;
struct ImVector_ImDrawVert {int Size;int Capacity;ImDrawVert* Data;} ImVector_ImDrawVert;
struct ImVector_ImDrawCmd {int Size;int Capacity;ImDrawCmd* Data;} ImVector_ImDrawCmd;
struct ImVector_ImFontPtr {int Size;int Capacity;ImFont** Data;} ImVector_ImFontPtr;
struct ImVector_TextRange {int Size;int Capacity;TextRange* Data;} ImVector_TextRange;
struct ImVector_ImVec4 {int Size;int Capacity;ImVec4* Data;} ImVector_ImVec4;
struct ImVector_ImDrawIdx {int Size;int Capacity;ImDrawIdx* Data;} ImVector_ImDrawIdx;
struct ImVector_ImVec2 {int Size;int Capacity;ImVec2* Data;} ImVector_ImVec2;
struct ImNewDummy {}; struct ImNewDummy {};
struct ImGuiOnceUponAFrame struct ImGuiOnceUponAFrame
{ {
@@ -583,16 +614,16 @@ struct ImGuiOnceUponAFrame
struct ImGuiTextFilter struct ImGuiTextFilter
{ {
char InputBuf[256]; char InputBuf[256];
ImVector/*<TextRange>*/ Filters; ImVector_TextRange Filters;
int CountGrep; int CountGrep;
}; };
struct ImGuiTextBuffer struct ImGuiTextBuffer
{ {
ImVector/*<char>*/ Buf; ImVector_char Buf;
}; };
struct ImGuiStorage struct ImGuiStorage
{ {
ImVector/*<Pair>*/ Data; ImVector_Pair Data;
}; };
struct ImGuiInputTextCallbackData struct ImGuiInputTextCallbackData
{ {
@@ -646,7 +677,6 @@ struct ImDrawCmd
ImDrawCallback UserCallback; ImDrawCallback UserCallback;
void* UserCallbackData; void* UserCallbackData;
}; };
typedef unsigned short ImDrawIdx;
struct ImDrawVert struct ImDrawVert
{ {
ImVec2 pos; ImVec2 pos;
@@ -655,8 +685,8 @@ struct ImDrawVert
}; };
struct ImDrawChannel struct ImDrawChannel
{ {
ImVector/*<ImDrawCmd>*/ CmdBuffer; ImVector_ImDrawCmd CmdBuffer;
ImVector/*<ImDrawIdx>*/ IdxBuffer; ImVector_ImDrawIdx IdxBuffer;
}; };
enum ImDrawCornerFlags_ enum ImDrawCornerFlags_
{ {
@@ -677,21 +707,21 @@ enum ImDrawListFlags_
}; };
struct ImDrawList struct ImDrawList
{ {
ImVector/*<ImDrawCmd>*/ CmdBuffer; ImVector_ImDrawCmd CmdBuffer;
ImVector/*<ImDrawIdx>*/ IdxBuffer; ImVector_ImDrawIdx IdxBuffer;
ImVector/*<ImDrawVert>*/ VtxBuffer; ImVector_ImDrawVert VtxBuffer;
ImDrawListFlags Flags; ImDrawListFlags Flags;
const ImDrawListSharedData* _Data; const ImDrawListSharedData* _Data;
const char* _OwnerName; const char* _OwnerName;
unsigned int _VtxCurrentIdx; unsigned int _VtxCurrentIdx;
ImDrawVert* _VtxWritePtr; ImDrawVert* _VtxWritePtr;
ImDrawIdx* _IdxWritePtr; ImDrawIdx* _IdxWritePtr;
ImVector/*<ImVec4>*/ _ClipRectStack; ImVector_ImVec4 _ClipRectStack;
ImVector/*<ImTextureID>*/ _TextureIdStack; ImVector_ImTextureID _TextureIdStack;
ImVector/*<ImVec2>*/ _Path; ImVector_ImVec2 _Path;
int _ChannelsCurrent; int _ChannelsCurrent;
int _ChannelsCount; int _ChannelsCount;
ImVector/*<ImDrawChannel>*/ _Channels; ImVector_ImDrawChannel _Channels;
}; };
struct ImDrawData struct ImDrawData
{ {
@@ -750,9 +780,9 @@ struct ImFontAtlas
int TexHeight; int TexHeight;
ImVec2 TexUvScale; ImVec2 TexUvScale;
ImVec2 TexUvWhitePixel; ImVec2 TexUvWhitePixel;
ImVector/*<ImFont*>*/ Fonts; ImVector_ImFontPtr Fonts;
ImVector/*<CustomRect>*/ CustomRects; ImVector_CustomRect CustomRects;
ImVector/*<ImFontConfig>*/ ConfigData; ImVector_ImFontConfig ConfigData;
int CustomRectIds[1]; int CustomRectIds[1];
}; };
struct ImFont struct ImFont
@@ -760,9 +790,9 @@ struct ImFont
float FontSize; float FontSize;
float Scale; float Scale;
ImVec2 DisplayOffset; ImVec2 DisplayOffset;
ImVector/*<ImFontGlyph>*/ Glyphs; ImVector_ImFontGlyph Glyphs;
ImVector/*<float>*/ IndexAdvanceX; ImVector_float IndexAdvanceX;
ImVector/*<unsigned short>*/ IndexLookup; ImVector_unsigned_short IndexLookup;
const ImFontGlyph* FallbackGlyph; const ImFontGlyph* FallbackGlyph;
float FallbackAdvanceX; float FallbackAdvanceX;
ImWchar FallbackChar; ImWchar FallbackChar;
@@ -775,7 +805,7 @@ struct ImFont
}; };
struct GlyphRangesBuilder struct GlyphRangesBuilder
{ {
ImVector/*<unsigned char>*/ UsedChars; ImVector_unsigned_char UsedChars;
}; };
struct CustomRect struct CustomRect
{ {
@@ -832,9 +862,6 @@ typedef ImGuiTextFilter::TextRange TextRange;
typedef ImGuiStorage::Pair Pair; typedef ImGuiStorage::Pair Pair;
typedef ImVector<TextRange> ImVector_TextRange; typedef ImVector<TextRange> ImVector_TextRange;
typedef ImVector<ImWchar> ImVector_ImWchar; typedef ImVector<ImWchar> ImVector_ImWchar;
#else //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
typedef ImVector ImVector_TextRange;
typedef ImVector ImVector_ImWchar;
#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS #endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
CIMGUI_API ImVec2* ImVec2_ImVec2(void); CIMGUI_API ImVec2* ImVec2_ImVec2(void);
CIMGUI_API void ImVec2_destroy(ImVec2* self); CIMGUI_API void ImVec2_destroy(ImVec2* self);

View File

@@ -418,11 +418,15 @@ local function struct_parser()
--nothing --nothing
else else
local linea = line:gsub("%S+",{class="struct",mutable=""}) local linea = line:gsub("%S+",{class="struct",mutable=""})
local template = linea:match("ImVector<([%w_]+)>") local template = linea:match("ImVector<(.+)>")
if template then if template then
ImVector_templates[template] = true local te = template:gsub("%s","_")
end te = te:gsub("%*","Ptr")
linea = linea:gsub("(%b<>)","/*%1*/") --comment template parameters ImVector_templates[template] = true
linea = linea:gsub("(%b<>)","_"..te) --comment template parameters
end
--linea = linea:gsub("(%b<>)","/*%1*/") --comment template parameters
--linea = linea:gsub("<([%w_]+)>","_%1") --ImVector expand templates
table.insert(structcdefs,linea..comment) table.insert(structcdefs,linea..comment)
end end
return return
@@ -602,8 +606,10 @@ local function func_parser()
-- end -- end
--argscsinpars = argscsinpars:gsub("&","") --argscsinpars = argscsinpars:gsub("&","")
local template = argscsinpars:match("ImVector<([%w_]+)>") local template = argscsinpars:match("ImVector<(.+)>")
if template then if template then
--template = template:gsub("%s","_")
--template = template:gsub("%*","Ptr")
ImVector_templates[template] = true ImVector_templates[template] = true
end end
@@ -929,8 +935,14 @@ local function gen_structs_and_enums_table(cdefs)
end end
--split type name1,name2; in several lines --split type name1,name2; in several lines
local typen,rest = line:match("([^,]+)%s(%S+[,;])") local typen,rest = line:match("([^,]+)%s(%S+[,;])")
local template_type = typen:match("/%*<(.+)>%*/") --local template_type = typen:match("/%*<(.+)>%*/")
if template_type then typen = typen:match("(.+)/%*") end --if template_type then typen = typen:match("(.+)/%*") end
local template_type = typen:match("ImVector_(.+)")
if template_type then
typen = "ImVector"
template_type = template_type:gsub("_"," ")
template_type = template_type:gsub("Ptr","%*")
end
for name in rest:gmatch("([^%s,;]+)%s?[,;]") do for name in rest:gmatch("([^%s,;]+)%s?[,;]") do
table.insert(outtab.structs[structnames[#structnames]],{type=typen,template_type=template_type,name=name}) table.insert(outtab.structs[structnames[#structnames]],{type=typen,template_type=template_type,name=name})
end end
@@ -985,8 +997,18 @@ local function gen_structs_and_enums_table(cdefs)
return outtab, typedefs_dict return outtab, typedefs_dict
end end
local function generate_templates(code,templates,typedefs)
for k,v in pairs(templates) do
--[[typedef struct ImVector{int Size;int Capacity;void* Data;} ImVector;]]
local te = k:gsub("%s","_")
te = te:gsub("%*","Ptr")
--table.insert(code,"typedef struct ImVector_"..te.." {int Size;int Capacity;"..k.."* Data;} ImVector_"..te..";\n")
table.insert(code,"struct ImVector_"..te.." {int Size;int Capacity;"..k.."* Data;} ImVector_"..te..";\n")
table.insert(typedefs,"typedef struct ImVector_"..te.." ImVector_"..te..";\n")
end
end
local function gen_structs_and_enums(cdefs) local function gen_structs_and_enums(cdefs,templates)
local function_closing_re = "}" local function_closing_re = "}"
local namespace_re = "namespace" local namespace_re = "namespace"
local in_namespace = false local in_namespace = false
@@ -998,7 +1020,7 @@ local function gen_structs_and_enums(cdefs)
local innerstructs = {} local innerstructs = {}
local typedefs_table = {} local typedefs_table = {}
local typedefs_dict = {} local typedefs_dict = {}
local linetypedefs = 1 --math.huge
local outtab = {} local outtab = {}
-- Output the file -- Output the file
--table.insert(outtab,"/////////////// BEGIN AUTOGENERATED SEGMENT\n") --table.insert(outtab,"/////////////// BEGIN AUTOGENERATED SEGMENT\n")
@@ -1027,15 +1049,8 @@ local function gen_structs_and_enums(cdefs)
-- ImVector special treatment -- 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,[[ table.insert(outtab,[[typedef struct ImVector{int Size;int Capacity;void* Data;} ImVector;]].."\n")
struct ImVector generate_templates(outtab,templates,typedefs_table)
{
int Size;
int Capacity;
void* Data;
};
typedef struct ImVector ImVector;
]])
structnames[#structnames] = nil structnames[#structnames] = nil
end end
break -- dont write break -- dont write
@@ -1049,9 +1064,14 @@ typedef struct ImVector ImVector;
end end
if #structnames < 2 then -- not inner if #structnames < 2 then -- not inner
if line:match("typedef") and line:match("ImDrawIdx") then --save typedefs of ImDrawIdx
table.insert(typedefs_table,line..";\n")
--linetypedefs = math.min(linetypedefs,#outtab)
break
end
if (#structnames > 0) then if (#structnames > 0) then
if line:match("typedef") then --dont allow inner typedefs if line:match("typedef") then --dont allow inner typedefs
break break --already saved
elseif not line:match("^{$") and not line:match(struct_closing_re) then --avoid tab { and }; elseif not line:match("^{$") and not line:match(struct_closing_re) then --avoid tab { and };
--line = " "..line --line = " "..line
end end
@@ -1060,6 +1080,7 @@ typedef struct ImVector ImVector;
local struct_closed_name = line:match(struct_closed_re) local struct_closed_name = line:match(struct_closed_re)
if struct_closed_name then if struct_closed_name then
table.insert(typedefs_table,"typedef struct "..struct_closed_name.." "..struct_closed_name..";\n") table.insert(typedefs_table,"typedef struct "..struct_closed_name.." "..struct_closed_name..";\n")
--linetypedefs = math.min(linetypedefs,#outtab)
typedefs_dict[struct_closed_name] = "struct "..struct_closed_name typedefs_dict[struct_closed_name] = "struct "..struct_closed_name
end end
end end
@@ -1076,6 +1097,7 @@ typedef struct ImVector ImVector;
local structname = structnames[#structnames] local structname = structnames[#structnames]
--st[#st + 1] = string.format("typedef struct %s %s;\n",structname,structname) --st[#st + 1] = string.format("typedef struct %s %s;\n",structname,structname)
table.insert(typedefs_table,string.format("typedef struct %s %s;\n",structname,structname)) table.insert(typedefs_table,string.format("typedef struct %s %s;\n",structname,structname))
--linetypedefs = math.min(linetypedefs,#outtab)
typedefs_dict[structname] = "struct "..structname typedefs_dict[structname] = "struct "..structname
structnames[#structnames] = nil structnames[#structnames] = nil
end end
@@ -1083,6 +1105,7 @@ typedef struct ImVector ImVector;
local structname = structnames[#structnames] local structname = structnames[#structnames]
--table.insert(outtab,"typedef struct "..structname.." "..structname..";\n") --table.insert(outtab,"typedef struct "..structname.." "..structname..";\n")
table.insert(typedefs_table,"typedef struct "..structname.." "..structname..";\n") table.insert(typedefs_table,"typedef struct "..structname.." "..structname..";\n")
--linetypedefs = math.min(linetypedefs,#outtab)
typedefs_dict[structname] = "struct "..structname typedefs_dict[structname] = "struct "..structname
structnames[#structnames] = nil structnames[#structnames] = nil
end end
@@ -1102,7 +1125,7 @@ typedef struct ImVector ImVector;
for i,l in ipairs(typedefs_table) do for i,l in ipairs(typedefs_table) do
if not uniques[l] then if not uniques[l] then
uniques[l] = true uniques[l] = true
table.insert(outtab,2,l) table.insert(outtab,linetypedefs,l)
end end
end end
local cstructsstr = table.concat(outtab) local cstructsstr = table.concat(outtab)
@@ -1145,10 +1168,10 @@ local function func_header_generate(FP)
for k,v in pairs(FP.ImVector_templates) do for k,v in pairs(FP.ImVector_templates) do
table.insert(outtab,"typedef ImVector<"..k.."> ImVector_"..k..";\n") table.insert(outtab,"typedef ImVector<"..k.."> ImVector_"..k..";\n")
end end
table.insert(outtab,"#else //CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n") -- table.insert(outtab,"#else //CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n")
for k,v in pairs(FP.ImVector_templates) do -- for k,v in pairs(FP.ImVector_templates) do
table.insert(outtab,"typedef ImVector ImVector_"..k..";\n") -- table.insert(outtab,"typedef ImVector ImVector_"..k..";\n")
end -- end
table.insert(outtab,"#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n") table.insert(outtab,"#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n")
for _,t in ipairs(FP.cdefs) do for _,t in ipairs(FP.cdefs) do
if t.cimguiname then if t.cimguiname then
@@ -1389,11 +1412,13 @@ local function set_defines(fdefs)
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)
--get all ImVector templates
local ImVector_templates = mergeT(STP.ImVector_templates,FP.ImVector_templates)
--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,typedefs_dict = gen_structs_and_enums(STP.lines) local cstructsstr,typedefs_dict = gen_structs_and_enums(STP.lines,ImVector_templates)
--for not gcc parsing --for not gcc parsing
if postfix == "_nopreprocess" then if postfix == "_nopreprocess" then
cstructsstr = "typedef unsigned short ImDrawIdx;\ntypedef void* ImTextureID;\n"..cstructsstr cstructsstr = "typedef unsigned short ImDrawIdx;\ntypedef void* ImTextureID;\n"..cstructsstr

View File

@@ -40,12 +40,30 @@ typedef struct ImColor_Simple { ImVec4_Simple Value;} ImColor_Simple;
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS #ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
struct ImDrawChannel;
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 unsigned short ImDrawIdx;;
typedef struct Pair Pair; typedef struct Pair Pair;
typedef struct TextRange TextRange; typedef struct TextRange TextRange;
typedef struct ImVector_ImVec2 ImVector_ImVec2;
typedef struct ImVector_ImDrawIdx ImVector_ImDrawIdx;
typedef struct ImVector_ImVec4 ImVector_ImVec4;
typedef struct ImVector_TextRange ImVector_TextRange;
typedef struct ImVector_ImFontPtr ImVector_ImFontPtr;
typedef struct ImVector_ImDrawCmd ImVector_ImDrawCmd;
typedef struct ImVector_ImDrawVert ImVector_ImDrawVert;
typedef struct ImVector_unsigned_short ImVector_unsigned_short;
typedef struct ImVector_ImTextureID ImVector_ImTextureID;
typedef struct ImVector_char ImVector_char;
typedef struct ImVector_ImDrawChannel ImVector_ImDrawChannel;
typedef struct ImVector_CustomRect ImVector_CustomRect;
typedef struct ImVector_Pair ImVector_Pair;
typedef struct ImVector_unsigned_char ImVector_unsigned_char;
typedef struct ImVector_ImFontGlyph ImVector_ImFontGlyph;
typedef struct ImVector_ImFontConfig ImVector_ImFontConfig;
typedef struct ImVector_ImWchar ImVector_ImWchar;
typedef struct ImVector_float ImVector_float;
typedef struct ImVec4 ImVec4; typedef struct ImVec4 ImVec4;
typedef struct ImVec2 ImVec2; typedef struct ImVec2 ImVec2;
typedef struct ImGuiTextBuffer ImGuiTextBuffer; typedef struct ImGuiTextBuffer ImGuiTextBuffer;
@@ -69,6 +87,7 @@ 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;
struct ImDrawChannel;
struct ImDrawCmd; struct ImDrawCmd;
struct ImDrawData; struct ImDrawData;
struct ImDrawList; struct ImDrawList;
@@ -568,13 +587,25 @@ struct ImGuiIO
float NavInputsDownDuration[ImGuiNavInput_COUNT]; float NavInputsDownDuration[ImGuiNavInput_COUNT];
float NavInputsDownDurationPrev[ImGuiNavInput_COUNT]; float NavInputsDownDurationPrev[ImGuiNavInput_COUNT];
}; };
struct ImVector typedef struct ImVector{int Size;int Capacity;void* Data;} ImVector;
{ struct ImVector_float {int Size;int Capacity;float* Data;} ImVector_float;
int Size; struct ImVector_ImWchar {int Size;int Capacity;ImWchar* Data;} ImVector_ImWchar;
int Capacity; struct ImVector_ImFontConfig {int Size;int Capacity;ImFontConfig* Data;} ImVector_ImFontConfig;
void* Data; struct ImVector_ImFontGlyph {int Size;int Capacity;ImFontGlyph* Data;} ImVector_ImFontGlyph;
}; struct ImVector_unsigned_char {int Size;int Capacity;unsigned char* Data;} ImVector_unsigned_char;
typedef struct ImVector ImVector; struct ImVector_Pair {int Size;int Capacity;Pair* Data;} ImVector_Pair;
struct ImVector_CustomRect {int Size;int Capacity;CustomRect* Data;} ImVector_CustomRect;
struct ImVector_ImDrawChannel {int Size;int Capacity;ImDrawChannel* Data;} ImVector_ImDrawChannel;
struct ImVector_char {int Size;int Capacity;char* Data;} ImVector_char;
struct ImVector_ImTextureID {int Size;int Capacity;ImTextureID* Data;} ImVector_ImTextureID;
struct ImVector_unsigned_short {int Size;int Capacity;unsigned short* Data;} ImVector_unsigned_short;
struct ImVector_ImDrawVert {int Size;int Capacity;ImDrawVert* Data;} ImVector_ImDrawVert;
struct ImVector_ImDrawCmd {int Size;int Capacity;ImDrawCmd* Data;} ImVector_ImDrawCmd;
struct ImVector_ImFontPtr {int Size;int Capacity;ImFont** Data;} ImVector_ImFontPtr;
struct ImVector_TextRange {int Size;int Capacity;TextRange* Data;} ImVector_TextRange;
struct ImVector_ImVec4 {int Size;int Capacity;ImVec4* Data;} ImVector_ImVec4;
struct ImVector_ImDrawIdx {int Size;int Capacity;ImDrawIdx* Data;} ImVector_ImDrawIdx;
struct ImVector_ImVec2 {int Size;int Capacity;ImVec2* Data;} ImVector_ImVec2;
struct ImNewDummy {}; struct ImNewDummy {};
struct ImGuiOnceUponAFrame struct ImGuiOnceUponAFrame
{ {
@@ -583,16 +614,16 @@ struct ImGuiOnceUponAFrame
struct ImGuiTextFilter struct ImGuiTextFilter
{ {
char InputBuf[256]; char InputBuf[256];
ImVector/*<TextRange>*/ Filters; ImVector_TextRange Filters;
int CountGrep; int CountGrep;
}; };
struct ImGuiTextBuffer struct ImGuiTextBuffer
{ {
ImVector/*<char>*/ Buf; ImVector_char Buf;
}; };
struct ImGuiStorage struct ImGuiStorage
{ {
ImVector/*<Pair>*/ Data; ImVector_Pair Data;
}; };
struct ImGuiInputTextCallbackData struct ImGuiInputTextCallbackData
{ {
@@ -646,7 +677,6 @@ struct ImDrawCmd
ImDrawCallback UserCallback; ImDrawCallback UserCallback;
void* UserCallbackData; void* UserCallbackData;
}; };
typedef unsigned short ImDrawIdx;
struct ImDrawVert struct ImDrawVert
{ {
ImVec2 pos; ImVec2 pos;
@@ -655,8 +685,8 @@ struct ImDrawVert
}; };
struct ImDrawChannel struct ImDrawChannel
{ {
ImVector/*<ImDrawCmd>*/ CmdBuffer; ImVector_ImDrawCmd CmdBuffer;
ImVector/*<ImDrawIdx>*/ IdxBuffer; ImVector_ImDrawIdx IdxBuffer;
}; };
enum ImDrawCornerFlags_ enum ImDrawCornerFlags_
{ {
@@ -677,21 +707,21 @@ enum ImDrawListFlags_
}; };
struct ImDrawList struct ImDrawList
{ {
ImVector/*<ImDrawCmd>*/ CmdBuffer; ImVector_ImDrawCmd CmdBuffer;
ImVector/*<ImDrawIdx>*/ IdxBuffer; ImVector_ImDrawIdx IdxBuffer;
ImVector/*<ImDrawVert>*/ VtxBuffer; ImVector_ImDrawVert VtxBuffer;
ImDrawListFlags Flags; ImDrawListFlags Flags;
const ImDrawListSharedData* _Data; const ImDrawListSharedData* _Data;
const char* _OwnerName; const char* _OwnerName;
unsigned int _VtxCurrentIdx; unsigned int _VtxCurrentIdx;
ImDrawVert* _VtxWritePtr; ImDrawVert* _VtxWritePtr;
ImDrawIdx* _IdxWritePtr; ImDrawIdx* _IdxWritePtr;
ImVector/*<ImVec4>*/ _ClipRectStack; ImVector_ImVec4 _ClipRectStack;
ImVector/*<ImTextureID>*/ _TextureIdStack; ImVector_ImTextureID _TextureIdStack;
ImVector/*<ImVec2>*/ _Path; ImVector_ImVec2 _Path;
int _ChannelsCurrent; int _ChannelsCurrent;
int _ChannelsCount; int _ChannelsCount;
ImVector/*<ImDrawChannel>*/ _Channels; ImVector_ImDrawChannel _Channels;
}; };
struct ImDrawData struct ImDrawData
{ {
@@ -750,9 +780,9 @@ struct ImFontAtlas
int TexHeight; int TexHeight;
ImVec2 TexUvScale; ImVec2 TexUvScale;
ImVec2 TexUvWhitePixel; ImVec2 TexUvWhitePixel;
ImVector/*<ImFont*>*/ Fonts; ImVector_ImFontPtr Fonts;
ImVector/*<CustomRect>*/ CustomRects; ImVector_CustomRect CustomRects;
ImVector/*<ImFontConfig>*/ ConfigData; ImVector_ImFontConfig ConfigData;
int CustomRectIds[1]; int CustomRectIds[1];
}; };
struct ImFont struct ImFont
@@ -760,9 +790,9 @@ struct ImFont
float FontSize; float FontSize;
float Scale; float Scale;
ImVec2 DisplayOffset; ImVec2 DisplayOffset;
ImVector/*<ImFontGlyph>*/ Glyphs; ImVector_ImFontGlyph Glyphs;
ImVector/*<float>*/ IndexAdvanceX; ImVector_float IndexAdvanceX;
ImVector/*<unsigned short>*/ IndexLookup; ImVector_unsigned_short IndexLookup;
const ImFontGlyph* FallbackGlyph; const ImFontGlyph* FallbackGlyph;
float FallbackAdvanceX; float FallbackAdvanceX;
ImWchar FallbackChar; ImWchar FallbackChar;
@@ -775,7 +805,7 @@ struct ImFont
}; };
struct GlyphRangesBuilder struct GlyphRangesBuilder
{ {
ImVector/*<unsigned char>*/ UsedChars; ImVector_unsigned_char UsedChars;
}; };
struct CustomRect struct CustomRect
{ {
@@ -832,9 +862,6 @@ typedef ImGuiTextFilter::TextRange TextRange;
typedef ImGuiStorage::Pair Pair; typedef ImGuiStorage::Pair Pair;
typedef ImVector<TextRange> ImVector_TextRange; typedef ImVector<TextRange> ImVector_TextRange;
typedef ImVector<ImWchar> ImVector_ImWchar; typedef ImVector<ImWchar> ImVector_ImWchar;
#else //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
typedef ImVector ImVector_TextRange;
typedef ImVector ImVector_ImWchar;
#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS #endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS
CIMGUI_API ImVec2* ImVec2_ImVec2(void); CIMGUI_API ImVec2* ImVec2_ImVec2(void);
CIMGUI_API void ImVec2_destroy(ImVec2* self); CIMGUI_API void ImVec2_destroy(ImVec2* self);

View File

@@ -1,6 +1,6 @@
struct GLFWwindow;
typedef struct SDL_Window SDL_Window; typedef struct SDL_Window SDL_Window;
typedef struct GLFWwindow GLFWwindow; typedef struct GLFWwindow GLFWwindow;
struct GLFWwindow;
struct SDL_Window; struct SDL_Window;
typedef union SDL_Event SDL_Event; typedef union SDL_Event SDL_Event;
CIMGUI_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window,bool install_callbacks); CIMGUI_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window,bool install_callbacks);