even some more work

This commit is contained in:
sonoro1234
2018-05-04 09:32:01 +02:00
parent 7b03588b3a
commit 1761822733
7 changed files with 628 additions and 532 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,14 @@
#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
typedef ImFontAtlas::GlyphRangesBuilder GlyphRangesBuilder;
typedef ImFontAtlas::CustomRect CustomRect;
typedef ImGuiTextFilter::TextRange TextRange;
typedef ImGuiStorage::Pair Pair;
typedef ImVector<TextRange> ImVector_TextRange;
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
CIMGUI_API ImGuiContext* igCreateContext(ImFontAtlas* shared_font_atlas);
CIMGUI_API void igDestroyContext(ImGuiContext* ctx);
CIMGUI_API ImGuiContext* igGetCurrentContext();
@@ -141,16 +152,16 @@ CIMGUI_API bool igCheckboxFlags(const char* label,unsigned int* flags,unsigned
CIMGUI_API bool igRadioButtonBool(const char* label,bool active);
CIMGUI_API bool igRadioButtonIntPtr(const char* label,int* v,int v_button);
CIMGUI_API void igPlotLinesFloatPtr(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride);
CIMGUI_API void igPlotLinesPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size);
CIMGUI_API void igPlotLinesFnPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size);
CIMGUI_API void igPlotHistogramFloatPtr(const char* label,const float* values,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size,int stride);
CIMGUI_API void igPlotHistogramPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size);
CIMGUI_API void igPlotHistogramFnPtr(const char* label,float(*values_getter)(void* data,int idx),void* data,int values_count,int values_offset,const char* overlay_text,float scale_min,float scale_max,ImVec2 graph_size);
CIMGUI_API void igProgressBar(float fraction,const ImVec2 size_arg,const char* overlay);
CIMGUI_API void igBullet();
CIMGUI_API bool igBeginCombo(const char* label,const char* preview_value,ImGuiComboFlags flags);
CIMGUI_API void igEndCombo();
CIMGUI_API bool igComboStr_arr(const char* label,int* current_item,const char* const items[],int items_count,int popup_max_height_in_items);
CIMGUI_API bool igComboStr(const char* label,int* current_item,const char* items_separated_by_zeros,int popup_max_height_in_items);
CIMGUI_API bool igComboPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int popup_max_height_in_items);
CIMGUI_API bool igComboFnPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int popup_max_height_in_items);
CIMGUI_API bool igDragFloat(const char* label,float* v,float v_speed,float v_min,float v_max,const char* display_format,float power);
CIMGUI_API bool igDragFloat2(const char* label,float v[2],float v_speed,float v_min,float v_max,const char* display_format,float power);
CIMGUI_API bool igDragFloat3(const char* label,float v[3],float v_speed,float v_min,float v_max,const char* display_format,float power);
@@ -205,12 +216,12 @@ CIMGUI_API void igTreePop();
CIMGUI_API void igTreeAdvanceToLabelPos();
CIMGUI_API float igGetTreeNodeToLabelSpacing();
CIMGUI_API void igSetNextTreeNodeOpen(bool is_open,ImGuiCond cond);
CIMGUI_API bool igCollapsingHeaderTreeNodeFlags(const char* label,ImGuiTreeNodeFlags flags);
CIMGUI_API bool igCollapsingHeader(const char* label,ImGuiTreeNodeFlags flags);
CIMGUI_API bool igCollapsingHeaderBoolPtr(const char* label,bool* p_open,ImGuiTreeNodeFlags flags);
CIMGUI_API bool igSelectableBool(const char* label,bool selected,ImGuiSelectableFlags flags,const ImVec2 size);
CIMGUI_API bool igSelectableBoolPtr(const char* label,bool* p_selected,ImGuiSelectableFlags flags,const ImVec2 size);
CIMGUI_API bool igListBoxStr_arr(const char* label,int* current_item,const char* const items[],int items_count,int height_in_items);
CIMGUI_API bool igListBoxPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int height_in_items);
CIMGUI_API bool igListBoxFnPtr(const char* label,int* current_item,bool(*items_getter)(void* data,int idx,const char** out_text),void* data,int items_count,int height_in_items);
CIMGUI_API bool igListBoxHeaderVec2(const char* label,const ImVec2 size);
CIMGUI_API bool igListBoxHeaderInt(const char* label,int items_count,int height_in_items);
CIMGUI_API void igListBoxFooter();
@@ -322,13 +333,13 @@ CIMGUI_API void ImGuiStyle_ScaleAllSizes(ImGuiStyle* self,float scale_factor);
CIMGUI_API void ImGuiIO_AddInputCharacter(ImGuiIO* self,ImWchar c);
CIMGUI_API void ImGuiIO_AddInputCharactersUTF8(ImGuiIO* self,const char* utf8_chars);
CIMGUI_API inline void ImGuiIO_ClearInputCharacters(ImGuiIO* self);
CIMGUI_API const char* TextRange_begin(ImGuiTextFilter::TextRange* self);
CIMGUI_API const char* TextRange_end(ImGuiTextFilter::TextRange* self);
CIMGUI_API bool TextRange_empty(ImGuiTextFilter::TextRange* self);
CIMGUI_API char TextRange_front(ImGuiTextFilter::TextRange* self);
CIMGUI_API bool TextRange_is_blank(ImGuiTextFilter::TextRange* self,char c);
CIMGUI_API void TextRange_trim_blanks(ImGuiTextFilter::TextRange* self);
CIMGUI_API void TextRange_split(ImGuiTextFilter::TextRange* self,char separator,ImVector<TextRange> out);
CIMGUI_API const char* TextRange_begin(TextRange* self);
CIMGUI_API const char* TextRange_end(TextRange* self);
CIMGUI_API bool TextRange_empty(TextRange* self);
CIMGUI_API char TextRange_front(TextRange* self);
CIMGUI_API bool TextRange_is_blank(TextRange* self,char c);
CIMGUI_API void TextRange_trim_blanks(TextRange* self);
CIMGUI_API void TextRange_split(TextRange* self,char separator,ImVector_TextRange out);
CIMGUI_API bool ImGuiTextFilter_Draw(ImGuiTextFilter* self,const char* label,float width);
CIMGUI_API bool ImGuiTextFilter_PassFilter(ImGuiTextFilter* self,const char* text,const char* text_end);
CIMGUI_API void ImGuiTextFilter_Build(ImGuiTextFilter* self);
@@ -443,13 +454,13 @@ CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesJapanese(ImFontAtlas* self)
CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesChinese(ImFontAtlas* self);
CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesCyrillic(ImFontAtlas* self);
CIMGUI_API const ImWchar* ImFontAtlas_GetGlyphRangesThai(ImFontAtlas* self);
CIMGUI_API bool GlyphRangesBuilder_GetBit(ImFontAtlas::GlyphRangesBuilder* self,int n);
CIMGUI_API void GlyphRangesBuilder_SetBit(ImFontAtlas::GlyphRangesBuilder* self,int n);
CIMGUI_API void GlyphRangesBuilder_AddChar(ImFontAtlas::GlyphRangesBuilder* self,ImWchar c);
CIMGUI_API void GlyphRangesBuilder_AddText(ImFontAtlas::GlyphRangesBuilder* self,const char* text,const char* text_end);
CIMGUI_API void GlyphRangesBuilder_AddRanges(ImFontAtlas::GlyphRangesBuilder* self,const ImWchar* ranges);
CIMGUI_API void GlyphRangesBuilder_BuildRanges(ImFontAtlas::GlyphRangesBuilder* self,ImVector<ImWchar>* out_ranges);
CIMGUI_API bool CustomRect_IsPacked(ImFontAtlas::CustomRect* self);
CIMGUI_API bool GlyphRangesBuilder_GetBit(GlyphRangesBuilder* self,int n);
CIMGUI_API void GlyphRangesBuilder_SetBit(GlyphRangesBuilder* self,int n);
CIMGUI_API void GlyphRangesBuilder_AddChar(GlyphRangesBuilder* self,ImWchar c);
CIMGUI_API void GlyphRangesBuilder_AddText(GlyphRangesBuilder* self,const char* text,const char* text_end);
CIMGUI_API void GlyphRangesBuilder_AddRanges(GlyphRangesBuilder* self,const ImWchar* ranges);
CIMGUI_API void GlyphRangesBuilder_BuildRanges(GlyphRangesBuilder* self,ImVector_ImWchar* out_ranges);
CIMGUI_API bool CustomRect_IsPacked(CustomRect* self);
CIMGUI_API int ImFontAtlas_AddCustomRectRegular(ImFontAtlas* self,unsigned int id,int width,int height);
CIMGUI_API int ImFontAtlas_AddCustomRectFontGlyph(ImFontAtlas* self,ImFont* font,ImWchar id,int width,int height,float advance_x,const ImVec2 offset);
CIMGUI_API const CustomRect* ImFontAtlas_GetCustomRectByIndex(ImFontAtlas* self,int index);

View File

@@ -26,3 +26,7 @@ CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const ch
buffer->appendfv(fmt, args);
va_end(args);
}
CIMGUI_API void ImFontConfig_DefaultConstructor(ImFontConfig *config)
{
*config = ImFontConfig();
}

View File

@@ -35,7 +35,7 @@ typedef unsigned long long ImU64;
#ifdef CIMGUI_DEFINE_ENUMS_AND_STRUCTS
#include "imgui_structs.h"
#endif // CIMGUI_DEFINE_ENUMS_AND_STRUCTS
/*
struct GlyphRangesBuilder
{
ImVector<unsigned char> UsedChars;
@@ -67,10 +67,17 @@ typedef struct TextRange TextRange;
};
typedef struct Pair Pair;
typedef ImFontAtlas::GlyphRangesBuilder GlyphRangesBuilder;
typedef ImFontAtlas::CustomRect CustomRect;
typedef ImGuiTextFilter::TextRange TextRange;
typedef ImGuiStorage::Pair Pair;
*/
#include "auto_funcs.h"
//no LogTextV
CIMGUI_API void igLogText(CONST char *fmt, ...);
//no appendfV
CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...);
CIMGUI_API void ImFontConfig_DefaultConstructor(ImFontConfig *config);

View File

@@ -12,7 +12,10 @@ end
local cimgui_manuals = {
igLogText = true,
ImGuiTextBuffer_appendf = true
ImGuiTextBuffer_appendf = true,
-------------------------
--TextRange_split = true,
--ImFontAtlas_CalcCustomRectUV = true
}
local function get_manuals(def)
@@ -25,6 +28,9 @@ local cimgui_overloads = {
["(const char*,const char*)"] = "igPushIDRange",
["(const void*)"] = "igPushIDPtr",
["(int)"] = "igPushIDInt"
},
igCollapsingHeader = {
["(const char*,ImGuiTreeNodeFlags)"] = "igCollapsingHeader"
}
}
@@ -40,6 +46,7 @@ end
cdefs = {}
local embeded_structs = {}
local ImVector_templates = {}
location_re = '^# %d+ "([^"]*)"'
cimpath_re = '^(.*[\\/])(imgui)%.h$'
define_re = "^#define%s+([^%s]+)%s+([^%s]+)$"
@@ -144,6 +151,13 @@ repeat -- simulate continue with break
local argscsinpars = args:gsub("(=[^,%(%)]*)(%b())","%1")
argscsinpars = argscsinpars:gsub("(=[^,%(%)]*)([,%)])","%2")
argscsinpars = argscsinpars:gsub("&","")
local template = argscsinpars:match("ImVector<([%w_]+)>")
if template then
ImVector_templates[template] = true
end
argscsinpars = argscsinpars:gsub("<([%w_]+)>","_%1") --ImVector
--print(funcname,ret,args,argscsinpars)
-- local signature = argscsinpars:gsub("([%w%s%*_]+)%s[%w_]+%s*([,%)])","%1%2")
-- signature = signature:gsub("%s*([,%)])","%1")
@@ -228,7 +242,25 @@ local function get_types(v)
end
end
end
local function typetoStr(typ)
--typ = typ:gsub("[^%(%)]+%(%*?(.+)%).+","%1") -- funcs
typ = typ:gsub("[^%(%)]+%(%*?(.+)%).+","FnPtr")
typ = typ:gsub("[%w_]+%[(%d*)%]","arr%1")
typ = typ:gsub("%*","Ptr")
typ = typ:gsub("void","")
typ = typ:gsub("unsigned%s","u")
typ = typ:gsub("const%s","")--"c")
typ = typ:gsub("%s+","_")
typ = typ:gsub("charPtr","Str")
typ = typ:gsub("int","Int")
typ = typ:gsub("bool","Bool")
typ = typ:gsub("float","Float")
typ = typ:gsub("uInt","Uint")
typ = typ:gsub("ImGui","")
typ = typ:gsub("Im","")
typ = typ:gsub("[<>]","")
return typ
end
local function name_overloadsAlgo(v)
local aa = {}
local bb = {}
@@ -288,24 +320,7 @@ local function name_overloadsAlgo(v)
end
return aa,bb
end
local function typetoStr(typ)
typ = typ:gsub("[^%(%)]+%(%*?(.+)%).+","%1") -- funcs
typ = typ:gsub("[%w_]+%[(%d*)%]","arr%1")
typ = typ:gsub("%*","Ptr")
typ = typ:gsub("void","")
typ = typ:gsub("unsigned%s","u")
typ = typ:gsub("const%s","")--"c")
typ = typ:gsub("%s+","_")
typ = typ:gsub("charPtr","Str")
typ = typ:gsub("int","Int")
typ = typ:gsub("bool","Bool")
typ = typ:gsub("float","Float")
typ = typ:gsub("uInt","Uint")
typ = typ:gsub("ImGui","")
typ = typ:gsub("Im","")
typ = typ:gsub("[<>]","")
return typ
end
local numoverloaded = 0
print"overloading"
for k,v in pairs(defsT) do
@@ -316,7 +331,7 @@ for k,v in pairs(defsT) do
local typesc,post = name_overloadsAlgo(v)
for i,t in ipairs(v) do
t.ov_cimguiname = getcimguiname_overload(t.stname,t.funcname,t.signature) or k..typetoStr(post[i])
print(i,t.signature,t.ret,t.ov_cimguiname)--post[i],typetoStr(post[i]))
print(i,t.signature,t.ret,t.ov_cimguiname,post[i])--,typetoStr(post[i]))
--prtable(typesc[i])
end
end
@@ -332,9 +347,14 @@ for i,t in ipairs(cdefs) do
end
print"//embeded_structs---------------------------------------------------------------------------"
for k,v in pairs(embeded_structs) do
print(k,v)
--print(k,v)
io.write("typedef ",v," ",k,";\n")
end
--[[
for k,v in pairs(ImVector_templates) do
--print(k,v)
io.write("typedef ImVector<",k,"> ImVector_",k,";\n")
end
---[[
print"//constructors------------------------------------------------------------------"
for i,t in ipairs(cdefs) do
if not t.ret then
@@ -342,7 +362,22 @@ for i,t in ipairs(cdefs) do
end
end
--]]
---------------------------------------------------------------------------------------------
-- auto_funcs.h
local hfile = io.open("./auto_funcs.h","w")
hfile:write("#ifndef CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n")
for k,v in pairs(embeded_structs) do
--print(k,v)
hfile:write("typedef ",v," ",k,";\n")
end
for k,v in pairs(ImVector_templates) do
hfile:write("typedef ImVector<",k,"> ImVector_",k,";\n")
end
hfile:write("#else //CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n")
for k,v in pairs(ImVector_templates) do
hfile:write("typedef ImVector ImVector_",k,";\n")
end
hfile:write("#endif //CIMGUI_DEFINE_ENUMS_AND_STRUCTS\n")
for _,t in ipairs(cdefs) do
local cimf = defsT[t.cimguiname]
local def = cimf[t.signature]
@@ -352,7 +387,8 @@ for _,t in ipairs(cdefs) do
hfile:write("CIMGUI_API"," ",def.ret," ",def.ov_cimguiname or def.cimguiname,def.args,";\n")
else
local empty = def.args:match("^%(%)") --no args
local imgui_stname = embeded_structs[def.stname] or def.stname
--local imgui_stname = embeded_structs[def.stname] or def.stname
local imgui_stname = def.stname
local args = def.args:gsub("^%(","("..imgui_stname.."* self"..(empty and "" or ","))
hfile:write("CIMGUI_API"," ",def.ret," ",def.ov_cimguiname or def.cimguiname,args,";\n")
end
@@ -369,11 +405,12 @@ for _,t in ipairs(cdefs) do
local manual = get_manuals(def)
if not manual and def.ret then --not constructor
local ptret = def.retref and "&" or ""
local castret = def.ret:gsub("[^%s]+",function(x)
local y = x:gsub("%*","")
local typ = embeded_structs[y]
if typ then return "("..x..")" else return "" end
end)
-- local castret = def.ret:gsub("[^%s]+",function(x)
-- local y = x:gsub("%*","")
-- local typ = embeded_structs[y]
-- if typ then return "("..x..")" else return "" end
-- end)
local castret = ""
if def.stname == "ImGui" then
if def.isvararg then
local call_args = def.call_args:gsub("%.%.%.","args")
@@ -393,7 +430,8 @@ for _,t in ipairs(cdefs) do
end
else
local empty = def.args:match("^%(%)") --no args
local imgui_stname = embeded_structs[def.stname] or def.stname
--local imgui_stname = embeded_structs[def.stname] or def.stname
local imgui_stname = def.stname
local args = def.args:gsub("^%(","("..imgui_stname.."* self"..(empty and "" or ","))
if def.isvararg then
local call_args = def.call_args:gsub("%.%.%.","args")

View File

@@ -13,6 +13,7 @@ define_re = "^#define%s+([^%s]+)%s+([^%s]+)$"
function_re = "%b()"
function_closed_re = "[;}]$"
function_closing_re = "}"
functype_re = "(%(%*)[%w_]+(%)%([^%(%)]*%))"
number_re = "^-?[0-9]+$"
hex_re = "0x[0-9a-fA-F]+$"
@@ -48,7 +49,8 @@ repeat -- simulate continue with break
break
end
if line:match(function_re) and not line:match("typedef.*%b().*%b().*") then
if line:match(function_re) and not line:match("typedef.*%b().*%b().*")
and not line:match(functype_re) then
-- function and functypedef
if not line:match(function_closed_re) then
in_function = true

View File

@@ -454,8 +454,12 @@ struct ImGuiIO
ImVec2 DisplayVisibleMax;
bool OptMacOSXBehaviors;
bool OptCursorBlink;
const char* (*GetClipboardTextFn)(void* user_data);
void (*SetClipboardTextFn)(void* user_data, const char* text);
void* ClipboardUserData;
void (*ImeSetInputScreenPosFn)(int x, int y);
void* ImeWindowHandle;
void (*RenderDrawListsFn)(ImDrawData* data);
ImVec2 MousePos;
bool MouseDown[5];
float MouseWheel;
@@ -713,6 +717,36 @@ struct ImFont
int MetricsTotalSurface;
};
typedef struct ImFont ImFont;
struct GlyphRangesBuilder
{
ImVector/*<unsigned char>*/ UsedChars;
};
typedef struct GlyphRangesBuilder GlyphRangesBuilder;
struct CustomRect
{
unsigned int ID;
unsigned short Width, Height;
unsigned short X, Y;
float GlyphAdvanceX;
ImVec2 GlyphOffset;
ImFont* Font;
};
typedef struct CustomRect CustomRect;
struct TextRange
{
const char* b;
const char* e;
};
typedef struct TextRange TextRange;
struct Pair
{
ImGuiID key;
union { int val_i; float val_f; void* val_p; };
};
typedef struct Pair Pair;
#endif //IMGUI_STRUCTS_INCLUDED
//////////////// END AUTOGENERATED SEGMENT