DiffAPIDesc: Support optional params in desc.
This commit is contained in:
parent
f0c53dbad4
commit
abf35f3976
@ -41,6 +41,7 @@ local g_CTypeToLuaType =
|
|||||||
unsigned = "number",
|
unsigned = "number",
|
||||||
["const AString"] = "string",
|
["const AString"] = "string",
|
||||||
["const char*"] = "string",
|
["const char*"] = "string",
|
||||||
|
["std::string"] = "string",
|
||||||
["Vector3<int>"] = "Vector3i",
|
["Vector3<int>"] = "Vector3i",
|
||||||
["Vector3<float>"] = "Vector3f",
|
["Vector3<float>"] = "Vector3f",
|
||||||
["Vector3<double>"] = "Vector3d",
|
["Vector3<double>"] = "Vector3d",
|
||||||
@ -129,13 +130,16 @@ end
|
|||||||
local function functionDescMatchesDocs(a_FunctionDesc, a_FunctionDoc)
|
local function functionDescMatchesDocs(a_FunctionDesc, a_FunctionDoc)
|
||||||
-- Check the number of parameters:
|
-- Check the number of parameters:
|
||||||
local numParams
|
local numParams
|
||||||
|
local numOptionalParams = 0
|
||||||
if (not(a_FunctionDesc.Params) or (a_FunctionDesc.Params == "")) then
|
if (not(a_FunctionDesc.Params) or (a_FunctionDesc.Params == "")) then
|
||||||
numParams = 0
|
numParams = 0
|
||||||
else
|
else
|
||||||
_, numParams = string.gsub(a_FunctionDesc.Params, ",", "")
|
_, numParams = string.gsub(a_FunctionDesc.Params, ",", "")
|
||||||
numParams = numParams + 1
|
numParams = numParams + 1
|
||||||
|
_, numOptionalParams = string.gsub(a_FunctionDesc.Params, "%b[]", "")
|
||||||
end
|
end
|
||||||
if (#(a_FunctionDoc.Params) ~= numParams) then
|
local numDocParams = #(a_FunctionDoc.Params)
|
||||||
|
if ((numDocParams > numParams) or (numDocParams < numParams - numOptionalParams)) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -151,20 +155,12 @@ end
|
|||||||
-- a_FunctionDocs is an array of function documentation items, as loaded from ToLua++'s parser
|
-- a_FunctionDocs is an array of function documentation items, as loaded from ToLua++'s parser
|
||||||
-- If all descriptions match, nil is returned instead
|
-- If all descriptions match, nil is returned instead
|
||||||
local function listMissingClassSingleFunctionDescs(a_FunctionDescs, a_FunctionDocs)
|
local function listMissingClassSingleFunctionDescs(a_FunctionDescs, a_FunctionDocs)
|
||||||
-- Generate a helper map of index -> true that monitors a_FunctionDescs' items' usage:
|
-- For each documentation item, try to find a match in a_FunctionDescs:
|
||||||
local freeDescs = {}
|
|
||||||
for i = 1, #a_FunctionDescs do
|
|
||||||
freeDescs[i] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- For each documentation item, try to find a match in a_FunctionDescs that hasn't been used yet:
|
|
||||||
local res = {}
|
local res = {}
|
||||||
for _, docs in ipairs(a_FunctionDocs) do
|
for _, docs in ipairs(a_FunctionDocs) do
|
||||||
local hasFound = false
|
local hasFound = false
|
||||||
for idx, _ in pairs(freeDescs) do
|
for _, desc in ipairs(a_FunctionDescs) do
|
||||||
local desc = a_FunctionDescs[idx]
|
|
||||||
if (functionDescMatchesDocs(desc, docs)) then
|
if (functionDescMatchesDocs(desc, docs)) then
|
||||||
freeDescs[idx] = nil
|
|
||||||
hasFound = true
|
hasFound = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -269,7 +265,11 @@ local function listMissingClassDescs(a_ClassName, a_ClassDesc, a_ClassDocs, a_Mi
|
|||||||
Constants = listMissingClassVarConstDescs(a_ClassDesc.Constants, a_ClassDocs.Constants),
|
Constants = listMissingClassVarConstDescs(a_ClassDesc.Constants, a_ClassDocs.Constants),
|
||||||
Variables = listMissingClassVarConstDescs(a_ClassDesc.Variables, a_ClassDocs.Variables),
|
Variables = listMissingClassVarConstDescs(a_ClassDesc.Variables, a_ClassDocs.Variables),
|
||||||
}
|
}
|
||||||
if not(missing.Functions) and not(missing.Constants) and not(missing.Variables) then
|
if (
|
||||||
|
not(missing.Functions) and
|
||||||
|
not(missing.Constants) and
|
||||||
|
not(missing.Variables)
|
||||||
|
) then
|
||||||
-- Nothing missing, don't add anything
|
-- Nothing missing, don't add anything
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user