add typedefs_dict

This commit is contained in:
sonoro1234
2018-07-19 11:14:26 +02:00
parent 1c61237dbf
commit ac4a2f13c0
3 changed files with 65 additions and 5 deletions

View File

@@ -0,0 +1 @@
{"ImDrawCornerFlags":"int","ImWchar":"unsigned short","ImGuiColumnsFlags":"int","ImGuiTextEditCallback":"int(*)(ImGuiTextEditCallbackData *data);","ImGuiTreeNodeFlags":"int","ImGuiFocusedFlags":"int","ImGuiSizeCallback":"void(*)(ImGuiSizeCallbackData* data);","ImU64":"unsigned long long","ImS64":"signed long long","ImDrawListFlags":"int","ImGuiBackendFlags":"int","ImGuiMouseCursor":"int","ImDrawIdx":"unsigned short","ImGuiColorEditFlags":"int","ImDrawCallback":"void(*)(const ImDrawList* parent_list,const ImDrawCmd* cmd);","const_iterator":"const value_type*","ImGuiDir":"int","ImGuiSelectableFlags":"int","value_type":"T","ImGuiCond":"int","ImU32":"unsigned int","ImS32":"signed int","ImGuiDragDropFlags":"int","ImGuiID":"unsigned int","ImGuiNavInput":"int","ImGuiCol":"int","ImTextureID":"void*","ImGuiStyleVar":"int","ImFontAtlasFlags":"int","ImGuiConfigFlags":"int","ImGuiDataType":"int","ImGuiInputTextFlags":"int","iterator":"value_type*","ImGuiKey":"int","ImGuiHoveredFlags":"int","ImGuiWindowFlags":"int","ImGuiComboFlags":"int"}

View File

@@ -0,0 +1,40 @@
local defs = {}
defs["ImDrawCornerFlags"] = "int"
defs["ImWchar"] = "unsigned short"
defs["ImGuiColumnsFlags"] = "int"
defs["ImGuiTextEditCallback"] = "int(*)(ImGuiTextEditCallbackData *data);"
defs["ImGuiTreeNodeFlags"] = "int"
defs["ImGuiFocusedFlags"] = "int"
defs["ImGuiSizeCallback"] = "void(*)(ImGuiSizeCallbackData* data);"
defs["ImU64"] = "unsigned long long"
defs["ImS64"] = "signed long long"
defs["ImDrawListFlags"] = "int"
defs["ImGuiBackendFlags"] = "int"
defs["ImGuiMouseCursor"] = "int"
defs["ImDrawIdx"] = "unsigned short"
defs["ImGuiColorEditFlags"] = "int"
defs["ImDrawCallback"] = "void(*)(const ImDrawList* parent_list,const ImDrawCmd* cmd);"
defs["const_iterator"] = "const value_type*"
defs["ImGuiDir"] = "int"
defs["ImGuiSelectableFlags"] = "int"
defs["value_type"] = "T"
defs["ImGuiCond"] = "int"
defs["ImU32"] = "unsigned int"
defs["ImS32"] = "signed int"
defs["ImGuiDragDropFlags"] = "int"
defs["ImGuiID"] = "unsigned int"
defs["ImGuiNavInput"] = "int"
defs["ImGuiCol"] = "int"
defs["ImTextureID"] = "void*"
defs["ImGuiStyleVar"] = "int"
defs["ImFontAtlasFlags"] = "int"
defs["ImGuiConfigFlags"] = "int"
defs["ImGuiDataType"] = "int"
defs["ImGuiInputTextFlags"] = "int"
defs["iterator"] = "value_type*"
defs["ImGuiKey"] = "int"
defs["ImGuiHoveredFlags"] = "int"
defs["ImGuiWindowFlags"] = "int"
defs["ImGuiComboFlags"] = "int"
return defs

View File

@@ -539,6 +539,7 @@ local function gen_structs_and_enums_table(cdefs)
local enumnames = {}
local enums_re = "^%s*enum%s+([^%s;]+)"
local outtab = {structs={},enums={}}
local typedefs_dict = {}
for i,line in ipairs(cdefs) do
repeat -- simulating continue with break
@@ -546,7 +547,23 @@ local function gen_structs_and_enums_table(cdefs)
local linecom = line
local line, comment = split_comment(line)
line = clean_spaces(line)
--typedefs dictionary
if line:match("typedef") then
local value,key = line:match("typedef%s+(.+)%s+([%w_]+);")
if key and value then
typedefs_dict[key] = value
else --try function typedef
local key = line:match("%(%*([%w_]+)%)%([^%(%)]*%)")
if key then
local linet = line
linet = linet:gsub("typedef ","")
linet = linet:gsub("%(%*("..key..")%)","(*)")
typedefs_dict[key] = linet
else
print(key,value,line)
end
end
end
if line:match(namespace_re) then
in_namespace = true
end
@@ -617,7 +634,7 @@ local function gen_structs_and_enums_table(cdefs)
end
until true
end
return outtab
return outtab, typedefs_dict
end
@@ -632,6 +649,7 @@ local function gen_structs_and_enums(cdefs)
local structnames = {}
local innerstructs = {}
local typedefs_table = {}
local outtab = {}
-- Output the file
--table.insert(outtab,"/////////////// BEGIN AUTOGENERATED SEGMENT\n")
@@ -943,9 +961,9 @@ end
save_data("./generated/definitions.lua",serializeTable("defs",pFP.defsT),"\nreturn defs")
----------save struct and enums lua table in structs_and_enums.lua for using in bindings
local structs_and_enums_table = gen_structs_and_enums_table(pSTP.lines)
local structs_and_enums_table,typedefs_dict = gen_structs_and_enums_table(pSTP.lines)
save_data("./generated/structs_and_enums.lua",serializeTable("defs",structs_and_enums_table),"\nreturn defs")
save_data("./generated/typedefs_dict.lua",serializeTable("defs",typedefs_dict),"\nreturn defs")
--=================================Now implementations
local iFP,iSTP
@@ -1005,6 +1023,7 @@ end
local json = require"json"
save_data("./generated/definitions.json",json.encode(json_prepare(pFP.defsT)))
save_data("./generated/structs_and_enums.json",json.encode(structs_and_enums_table))
save_data("./generated/typedefs_dict.json",json.encode(typedefs_dict))
if iFP then
save_data("./generated/impl_definitions.json",json.encode(json_prepare(iFP.defsT)))
end