mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 11:58:30 +01:00
parse unnamed unions
This commit is contained in:
@@ -1019,6 +1019,12 @@ function M.Parser()
|
||||
template_type = template_type:gsub("Ptr","%*")
|
||||
end
|
||||
for name in rest:gmatch("([^%s,;]+)%s?[,;]") do
|
||||
--unnamed unions
|
||||
local union_re = "^([^;{}]-union[^;{}]-%b{}[%s%w_%(%)]*;)"
|
||||
if line:match(union_re) and name == "}" then
|
||||
typen = typen..name
|
||||
name = ""
|
||||
end
|
||||
local namebitfield,bitfield = name:match("([^:]+):(%d+)") --take care of bitfields
|
||||
table.insert(outtab,{type=typen,template_type=template_type,name=namebitfield or name,bitfield=bitfield})
|
||||
end
|
||||
|
@@ -484,23 +484,9 @@ set_defines(parser1.defsT)
|
||||
save_data("./output/definitions.lua",serializeTableF(parser1.defsT))
|
||||
|
||||
----------save struct and enums lua table in structs_and_enums.lua for using in bindings
|
||||
--TODO do union corrections not as exception
|
||||
local structs_and_enums_table = parser1:gen_structs_and_enums_table()
|
||||
--correct Pair union member if exists (until 1.71)
|
||||
if structs_and_enums_table["structs"]["Pair"] then
|
||||
structs_and_enums_table["structs"]["Pair"][2]["name"] = ""
|
||||
structs_and_enums_table["structs"]["Pair"][2]["type"] = structs_and_enums_table["structs"]["Pair"][2]["type"] .. "}"
|
||||
end
|
||||
|
||||
-- union in 1.72 and after
|
||||
if structs_and_enums_table["structs"]["ImGuiStoragePair"] then
|
||||
structs_and_enums_table["structs"]["ImGuiStoragePair"][2]["name"] = ""
|
||||
structs_and_enums_table["structs"]["ImGuiStoragePair"][2]["type"] = structs_and_enums_table["structs"]["ImGuiStoragePair"][2]["type"] .. "}"
|
||||
end
|
||||
if structs_and_enums_table["structs"]["ImGuiStyleMod"] then
|
||||
structs_and_enums_table["structs"]["ImGuiStyleMod"][2]["name"] = ""
|
||||
structs_and_enums_table["structs"]["ImGuiStyleMod"][2]["type"] = structs_and_enums_table["structs"]["ImGuiStyleMod"][2]["type"] .. "}"
|
||||
end
|
||||
local structs_and_enums_table = parser1:gen_structs_and_enums_table()
|
||||
|
||||
-----------------------
|
||||
save_data("./output/structs_and_enums.lua",serializeTableF(structs_and_enums_table))
|
||||
save_data("./output/typedefs_dict.lua",serializeTableF(parser1.typedefs_dict))
|
||||
|
Reference in New Issue
Block a user