diff --git a/generator/cpp2ffi.lua b/generator/cpp2ffi.lua index 2d0b686..a78fea0 100644 --- a/generator/cpp2ffi.lua +++ b/generator/cpp2ffi.lua @@ -109,7 +109,7 @@ end local function clean_spaces(cad) cad = strip(cad) cad = cad:gsub("%s+"," ") --not more than one space - cad = cad:gsub("%s*([%(%),=])%s*","%1") --not spaces with ( , ) + cad = cad:gsub("%s*([%(%),=:])%s*","%1") --not spaces with ( , ) or ( = ) or ( : ) return cad end function strsplit(str, pat) @@ -915,9 +915,10 @@ function M.Parser() local typen,rest = line:match("%s*([^,]+)%s(%S+[,;])") --local template_type = typen:match("/%*<(.+)>%*/") --if template_type then typen = typen:match("(.+)/%*") end - if not typen then -- Lets try Type*name - typen,rest = line:match("([^,]+%*)(%S+[,;])") - end + if not typen then -- Lets try Type*name + typen,rest = line:match("([^,]+%*)(%S+[,;])") + end + local template_type for k,v in pairs(self.templates) do template_type = typen:match(k.."_(.+)") @@ -928,7 +929,8 @@ function M.Parser() template_type = template_type:gsub("Ptr","%*") end for name in rest:gmatch("([^%s,;]+)%s?[,;]") do - table.insert(outtab,{type=typen,template_type=template_type,name=name}) + 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 end end diff --git a/generator/generator.lua b/generator/generator.lua index bee6598..cdb4b9a 100644 --- a/generator/generator.lua +++ b/generator/generator.lua @@ -696,7 +696,7 @@ 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 --- 1.72 and after +-- 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"] .. "}"