mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-27 10:00:20 +01:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
51f02dca4d | ||
![]() |
84a9656889 | ||
![]() |
553df3da32 | ||
![]() |
04d4a19beb | ||
![]() |
3b9c53b2a2 | ||
![]() |
6f9e3db1d1 | ||
![]() |
d3eb876266 | ||
![]() |
3efb1001aa | ||
![]() |
a91c611bca | ||
![]() |
5b7abe8b4d | ||
![]() |
812af400f1 | ||
![]() |
2d3cf59b21 | ||
![]() |
e7eb9c511b | ||
![]() |
2759a8ed4d | ||
![]() |
073f438467 | ||
![]() |
f7856b27b0 | ||
![]() |
99c7d7cfdf | ||
![]() |
31871f9975 | ||
![]() |
c487b0266e | ||
![]() |
3b386799e4 |
@@ -20,6 +20,7 @@ endif(WIN32)
|
|||||||
#add library and link
|
#add library and link
|
||||||
add_library(cimgui SHARED ${IMGUI_SOURCES})
|
add_library(cimgui SHARED ${IMGUI_SOURCES})
|
||||||
target_link_libraries(cimgui ${IMGUI_LIBRARIES})
|
target_link_libraries(cimgui ${IMGUI_LIBRARIES})
|
||||||
|
set_target_properties(cimgui PROPERTIES PREFIX "")
|
||||||
|
|
||||||
#install
|
#install
|
||||||
install(TARGETS cimgui
|
install(TARGETS cimgui
|
||||||
|
40
README.md
40
README.md
@@ -20,18 +20,44 @@ Notes:
|
|||||||
* clone
|
* clone
|
||||||
* git clone --recursive https://github.com/cimgui/cimgui.git
|
* git clone --recursive https://github.com/cimgui/cimgui.git
|
||||||
* git submodule update
|
* git submodule update
|
||||||
* make using makefile on linux/macOS/mingw (Or use CMake to generate project)
|
* compile
|
||||||
|
* using makefile on linux/macOS/mingw (Or use CMake to generate project)
|
||||||
|
* or as in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master_auto_implementations/build
|
||||||
|
|
||||||
# auto binding generation
|
# using generator
|
||||||
|
|
||||||
* you will need LuaJIT (https://github.com/LuaJIT/LuaJIT.git better 2.1 branch) or precompiled for linux/macOS/windows in https://luapower.com/luajit/download
|
* you will need LuaJIT (https://github.com/LuaJIT/LuaJIT.git better 2.1 branch) or precompiled for linux/macOS/windows in https://luapower.com/luajit/download
|
||||||
* need also gcc compiler for doing preprocessing (In windows MinGW-W64-builds for example)
|
* you can use also a C++ compiler for doing preprocessing: gcc (In windows MinGW-W64-builds for example), clang or cl (MSVC) or not use a compiler (experimental nocompiler option) at all. (this repo was done with gcc)
|
||||||
* update `imgui` folder to the version you desire.
|
* update `imgui` folder to the version you desire.
|
||||||
* run `generator/generator.bat` (or make a .sh version and please PR) with gcc and LuaJIT on your PATH.
|
* edit `generator/generator.bat` (or make a .sh version and please PR) to choose between gcc, clang, cl or nocompiler. Run it with gcc, clang or cl and LuaJIT on your PATH.
|
||||||
* 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.
|
* 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.
|
||||||
* build as shown in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master_auto_implementations/build
|
|
||||||
* generate binding as done in https://github.com/sonoro1234/LuaJIT-ImGui/blob/master_auto_implementations/lua/build.bat
|
|
||||||
|
|
||||||
|
# generate binding
|
||||||
|
* 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
|
# 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`
|
* 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`
|
||||||
@@ -47,5 +73,5 @@ Notes:
|
|||||||
* [ImGuiCS](https://github.com/conatuscreative/ImGuiCS)
|
* [ImGuiCS](https://github.com/conatuscreative/ImGuiCS)
|
||||||
* [imgui-rs](https://github.com/Gekkio/imgui-rs)
|
* [imgui-rs](https://github.com/Gekkio/imgui-rs)
|
||||||
* [imgui-pas](https://github.com/dpethes/imgui-pas)
|
* [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)
|
* [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);
|
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);
|
return ImGui::GetID(str_id_begin,str_id_end);
|
||||||
}
|
}
|
||||||
|
5
cimgui.h
5
cimgui.h
@@ -40,7 +40,7 @@ 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;
|
||||||
@@ -69,7 +69,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;
|
||||||
struct ImDrawChannel;
|
|
||||||
struct ImDrawCmd;
|
struct ImDrawCmd;
|
||||||
struct ImDrawData;
|
struct ImDrawData;
|
||||||
struct ImDrawList;
|
struct ImDrawList;
|
||||||
@@ -955,7 +954,7 @@ CIMGUI_API void igPushIDPtr(const void* ptr_id);
|
|||||||
CIMGUI_API void igPushIDInt(int int_id);
|
CIMGUI_API void igPushIDInt(int int_id);
|
||||||
CIMGUI_API void igPopID(void);
|
CIMGUI_API void igPopID(void);
|
||||||
CIMGUI_API ImGuiID igGetIDStr(const char* str_id);
|
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 ImGuiID igGetIDPtr(const void* ptr_id);
|
||||||
CIMGUI_API void igTextUnformatted(const char* text,const char* text_end);
|
CIMGUI_API void igTextUnformatted(const char* text,const char* text_end);
|
||||||
CIMGUI_API void igText(const char* fmt,...);
|
CIMGUI_API void igText(const char* fmt,...);
|
||||||
|
@@ -14,8 +14,9 @@
|
|||||||
:: set PATH=%PATH%;C:\luaGL;C:\i686-7.2.0-release-posix-dwarf-rt_v5-rev1\mingw32\bin;
|
:: set PATH=%PATH%;C:\luaGL;C:\i686-7.2.0-release-posix-dwarf-rt_v5-rev1\mingw32\bin;
|
||||||
:: set PATH=%PATH%;C:\luaGL\sources\luajit-master\luajit-master\bin\mingw32;C:\mingw32\bin;
|
:: set PATH=%PATH%;C:\luaGL\sources\luajit-master\luajit-master\bin\mingw32;C:\mingw32\bin;
|
||||||
::process files
|
::process files
|
||||||
:: arg[1..n] name of implementations to generate
|
:: arg[1] compiler name gcc, clang, cl or nocompiler
|
||||||
luajit ./generator.lua glfw opengl3 opengl2 sdl
|
:: arg[2..n] name of implementations to generate
|
||||||
|
luajit ./generator.lua gcc glfw opengl3 opengl2 sdl
|
||||||
|
|
||||||
::leave console open
|
::leave console open
|
||||||
cmd /k
|
cmd /k
|
||||||
|
@@ -5,27 +5,41 @@
|
|||||||
assert(_VERSION=='Lua 5.1',"Must use LuaJIT")
|
assert(_VERSION=='Lua 5.1',"Must use LuaJIT")
|
||||||
assert(bit,"Must use LuaJIT")
|
assert(bit,"Must use LuaJIT")
|
||||||
local script_args = {...}
|
local script_args = {...}
|
||||||
|
local COMPILER = script_args[1]
|
||||||
--test gcc present
|
local CPRE,CTEST
|
||||||
local HAVE_GCC
|
if COMPILER == "gcc" or COMPILER == "clang" then
|
||||||
local pipe,err = io.popen("gcc --version","r")
|
CPRE = COMPILER..[[ -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]]
|
||||||
|
CTEST = COMPILER.." --version"
|
||||||
|
elseif COMPILER == "cl" then
|
||||||
|
CPRE = COMPILER..[[ /E /DIMGUI_DISABLE_OBSOLETE_FUNCTIONS /DIMGUI_API="" /DIMGUI_IMPL_API="" ]]
|
||||||
|
CTEST = COMPILER
|
||||||
|
else
|
||||||
|
print("Working without compiler ")
|
||||||
|
end
|
||||||
|
--test compiler present
|
||||||
|
local HAVE_COMPILER = false
|
||||||
|
if CTEST then
|
||||||
|
local pipe,err = io.popen(CTEST,"r")
|
||||||
if pipe then
|
if pipe then
|
||||||
local str = pipe:read"*a"
|
local str = pipe:read"*a"
|
||||||
print(str)
|
print(str)
|
||||||
pipe:close()
|
pipe:close()
|
||||||
if str=="" then
|
if str=="" then
|
||||||
HAVE_GCC = false
|
HAVE_COMPILER = false
|
||||||
else
|
else
|
||||||
HAVE_GCC = true
|
HAVE_COMPILER = true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
HAVE_GCC = false
|
HAVE_COMPILER = false
|
||||||
print(err)
|
print(err)
|
||||||
end
|
end
|
||||||
print("HAVE_GCC",HAVE_GCC)
|
assert(HAVE_COMPILER,"gcc, clang or cl needed to run script")
|
||||||
|
end --CTEST
|
||||||
|
|
||||||
|
print("HAVE_COMPILER",HAVE_COMPILER)
|
||||||
--get implementations
|
--get implementations
|
||||||
local implementations = {}
|
local implementations = {}
|
||||||
for i=1,#script_args do table.insert(implementations,script_args[i]) end
|
for i=2,#script_args do table.insert(implementations,script_args[i]) end
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
--this table has the functions to be skipped in generation
|
--this table has the functions to be skipped in generation
|
||||||
@@ -48,6 +62,9 @@ local cimgui_overloads = {
|
|||||||
--["(const void*)"] = "igPushIDPtr",
|
--["(const void*)"] = "igPushIDPtr",
|
||||||
--["(int)"] = "igPushIDInt"
|
--["(int)"] = "igPushIDInt"
|
||||||
},
|
},
|
||||||
|
igGetID = {
|
||||||
|
["(const char*,const char*)"] = "igGetIDRange",
|
||||||
|
},
|
||||||
ImDrawList_AddText = {
|
ImDrawList_AddText = {
|
||||||
["(const ImVec2,ImU32,const char*,const char*)"] = "ImDrawList_AddText",
|
["(const ImVec2,ImU32,const char*,const char*)"] = "ImDrawList_AddText",
|
||||||
},
|
},
|
||||||
@@ -82,34 +99,107 @@ local gdefines = {} --for FLT_MAX and others
|
|||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
--helper functions
|
--helper functions
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
--iterates lines from a .h file and discards between #if.. and #endif
|
|
||||||
local function filelines(file)
|
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 = {}
|
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_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()
|
local function location_it()
|
||||||
repeat
|
repeat
|
||||||
local line = file:read"*l"
|
local line = file:read"*l"
|
||||||
if not line then return nil end
|
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
|
if line:match("#if") then
|
||||||
iflevels[#iflevels +1 ] = true
|
iflevels[#iflevels +1 ] = prepro_boolif(pre,cond)
|
||||||
elseif line:match("#endif") then
|
elseif line:match("#endif") then
|
||||||
iflevels[#iflevels] = nil
|
iflevels[#iflevels] = nil
|
||||||
|
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
|
end
|
||||||
-- skip
|
-- skip
|
||||||
elseif #iflevels == 0 then
|
elseif #iflevels == 0 or iflevels[#iflevels] then
|
||||||
-- drop IMGUI_APIX
|
-- drop IMGUI_APIX
|
||||||
line = line:gsub("IMGUI_IMPL_API","")
|
line = line:gsub("IMGUI_IMPL_API","")
|
||||||
-- drop IMGUI_API
|
-- drop IMGUI_API
|
||||||
line = line:gsub("IMGUI_API","")
|
line = line:gsub("IMGUI_API","")
|
||||||
return line
|
return line,locats[1]
|
||||||
end
|
end
|
||||||
until false
|
until false
|
||||||
end
|
end
|
||||||
return location_it
|
return location_it
|
||||||
end
|
end
|
||||||
--iterates lines from a gcc -E in a specific location
|
--iterates lines from a gcc/clang -E in a specific location
|
||||||
local function location(file,locpathT)
|
local function location(file,locpathT)
|
||||||
local location_re = '^# (%d+) "([^"]*)"'
|
local location_re
|
||||||
|
if COMPILER == "cl" then
|
||||||
|
location_re = '^#line (%d+) "([^"]*)"'
|
||||||
|
else --gcc, clang
|
||||||
|
location_re = '^# (%d+) "([^"]*)"'
|
||||||
|
end
|
||||||
local path_reT = {}
|
local path_reT = {}
|
||||||
for i,locpath in ipairs(locpathT) do
|
for i,locpath in ipairs(locpathT) do
|
||||||
table.insert(path_reT,'^(.*[\\/])('..locpath..')%.h$')
|
table.insert(path_reT,'^(.*[\\/])('..locpath..')%.h$')
|
||||||
@@ -132,7 +222,9 @@ local function location(file,locpathT)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if line:sub(1,1) == "#" then
|
if #line==0 then --nothing on emptyline
|
||||||
|
elseif not line:match("%S") then --nothing if only spaces
|
||||||
|
elseif line:sub(1,1) == "#" then
|
||||||
-- Is this a location pragma?
|
-- Is this a location pragma?
|
||||||
local loc_num_t,location_match = line:match(location_re)
|
local loc_num_t,location_match = line:match(location_re)
|
||||||
if location_match then
|
if location_match then
|
||||||
@@ -161,7 +253,7 @@ local function location(file,locpathT)
|
|||||||
--return line,loc_num_real, which_location
|
--return line,loc_num_real, which_location
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
until false
|
until false --forever
|
||||||
end
|
end
|
||||||
return location_it
|
return location_it
|
||||||
end
|
end
|
||||||
@@ -264,10 +356,6 @@ local function clean_spaces(cad)
|
|||||||
cad = cad:gsub("%s*([%(%),=])%s*","%1") --not spaces with ( , )
|
cad = cad:gsub("%s*([%(%),=])%s*","%1") --not spaces with ( , )
|
||||||
return cad
|
return cad
|
||||||
end
|
end
|
||||||
local function split_comment(line)
|
|
||||||
local comment = line:match("(%s*//.*)") or ""
|
|
||||||
return line:gsub("%s*//.*",""),comment
|
|
||||||
end
|
|
||||||
local function get_manuals(def)
|
local function get_manuals(def)
|
||||||
return cimgui_manuals[def.ov_cimguiname] or cimgui_manuals[def.cimguiname]
|
return cimgui_manuals[def.ov_cimguiname] or cimgui_manuals[def.cimguiname]
|
||||||
end
|
end
|
||||||
@@ -288,7 +376,7 @@ end
|
|||||||
local function struct_parser()
|
local function struct_parser()
|
||||||
local function_re = "(%a*%w+%s*%b())" --"(%a*%w+%b())" --"(%a*%w+%s+%w+%b())"
|
local function_re = "(%a*%w+%s*%b())" --"(%a*%w+%b())" --"(%a*%w+%s+%w+%b())"
|
||||||
local function_closing_re = "}"
|
local function_closing_re = "}"
|
||||||
local function_closed_re = "[;}]$"
|
local function_closed_re = "[;}]%s*$"
|
||||||
local operator_re = "operator.-%b()"
|
local operator_re = "operator.-%b()"
|
||||||
local functype_re = "(%(%*)[%w_]+(%)%([^%(%)]*%))"
|
local functype_re = "(%(%*)[%w_]+(%)%([^%(%)]*%))"
|
||||||
local initial_comment_re = [[^%s*//.*]]
|
local initial_comment_re = [[^%s*//.*]]
|
||||||
@@ -307,6 +395,7 @@ local function struct_parser()
|
|||||||
|
|
||||||
--if in_function discard
|
--if in_function discard
|
||||||
if in_functionst then
|
if in_functionst then
|
||||||
|
--table.insert(structcdefs,"en function:"..line) --debug
|
||||||
if line:match(function_closing_re) then
|
if line:match(function_closing_re) then
|
||||||
in_functionst = false
|
in_functionst = false
|
||||||
--print("in function:",line)
|
--print("in function:",line)
|
||||||
@@ -314,16 +403,13 @@ local function struct_parser()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (line:match(function_re) or line:match(operator_re)) and not line:match("typedef.*%b().*%b().*")
|
if (line:match(function_re) or line:match(operator_re)) and not line:match("typedef.*%b().*%b().*")
|
||||||
and not line:match(functype_re) then
|
and not line:match(functype_re) then
|
||||||
|
--table.insert(structcdefs,"function test2:"..line) --debug
|
||||||
if not line:match(function_closed_re) then
|
if not line:match(function_closed_re) then
|
||||||
--print("match:",line)
|
--print("match:",line)
|
||||||
in_functionst = true
|
in_functionst = true
|
||||||
end
|
end
|
||||||
--else
|
|
||||||
--table.insert(structcdefs,linecommented)
|
|
||||||
elseif line:match("template") then
|
elseif line:match("template") then
|
||||||
--nothing
|
--nothing
|
||||||
elseif line:match("public:") then
|
elseif line:match("public:") then
|
||||||
@@ -332,7 +418,6 @@ local function struct_parser()
|
|||||||
local linea = line:gsub("%S+",{class="struct",mutable=""})
|
local linea = line:gsub("%S+",{class="struct",mutable=""})
|
||||||
linea = linea:gsub("(%b<>)","/*%1*/") --comment template parameters
|
linea = linea:gsub("(%b<>)","/*%1*/") --comment template parameters
|
||||||
table.insert(structcdefs,linea..comment)
|
table.insert(structcdefs,linea..comment)
|
||||||
|
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -563,9 +648,13 @@ local function func_parser()
|
|||||||
end
|
end
|
||||||
table.insert(argsArr,{type=type,name=name,ret=retf,signature=sigf})
|
table.insert(argsArr,{type=type,name=name,ret=retf,signature=sigf})
|
||||||
if arg:match("&") and not arg:match("const") then
|
if arg:match("&") and not arg:match("const") then
|
||||||
|
--only post error if not manual
|
||||||
|
local cname = getcimguiname(stname,funcname)
|
||||||
|
if not cimgui_manuals[cname] then
|
||||||
print("reference to no const arg in",funcname,argscsinpars)
|
print("reference to no const arg in",funcname,argscsinpars)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
argscsinpars = argscsinpars:gsub("&","")
|
argscsinpars = argscsinpars:gsub("&","")
|
||||||
|
|
||||||
local signature = argscsinpars:gsub("([%w%s%*_]+)%s[%w_]+%s*([,%)])","%1%2")
|
local signature = argscsinpars:gsub("([%w%s%*_]+)%s[%w_]+%s*([,%)])","%1%2")
|
||||||
@@ -792,6 +881,11 @@ local function gen_structs_and_enums_table(cdefs)
|
|||||||
|
|
||||||
if (#enumnames > 0) then
|
if (#enumnames > 0) then
|
||||||
assert(#structnames==0,"enum in struct")
|
assert(#structnames==0,"enum in struct")
|
||||||
|
-- if #structnames~=0 then
|
||||||
|
-- print(line,#line)
|
||||||
|
-- print(linecom,#linecom)
|
||||||
|
-- error"enuminstruct"
|
||||||
|
-- end
|
||||||
if line:match(struct_closing_re) and not line:match(struct_op_close_re) then
|
if line:match(struct_closing_re) and not line:match(struct_op_close_re) then
|
||||||
enumnames[#enumnames] = nil
|
enumnames[#enumnames] = nil
|
||||||
break
|
break
|
||||||
@@ -925,13 +1019,15 @@ 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,[[struct ImVector
|
table.insert(outtab,[[
|
||||||
|
struct ImVector
|
||||||
{
|
{
|
||||||
int Size;
|
int Size;
|
||||||
int Capacity;
|
int Capacity;
|
||||||
void* Data;
|
void* Data;
|
||||||
};
|
};
|
||||||
typedef struct ImVector ImVector;]])
|
typedef struct ImVector ImVector;
|
||||||
|
]])
|
||||||
structnames[#structnames] = nil
|
structnames[#structnames] = nil
|
||||||
end
|
end
|
||||||
break -- dont write
|
break -- dont write
|
||||||
@@ -1205,7 +1301,8 @@ local function check_arg_detection(fdefs,typedefs)
|
|||||||
print"-----------------end check arg detection-----------------------"
|
print"-----------------end check arg detection-----------------------"
|
||||||
end
|
end
|
||||||
local function get_defines(t)
|
local function get_defines(t)
|
||||||
local pipe,err = io.popen([[gcc -E -dM -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h]],"r")
|
if COMPILER == "cl" then print"can't get defines with cl compiler"; return {} end
|
||||||
|
local pipe,err = io.popen(COMPILER..[[ -E -dM -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h]],"r")
|
||||||
local defines = {}
|
local defines = {}
|
||||||
while true do
|
while true do
|
||||||
local line = pipe:read"*l"
|
local line = pipe:read"*l"
|
||||||
@@ -1294,35 +1391,20 @@ pipe:close()
|
|||||||
cimgui_header = cimgui_header:gsub("XXX",imgui_version)
|
cimgui_header = cimgui_header:gsub("XXX",imgui_version)
|
||||||
print("IMGUI_VERSION",imgui_version)
|
print("IMGUI_VERSION",imgui_version)
|
||||||
--get some defines----------------------------
|
--get some defines----------------------------
|
||||||
if HAVE_GCC then
|
if HAVE_COMPILER then
|
||||||
gdefines = get_defines{"IMGUI_VERSION","FLT_MAX"}
|
gdefines = get_defines{"IMGUI_VERSION","FLT_MAX"}
|
||||||
end
|
end
|
||||||
--first without gcc
|
|
||||||
---[[
|
|
||||||
print"------------------generation without precompiler------------------------"
|
|
||||||
local pipe,err = io.open("../imgui/imgui.h","r")
|
|
||||||
if not pipe then
|
|
||||||
error("could not open file:"..err)
|
|
||||||
end
|
|
||||||
|
|
||||||
local STP = struct_parser()
|
--generation
|
||||||
local FP = func_parser()
|
print("------------------generation with "..COMPILER.."------------------------")
|
||||||
|
|
||||||
for line in filelines(pipe) do
|
|
||||||
local line, comment = split_comment(line)
|
|
||||||
STP.insert(line,comment)
|
|
||||||
FP.insert(line,comment)
|
|
||||||
end
|
|
||||||
pipe:close()
|
|
||||||
FP:compute_overloads()
|
|
||||||
cimgui_generation("_nopreprocess",STP,FP)
|
|
||||||
--]]
|
|
||||||
--then gcc
|
|
||||||
print"------------------generation with precompiler------------------------"
|
|
||||||
local pFP,pSTP,typedefs_dict2
|
local pFP,pSTP,typedefs_dict2
|
||||||
|
|
||||||
if HAVE_GCC then
|
local pipe,err
|
||||||
local pipe,err = io.popen([[gcc -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../imgui/imgui.h]],"r")
|
if HAVE_COMPILER then
|
||||||
|
pipe,err = io.popen(CPRE..[[../imgui/imgui.h]],"r")
|
||||||
|
else
|
||||||
|
pipe,err = io.open([[../imgui/imgui.h]],"r")
|
||||||
|
end
|
||||||
|
|
||||||
if not pipe then
|
if not pipe then
|
||||||
error("could not execute gcc "..err)
|
error("could not execute gcc "..err)
|
||||||
@@ -1331,19 +1413,24 @@ end
|
|||||||
pSTP = struct_parser() --overwrite
|
pSTP = struct_parser() --overwrite
|
||||||
pFP = func_parser() --overwrite
|
pFP = func_parser() --overwrite
|
||||||
|
|
||||||
for line in location(pipe,{"imgui"}) do
|
local iterator = (HAVE_COMPILER and location) or filelines
|
||||||
|
|
||||||
|
for line in iterator(pipe,{"imgui"}) do
|
||||||
local line, comment = split_comment(line)
|
local line, comment = split_comment(line)
|
||||||
|
--line = clean_spaces(line)
|
||||||
|
--comment = ""
|
||||||
pSTP.insert(line,comment)
|
pSTP.insert(line,comment)
|
||||||
pFP.insert(line,comment)
|
pFP.insert(line,comment)
|
||||||
end
|
end
|
||||||
pipe:close()
|
pipe:close()
|
||||||
|
|
||||||
local ovstr = pFP:compute_overloads()
|
local ovstr = pFP:compute_overloads()
|
||||||
ADDnonUDT(pFP)
|
ADDnonUDT(pFP)
|
||||||
save_data("./output/overloads.txt",ovstr)
|
save_data("./output/overloads.txt",ovstr)
|
||||||
typedefs_dict2 = cimgui_generation("",pSTP,pFP)
|
typedefs_dict2 = cimgui_generation("",pSTP,pFP)
|
||||||
--check arg detection failure if no name in function declaration
|
--check arg detection failure if no name in function declaration
|
||||||
check_arg_detection(pFP.defsT,typedefs_dict2)
|
check_arg_detection(pFP.defsT,typedefs_dict2)
|
||||||
end
|
|
||||||
|
|
||||||
----------save fundefs in definitions.lua for using in bindings
|
----------save fundefs in definitions.lua for using in bindings
|
||||||
set_defines(pFP.defsT)
|
set_defines(pFP.defsT)
|
||||||
@@ -1367,8 +1454,8 @@ if #implementations > 0 then
|
|||||||
local source = [[../imgui/examples/imgui_impl_]].. impl .. ".h "
|
local source = [[../imgui/examples/imgui_impl_]].. impl .. ".h "
|
||||||
local locati = [[imgui_impl_]].. impl
|
local locati = [[imgui_impl_]].. impl
|
||||||
local pipe,err
|
local pipe,err
|
||||||
if HAVE_GCC then
|
if HAVE_COMPILER then
|
||||||
pipe,err = io.popen([[gcc -E -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ]] ..source,"r")
|
pipe,err = io.popen(CPRE..source,"r")
|
||||||
else
|
else
|
||||||
pipe,err = io.open(source,"r")
|
pipe,err = io.open(source,"r")
|
||||||
end
|
end
|
||||||
@@ -1376,7 +1463,7 @@ if #implementations > 0 then
|
|||||||
error("could not get file: "..err)
|
error("could not get file: "..err)
|
||||||
end
|
end
|
||||||
|
|
||||||
local iterator = (HAVE_GCC and location) or filelines
|
local iterator = (HAVE_COMPILER and location) or filelines
|
||||||
|
|
||||||
for line,locat in iterator(pipe,{locati}) do
|
for line,locat in iterator(pipe,{locati}) do
|
||||||
local line, comment = split_comment(line)
|
local line, comment = split_comment(line)
|
||||||
|
@@ -477,7 +477,7 @@ CIMGUI_API ImGuiID igGetIDStr(const char* str_id)
|
|||||||
{
|
{
|
||||||
return ImGui::GetID(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);
|
return ImGui::GetID(str_id_begin,str_id_end);
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,7 @@ 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;
|
||||||
@@ -69,7 +69,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;
|
||||||
struct ImDrawChannel;
|
|
||||||
struct ImDrawCmd;
|
struct ImDrawCmd;
|
||||||
struct ImDrawData;
|
struct ImDrawData;
|
||||||
struct ImDrawList;
|
struct ImDrawList;
|
||||||
@@ -955,7 +954,7 @@ CIMGUI_API void igPushIDPtr(const void* ptr_id);
|
|||||||
CIMGUI_API void igPushIDInt(int int_id);
|
CIMGUI_API void igPushIDInt(int int_id);
|
||||||
CIMGUI_API void igPopID(void);
|
CIMGUI_API void igPopID(void);
|
||||||
CIMGUI_API ImGuiID igGetIDStr(const char* str_id);
|
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 ImGuiID igGetIDPtr(const void* ptr_id);
|
||||||
CIMGUI_API void igTextUnformatted(const char* text,const char* text_end);
|
CIMGUI_API void igTextUnformatted(const char* text,const char* text_end);
|
||||||
CIMGUI_API void igText(const char* fmt,...);
|
CIMGUI_API void igText(const char* fmt,...);
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
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] = {}
|
||||||
defs["igGetID"][2]["argsT"][2]["type"] = "const char*"
|
defs["igGetID"][2]["argsT"][2]["type"] = "const char*"
|
||||||
defs["igGetID"][2]["argsT"][2]["name"] = "str_id_end"
|
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]["defaults"] = {}
|
||||||
defs["igGetID"][2]["signature"] = "(const char*,const char*)"
|
defs["igGetID"][2]["signature"] = "(const char*,const char*)"
|
||||||
defs["igGetID"][2]["cimguiname"] = "igGetID"
|
defs["igGetID"][2]["cimguiname"] = "igGetID"
|
||||||
|
@@ -43,7 +43,7 @@ igMenuItem 2
|
|||||||
2 bool igMenuItemBoolPtr (const char*,const char*,bool*,bool)
|
2 bool igMenuItemBoolPtr (const char*,const char*,bool*,bool)
|
||||||
igGetID 3
|
igGetID 3
|
||||||
1 ImGuiID igGetIDStr (const char*)
|
1 ImGuiID igGetIDStr (const char*)
|
||||||
2 ImGuiID igGetIDStrStr (const char*,const char*)
|
2 ImGuiID igGetIDRange (const char*,const char*)
|
||||||
3 ImGuiID igGetIDPtr (const void*)
|
3 ImGuiID igGetIDPtr (const void*)
|
||||||
igListBoxHeader 2
|
igListBoxHeader 2
|
||||||
1 bool igListBoxHeaderVec2 (const char*,const ImVec2)
|
1 bool igListBoxHeaderVec2 (const char*,const ImVec2)
|
||||||
|
Reference in New Issue
Block a user