Skip to content

Commit 86d70a4

Browse files
author
Sewbacca
committed
Added vararg support
1 parent 7eaec04 commit 86d70a4

File tree

10 files changed

+44
-18
lines changed

10 files changed

+44
-18
lines changed

meta/3rd/love2d/library/love.data.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ function love.data.newDataView(data, offset, size) end
9494
---@param container love.ContainerType # What type to return the encoded data as.
9595
---@param format string # A string determining how the values are packed. Follows the rules of Lua 5.3's string.pack format strings.
9696
---@param v1 number|boolean|string # The first value (number, boolean, or string) to serialize.
97+
---@vararg number|boolean|string # Additional values to serialize.
9798
---@return love.Data|string data # Data/string which contains the serialized data.
98-
function love.data.pack(container, format, v1) end
99+
function love.data.pack(container, format, v1, ...) end
99100

100101
---
101102
---Unpacks (deserializes) a byte-string or Data into simple Lua values.

meta/3rd/love2d/library/love.event.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ function love.event.pump() end
4040
---@param d? any # Fourth event argument.
4141
---@param e? any # Fifth event argument.
4242
---@param f? any # Sixth event argument.
43-
function love.event.push(n, a, b, c, d, e, f) end
43+
---@vararg any # Further event arguments may follow.
44+
function love.event.push(n, a, b, c, d, e, f, ...) end
4445

4546
---
4647
---Adds the quit event to the queue.

meta/3rd/love2d/library/love.font.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ function Rasterizer:getLineHeight() end
177177
---
178178
---@param glyph1 string|number # Glyph
179179
---@param glyph2 string|number # Glyph
180+
---@vararg string|number # Additional glyphs
180181
---@return boolean hasGlyphs # Whatever font contains specified glyphs.
181-
function Rasterizer:hasGlyphs(glyph1, glyph2) end
182+
function Rasterizer:hasGlyphs(glyph1, glyph2, ...) end
182183

183184
---
184185
---True Type hinting mode.

meta/3rd/love2d/library/love.graphics.lua

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ function love.graphics.isWireframe() end
474474
---@param y1 number # The position of first point on the y-axis.
475475
---@param x2 number # The position of second point on the x-axis.
476476
---@param y2 number # The position of second point on the y-axis.
477-
function love.graphics.line(x1, y1, x2, y2) end
477+
---@vararg number # You can continue passing point positions to draw a polyline.
478+
function love.graphics.line(x1, y1, x2, y2, ...) end
478479

479480
---
480481
---Creates a new array Image.
@@ -694,7 +695,8 @@ function love.graphics.origin() end
694695
---@overload fun(points: table)
695696
---@param x number # The position of the first point on the x-axis.
696697
---@param y number # The position of the first point on the y-axis.
697-
function love.graphics.points(x, y) end
698+
---@vararg number # The x and y coordinates of additional points.
699+
function love.graphics.points(x, y, ...) end
698700

699701
---
700702
---Draw a polygon.
@@ -703,7 +705,8 @@ function love.graphics.points(x, y) end
703705
---
704706
---@overload fun(mode: love.DrawMode, vertices: table)
705707
---@param mode love.DrawMode # How to draw the polygon.
706-
function love.graphics.polygon(mode) end
708+
---@vararg number # The vertices of the polygon.
709+
function love.graphics.polygon(mode, ...) end
707710

708711
---
709712
---Pops the current coordinate transformation from the transformation stack.
@@ -1227,7 +1230,8 @@ function Font:hasGlyphs(text) end
12271230
---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).
12281231
---
12291232
---@param fallbackfont1 love.Font # The first fallback Font to use.
1230-
function Font:setFallbacks(fallbackfont1) end
1233+
---@vararg love.Font # Additional fallback Fonts.
1234+
function Font:setFallbacks(fallbackfont1, ...) end
12311235

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

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

14181424
---
14191425
---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.
@@ -1965,7 +1971,8 @@ function Shader:hasUniform(name) end
19651971
---@overload fun(self: love.Shader, name: string, matrixlayout: love.MatrixLayout, data: love.Data, offset: number, size: number)
19661972
---@param name string # Name of the number to send to the shader.
19671973
---@param number number # Number to send to store in the uniform variable.
1968-
function Shader:send(name, number) end
1974+
---@vararg number # Additional numbers to send if the uniform variable is an array.
1975+
function Shader:send(name, number, ...) end
19691976

19701977
---
19711978
---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.
@@ -1984,7 +1991,8 @@ function Shader:send(name, number) end
19841991
---
19851992
---@param name string # The name of the color extern variable to send to in the shader.
19861993
---@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.
1987-
function Shader:sendColor(name, color) end
1994+
---@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).
1995+
function Shader:sendColor(name, color, ...) end
19881996

19891997
---
19901998
---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.

meta/3rd/love2d/library/love.keyboard.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ function love.keyboard.isDown(key) end
6060
---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.
6161
---
6262
---@param scancode love.Scancode # A Scancode to check.
63+
---@vararg love.Scancode # Additional Scancodes to check.
6364
---@return boolean down # True if any supplied Scancode is down, false if not.
64-
function love.keyboard.isScancodeDown(scancode) end
65+
function love.keyboard.isScancodeDown(scancode, ...) end
6566

6667
---
6768
---Enables or disables key repeat for love.keypressed. It is disabled by default.

meta/3rd/love2d/library/love.math.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,10 @@ function Transform:scale(sx, sy) end
454454
---@overload fun(self: love.Transform, layout: love.MatrixLayout, matrix: table):love.Transform
455455
---@param e1_1 number # The first column of the first row of the matrix.
456456
---@param e1_2 number # The second column of the first row of the matrix.
457+
---@vararg number # Additional matrix elements.
457458
---@param e4_4 number # The fourth column of the fourth row of the matrix.
458459
---@return love.Transform transform # The Transform object the method was called on. Allows easily chaining Transform methods.
459-
function Transform:setMatrix(e1_1, e1_2, e4_4) end
460+
function Transform:setMatrix(e1_1, e1_2, ..., e4_4) end
460461

461462
---
462463
---Resets the Transform to the specified transformation parameters.

meta/3rd/love2d/library/love.mouse.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ function love.mouse.isCursorSupported() end
6464
---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.
6565
---
6666
---@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.
67+
---@vararg number # Additional button numbers to check.
6768
---@return boolean down # True if any specified button is down.
68-
function love.mouse.isDown(button) end
69+
function love.mouse.isDown(button, ...) end
6970

7071
---
7172
---Checks if the mouse is grabbed.

meta/3rd/love2d/library/love.physics.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ function love.physics.newBody(world, x, y, type) end
5757
---@param y1 number # The y position of the first point.
5858
---@param x2 number # The x position of the second point.
5959
---@param y2 number # The y position of the second point.
60+
---@vararg number # Additional point positions.
6061
---@return love.ChainShape shape # The new shape.
61-
function love.physics.newChainShape(loop, x1, y1, x2, y2) end
62+
function love.physics.newChainShape(loop, x1, y1, x2, y2, ...) end
6263

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

173175
---
174176
---Creates a PrismaticJoint between two bodies.
@@ -499,11 +501,12 @@ function Body:getLocalPoint(worldX, worldY) end
499501
---@param y1 number # (Argument) The y position of the first point.
500502
---@param x2 number # (Argument) The x position of the second point.
501503
---@param y2 number # (Argument) The y position of the second point.
504+
---@vararg number # (Argument) You can continue passing x and y position of the points.
502505
---@return number x1 # (Result) The transformed x position of the first point.
503506
---@return number y1 # (Result) The transformed y position of the first point.
504507
---@return number x2 # (Result) The transformed x position of the second point.
505508
---@return number y2 # (Result) The transformed y position of the second point.
506-
function Body:getLocalPoints(x1, y1, x2, y2) end
509+
function Body:getLocalPoints(x1, y1, x2, y2, ...) end
507510

508511
---
509512
---Transform a vector from world coordinates to local coordinates.

meta/3rd/love2d/library/love.thread.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ function Channel:peek() end
8686
---
8787
---@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.
8888
---@param arg1 any # Additional arguments that the given function will receive when it is called.
89+
---@vararg any # Additional arguments that the given function will receive when it is called.
8990
---@return any ret1 # The first return value of the given function (if any.)
90-
function Channel:performAtomic(func, arg1) end
91+
function Channel:performAtomic(func, arg1, ...) end
9192

9293
---
9394
---Retrieves the value of a Channel message and removes it from the message queue.

tools/love-api.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ local function buildFunction(func, node, typeName)
167167
param.description
168168
)
169169
end
170+
171+
if param.name == "..." then
172+
params[#params+1] = param.name
173+
text[#text+1] = ('---@vararg %s # %s'):format(
174+
buildType(param),
175+
param.description
176+
)
177+
end
170178
end
171179
for _, rtn in ipairs(func.variants[1].returns or {}) do
172180
for returnName in rtn.name:gmatch '[%a_][%w_]*' do

0 commit comments

Comments
 (0)