Skip to content

Commit 944734c

Browse files
authored
Remove @PlaydateMain macro and SwiftSyntax dependency (#158)
1 parent edb42dd commit 944734c

File tree

11 files changed

+55
-96
lines changed

11 files changed

+55
-96
lines changed

Examples/FlappySwift/Sources/FlappySwift/Game.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ final class TestScene: Scene {}
66

77
// MARK: - Game
88

9-
@PlaydateMain
109
final class Game: PlaydateGame {
1110
var highScore = 0
1211

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import PlaydateKit
2+
3+
/// Boilerplate entry code
4+
nonisolated(unsafe) var game: Game!
5+
@_cdecl("eventHandler") func eventHandler(
6+
pointer: UnsafeMutablePointer<PlaydateAPI>!,
7+
event: System.Event,
8+
arg _: CUnsignedInt
9+
) -> CInt {
10+
switch event {
11+
case .initialize:
12+
Playdate.initialize(with: pointer)
13+
game = Game()
14+
System.updateCallback = game.update
15+
default: game.handle(event)
16+
}
17+
return 0
18+
}

Examples/Pong/Sources/Pong/Game.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import PlaydateKit
22

33
// MARK: - Game
44

5-
@PlaydateMain
65
final class Game: PlaydateGame {
76
// MARK: Lifecycle
87

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import PlaydateKit
2+
3+
/// Boilerplate entry code
4+
nonisolated(unsafe) var game: Game!
5+
@_cdecl("eventHandler") func eventHandler(
6+
pointer: UnsafeMutablePointer<PlaydateAPI>!,
7+
event: System.Event,
8+
arg _: CUnsignedInt
9+
) -> CInt {
10+
switch event {
11+
case .initialize:
12+
Playdate.initialize(with: pointer)
13+
game = Game()
14+
System.updateCallback = game.update
15+
default: game.handle(event)
16+
}
17+
return 0
18+
}

Examples/Xkpd/Sources/Xkpd/Game.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import PlaydateKit
22

33
// MARK: - Game
44

5-
@PlaydateMain
65
final class Game: PlaydateGame {
76
// MARK: Lifecycle
87

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import PlaydateKit
2+
3+
/// Boilerplate entry code
4+
nonisolated(unsafe) var game: Game!
5+
@_cdecl("eventHandler") func eventHandler(
6+
pointer: UnsafeMutablePointer<PlaydateAPI>!,
7+
event: System.Event,
8+
arg _: CUnsignedInt
9+
) -> CInt {
10+
switch event {
11+
case .initialize:
12+
Playdate.initialize(with: pointer)
13+
game = Game.instance
14+
System.updateCallback = game.update
15+
default: game.handle(event)
16+
}
17+
return 0
18+
}

Package.resolved

Lines changed: 0 additions & 15 deletions
This file was deleted.

Package.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// swift-tools-version: 6.1
22

33
import PackageDescription
4-
import CompilerPluginSupport
54

65
let armToolchainPath: String = if let path = Context.environment["ARM_NONE_EABI_GCC_PATH"] {
76
path
@@ -38,20 +37,10 @@ let package = Package(
3837
.plugin(name: "PDCPlugin", targets: ["PDCPlugin"]),
3938
.plugin(name: "RenamePlugin", targets: ["RenamePlugin"])
4039
],
41-
dependencies: [
42-
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "601.0.1"),
43-
],
4440
targets: [
45-
.macro(
46-
name: "PlaydateKitMacros",
47-
dependencies: [
48-
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
49-
.product(name: "SwiftCompilerPlugin", package: "swift-syntax")
50-
]
51-
),
5241
.target(
5342
name: "PlaydateKit",
54-
dependencies: ["CPlaydate", "PlaydateKitMacros"],
43+
dependencies: ["CPlaydate"],
5544
swiftSettings: [
5645
.enableExperimentalFeature("Embedded"),
5746
.unsafeFlags([

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Your `PlaydateGame` object manages the game lifecycle, receiving events such as
3535
```swift
3636
import PlaydateKit
3737

38-
@PlaydateMain
3938
final class Game: PlaydateGame {
4039
init() {
4140
System.addCheckmarkMenuItem(title: "check me") { isChecked in

Sources/PlaydateKit/PlaydateMain.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)