mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-11 12:18:30 +01:00
new recursive parser3: take care of static functions
This commit is contained in:
@@ -432,6 +432,11 @@ local function parseFunction(self,stname,lineorig,namespace,locat)
|
|||||||
--clean attribute
|
--clean attribute
|
||||||
line = line:gsub("%s*__attribute__%b()","")
|
line = line:gsub("%s*__attribute__%b()","")
|
||||||
--clean static and inline and mutable
|
--clean static and inline and mutable
|
||||||
|
local is_static_function
|
||||||
|
if line:match("static") and stname~="" then
|
||||||
|
print("parseFuncion static",line)
|
||||||
|
is_static_function = true
|
||||||
|
end
|
||||||
line = line:gsub("static","")
|
line = line:gsub("static","")
|
||||||
line = line:gsub("inline","")
|
line = line:gsub("inline","")
|
||||||
line = line:gsub("mutable","")
|
line = line:gsub("mutable","")
|
||||||
@@ -617,6 +622,7 @@ local function parseFunction(self,stname,lineorig,namespace,locat)
|
|||||||
defT.namespace = namespace
|
defT.namespace = namespace
|
||||||
defT.cimguiname = cimguiname
|
defT.cimguiname = cimguiname
|
||||||
defT.stname = stname
|
defT.stname = stname
|
||||||
|
defT.is_static_function = is_static_function
|
||||||
defT.funcname = funcname
|
defT.funcname = funcname
|
||||||
defT.argsoriginal = args
|
defT.argsoriginal = args
|
||||||
defT.args= asp --argscsinpars
|
defT.args= asp --argscsinpars
|
||||||
@@ -649,8 +655,8 @@ end
|
|||||||
|
|
||||||
local function AdjustArguments(FP)
|
local function AdjustArguments(FP)
|
||||||
for fun,defs in pairs(FP.defsT) do
|
for fun,defs in pairs(FP.defsT) do
|
||||||
--struct function but no constructors
|
--struct function but no constructors or static functions
|
||||||
if defs[1].stname~="" and defs[1].ret then
|
if defs[1].stname~="" and defs[1].ret and not defs[1].is_static_function then
|
||||||
--print("adjusting",fun)
|
--print("adjusting",fun)
|
||||||
for i,def in ipairs(defs) do
|
for i,def in ipairs(defs) do
|
||||||
local empty = def.args:match("^%(%)") --no args
|
local empty = def.args:match("^%(%)") --no args
|
||||||
@@ -1036,12 +1042,11 @@ function M.Parser()
|
|||||||
if not (it.re_name == "vardef_re" and it2:match"static") then
|
if not (it.re_name == "vardef_re" and it2:match"static") then
|
||||||
table.insert(outtab,it2)
|
table.insert(outtab,it2)
|
||||||
end
|
end
|
||||||
elseif it.re_name == "struct_re" then
|
elseif it.re_name == "struct_re" or it.re_name == "enum_re" then
|
||||||
--print("inerstructs",it.item)
|
--nop
|
||||||
--table.insert(self.inerstructs,it)
|
|
||||||
elseif it.re_name ~= "functionD_re" and it.re_name ~= "function_re" then
|
elseif it.re_name ~= "functionD_re" and it.re_name ~= "function_re" then
|
||||||
print(it.re_name,"not processed")
|
print(it.re_name,"not processed clean_struct",it.item:sub(1,12))
|
||||||
M.prtable(it)
|
--M.prtable(it)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--final
|
--final
|
||||||
@@ -1088,7 +1093,7 @@ function M.Parser()
|
|||||||
elseif it.re_name == "namespace_re" or it.re_name == "union_re" or it.re_name == "functype_re" then
|
elseif it.re_name == "namespace_re" or it.re_name == "union_re" or it.re_name == "functype_re" then
|
||||||
--nop
|
--nop
|
||||||
elseif it.re_name ~= "functionD_re" and it.re_name ~= "function_re" then
|
elseif it.re_name ~= "functionD_re" and it.re_name ~= "function_re" then
|
||||||
print("not processed",it.re_name,it.item)
|
print("not processed",it.re_name,it.item:sub(1,20))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1563,6 +1568,7 @@ local function ImGui_f_implementation(outtab,def)
|
|||||||
table.insert(outtab,"CIMGUI_API".." "..def.ret.." "..def.ov_cimguiname..def.args.."\n")
|
table.insert(outtab,"CIMGUI_API".." "..def.ret.." "..def.ov_cimguiname..def.args.."\n")
|
||||||
table.insert(outtab,"{\n")
|
table.insert(outtab,"{\n")
|
||||||
local namespace = def.namespace and def.namespace.."::" or ""
|
local namespace = def.namespace and def.namespace.."::" or ""
|
||||||
|
namespace = def.is_static_function and namespace..def.stname.."::" or namespace
|
||||||
if def.isvararg then
|
if def.isvararg then
|
||||||
local call_args = def.call_args:gsub("%.%.%.","args")
|
local call_args = def.call_args:gsub("%.%.%.","args")
|
||||||
table.insert(outtab," va_list args;\n")
|
table.insert(outtab," va_list args;\n")
|
||||||
@@ -1640,7 +1646,7 @@ local function func_implementation(FP)
|
|||||||
table.insert(outtab,"{\n")
|
table.insert(outtab,"{\n")
|
||||||
table.insert(outtab," IM_DELETE(self);\n")
|
table.insert(outtab," IM_DELETE(self);\n")
|
||||||
table.insert(outtab,"}\n")
|
table.insert(outtab,"}\n")
|
||||||
elseif def.stname == "" then
|
elseif def.stname == "" or def.is_static_function then
|
||||||
ImGui_f_implementation(outtab,def)
|
ImGui_f_implementation(outtab,def)
|
||||||
else -- stname
|
else -- stname
|
||||||
struct_f_implementation(outtab,def)
|
struct_f_implementation(outtab,def)
|
||||||
@@ -1692,7 +1698,7 @@ local function func_header_generate(FP)
|
|||||||
table.insert(outtab,"CIMGUI_API void "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
table.insert(outtab,"CIMGUI_API void "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
||||||
else --not constructor
|
else --not constructor
|
||||||
|
|
||||||
if def.stname == "" then --ImGui namespace or top level
|
if def.stname == "" or def.is_static_function then --ImGui namespace or top level
|
||||||
table.insert(outtab,"CIMGUI_API "..def.ret.." ".. def.ov_cimguiname ..(empty and "(void)" or def.args)..";"..addcoment.."\n")
|
table.insert(outtab,"CIMGUI_API "..def.ret.." ".. def.ov_cimguiname ..(empty and "(void)" or def.args)..";"..addcoment.."\n")
|
||||||
else
|
else
|
||||||
table.insert(outtab,"CIMGUI_API "..def.ret.." "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
table.insert(outtab,"CIMGUI_API "..def.ret.." "..def.ov_cimguiname..def.args..";"..addcoment.."\n")
|
||||||
|
Reference in New Issue
Block a user