Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions genEmmyAPI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ local function stripNewlines(src)
return string.gsub(src, "\n", " ")
end

local function getReturnType(ret)
-- Include fields with their types when the return type is a table with known fields and types
if ret.table then
local s = "{"
for i, field in ipairs(ret.table) do
local decl = field.name .. ":" .. field.type
if i == 1 then
s = s .. decl
else
s = s .. ', ' .. decl
end
end
s = s .. "}"
return s
else
return ret.type
end
end

local function genReturns(variant)
local returns = variant.returns
local s = ""
Expand All @@ -21,9 +40,9 @@ local function genReturns(variant)
num = #returns
for i, ret in ipairs(returns) do
if i == 1 then
s = ret.type
s = getReturnType(ret)
else
s = s .. ', ' .. ret.type
s = s .. ', ' .. getReturnType(ret)
end
end
else
Expand Down