I'm trying to build something which leverages __stub.lua
and I ran into a handful of issues:
- Some lines are invalid Lua code: for example positional parameters are stubbed with names that are invalid identifiers, either with invalid characters ("-"), as reserved keywords (repeat, function, end):
104 function playdate.graphics.sprite.setBounds(upper-left-x, upper-left-y, width, height) end
296 function playdate.graphics.perlin(x, y, z, repeat, octaves, persistence) end
297 function playdate.graphics.perlinArray(count, x, dx, y, dy, z, dz, repeat, octaves, persistence) end
573 function playdate.sound.fileplayer.setLoopRange(start, end, loopCallback, arg) end
622 function playdate.sound.synth.setFinishCallback(function) end
650 function playdate.sound.envelope.setRateScaling(scaling, start, end) end
And setStencilPattern confuses a calling convention with the signature resulting in an invalid statement.
306 function playdate.graphics.setStencilPattern({ row1, row2, row3, row4, row5, row6, row7, row8 }) end
- Some function signatures have duplicated portions, for example 13 instances of "playdate.playdate.*" and others have missing/duplicated parts:
697 function playdate.sound.delayline.addTap(delay)(delay) end
698 function playdate.sound.delayline.setFeedback(level)(level) end
704 function playdate.sound.delaylinetap.setFlipChannels(flag)(flag) end
606 function playdate.sound.synth.new.waveform(waveform) end
607 function playdate.sound.synth.new.sample(sample, sustainStart, sustainEnd) end
playdate.crankIndicator.* (should be pladyate.ui.crankIndicator.*)
playdate.geometry.lineSegment.fast.intersection (should be fast_intersection)
playdate.gridView.* (should be playdate.ui.gridview)
playdate.gridview.* (should be playdate.ui.gridView and fix camelCase)
playdate.sound.synth.new.{waveform,sample} (should be playdate.sound.synth.new(...))
playdate.where (should be where())
playdate.printTable (should be printTable)
-
Multiple issues with setSencialPattern. First
playdate.graphics.sprite:setStencilPattern
shows up asplaydate.graphics.setStencilPattern
You can see it wrong in the html docs too. (doc link). Also the stub mentioned above should be something likesetStencilPattern(rowTable)
. -
Nearly all constructors are absent (e.g. notice __stub.lua has no rect.new, sprite.new, image.new, etc) and some are duplicated under the wrong name (playdate.timer.new2, playdate.graphics.animator.new1-5).
-
Some (not all) of the playdate sub-namespaces are stubbed out as functions, which is incorrect. For example playdate.graphics is not a function and has things under its namespace and so should not have a stubbed function itself.
Which leads me my following suggestion: If you fix all the above issues __stub.lua
becomes valid lua in the presence of a playdate
global table including all the sub-namespaces. So you could add a test to your CI that would catch invalid identifiers or namespace typos introduced in the future:
lua -e 'playdate = {
datastore={},
display={},
easingFunctions={},
inputHandlers={},
file={file={}},
geometry={affineTransform={},arc={},lineSegment={},point={},polygon={},rect={},size={},vector2D={}},
graphics={image={},imagetable={},sprite={},tilemap={},nineSlice={},animation={blinker={},loop={}},animator={},font={},video={}},
keyboard={},
math={},
menu={item={}},
pathfinder={graph={},node={}},
simulator={},
sound={sampleplayer={},fileplayer={},sample={},channel={},synth={},signal={},lfo={},envelope={},bitcrusher={},ringmod={},onepolefilter={},twopolefilter={},overdrive={},delayline={},delaylinetap={},sequence={},track={},instrument={},controlsignal={},micinput={}},
string={},
timer={},
frameTimer={},
ui={crankIndicator={},gridview={}},
}
table={}
json={}' ~/Developer/PlaydateSDK/CoreLibs/__stub.lua
- The signatures for all instance methods are incorrect. They should either use a colon or have self listed as the first parameter:
BAD: playdate.graphics.image.getSize()
OK: playdate.graphics.image.getSize(self)
OK: playdate.graphics.image:getSize()
As always, thanks for creating a truly great SDK! It's very much a pleasure to work with.