mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-13 21:28:30 +01:00
add typedefs_dict
This commit is contained in:
1
generator/generated/typedefs_dict.json
Normal file
1
generator/generated/typedefs_dict.json
Normal 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"}
|
40
generator/generated/typedefs_dict.lua
Normal file
40
generator/generated/typedefs_dict.lua
Normal 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
|
@@ -539,6 +539,7 @@ local function gen_structs_and_enums_table(cdefs)
|
|||||||
local enumnames = {}
|
local enumnames = {}
|
||||||
local enums_re = "^%s*enum%s+([^%s;]+)"
|
local enums_re = "^%s*enum%s+([^%s;]+)"
|
||||||
local outtab = {structs={},enums={}}
|
local outtab = {structs={},enums={}}
|
||||||
|
local typedefs_dict = {}
|
||||||
|
|
||||||
for i,line in ipairs(cdefs) do
|
for i,line in ipairs(cdefs) do
|
||||||
repeat -- simulating continue with break
|
repeat -- simulating continue with break
|
||||||
@@ -546,7 +547,23 @@ local function gen_structs_and_enums_table(cdefs)
|
|||||||
local linecom = line
|
local linecom = line
|
||||||
local line, comment = split_comment(line)
|
local line, comment = split_comment(line)
|
||||||
line = clean_spaces(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
|
if line:match(namespace_re) then
|
||||||
in_namespace = true
|
in_namespace = true
|
||||||
end
|
end
|
||||||
@@ -617,7 +634,7 @@ local function gen_structs_and_enums_table(cdefs)
|
|||||||
end
|
end
|
||||||
until true
|
until true
|
||||||
end
|
end
|
||||||
return outtab
|
return outtab, typedefs_dict
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -632,6 +649,7 @@ local function gen_structs_and_enums(cdefs)
|
|||||||
local structnames = {}
|
local structnames = {}
|
||||||
local innerstructs = {}
|
local innerstructs = {}
|
||||||
local typedefs_table = {}
|
local typedefs_table = {}
|
||||||
|
|
||||||
local outtab = {}
|
local outtab = {}
|
||||||
-- Output the file
|
-- Output the file
|
||||||
--table.insert(outtab,"/////////////// BEGIN AUTOGENERATED SEGMENT\n")
|
--table.insert(outtab,"/////////////// BEGIN AUTOGENERATED SEGMENT\n")
|
||||||
@@ -644,7 +662,7 @@ local function gen_structs_and_enums(cdefs)
|
|||||||
local desired_linelen = (linelen==0) and 0 or math.max(math.ceil(linelen/10)*10,40)
|
local desired_linelen = (linelen==0) and 0 or math.max(math.ceil(linelen/10)*10,40)
|
||||||
local spaces_to_add = 0 --desired_linelen - linelen
|
local spaces_to_add = 0 --desired_linelen - linelen
|
||||||
local linecom = line..string.rep(" ",spaces_to_add)..comment
|
local linecom = line..string.rep(" ",spaces_to_add)..comment
|
||||||
|
|
||||||
if line:match(namespace_re) then
|
if line:match(namespace_re) then
|
||||||
in_namespace = true
|
in_namespace = true
|
||||||
end
|
end
|
||||||
@@ -943,9 +961,9 @@ end
|
|||||||
save_data("./generated/definitions.lua",serializeTable("defs",pFP.defsT),"\nreturn defs")
|
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
|
----------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/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
|
--=================================Now implementations
|
||||||
|
|
||||||
local iFP,iSTP
|
local iFP,iSTP
|
||||||
@@ -1005,6 +1023,7 @@ end
|
|||||||
local json = require"json"
|
local json = require"json"
|
||||||
save_data("./generated/definitions.json",json.encode(json_prepare(pFP.defsT)))
|
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/structs_and_enums.json",json.encode(structs_and_enums_table))
|
||||||
|
save_data("./generated/typedefs_dict.json",json.encode(typedefs_dict))
|
||||||
if iFP then
|
if iFP then
|
||||||
save_data("./generated/impl_definitions.json",json.encode(json_prepare(iFP.defsT)))
|
save_data("./generated/impl_definitions.json",json.encode(json_prepare(iFP.defsT)))
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user