31 Commits
Author SHA1 Message Date
javier d0a561b91f Changed the CPlaydate import to internal for the Lua type in the Playdate bindings target. 2026-07-26 12:44:34 +02:00
javier d84113f7a8 Fixed the double-free in the "deinit" method of the Sound Effect type in the Playdate bindings target and cover ownership. v1.0.1 2026-07-26 00:45:45 +02:00
javier d233cbaddb EncodeD JSON output as UTF-8 bytes for the JSON encoder in the Playdate bindings target. 2026-07-26 00:37:32 +02:00
javier 0d0b397ce1 Added convenience overloads to Rect and also, Collection conformance in the Playdate bindings target. 2026-07-26 00:31:58 +02:00
javier 41558399e3 Standardized some arguments labels throughout the Playdate bindings target. 2026-07-26 00:25:43 +02:00
javier 2b046005d1 Converted get/set methods pairs to computed properties throughout the Playdate bindings target. 2026-07-26 00:20:19 +02:00
javier 8b002d9be8 Update the copyright holder in the LICENSE file. 2026-07-25 23:57:55 +02:00
javier 1fbab4b180 Lowered the Swift tools required to build this project to 6.3 and also, polished some documentation in the READMe file. v1.0.0 2026-07-25 23:37:33 +02:00
javier 8c646c0347 Removed the Github CI actions (temporarily!) from the project. 2026-07-25 13:16:08 +02:00
javier ebacdbea55 Updated some documentation for the README file in the Playdate project.
CI / Build & test (macOS) (push) Has been cancelled
CI / Embedded Swift cross-compile (push) Has been cancelled
Documentation / deploy (push) Has been cancelled
2026-07-25 13:05:57 +02:00
javier 91783deb7b Added missing documentation to the source code in the Playdate bindings target.
CI / Build & test (macOS) (push) Has been cancelled
CI / Embedded Swift cross-compile (push) Has been cancelled
Documentation / deploy (push) Has been cancelled
2026-07-25 12:55:53 +02:00
javier b435a6e8bd Restructured the source code in the Playdate bindings target. 2026-07-25 12:40:14 +02:00
javier 2e7ee12ec1 Adjusted the naming of the library in the Package file.
CI / Build & test (macOS) (push) Has been cancelled
CI / Embedded Swift cross-compile (push) Has been cancelled
Documentation / deploy (push) Has been cancelled
2026-07-25 12:02:55 +02:00
javier f6645d2613 Added a Makefile file to handle the development lifecycle in the project. 2026-07-25 11:48:09 +02:00
javier f04a5ea7df Added convenience make targets and refined documentation in the HelloPlayDate example target. 2026-07-25 11:33:09 +02:00
javier 988f900c23 Updated the documentation of the README file in the PlayDate bindings target. 2026-07-25 10:59:47 +02:00
javier 19af75cf7b Added optimized device builds and harden the Embedded toolchain setup in both the PlayDate bindings and HelloPlayDate example targets. 2026-07-25 10:53:44 +02:00
javier dfeadabfb6 Cached API tables and cut allocations in the PlayDate bindings target. 2026-07-25 10:43:32 +02:00
javier 6594794cec Fixed wrapper module rebuild dependencies on the Makefile file in the HelloPlaydate example target. 2026-07-25 10:29:30 +02:00
javier 1d9504c225 Fixed some wrapper lifetime and leak issues found in PlayDate bindings target. 2026-07-25 10:28:24 +02:00
javier 06bd50ea83 Implemented a "posix_memalign" shim on Support in the PlayDate binding target for Embedded Swift on device. 2026-07-25 10:12:17 +02:00
javier 69813b2a76 Wrapped C enum raw values in explicit width conversions throughout the PlayDate binding target. 2026-07-25 10:10:43 +02:00
javier 29619720f7 Added a Makefile build for the HelloPlaydate example target. 2026-07-25 10:09:34 +02:00
javierandClaude Fable 5 c208382bf8 Add swift-format configuration
Codifies the project's existing style: 4-space indentation, 120-column
lines, ordered imports, one blank line maximum, and private file-scoped
declarations. The force-unwrap/IUO/force-try lint rules stay disabled
because the binding uses those deliberately (the API bootstrap statics,
unsafelyUnwrapped function-pointer calls). Formatting-behavior options
mirror the current layout; the main known divergence is continuation-line
style, where swift-format's fixed indent differs from the paren-aligned
wrapping used in places.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-25 07:34:25 +02:00
javierandClaude Fable 5 d914e0f8fb Remove per-call overhead from API access and text conversion
Two hot-path optimizations for the device's Cortex-M7 (and debug simulator
builds):

- The ten sub-API pointers are cached once in Playdate.initialize(with:);
  wrapper accessors now return UnsafePointer and call sites read a single
  field through it, instead of unwrapping the optional API struct and
  copying a whole sub-API struct of function pointers on every call.
  Nested sub-APIs (sound classes, effects, video, tilemap, http/tcp)
  derive from the cached pointers with one field load.

- String -> C conversions (withPlaydateCString, and a new withPlaydateUTF8
  used by the text drawing/measuring APIs) use withUnsafeTemporaryAllocation
  instead of building a ContiguousArray, so logging and drawText in the
  update loop no longer heap-allocate per call. Verified within the
  Embedded Swift subset by the device cross-compile.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-25 07:23:19 +02:00
javierandClaude Fable 5 e4e99cc894 Add a mock PlaydateAPI test harness for the wrapper layer
The mock allocates real playdate_* structs whose function pointers are
Swift stubs that record their arguments, then hands the fake PlaydateAPI*
to Playdate.initialize(with:). This makes the wrapper plumbing testable on
the host: argument forwarding and type conversion (buttons, colors,
patterns, UTF-8 text), callback trampolines (menu items, sprite update,
audio sources), ownership (bitmaps freed exactly once, table-vended
bitmaps not freed, file handles closed once), collision-info parsing with
system-allocator balance, the JSON tree builder driven by a simulated
parser callback sequence, and regression tests for the CallbackSource
lifecycle fix. Tests run serialized because the recording state is global.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-25 07:15:50 +02:00
javierandClaude Fable 5 61fb06e45e Fix CallbackSource registrations outliving their sources
Callback-based sound sources are kept alive in a static registry while the
C side may still invoke their trampoline, but nothing ever removed them:
every callback source leaked its wrapper and closure permanently, and a
source retained only by a transient Channel.default wrapper relied on that
leak for safety. The registry is now the single source of truth and is
purged on Sound.removeSource, Channel.removeSource, and when an owned
channel is freed (its sources can no longer be pulled).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-25 07:09:30 +02:00
javierandClaude Fable 5 8cf0715cdc Add DocC documentation and a runnable example game
- DocC catalog (Sources/PlayDate/PlayDate.docc) with a curated landing
  page and a Getting Started article; swift-docc-plugin wired up for
  `swift package generate-documentation`, and a GitHub Pages deployment
  workflow renders docs on every push to main.
- Examples/HelloPlaydate: a minimal game (bouncing box, crank needle,
  button handling, system menu item) whose build.sh compiles the game as
  a dylib and produces a runnable simulator .pdx via the SDK's pdc.
  Verified: the pdx builds and exports the eventHandler entry point.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 11:29:13 +02:00
javierandClaude Fable 5 6485997edc Promote subsystem namespaces to the top level of the module
System, Display, Graphics, Sprite, Sound, File, JSON, Lua, Scoreboards,
Network, Rect, SystemEvent, and AccessReply now live at module scope
instead of being nested in the Playdate enum; consumers write
System.log(...) instead of Playdate.System.log(...), and can qualify with
the module name (PlayDate.System) on collision. The Playdate enum remains
only as the raw C API bootstrap (initialize(with:), api, apiPointer), and
Playdate.Error is renamed PlaydateError so no top-level type shadows
Swift.Error.

Breaking change for any existing consumers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 11:10:25 +02:00
javierandClaude Fable 5 3ee071e098 Add CI: host tests, consumer smoke test, Embedded Swift check
Three jobs in GitHub Actions:
- Build & test on macOS against SDK headers fetched from Panic (cached),
  with the pkg-config module generated into PKG_CONFIG_PATH.
- A consumer smoke test (Scripts/consumer-test.sh) generating a scratch
  package that depends on play-date, guarding setting propagation.
- An Embedded Swift cross-compile for armv7em-none-none-eabi
  (Scripts/build-embedded.sh) on a swift.org snapshot toolchain — the
  check that enforces the Embedded Swift subset promise. Verified locally:
  the full module compiles for the device triple with no violations.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 10:57:45 +02:00
javierandClaude Fable 5 09760f99b0 Swift bindings to the Playdate C API
Wraps all ten subsystems of the Playdate SDK 3.1.1 C API (system, display,
graphics, sprites, sound, file, JSON, Lua, scoreboards, network) in
idiomatic Swift: namespaced APIs, wrapper types with ownership semantics,
closures for callbacks, and typed throws. Written within the Embedded Swift
subset so the same code can target the device.

The SDK headers are resolved through a "playdate" pkg-config module
(Scripts/install-pkgconfig.sh), so the package works as a normal SwiftPM
dependency without unsafe build flags.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 10:33:45 +02:00