mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
Merge branch 'docking_inter'
This commit is contained in:
@@ -11,7 +11,13 @@
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
|
#ifdef IMGUI_HAS_IMSTR
|
||||||
|
#define igBegin SigBegin
|
||||||
|
#define igSliderFloat SigSliderFloat
|
||||||
|
#define igCheckbox SigCheckbox
|
||||||
|
#define igColorEdit3 SigColorEdit3
|
||||||
|
#define igButton SigButton
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_Window *window = NULL;
|
SDL_Window *window = NULL;
|
||||||
|
|
||||||
|
@@ -165,8 +165,11 @@ local function parse_enum_value(value, allenums,dontpost)
|
|||||||
--already in allenums
|
--already in allenums
|
||||||
if allenums[clean(value)] then return allenums[clean(value)] end
|
if allenums[clean(value)] then return allenums[clean(value)] end
|
||||||
--must be several and operators
|
--must be several and operators
|
||||||
--precedence order (hope not ())
|
------------precedence order (hope not ())
|
||||||
assert(not value:match("[%(%)]"))
|
--first drop outer ()
|
||||||
|
value = value:gsub("^(%()",""):gsub("(%))$","")
|
||||||
|
assert(not value:match("[%(%)]"),value)
|
||||||
|
|
||||||
local several,seps = strsplit(value,"([<>&|~%+]+)")
|
local several,seps = strsplit(value,"([<>&|~%+]+)")
|
||||||
--M.prtable(value,several,seps)
|
--M.prtable(value,several,seps)
|
||||||
assert(#seps+1==#several)
|
assert(#seps+1==#several)
|
||||||
@@ -182,6 +185,9 @@ local function parse_enum_value(value, allenums,dontpost)
|
|||||||
local val2 = clean(several[i+1])
|
local val2 = clean(several[i+1])
|
||||||
if allenums[val1] then val1 = allenums[val1] end
|
if allenums[val1] then val1 = allenums[val1] end
|
||||||
if allenums[val2] then val2 = allenums[val2] end
|
if allenums[val2] then val2 = allenums[val2] end
|
||||||
|
--clean 1u
|
||||||
|
if type(val1)=="string" then val1 = val1:gsub("(%d)(u)$","%1") end
|
||||||
|
if type(val2)=="string" then val2 = val2:gsub("(%d)(u)$","%1") end
|
||||||
--for getting numbers from "1ULL"
|
--for getting numbers from "1ULL"
|
||||||
if type(val1)=="string" then val1 = loadstring("return "..val1)() end
|
if type(val1)=="string" then val1 = loadstring("return "..val1)() end
|
||||||
if type(val2)=="string" then val2 = loadstring("return "..val2)() end
|
if type(val2)=="string" then val2 = loadstring("return "..val2)() end
|
||||||
@@ -414,14 +420,13 @@ local function parseItems(txt,linenumdict, itparent, dumpit)
|
|||||||
end
|
end
|
||||||
M.parseItems = parseItems
|
M.parseItems = parseItems
|
||||||
local function name_overloadsAlgo(v)
|
local function name_overloadsAlgo(v)
|
||||||
|
|
||||||
local aa = {}
|
local aa = {}
|
||||||
local bb = {}
|
local bb = {}
|
||||||
local done = {}
|
local done = {}
|
||||||
local maxnum = 0
|
local maxnum = 0
|
||||||
for i,t in ipairs(v) do
|
for i,t in ipairs(v) do
|
||||||
bb[i] = ""
|
bb[i] = ""
|
||||||
--local signature = t.signature:sub(2,-2) -- without parenthesis
|
|
||||||
--inside parenthesis
|
|
||||||
local signature = t.signature:match("%b()")
|
local signature = t.signature:match("%b()")
|
||||||
signature = signature:sub(2,-2)
|
signature = signature:sub(2,-2)
|
||||||
--add const function
|
--add const function
|
||||||
@@ -430,47 +435,52 @@ local function name_overloadsAlgo(v)
|
|||||||
end
|
end
|
||||||
aa[i] = {}
|
aa[i] = {}
|
||||||
local num = 1
|
local num = 1
|
||||||
--for typec in t.signature:gmatch(".-([^,%(%s]+)[,%)]") do
|
|
||||||
--for typec in t.signature:gmatch(".-([^,%(]+)[,%)]") do
|
|
||||||
--for typec in signature:gmatch(".-([^,]+),?") do
|
|
||||||
for typec in signature:gsub("(%(.-%))", function(x) return x:gsub(",","\0") end):gmatch(".-([^,]+),?") do
|
for typec in signature:gsub("(%(.-%))", function(x) return x:gsub(",","\0") end):gmatch(".-([^,]+),?") do
|
||||||
--typec = typec:gsub
|
|
||||||
aa[i][num] = typec:gsub("%z+", ",")
|
aa[i][num] = typec:gsub("%z+", ",")
|
||||||
num = num + 1
|
num = num + 1
|
||||||
end
|
end
|
||||||
num = num - 1
|
num = num - 1
|
||||||
maxnum = (num > maxnum) and num or maxnum
|
maxnum = (num > maxnum) and num or maxnum
|
||||||
end
|
end
|
||||||
|
|
||||||
for l=1,maxnum do
|
for l=1,maxnum do
|
||||||
local keys = {}
|
local keys = {}
|
||||||
local diferent = true
|
local diferent = true
|
||||||
local equal = true
|
local equal = true
|
||||||
for i=1,#v do
|
for i=1,#v do
|
||||||
aa[i][l] = aa[i][l] or "nil"
|
aa[i][l] = aa[i][l] or "nil"
|
||||||
keys[aa[i][l]] = 1 + (aa[i][l] and keys[aa[i][l]] or 0)
|
keys[aa[i][l]] = 1 + (keys[aa[i][l]] or 0)
|
||||||
if not done[i] then
|
if not done[i] then
|
||||||
for j=i+1,#v do
|
for j=i+1,#v do
|
||||||
if not done[j] then
|
if not done[j] then
|
||||||
if aa[i][l] == aa[j][l] then
|
if aa[i][l] == aa[j][l] then
|
||||||
diferent = false
|
diferent = false
|
||||||
else
|
else
|
||||||
equal = false
|
equal = false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not equal then -- not all the same
|
if not equal then -- not all the same
|
||||||
for i=1,#v do
|
for i=1,#v do
|
||||||
if not done[i] then
|
if not done[i] then
|
||||||
bb[i] = bb[i]..(aa[i][l]=="nil" and "" or aa[i][l])
|
bb[i] = bb[i]..(aa[i][l]=="nil" and "" or aa[i][l])
|
||||||
if keys[aa[i][l]] == 1 then
|
-- if keys[aa[i][l]] == 1 then
|
||||||
done[i] = true
|
-- done[i] = true
|
||||||
end
|
-- end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--test done
|
||||||
|
for i=1,#v do
|
||||||
|
done[i] = true
|
||||||
|
for j=1,#v do
|
||||||
|
if i~=j and bb[i]==bb[j] then
|
||||||
|
done[i] = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
--avoid empty postfix which will be reserved to generic
|
--avoid empty postfix which will be reserved to generic
|
||||||
for i,v in ipairs(bb) do if v=="" then bb[i]="Nil" end end
|
for i,v in ipairs(bb) do if v=="" then bb[i]="Nil" end end
|
||||||
@@ -493,6 +503,7 @@ local function typetoStr(typ)
|
|||||||
typ = typ:gsub("float","Float")
|
typ = typ:gsub("float","Float")
|
||||||
typ = typ:gsub("uInt","Uint")
|
typ = typ:gsub("uInt","Uint")
|
||||||
typ = typ:gsub("ImGui","")
|
typ = typ:gsub("ImGui","")
|
||||||
|
typ = typ:gsub("ImStr","STR")
|
||||||
typ = typ:gsub("Im","")
|
typ = typ:gsub("Im","")
|
||||||
typ = typ:gsub("[<>]","")
|
typ = typ:gsub("[<>]","")
|
||||||
return typ
|
return typ
|
||||||
@@ -769,6 +780,84 @@ local function AdjustArguments(FP)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local function ADDIMSTR_S(FP)
|
||||||
|
local defsT = FP.defsT
|
||||||
|
local newcdefs = {}
|
||||||
|
for numcdef,t in ipairs(FP.funcdefs) do
|
||||||
|
newcdefs[#newcdefs+1] = t
|
||||||
|
if t.cimguiname then
|
||||||
|
local cimf = defsT[t.cimguiname]
|
||||||
|
local defT = cimf[t.signature]
|
||||||
|
|
||||||
|
--if isIMSTR return generate _S version
|
||||||
|
local isIMSTR = false
|
||||||
|
for i,arg in ipairs(defT.argsT) do
|
||||||
|
if arg.type == "ImStr" then isIMSTR=true;break end
|
||||||
|
end
|
||||||
|
--if defT.ret=="ImVec2" or defT.ret=="ImVec4" or defT.ret=="ImColor" then
|
||||||
|
--if isIMSTR then print(t.cimguiname,defT.ov_cimguiname,defT.argsoriginal,"isIMSTR") end
|
||||||
|
if isIMSTR then
|
||||||
|
--passing as a pointer arg
|
||||||
|
local defT2 = {}
|
||||||
|
--first strings
|
||||||
|
for k,v in pairs(defT) do
|
||||||
|
defT2[k] = v
|
||||||
|
end
|
||||||
|
--then argsT table
|
||||||
|
defT2.argsT = {}
|
||||||
|
for k,v in ipairs(defT.argsT) do
|
||||||
|
local typ = v.type == "ImStr" and "const char*" or v.type
|
||||||
|
table.insert(defT2.argsT,{type=typ,name=v.name})
|
||||||
|
end
|
||||||
|
--defaults table
|
||||||
|
defT2.defaults = {}
|
||||||
|
for k,v in pairs(defT.defaults) do
|
||||||
|
defT2.defaults[k] = v
|
||||||
|
end
|
||||||
|
defT2.args = defT2.args:gsub("ImStr","const char*")
|
||||||
|
--recreate call_args for wrapping into ImStr
|
||||||
|
local caar
|
||||||
|
if #defT.argsT > 0 then
|
||||||
|
caar = "("
|
||||||
|
for i,v in ipairs(defT.argsT) do
|
||||||
|
local name = v.name --v.type == "ImStr" and "ImStr("..v.name..")" or v.name --wrap
|
||||||
|
if v.ret then --function pointer
|
||||||
|
caar = caar .. name .. ","
|
||||||
|
else
|
||||||
|
local callname = v.reftoptr and "*"..name or name
|
||||||
|
caar = caar .. callname .. ","
|
||||||
|
end
|
||||||
|
end
|
||||||
|
caar = caar:sub(1,-2)..")"
|
||||||
|
else
|
||||||
|
caar = "()"
|
||||||
|
end
|
||||||
|
defT2.call_args = caar --:gsub("ImStr%(([^%(%)]+)%)","%1") --unwrap
|
||||||
|
------------------
|
||||||
|
defT2.signature = defT.signature:gsub("ImStr","const char*") --.."_S"
|
||||||
|
defT2.ov_cimguiname = defT2.ov_cimguiname .. "_Strv"
|
||||||
|
defT2.isIMSTR_S = 1
|
||||||
|
-- check there is not an equal version in imgui_stname
|
||||||
|
local doadd = true
|
||||||
|
for i,dd in ipairs(cimf) do
|
||||||
|
if dd.signature == defT2.signature then
|
||||||
|
doadd = false;
|
||||||
|
print("skip _S addition",defT2.cimguiname)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--add _S version
|
||||||
|
if doadd then
|
||||||
|
cimf[#cimf+1] = defT2
|
||||||
|
cimf[defT2.signature] = defT2
|
||||||
|
newcdefs[#newcdefs+1] = {stname=t.stname,funcname=t.funcname,args=defT2.args,signature=defT2.signature,cimguiname=defT2.cimguiname,ret =defT2.ret}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else print("not cimguiname in");M.prtable(t)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
FP.funcdefs = newcdefs
|
||||||
|
end
|
||||||
local function ADDnonUDT(FP)
|
local function ADDnonUDT(FP)
|
||||||
local defsT = FP.defsT
|
local defsT = FP.defsT
|
||||||
--local newcdefs = {}
|
--local newcdefs = {}
|
||||||
@@ -1491,6 +1580,7 @@ function M.Parser()
|
|||||||
for k,v in pairs(self.alltypes) do print(k, typetoStr(k) ) end
|
for k,v in pairs(self.alltypes) do print(k, typetoStr(k) ) end
|
||||||
end
|
end
|
||||||
function par:compute_overloads()
|
function par:compute_overloads()
|
||||||
|
--ADDIMSTR_S(self)
|
||||||
local strt = {}
|
local strt = {}
|
||||||
local numoverloaded = 0
|
local numoverloaded = 0
|
||||||
self.alltypes = {}
|
self.alltypes = {}
|
||||||
@@ -1506,8 +1596,15 @@ function M.Parser()
|
|||||||
for i,t in ipairs(v) do
|
for i,t in ipairs(v) do
|
||||||
--take overloaded name from manual table or algorythm
|
--take overloaded name from manual table or algorythm
|
||||||
t.ov_cimguiname = self.getCname_overload(t.stname,t.funcname,t.signature,t.namespace) or k..typetoStr(post[i])
|
t.ov_cimguiname = self.getCname_overload(t.stname,t.funcname,t.signature,t.namespace) or k..typetoStr(post[i])
|
||||||
|
--check ...
|
||||||
|
if( t.ov_cimguiname:match"%.%.%.") then
|
||||||
|
print("... in ov",t.ov_cimguiname)
|
||||||
|
for i,dd in ipairs(v) do
|
||||||
|
print(dd.signature,post[i])
|
||||||
|
end
|
||||||
|
error"Bad check ..."
|
||||||
|
end
|
||||||
table.insert(strt,string.format("%d\t%s\t%s %s",i,t.ret,t.ov_cimguiname,t.signature))
|
table.insert(strt,string.format("%d\t%s\t%s %s",i,t.ret,t.ov_cimguiname,t.signature))
|
||||||
--M.prtable(typesc[i],post)
|
|
||||||
end
|
end
|
||||||
--check not two names are equal (produced by bad cimguiname_overload)
|
--check not two names are equal (produced by bad cimguiname_overload)
|
||||||
for i=1,#v-1 do
|
for i=1,#v-1 do
|
||||||
@@ -1525,8 +1622,10 @@ function M.Parser()
|
|||||||
end)
|
end)
|
||||||
--print(numoverloaded, "overloaded")
|
--print(numoverloaded, "overloaded")
|
||||||
table.insert(strt,string.format("%d overloaded",numoverloaded))
|
table.insert(strt,string.format("%d overloaded",numoverloaded))
|
||||||
|
ADDIMSTR_S(self)
|
||||||
AdjustArguments(self)
|
AdjustArguments(self)
|
||||||
ADDnonUDT(self)
|
ADDnonUDT(self)
|
||||||
|
|
||||||
--ADDdestructors(self)
|
--ADDdestructors(self)
|
||||||
self.overloadstxt = table.concat(strt,"\n")
|
self.overloadstxt = table.concat(strt,"\n")
|
||||||
end
|
end
|
||||||
|
@@ -313,6 +313,9 @@ local function cimgui_generation(parser)
|
|||||||
if gdefines.IMGUI_HAS_DOCK then
|
if gdefines.IMGUI_HAS_DOCK then
|
||||||
cstructsstr = cstructsstr.."\n#define IMGUI_HAS_DOCK 1\n"
|
cstructsstr = cstructsstr.."\n#define IMGUI_HAS_DOCK 1\n"
|
||||||
end
|
end
|
||||||
|
if gdefines.IMGUI_HAS_IMSTR then
|
||||||
|
cstructsstr = cstructsstr.."\n#define IMGUI_HAS_IMSTR 1\n"
|
||||||
|
end
|
||||||
|
|
||||||
hstrfile = hstrfile:gsub([[#include "imgui_structs%.h"]],cstructsstr)
|
hstrfile = hstrfile:gsub([[#include "imgui_structs%.h"]],cstructsstr)
|
||||||
local cfuncsstr = func_header_generate(parser)
|
local cfuncsstr = func_header_generate(parser)
|
||||||
@@ -333,13 +336,13 @@ end
|
|||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
--get imgui.h version and IMGUI_HAS_DOCK--------------------------
|
--get imgui.h version and IMGUI_HAS_DOCK--------------------------
|
||||||
--get some defines wont work for cl ----------------
|
--get some defines wont work for cl ----------------
|
||||||
gdefines = get_defines{"IMGUI_VERSION","FLT_MAX","FLT_MIN","IMGUI_HAS_DOCK"}
|
gdefines = get_defines{"IMGUI_VERSION","FLT_MAX","FLT_MIN","IMGUI_HAS_DOCK","IMGUI_HAS_IMSTR"}
|
||||||
--this will work for cl
|
--this will work for cl
|
||||||
local pipe,err = io.open("../imgui/imgui.h","r")
|
local pipe,err = io.open("../imgui/imgui.h","r")
|
||||||
if not pipe then
|
if not pipe then
|
||||||
error("could not open file:"..err)
|
error("could not open file:"..err)
|
||||||
end
|
end
|
||||||
local imgui_version,has_dock
|
local imgui_version,has_dock,has_imstr
|
||||||
while true do
|
while true do
|
||||||
local line = pipe:read"*l"
|
local line = pipe:read"*l"
|
||||||
if not line then break end
|
if not line then break end
|
||||||
@@ -349,11 +352,15 @@ while true do
|
|||||||
if not has_dock then
|
if not has_dock then
|
||||||
has_dock = line:match([[#define%s+IMGUI_HAS_DOCK]])--%s*(".+")]])
|
has_dock = line:match([[#define%s+IMGUI_HAS_DOCK]])--%s*(".+")]])
|
||||||
end
|
end
|
||||||
if imgui_version and has_dock then break end
|
if not has_imstr then
|
||||||
|
has_imstr = line:match([[#define%s+IMGUI_HAS_IMSTR]])--%s*(".+")]])
|
||||||
|
end
|
||||||
|
if imgui_version and has_dock and has_imstr then break end
|
||||||
end
|
end
|
||||||
pipe:close()
|
pipe:close()
|
||||||
|
|
||||||
if has_dock then gdefines.IMGUI_HAS_DOCK = true end
|
if has_dock then gdefines.IMGUI_HAS_DOCK = true end
|
||||||
|
if has_imstr then gdefines.IMGUI_HAS_IMSTR = true end
|
||||||
|
|
||||||
cimgui_header = cimgui_header:gsub("XXX",imgui_version)
|
cimgui_header = cimgui_header:gsub("XXX",imgui_version)
|
||||||
if INTERNAL_GENERATION then
|
if INTERNAL_GENERATION then
|
||||||
@@ -369,6 +376,7 @@ if gdefines.IMGUI_HAS_DOCK then
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
print("IMGUI_HAS_IMSTR",gdefines.IMGUI_HAS_IMSTR)
|
||||||
print("IMGUI_HAS_DOCK",gdefines.IMGUI_HAS_DOCK)
|
print("IMGUI_HAS_DOCK",gdefines.IMGUI_HAS_DOCK)
|
||||||
print("IMGUI_VERSION",imgui_version)
|
print("IMGUI_VERSION",imgui_version)
|
||||||
|
|
||||||
|
@@ -2,6 +2,14 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "../cimgui.h"
|
#include "../cimgui.h"
|
||||||
|
|
||||||
|
#ifdef IMGUI_HAS_IMSTR
|
||||||
|
#define igBegin SigBegin
|
||||||
|
#define igSliderFloat SigSliderFloat
|
||||||
|
#define igCheckbox SigCheckbox
|
||||||
|
#define igColorEdit3 SigColorEdit3
|
||||||
|
#define igButton SigButton
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
assert(igDebugCheckVersionAndDataLayout(igGetVersion(), sizeof(ImGuiIO), sizeof(ImGuiStyle),
|
assert(igDebugCheckVersionAndDataLayout(igGetVersion(), sizeof(ImGuiIO), sizeof(ImGuiStyle),
|
||||||
|
Reference in New Issue
Block a user