Skip to content

Added vararg support #1183

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 29, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion meta/3rd/love2d/library/love.data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ function love.data.newDataView(data, offset, size) end
---@param container love.ContainerType # What type to return the encoded data as.
---@param format string # A string determining how the values are packed. Follows the rules of Lua 5.3's string.pack format strings.
---@param v1 number|boolean|string # The first value (number, boolean, or string) to serialize.
---@vararg number|boolean|string # Additional values to serialize.
---@return love.Data|string data # Data/string which contains the serialized data.
function love.data.pack(container, format, v1) end
function love.data.pack(container, format, v1, ...) end

---
---Unpacks (deserializes) a byte-string or Data into simple Lua values.
Expand Down
3 changes: 2 additions & 1 deletion meta/3rd/love2d/library/love.event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function love.event.pump() end
---@param d? any # Fourth event argument.
---@param e? any # Fifth event argument.
---@param f? any # Sixth event argument.
function love.event.push(n, a, b, c, d, e, f) end
---@vararg any # Further event arguments may follow.
function love.event.push(n, a, b, c, d, e, f, ...) end

---
---Adds the quit event to the queue.
Expand Down
3 changes: 2 additions & 1 deletion meta/3rd/love2d/library/love.font.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ function Rasterizer:getLineHeight() end
---
---@param glyph1 string|number # Glyph
---@param glyph2 string|number # Glyph
---@vararg string|number # Additional glyphs
---@return boolean hasGlyphs # Whatever font contains specified glyphs.
function Rasterizer:hasGlyphs(glyph1, glyph2) end
function Rasterizer:hasGlyphs(glyph1, glyph2, ...) end

---
---True Type hinting mode.
Expand Down
24 changes: 16 additions & 8 deletions meta/3rd/love2d/library/love.graphics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ function love.graphics.isWireframe() end
---@param y1 number # The position of first point on the y-axis.
---@param x2 number # The position of second point on the x-axis.
---@param y2 number # The position of second point on the y-axis.
function love.graphics.line(x1, y1, x2, y2) end
---@vararg number # You can continue passing point positions to draw a polyline.
function love.graphics.line(x1, y1, x2, y2, ...) end

---
---Creates a new array Image.
Expand Down Expand Up @@ -694,7 +695,8 @@ function love.graphics.origin() end
---@overload fun(points: table)
---@param x number # The position of the first point on the x-axis.
---@param y number # The position of the first point on the y-axis.
function love.graphics.points(x, y) end
---@vararg number # The x and y coordinates of additional points.
function love.graphics.points(x, y, ...) end

---
---Draw a polygon.
Expand All @@ -703,7 +705,8 @@ function love.graphics.points(x, y) end
---
---@overload fun(mode: love.DrawMode, vertices: table)
---@param mode love.DrawMode # How to draw the polygon.
function love.graphics.polygon(mode) end
---@vararg number # The vertices of the polygon.
function love.graphics.polygon(mode, ...) end

---
---Pops the current coordinate transformation from the transformation stack.
Expand Down Expand Up @@ -1227,7 +1230,8 @@ function Font:hasGlyphs(text) end
---Sets the fallback fonts. When the Font doesn't contain a glyph, it will substitute the glyph from the next subsequent fallback Fonts. This is akin to setting a 'font stack' in Cascading Style Sheets (CSS).
---
---@param fallbackfont1 love.Font # The first fallback Font to use.
function Font:setFallbacks(fallbackfont1) end
---@vararg love.Font # Additional fallback Fonts.
function Font:setFallbacks(fallbackfont1, ...) end

---
---Sets the filter mode for a font.
Expand Down Expand Up @@ -1402,7 +1406,8 @@ function Mesh:setTexture(texture) end
---@overload fun(self: love.Mesh, index: number, vertex: table)
---@param index number # The index of the the vertex you want to modify (one-based).
---@param attributecomponent number # The first component of the first vertex attribute in the specified vertex.
function Mesh:setVertex(index, attributecomponent) end
---@vararg number # Additional components of all vertex attributes in the specified vertex.
function Mesh:setVertex(index, attributecomponent, ...) end

---
---Sets the properties of a specific attribute within a vertex in the Mesh.
Expand All @@ -1413,7 +1418,8 @@ function Mesh:setVertex(index, attributecomponent) end
---@param attributeindex number # The index of the attribute within the vertex to be modified (one-based).
---@param value1 number # The new value for the first component of the attribute.
---@param value2 number # The new value for the second component of the attribute.
function Mesh:setVertexAttribute(vertexindex, attributeindex, value1, value2) end
---@vararg number # Any additional vertex attribute components.
function Mesh:setVertexAttribute(vertexindex, attributeindex, value1, value2, ...) end

---
---Sets the vertex map for the Mesh. The vertex map describes the order in which the vertices are used when the Mesh is drawn. The vertices, vertex map, and mesh draw mode work together to determine what exactly is displayed on the screen.
Expand Down Expand Up @@ -1965,7 +1971,8 @@ function Shader:hasUniform(name) end
---@overload fun(self: love.Shader, name: string, matrixlayout: love.MatrixLayout, data: love.Data, offset: number, size: number)
---@param name string # Name of the number to send to the shader.
---@param number number # Number to send to store in the uniform variable.
function Shader:send(name, number) end
---@vararg number # Additional numbers to send if the uniform variable is an array.
function Shader:send(name, number, ...) end

---
---Sends one or more colors to a special (''extern'' / ''uniform'') vec3 or vec4 variable inside the shader. The color components must be in the range of 1. The colors are gamma-corrected if global gamma-correction is enabled.
Expand All @@ -1984,7 +1991,8 @@ function Shader:send(name, number) end
---
---@param name string # The name of the color extern variable to send to in the shader.
---@param color table # A table with red, green, blue, and optional alpha color components in the range of 1 to send to the extern as a vector.
function Shader:sendColor(name, color) end
---@vararg table # Additional colors to send in case the extern is an array. All colors need to be of the same size (e.g. only vec3's).
function Shader:sendColor(name, color, ...) end

---
---Using a single image, draw any number of identical copies of the image using a single call to love.graphics.draw(). This can be used, for example, to draw repeating copies of a single background image with high performance.
Expand Down
3 changes: 2 additions & 1 deletion meta/3rd/love2d/library/love.keyboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ function love.keyboard.isDown(key) end
---Unlike regular KeyConstants, Scancodes are keyboard layout-independent. The scancode 'w' is used if the key in the same place as the 'w' key on an American keyboard is pressed, no matter what the key is labelled or what the user's operating system settings are.
---
---@param scancode love.Scancode # A Scancode to check.
---@vararg love.Scancode # Additional Scancodes to check.
---@return boolean down # True if any supplied Scancode is down, false if not.
function love.keyboard.isScancodeDown(scancode) end
function love.keyboard.isScancodeDown(scancode, ...) end

---
---Enables or disables key repeat for love.keypressed. It is disabled by default.
Expand Down
3 changes: 2 additions & 1 deletion meta/3rd/love2d/library/love.math.lua
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,10 @@ function Transform:scale(sx, sy) end
---@overload fun(self: love.Transform, layout: love.MatrixLayout, matrix: table):love.Transform
---@param e1_1 number # The first column of the first row of the matrix.
---@param e1_2 number # The second column of the first row of the matrix.
---@vararg number # Additional matrix elements.
---@param e4_4 number # The fourth column of the fourth row of the matrix.
---@return love.Transform transform # The Transform object the method was called on. Allows easily chaining Transform methods.
function Transform:setMatrix(e1_1, e1_2, e4_4) end
function Transform:setMatrix(e1_1, e1_2, ..., e4_4) end

---
---Resets the Transform to the specified transformation parameters.
Expand Down
3 changes: 2 additions & 1 deletion meta/3rd/love2d/library/love.mouse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ function love.mouse.isCursorSupported() end
---This function does not detect mouse wheel scrolling; you must use the love.wheelmoved (or love.mousepressed in version 0.9.2 and older) callback for that.
---
---@param button number # The index of a button to check. 1 is the primary mouse button, 2 is the secondary mouse button and 3 is the middle button. Further buttons are mouse dependant.
---@vararg number # Additional button numbers to check.
---@return boolean down # True if any specified button is down.
function love.mouse.isDown(button) end
function love.mouse.isDown(button, ...) end

---
---Checks if the mouse is grabbed.
Expand Down
9 changes: 6 additions & 3 deletions meta/3rd/love2d/library/love.physics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ function love.physics.newBody(world, x, y, type) end
---@param y1 number # The y position of the first point.
---@param x2 number # The x position of the second point.
---@param y2 number # The y position of the second point.
---@vararg number # Additional point positions.
---@return love.ChainShape shape # The new shape.
function love.physics.newChainShape(loop, x1, y1, x2, y2) end
function love.physics.newChainShape(loop, x1, y1, x2, y2, ...) end

---
---Creates a new CircleShape.
Expand Down Expand Up @@ -167,8 +168,9 @@ function love.physics.newMouseJoint(body, x, y) end
---@param y2 number # The y position of the second point.
---@param x3 number # The x position of the third point.
---@param y3 number # The y position of the third point.
---@vararg number # You can continue passing more point positions to create the PolygonShape.
---@return love.PolygonShape shape # A new PolygonShape.
function love.physics.newPolygonShape(x1, y1, x2, y2, x3, y3) end
function love.physics.newPolygonShape(x1, y1, x2, y2, x3, y3, ...) end

---
---Creates a PrismaticJoint between two bodies.
Expand Down Expand Up @@ -499,11 +501,12 @@ function Body:getLocalPoint(worldX, worldY) end
---@param y1 number # (Argument) The y position of the first point.
---@param x2 number # (Argument) The x position of the second point.
---@param y2 number # (Argument) The y position of the second point.
---@vararg number # (Argument) You can continue passing x and y position of the points.
---@return number x1 # (Result) The transformed x position of the first point.
---@return number y1 # (Result) The transformed y position of the first point.
---@return number x2 # (Result) The transformed x position of the second point.
---@return number y2 # (Result) The transformed y position of the second point.
function Body:getLocalPoints(x1, y1, x2, y2) end
function Body:getLocalPoints(x1, y1, x2, y2, ...) end

---
---Transform a vector from world coordinates to local coordinates.
Expand Down
3 changes: 2 additions & 1 deletion meta/3rd/love2d/library/love.thread.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ function Channel:peek() end
---
---@param func function # The function to call, the form of function(channel, arg1, arg2, ...) end. The Channel is passed as the first argument to the function when it is called.
---@param arg1 any # Additional arguments that the given function will receive when it is called.
---@vararg any # Additional arguments that the given function will receive when it is called.
---@return any ret1 # The first return value of the given function (if any.)
function Channel:performAtomic(func, arg1) end
function Channel:performAtomic(func, arg1, ...) end

---
---Retrieves the value of a Channel message and removes it from the message queue.
Expand Down
8 changes: 8 additions & 0 deletions tools/love-api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ local function buildFunction(func, node, typeName)
param.description
)
end

if param.name == "..." then
params[#params+1] = param.name
text[#text+1] = ('---@vararg %s # %s'):format(
buildType(param),
param.description
)
end
end
for _, rtn in ipairs(func.variants[1].returns or {}) do
for returnName in rtn.name:gmatch '[%a_][%w_]*' do
Expand Down