Skip to content

Commit d1a059a

Browse files
committed
Refactor shared libraries
1 parent dc14287 commit d1a059a

File tree

7 files changed

+18
-20
lines changed

7 files changed

+18
-20
lines changed

Package.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ let package = Package(
1010
products: [
1111
.library(name: "GateEngine", targets: ["GateEngine"]),
1212
.library(name: "GameMath", targets: ["GameMath"]),
13+
.library(name: "GateUtilities", targets: ["GateUtilities"]),
1314
],
1415
traits: [
1516
.default(enabledTraits: ["SIMD"]),
@@ -75,7 +76,7 @@ let package = Package(
7576
)
7677

7778
dependencies.append(contentsOf: [
78-
"GateEngineShared",
79+
"GateUtilities",
7980
"GameMath",
8081
"Shaders",
8182
"TrueType",
@@ -229,7 +230,7 @@ let package = Package(
229230
.target(
230231
name: "Shaders",
231232
dependencies: [
232-
"GateEngineShared",
233+
"GateUtilities",
233234
"GameMath",
234235
.product(name: "Collections", package: "swift-collections")
235236
],
@@ -241,7 +242,7 @@ let package = Package(
241242
.target(
242243
name: "GameMath",
243244
dependencies: [
244-
"GateEngineShared"
245+
"GateUtilities"
245246
],
246247
swiftSettings: .default(withCustomization: { settings in
247248
#if false
@@ -256,7 +257,7 @@ let package = Package(
256257
})
257258
),
258259

259-
.target(name: "GateEngineShared", swiftSettings: .default),
260+
.target(name: "GateUtilities", swiftSettings: .default),
260261
])
261262

262263
// MARK: - Macros

Sources/GameMath/Degrees & Radians.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* http://stregasgate.com
66
*/
77

8-
import GateEngineShared
9-
108
public protocol Angle: Sendable, RawRepresentable, Numeric, Comparable, FloatingPoint where RawValue == Float {
119
var rawValue: RawValue {get set}
1210

Sources/GameMath/GameMath.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* http://stregasgate.com
66
*/
77

8-
import Foundation
8+
@_exported import GateUtilities
9+
910
@_exported import func Foundation.ceil
1011
@_exported import func Foundation.floor
1112
@_exported import func Foundation.round
@@ -15,5 +16,3 @@ import Foundation
1516
@_exported import func Foundation.tan
1617
@_exported import func Foundation.acos
1718
@_exported import func Foundation.atan2
18-
19-
@_exported import GateEngineShared

Sources/GateEngine/GateEngine.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,12 @@
77

88
import Foundation
99

10-
@_exported public import GateEngineShared
10+
@_exported public import GateUtilities
1111
@_exported public import GameMath
1212

1313
@_exported import struct Foundation.Data
1414
@_exported import struct Foundation.Date
1515
@_exported import struct Foundation.URL
16-
@_exported import func Foundation.acos
17-
@_exported import func Foundation.atan2
18-
@_exported import func Foundation.ceil
19-
@_exported import func Foundation.cos
20-
@_exported import func Foundation.floor
21-
@_exported import func Foundation.pow
22-
@_exported import func Foundation.round
23-
@_exported import func Foundation.sin
24-
@_exported import func Foundation.tan
2516

2617
@attached(member, names: named(phase), named(macroPhase))
2718
public macro System(_ macroPhase: GateEngine.System.Phase) = #externalMacro(module: "ECSMacros", type: "ECSSystemMacro")

Sources/GateEngine/Resources/Skinning/Raw/RawSkeleton.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* http://stregasgate.com
66
*/
77

8-
import GameMath
8+
public import GameMath
9+
public import GateUtilities
910

1011
public struct RawSkeleton: Equatable, Hashable, Codable, BinaryCodable {
1112
public var joints: [RawJoint] = []

Sources/GateEngineShared/BinaryCodable.swift renamed to Sources/GateUtilities/BinaryCodable.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ public struct BinaryCodableHeader {
3434
self.magic2 = magic
3535
self._version = version.rawValue
3636
}
37+
38+
/// Returns the BinaryCodableVersion if the header is valid and matches the criteria
39+
public func validatedVersionMatching(magic magic2: UInt32, documentLength: UInt32) -> BinaryCodableVersion? {
40+
guard self.magic1 == Self.magic1 else {return nil}
41+
guard self.magic2 == magic2 else {return nil}
42+
guard self.documentLength == documentLength else {return nil}
43+
return self.version
44+
}
3745
}
3846

3947
/// GateEngine standard binary codable format

0 commit comments

Comments
 (0)