summaryrefslogtreecommitdiffstats
path: root/src/Bindings/DiffAPIDesc.lua
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-07-05 09:10:19 +0200
committerMattes D <github@xoft.cz>2016-07-18 22:11:39 +0200
commitabf35f39761f70975535d8776e8ed8d7a2546b14 (patch)
treef3878f2f2df0aeeca2effd9aceed968b731fe1d9 /src/Bindings/DiffAPIDesc.lua
parentLuaAPI: Fixed bindings for cChunkDesc:GetBlockTypeMeta (diff)
downloadcuberite-abf35f39761f70975535d8776e8ed8d7a2546b14.tar
cuberite-abf35f39761f70975535d8776e8ed8d7a2546b14.tar.gz
cuberite-abf35f39761f70975535d8776e8ed8d7a2546b14.tar.bz2
cuberite-abf35f39761f70975535d8776e8ed8d7a2546b14.tar.lz
cuberite-abf35f39761f70975535d8776e8ed8d7a2546b14.tar.xz
cuberite-abf35f39761f70975535d8776e8ed8d7a2546b14.tar.zst
cuberite-abf35f39761f70975535d8776e8ed8d7a2546b14.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/DiffAPIDesc.lua24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Bindings/DiffAPIDesc.lua b/src/Bindings/DiffAPIDesc.lua
index b9314c9cd..8b8c340e2 100644
--- a/src/Bindings/DiffAPIDesc.lua
+++ b/src/Bindings/DiffAPIDesc.lua
@@ -41,6 +41,7 @@ local g_CTypeToLuaType =
unsigned = "number",
["const AString"] = "string",
["const char*"] = "string",
+ ["std::string"] = "string",
["Vector3<int>"] = "Vector3i",
["Vector3<float>"] = "Vector3f",
["Vector3<double>"] = "Vector3d",
@@ -129,13 +130,16 @@ end
local function functionDescMatchesDocs(a_FunctionDesc, a_FunctionDoc)
-- Check the number of parameters:
local numParams
+ local numOptionalParams = 0
if (not(a_FunctionDesc.Params) or (a_FunctionDesc.Params == "")) then
numParams = 0
else
_, numParams = string.gsub(a_FunctionDesc.Params, ",", "")
numParams = numParams + 1
+ _, numOptionalParams = string.gsub(a_FunctionDesc.Params, "%b[]", "")
end
- if (#(a_FunctionDoc.Params) ~= numParams) then
+ local numDocParams = #(a_FunctionDoc.Params)
+ if ((numDocParams > numParams) or (numDocParams < numParams - numOptionalParams)) then
return false
end
@@ -151,20 +155,12 @@ end
-- a_FunctionDocs is an array of function documentation items, as loaded from ToLua++'s parser
-- If all descriptions match, nil is returned instead
local function listMissingClassSingleFunctionDescs(a_FunctionDescs, a_FunctionDocs)
- -- Generate a helper map of index -> true that monitors a_FunctionDescs' items' usage:
- 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:
+ -- For each documentation item, try to find a match in a_FunctionDescs:
local res = {}
for _, docs in ipairs(a_FunctionDocs) do
local hasFound = false
- for idx, _ in pairs(freeDescs) do
- local desc = a_FunctionDescs[idx]
+ for _, desc in ipairs(a_FunctionDescs) do
if (functionDescMatchesDocs(desc, docs)) then
- freeDescs[idx] = nil
hasFound = true
break
end
@@ -269,7 +265,11 @@ local function listMissingClassDescs(a_ClassName, a_ClassDesc, a_ClassDocs, a_Mi
Constants = listMissingClassVarConstDescs(a_ClassDesc.Constants, a_ClassDocs.Constants),
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
return
end