mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-14 05:38:29 +01:00
let FLT_MAX be a string in definitions.lua to use after igGET_FLT_MAX to get compiler value
This commit is contained in:
@@ -78,6 +78,7 @@ local cimgui_overloads = {
|
||||
local cimgui_header =
|
||||
[[//This file is automatically generated by generator.lua from https://github.com/cimgui/cimgui
|
||||
//based on imgui.h file version XXX from Dear ImGui https://github.com/ocornut/imgui]]
|
||||
local gdefines = {} --for FLT_MAX and others
|
||||
--------------------------------------------------------------------------
|
||||
--helper functions
|
||||
--------------------------------------------------------------------------
|
||||
@@ -1203,6 +1204,50 @@ local function check_arg_detection(fdefs,typedefs)
|
||||
end
|
||||
print"-----------------end check arg detection-----------------------"
|
||||
end
|
||||
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")
|
||||
local defines = {}
|
||||
while true do
|
||||
local line = pipe:read"*l"
|
||||
if not line then break end
|
||||
local key,value = line:match([[#define%s+(%S+)%s+(.+)]])
|
||||
if not key or not value then
|
||||
--print(line)
|
||||
else
|
||||
defines[key]=value
|
||||
end
|
||||
end
|
||||
pipe:close()
|
||||
--require"anima.utils"
|
||||
--prtable(defines)
|
||||
--FLT_MAX
|
||||
local ret = {}
|
||||
for i,v in ipairs(t) do
|
||||
local aa = defines[v]
|
||||
while true do
|
||||
local tmp = defines[aa]
|
||||
if not tmp then
|
||||
break
|
||||
else
|
||||
aa = tmp
|
||||
end
|
||||
end
|
||||
ret[v] = aa
|
||||
end
|
||||
return ret
|
||||
end
|
||||
--subtitution of FLT_MAX value for FLT_MAX
|
||||
local function set_defines(fdefs)
|
||||
for k,defT in pairs(fdefs) do
|
||||
for i,def in ipairs(defT) do
|
||||
for name,default in pairs(def.defaults) do
|
||||
if default == gdefines.FLT_MAX then
|
||||
def.defaults[name] = "FLT_MAX"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--generate cimgui.cpp cimgui.h and auto versions depending on postfix
|
||||
local function cimgui_generation(postfix,STP,FP)
|
||||
--merge it in cimgui_template.h to cimgui.h
|
||||
@@ -1247,6 +1292,11 @@ while true do
|
||||
end
|
||||
pipe:close()
|
||||
cimgui_header = cimgui_header:gsub("XXX",imgui_version)
|
||||
print("IMGUI_VERSION",imgui_version)
|
||||
--get some defines----------------------------
|
||||
if HAVE_GCC then
|
||||
gdefines = get_defines{"IMGUI_VERSION","FLT_MAX"}
|
||||
end
|
||||
--first without gcc
|
||||
---[[
|
||||
print"------------------generation without precompiler------------------------"
|
||||
@@ -1296,6 +1346,7 @@ check_arg_detection(pFP.defsT,typedefs_dict2)
|
||||
end
|
||||
|
||||
----------save fundefs in definitions.lua for using in bindings
|
||||
set_defines(pFP.defsT)
|
||||
save_data("./output/definitions.lua",serializeTable("defs",pFP.defsT),"\nreturn defs")
|
||||
|
||||
----------save struct and enums lua table in structs_and_enums.lua for using in bindings
|
||||
|
Reference in New Issue
Block a user