APIDump: Added support for overloaded functions.
This commit is contained in:
parent
0b10f5f795
commit
de77eaaecd
@ -152,10 +152,16 @@ g_APIDesc =
|
|||||||
Functions =
|
Functions =
|
||||||
{
|
{
|
||||||
GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" },
|
GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" },
|
||||||
GetSlot = { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" },
|
GetSlot =
|
||||||
GetSlot = { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" },
|
{
|
||||||
SetSlot = { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" },
|
{ Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" },
|
||||||
SetSlot = { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" },
|
{ Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" },
|
||||||
|
},
|
||||||
|
SetSlot =
|
||||||
|
{
|
||||||
|
{ Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" },
|
||||||
|
{ Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Constants =
|
Constants =
|
||||||
{
|
{
|
||||||
@ -297,10 +303,16 @@ g_APIDesc =
|
|||||||
GetIngredientsHeight = { Params = "", Return = "number", Notes = "Returns the height of the ingredients' grid" },
|
GetIngredientsHeight = { Params = "", Return = "number", Notes = "Returns the height of the ingredients' grid" },
|
||||||
GetIngredientsWidth = { Params = "", Return = "number", Notes = "Returns the width of the ingredients' grid" },
|
GetIngredientsWidth = { Params = "", Return = "number", Notes = "Returns the width of the ingredients' grid" },
|
||||||
GetResult = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the result of the recipe" },
|
GetResult = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the result of the recipe" },
|
||||||
SetIngredient = { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" },
|
SetIngredient =
|
||||||
SetIngredient = { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" },
|
{
|
||||||
SetResult = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the result item" },
|
{ Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" },
|
||||||
SetResult = { Params = "ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the result item" },
|
{ Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" },
|
||||||
|
},
|
||||||
|
SetResult =
|
||||||
|
{
|
||||||
|
{ Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the result item" },
|
||||||
|
{ Params = "ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the result item" },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Constants =
|
Constants =
|
||||||
{
|
{
|
||||||
|
@ -269,20 +269,42 @@ function ReadDescriptions(a_API)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cls.Undocumented = {}; -- This will contain all the API objects that are not documented
|
||||||
|
|
||||||
|
local DoxyFunctions = {}; -- This will contain all the API functions together with their documentation
|
||||||
|
|
||||||
|
local function AddFunction(a_Name, a_Params, a_Return, a_Notes)
|
||||||
|
table.insert(DoxyFunctions, {Name = a_Name, Params = a_Params, Return = a_Return, Notes = a_Notes});
|
||||||
|
end
|
||||||
|
|
||||||
if (APIDesc.Functions ~= nil) then
|
if (APIDesc.Functions ~= nil) then
|
||||||
-- Assign function descriptions:
|
-- Assign function descriptions:
|
||||||
for j, func in ipairs(cls.Functions) do
|
for j, func in ipairs(cls.Functions) do
|
||||||
local FnName = func.DocID or func.Name;
|
local FnName = func.DocID or func.Name;
|
||||||
local FnDesc = APIDesc.Functions[FnName];
|
local FnDesc = APIDesc.Functions[FnName];
|
||||||
if (FnDesc ~= nil) then
|
if (FnDesc == nil) then
|
||||||
func.Params = FnDesc.Params;
|
-- No description for this API function
|
||||||
func.Return = FnDesc.Return;
|
AddFunction(func.Name);
|
||||||
func.Notes = FnDesc.Notes;
|
table.insert(cls.Undocumented, func.Name);
|
||||||
|
else
|
||||||
|
-- Description is available
|
||||||
|
if (FnDesc[1] == nil) then
|
||||||
|
-- Single function definition
|
||||||
|
AddFunction(func.Name, FnDesc.Params, FnDesc.Return, FnDesc.Notes);
|
||||||
|
else
|
||||||
|
-- Multiple function overloads
|
||||||
|
for k, desc in ipairs(FnDesc) do
|
||||||
|
AddFunction(func.Name, desc.Params, desc.Return, desc.Notes);
|
||||||
|
end -- for k, desc - FnDesc[]
|
||||||
|
end
|
||||||
FnDesc.IsExported = true;
|
FnDesc.IsExported = true;
|
||||||
end
|
end
|
||||||
end -- for j, func
|
end -- for j, func
|
||||||
|
|
||||||
|
-- Replace functions with their described and overload-expanded versions:
|
||||||
|
cls.Functions = DoxyFunctions;
|
||||||
|
|
||||||
-- Add all non-exported function descriptions to UnexportedDocumented:
|
-- Add all non-exported function descriptions to UnexportedDocumented:
|
||||||
for j, func in pairs(APIDesc.Functions) do
|
for j, func in pairs(APIDesc.Functions) do
|
||||||
-- TODO
|
-- TODO
|
||||||
@ -293,7 +315,10 @@ function ReadDescriptions(a_API)
|
|||||||
-- Assign constant descriptions:
|
-- Assign constant descriptions:
|
||||||
for j, cons in ipairs(cls.Constants) do
|
for j, cons in ipairs(cls.Constants) do
|
||||||
local CnDesc = APIDesc.Constants[cons.Name];
|
local CnDesc = APIDesc.Constants[cons.Name];
|
||||||
if (CnDesc ~= nil) then
|
if (CnDesc == nil) then
|
||||||
|
-- Not documented
|
||||||
|
table.insert(cls.Undocumented, cons.Name);
|
||||||
|
else
|
||||||
cons.Notes = CnDesc.Notes;
|
cons.Notes = CnDesc.Notes;
|
||||||
CnDesc.IsExported = true;
|
CnDesc.IsExported = true;
|
||||||
end
|
end
|
||||||
@ -318,6 +343,13 @@ function ReadDescriptions(a_API)
|
|||||||
-- Sort the functions (they may have been renamed):
|
-- Sort the functions (they may have been renamed):
|
||||||
table.sort(cls.Functions,
|
table.sort(cls.Functions,
|
||||||
function(f1, f2)
|
function(f1, f2)
|
||||||
|
if (f1.Name == f2.Name) then
|
||||||
|
-- Same name, either comparing the same function to itself, or two overloads, in which case compare the params
|
||||||
|
if ((f1.Params == nil) or (f2.Params == nil)) then
|
||||||
|
return 0;
|
||||||
|
end
|
||||||
|
return (f1.Params < f2.Params);
|
||||||
|
end
|
||||||
return (f1.Name < f2.Name);
|
return (f1.Name < f2.Name);
|
||||||
end
|
end
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user