mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-13 13:18:31 +01:00
Merge pull request #64 from sonoro1234/argdetection_failure
Argdetection failure
This commit is contained in:
@@ -469,8 +469,8 @@ local function func_parser()
|
|||||||
argscsinpars = argscsinpars:gsub("<([%w_]+)>","_%1") --ImVector
|
argscsinpars = argscsinpars:gsub("<([%w_]+)>","_%1") --ImVector
|
||||||
|
|
||||||
local argsArr = {}
|
local argsArr = {}
|
||||||
local functype_re = "^%s*[%w%s%*]+%(%*[%w_]+%)%([^%(%)]*%)"
|
local functype_re = "^%s*[%w%s%*]+%(%*[%w_]+%)%([^%(%)]*%)"
|
||||||
local functype_reex = "^(%s*[%w%s%*]+)%(%*([%w_]+)%)(%([^%(%)]*%))"
|
local functype_reex = "^(%s*[%w%s%*]+)%(%*([%w_]+)%)(%([^%(%)]*%))"
|
||||||
local functype_arg_rest = "^(%s*[%w%s%*]+%(%*[%w_]+%)%([^%(%)]*%)),*(.*)"
|
local functype_arg_rest = "^(%s*[%w%s%*]+%(%*[%w_]+%)%([^%(%)]*%)),*(.*)"
|
||||||
local rest = argscsinpars:sub(2,-2) --strip ()
|
local rest = argscsinpars:sub(2,-2) --strip ()
|
||||||
|
|
||||||
@@ -498,17 +498,20 @@ local function func_parser()
|
|||||||
else
|
else
|
||||||
type,name = arg:match("(.+)%s([^%s]+)")
|
type,name = arg:match("(.+)%s([^%s]+)")
|
||||||
end
|
end
|
||||||
--if not type or not name then print(funcname,type,name,argscsinpars,arg) end
|
if not type or not name then
|
||||||
--float name[2] to float[2] name
|
print("failure arg detection",funcname,type,name,argscsinpars,arg)
|
||||||
local siz = name:match("(%[%d*%])")
|
else
|
||||||
if siz then
|
--float name[2] to float[2] name
|
||||||
type = type..siz
|
local siz = name:match("(%[%d*%])")
|
||||||
name = name:gsub("(%[%d*%])","")
|
if siz then
|
||||||
end
|
type = type..siz
|
||||||
|
name = name:gsub("(%[%d*%])","")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
table.insert(argsArr,{type=type,name=name,ret=retf,signature=sigf})
|
table.insert(argsArr,{type=type,name=name,ret=retf,signature=sigf})
|
||||||
if arg:match("&") and not arg:match("const") then
|
if arg:match("&") and not arg:match("const") then
|
||||||
print(funcname,argscsinpars)
|
print("reference to no const arg in",funcname,argscsinpars)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
argscsinpars = argscsinpars:gsub("&","")
|
argscsinpars = argscsinpars:gsub("&","")
|
||||||
@@ -1122,7 +1125,33 @@ local function func_implementation(FP)
|
|||||||
--cppfile:close()
|
--cppfile:close()
|
||||||
return table.concat(outtab)
|
return table.concat(outtab)
|
||||||
end
|
end
|
||||||
|
--only basic ending
|
||||||
|
local c_types = {
|
||||||
|
["char"]=true,
|
||||||
|
["int"]=true,
|
||||||
|
["float"]=true,
|
||||||
|
["double"]=true,
|
||||||
|
["short"]=true,
|
||||||
|
["long"]=true,
|
||||||
|
["signed"]=true,
|
||||||
|
["unsigned"]=true,
|
||||||
|
["size_t"]=true,
|
||||||
|
["ptrdiff_t"]=true,
|
||||||
|
}
|
||||||
|
local function check_arg_detection(fdefs,typedefs)
|
||||||
|
print"-----------------check arg detection---------------------------"
|
||||||
|
for k,defT in pairs(fdefs) do
|
||||||
|
for i,def in ipairs(defT) do
|
||||||
|
for j,arg in ipairs(def.argsT) do
|
||||||
|
--check name is not type, which happens in declaration without name
|
||||||
|
if not arg.type or not arg.name or c_types[arg.name] or typedefs[arg.name] then
|
||||||
|
print("bad argument name",arg.name, "in",def.funcname,def.args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print"-----------------end check arg detection-----------------------"
|
||||||
|
end
|
||||||
--generate cimgui.cpp cimgui.h and auto versions depending on postfix
|
--generate cimgui.cpp cimgui.h and auto versions depending on postfix
|
||||||
local function cimgui_generation(postfix,STP,FP)
|
local function cimgui_generation(postfix,STP,FP)
|
||||||
--merge it in cimgui_template.h to cimgui.h
|
--merge it in cimgui_template.h to cimgui.h
|
||||||
@@ -1194,7 +1223,8 @@ local ovstr = pFP:compute_overloads()
|
|||||||
ADDnonUDT(pFP)
|
ADDnonUDT(pFP)
|
||||||
save_data("./generated/overloads.txt",ovstr)
|
save_data("./generated/overloads.txt",ovstr)
|
||||||
typedefs_dict2 = cimgui_generation("_auto",pSTP,pFP)
|
typedefs_dict2 = cimgui_generation("_auto",pSTP,pFP)
|
||||||
|
--check arg detection failure if no name in function declaration
|
||||||
|
check_arg_detection(pFP.defsT,typedefs_dict2)
|
||||||
end
|
end
|
||||||
|
|
||||||
----------save fundefs in definitions.lua for using in bindings
|
----------save fundefs in definitions.lua for using in bindings
|
||||||
|
Reference in New Issue
Block a user