mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
51f02dca4d | ||
![]() |
84a9656889 | ||
![]() |
553df3da32 | ||
![]() |
04d4a19beb | ||
![]() |
3b9c53b2a2 | ||
![]() |
6f9e3db1d1 | ||
![]() |
d3eb876266 |
27
README.md
27
README.md
@@ -33,10 +33,31 @@ Notes:
|
||||
* as a result some files are generated: `cimgui.cpp` and `cimgui.h` for compiling and some lua/json files with information about the binding: `definitions.json` with function info, `structs_and_enums.json` with struct and enum info, `impl_definitions.json` with functions from the implementations info.
|
||||
|
||||
# generate binding
|
||||
* with your prefered languaje from lua or json files as in:
|
||||
* with your prefered language you can use the lua or json files generated as in:
|
||||
* https://github.com/sonoro1234/LuaJIT-ImGui/blob/master_auto_implementations/lua/build.bat (with lua code generation in https://github.com/sonoro1234/LuaJIT-ImGui/blob/master_auto_implementations/lua/class_gen.lua)
|
||||
* https://github.com/mellinoe/ImGui.NET/tree/autogen/src/CodeGenerator
|
||||
|
||||
### definitions description
|
||||
* It is a collection in which key is the cimgui name that would result without overloadings and the value is an array of overloadings (may be only one overloading)
|
||||
* Each overloading is a collection. Some relevant keys and values are:
|
||||
* stname : the name of the struct the function belongs to (may be ImGui if it is top level in ImGui namespace)
|
||||
* ov_cimguiname : the overloaded cimgui name (if absent it would be taken from cimguiname)
|
||||
* cimguiname : the name without overloading (this should be used if there is not ov_cimguiname)
|
||||
* call_args : a string with the argument names separated by commas
|
||||
* args : the same as above but with types
|
||||
* ret : the return type
|
||||
* argsT : an array of collections (each one with type: argument type and name: the argument name)
|
||||
* defaults : a collection in which key is argument name and value is the default value.
|
||||
* manual : will be true if this function is hand-written (not generated)
|
||||
* nonUDT : if present can be 1 or 2 (explained meaning in usage) if return type was a user defined type
|
||||
### structs_and_enums description
|
||||
* Is is a collection with two items:
|
||||
* under key enums we get the enums collection in which each key is the enum tagname and the value is an array of the ordered values represented as a collection with keys
|
||||
* name : the name of this enum value
|
||||
* value : the C string
|
||||
* calc_value : the numeric value corresponding to value
|
||||
* under key structs we get the structs collection in which the key is the struct name and the value is an array of the struct members. Each one given as a collection with keys
|
||||
* type : the type of the struct member
|
||||
* name : the name of the struct member
|
||||
# usage
|
||||
|
||||
* use whatever method is in ImGui c++ namespace in the original [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h) by prepending `ig`
|
||||
@@ -52,5 +73,5 @@ Notes:
|
||||
* [ImGuiCS](https://github.com/conatuscreative/ImGuiCS)
|
||||
* [imgui-rs](https://github.com/Gekkio/imgui-rs)
|
||||
* [imgui-pas](https://github.com/dpethes/imgui-pas)
|
||||
* [odin-dear_imgui](https://github.com/ThisDrunkDane/odin-dear_imgui)
|
||||
* [odin-imgui](https://github.com/ThisDrunkDane/odin-imgui)
|
||||
* [LuaJIT-imgui](https://github.com/sonoro1234/LuaJIT-ImGui)
|
||||
|
@@ -477,7 +477,7 @@ CIMGUI_API ImGuiID igGetIDStr(const char* str_id)
|
||||
{
|
||||
return ImGui::GetID(str_id);
|
||||
}
|
||||
CIMGUI_API ImGuiID igGetIDStrStr(const char* str_id_begin,const char* str_id_end)
|
||||
CIMGUI_API ImGuiID igGetIDRange(const char* str_id_begin,const char* str_id_end)
|
||||
{
|
||||
return ImGui::GetID(str_id_begin,str_id_end);
|
||||
}
|
||||
|
2
cimgui.h
2
cimgui.h
@@ -954,7 +954,7 @@ CIMGUI_API void igPushIDPtr(const void* ptr_id);
|
||||
CIMGUI_API void igPushIDInt(int int_id);
|
||||
CIMGUI_API void igPopID(void);
|
||||
CIMGUI_API ImGuiID igGetIDStr(const char* str_id);
|
||||
CIMGUI_API ImGuiID igGetIDStrStr(const char* str_id_begin,const char* str_id_end);
|
||||
CIMGUI_API ImGuiID igGetIDRange(const char* str_id_begin,const char* str_id_end);
|
||||
CIMGUI_API ImGuiID igGetIDPtr(const void* ptr_id);
|
||||
CIMGUI_API void igTextUnformatted(const char* text,const char* text_end);
|
||||
CIMGUI_API void igText(const char* fmt,...);
|
||||
|
@@ -62,6 +62,9 @@ local cimgui_overloads = {
|
||||
--["(const void*)"] = "igPushIDPtr",
|
||||
--["(int)"] = "igPushIDInt"
|
||||
},
|
||||
igGetID = {
|
||||
["(const char*,const char*)"] = "igGetIDRange",
|
||||
},
|
||||
ImDrawList_AddText = {
|
||||
["(const ImVec2,ImU32,const char*,const char*)"] = "ImDrawList_AddText",
|
||||
},
|
||||
@@ -96,27 +99,86 @@ local gdefines = {} --for FLT_MAX and others
|
||||
--------------------------------------------------------------------------
|
||||
--helper functions
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
local function split_comment(line)
|
||||
local comment = line:match("(%s*//.*)") or ""
|
||||
line = line:gsub("%s*//.*","")
|
||||
line = line:gsub("%s*$","")
|
||||
return line,comment
|
||||
end
|
||||
--minimal preprocessor
|
||||
local function filelines(file,locats)
|
||||
local iflevels = {}
|
||||
--generated known prepros
|
||||
local prepro = {
|
||||
["#if"]={
|
||||
[ "defined(__clang__) || defined(__GNUC__)" ]=false,
|
||||
[ "defined(__clang__)" ]=false,
|
||||
[ "defined(_MSC_VER) && !defined(__clang__)" ]=false,
|
||||
[ "!defined(IMGUI_DISABLE_INCLUDE_IMCONFIG_H) || defined(IMGUI_INCLUDE_IMCONFIG_H)" ]=false,
|
||||
[ "!defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \\" ]=false,
|
||||
},
|
||||
["#elif"]={
|
||||
[ "defined(__GNUC__) && __GNUC__ >= 8" ]=false,
|
||||
[ "(defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100)" ]=false,
|
||||
},
|
||||
["#ifdef"]={
|
||||
[ "IM_VEC4_CLASS_EXTRA" ]=false,
|
||||
[ "IMGUI_USER_CONFIG" ]=false,
|
||||
[ "IMGUI_INCLUDE_IMGUI_USER_H" ]=false,
|
||||
[ "IMGUI_USE_BGRA_PACKED_COLOR" ]=false,
|
||||
[ "IM_VEC2_CLASS_EXTRA" ]=false,
|
||||
},
|
||||
["#ifndef"]={
|
||||
[ "IMGUI_API" ]=false,
|
||||
[ "IMGUI_IMPL_API" ]=false,
|
||||
[ "IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT" ]=true,
|
||||
[ "IM_ASSERT" ]=false,
|
||||
[ "ImTextureID" ]=true,
|
||||
[ "ImDrawIdx" ]=true,
|
||||
[ "IMGUI_DISABLE_OBSOLETE_FUNCTIONS" ]=false,
|
||||
},
|
||||
}
|
||||
--only one case is true
|
||||
local function prepro_boolif(line)
|
||||
local function prepro_boolifBAK(line)
|
||||
local ma = line:match("#ifndef%s+IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT") or line:match("#ifndef%s+ImTextureID")
|
||||
return not (ma==nil)
|
||||
end
|
||||
local function prepro_boolif(pre,cond)
|
||||
local conds = prepro[pre]
|
||||
assert(conds,pre.." has no conds-----------------------------")
|
||||
local res = conds[cond]
|
||||
--assert(type(res)~="nil",cond.." not found")
|
||||
if type(res)=="nil" then
|
||||
print(pre,cond,"not found in precompiler database, returning false.")
|
||||
res = false
|
||||
end
|
||||
return res
|
||||
end
|
||||
local function location_it()
|
||||
repeat
|
||||
local line = file:read"*l"
|
||||
if not line then return nil end
|
||||
if line:sub(1,1) == "#" then
|
||||
--if line:sub(1,1) == "#" then
|
||||
if line:match("^%s*#") then
|
||||
line,_ = split_comment(line)
|
||||
local pre,cond = line:match("^%s*(#%S*)%s+(.*)%s*$")
|
||||
if line:match("#if") then
|
||||
iflevels[#iflevels +1 ] = prepro_boolif(line)
|
||||
iflevels[#iflevels +1 ] = prepro_boolif(pre,cond)
|
||||
elseif line:match("#endif") then
|
||||
iflevels[#iflevels] = nil
|
||||
elseif line:match("#elseif") then
|
||||
iflevels[#iflevels] = false -- all false now
|
||||
elseif line:match("#elif") then
|
||||
if not iflevels[#iflevels] then
|
||||
iflevels[#iflevels] = prepro_boolif(pre,cond)
|
||||
else --was true
|
||||
iflevels[#iflevels] = false
|
||||
end
|
||||
elseif line:match("#else") then
|
||||
iflevels[#iflevels] = not iflevels[#iflevels]
|
||||
else
|
||||
if not (pre:match("#define") or pre:match"#include" or pre:match"#pragma") then
|
||||
print("not expected preprocessor directive ",pre)
|
||||
end
|
||||
end
|
||||
-- skip
|
||||
elseif #iflevels == 0 or iflevels[#iflevels] then
|
||||
@@ -294,12 +356,6 @@ local function clean_spaces(cad)
|
||||
cad = cad:gsub("%s*([%(%),=])%s*","%1") --not spaces with ( , )
|
||||
return cad
|
||||
end
|
||||
local function split_comment(line)
|
||||
local comment = line:match("(%s*//.*)") or ""
|
||||
line = line:gsub("%s*//.*","")
|
||||
line = line:gsub("%s*$","")
|
||||
return line,comment
|
||||
end
|
||||
local function get_manuals(def)
|
||||
return cimgui_manuals[def.ov_cimguiname] or cimgui_manuals[def.cimguiname]
|
||||
end
|
||||
@@ -1362,6 +1418,7 @@ local iterator = (HAVE_COMPILER and location) or filelines
|
||||
for line in iterator(pipe,{"imgui"}) do
|
||||
local line, comment = split_comment(line)
|
||||
--line = clean_spaces(line)
|
||||
--comment = ""
|
||||
pSTP.insert(line,comment)
|
||||
pFP.insert(line,comment)
|
||||
end
|
||||
|
@@ -477,7 +477,7 @@ CIMGUI_API ImGuiID igGetIDStr(const char* str_id)
|
||||
{
|
||||
return ImGui::GetID(str_id);
|
||||
}
|
||||
CIMGUI_API ImGuiID igGetIDStrStr(const char* str_id_begin,const char* str_id_end)
|
||||
CIMGUI_API ImGuiID igGetIDRange(const char* str_id_begin,const char* str_id_end)
|
||||
{
|
||||
return ImGui::GetID(str_id_begin,str_id_end);
|
||||
}
|
||||
|
@@ -954,7 +954,7 @@ CIMGUI_API void igPushIDPtr(const void* ptr_id);
|
||||
CIMGUI_API void igPushIDInt(int int_id);
|
||||
CIMGUI_API void igPopID(void);
|
||||
CIMGUI_API ImGuiID igGetIDStr(const char* str_id);
|
||||
CIMGUI_API ImGuiID igGetIDStrStr(const char* str_id_begin,const char* str_id_end);
|
||||
CIMGUI_API ImGuiID igGetIDRange(const char* str_id_begin,const char* str_id_end);
|
||||
CIMGUI_API ImGuiID igGetIDPtr(const void* ptr_id);
|
||||
CIMGUI_API void igTextUnformatted(const char* text,const char* text_end);
|
||||
CIMGUI_API void igText(const char* fmt,...);
|
||||
|
File diff suppressed because one or more lines are too long
@@ -4135,7 +4135,7 @@ defs["igGetID"][2]["argsT"][1]["name"] = "str_id_begin"
|
||||
defs["igGetID"][2]["argsT"][2] = {}
|
||||
defs["igGetID"][2]["argsT"][2]["type"] = "const char*"
|
||||
defs["igGetID"][2]["argsT"][2]["name"] = "str_id_end"
|
||||
defs["igGetID"][2]["ov_cimguiname"] = "igGetIDStrStr"
|
||||
defs["igGetID"][2]["ov_cimguiname"] = "igGetIDRange"
|
||||
defs["igGetID"][2]["defaults"] = {}
|
||||
defs["igGetID"][2]["signature"] = "(const char*,const char*)"
|
||||
defs["igGetID"][2]["cimguiname"] = "igGetID"
|
||||
|
@@ -43,7 +43,7 @@ igMenuItem 2
|
||||
2 bool igMenuItemBoolPtr (const char*,const char*,bool*,bool)
|
||||
igGetID 3
|
||||
1 ImGuiID igGetIDStr (const char*)
|
||||
2 ImGuiID igGetIDStrStr (const char*,const char*)
|
||||
2 ImGuiID igGetIDRange (const char*,const char*)
|
||||
3 ImGuiID igGetIDPtr (const void*)
|
||||
igListBoxHeader 2
|
||||
1 bool igListBoxHeaderVec2 (const char*,const ImVec2)
|
||||
|
Reference in New Issue
Block a user