mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-09 19:38:30 +01:00
cpp2ffi: allow function typedefs (not only function pointer typedefs)
This commit is contained in:
@@ -287,7 +287,7 @@ local function getRE()
|
||||
typedef_re = "^\n*%s*(typedef[^;]+;)",
|
||||
typedef_st_re = "^\n*(typedef%s+struct%s*%b{}.-;)",
|
||||
functypedef_re = "^\n*%s*(typedef[%w%s%*_]+%(%s*%*%s*[%w_]+%s*%)%s*%b()%s*;)",
|
||||
functypedef_re = "^\n*%s*(typedef[%w%s%*_]+%([^*]*%*%s*[%w_]+%s*%)%s*%b()%s*;)",
|
||||
functypedef_re = "^\n*%s*(typedef[%w%s%*_]+%([^*]*%*?%s*[%w_]+%s*%)%s*%b()%s*;)",
|
||||
--vardef_re = "^\n*([^;{}%(%)]+;)",
|
||||
--change for things as
|
||||
--[[ImU8 Used4kPagesMap[((sizeof(ImWchar16) == 2 ? 0xFFFF : 0x10FFFF)+1)/4096/8];]]
|
||||
@@ -1084,16 +1084,25 @@ function M.Parser()
|
||||
local value,key = line:match("typedef%s+(.+)%s+([%w_]+);")
|
||||
if key and value then
|
||||
self.typedefs_dict[key] = value
|
||||
else --try function typedef
|
||||
else --try function pointer typedef
|
||||
local key = line:match("%(%*([%w_]+)%)%([^%(%)]*%)")
|
||||
if key then
|
||||
local linet = line
|
||||
linet = linet:gsub("typedef ","")
|
||||
linet = linet:gsub("%(%*("..key..")%)","(*)")
|
||||
self.typedefs_dict[key] = linet
|
||||
elseif not line:match"typedef%s*struct" then --discard typedef struct
|
||||
print("typedef not found")
|
||||
print(key,value,line)
|
||||
else
|
||||
--try function typedef
|
||||
key = line:match("%(([%w_]+)%)%([^%(%)]*%)")
|
||||
if key then
|
||||
local linet = line
|
||||
linet = linet:gsub("typedef ","")
|
||||
linet = linet:gsub("%(("..key..")%)","()")
|
||||
self.typedefs_dict[key] = linet
|
||||
elseif not line:match"typedef%s*struct" then --discard typedef struct
|
||||
print("typedef not found")
|
||||
print(key,value,line)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user