Skip to content

Commit

Permalink
Update for Swift 6
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Dec 15, 2024
1 parent 9cda4a1 commit fa6b1f1
Show file tree
Hide file tree
Showing 23 changed files with 142 additions and 568 deletions.
33 changes: 23 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
// swift-tools-version:4.1
// swift-tools-version:6.0
import PackageDescription

let package = Package(
name: "Cacao",
products: [
.library(name: "Cacao", targets: ["Cacao"]),
.executable(name: "CacaoDemo", targets: ["CacaoDemo"]),
],
.library(
name: "Cacao",
targets: ["Cacao"]
),
.executable(
name: "CacaoDemo",
targets: ["CacaoDemo"]
),
],
dependencies: [
.package(
url: "https://github.com/PureSwift/Silica.git",
.branch("master")
branch: "master"
),
.package(
url: "https://github.com/PureSwift/Cairo.git",
.branch("master")
branch: "master"
),
.package(
url: "https://github.com/PureSwift/SDL.git",
.branch("master")
branch: "master"
)
],
targets: [
Expand All @@ -30,11 +36,18 @@ let package = Package(
"SDL"
]
),
.target(
.executableTarget(
name: "CacaoDemo",
dependencies: [
"Cacao"
]
],
swiftSettings: [.swiftLanguageMode(.v5)]
),
]
.testTarget(
name: "CacaoTests",
dependencies: [
"Cacao"
]
)
]
)
31 changes: 16 additions & 15 deletions Sources/Cacao/NSStringDrawing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,34 +152,35 @@ extension NSLineBreakMode: CacaoConvertible {
/// Rendering options for a string when it is drawn.
public struct NSStringDrawingOptions: OptionSet, ExpressibleByIntegerLiteral {

public static let usesLineFragmentOrigin = NSStringDrawingOptions(rawValue: (1 << 0))
public static let usesFontLeading = NSStringDrawingOptions(rawValue: (1 << 1))
public static let usesDeviceMetrics = NSStringDrawingOptions(rawValue: (1 << 3))
public static let truncatesLastVisibleLine = NSStringDrawingOptions(rawValue: (1 << 5))

public var rawValue: Int

public init(rawValue: Int) {

self.rawValue = rawValue
}

public init(integerLiteral value: Int) {

self.rawValue = value
}

public init() {

self = NSStringDrawingOptions.usesLineFragmentOrigin
self = .usesLineFragmentOrigin
}
}

public extension NSStringDrawingOptions {

static var usesLineFragmentOrigin: NSStringDrawingOptions { NSStringDrawingOptions(rawValue: (1 << 0)) }
static var usesFontLeading: NSStringDrawingOptions { NSStringDrawingOptions(rawValue: (1 << 1)) }
static var usesDeviceMetrics: NSStringDrawingOptions { NSStringDrawingOptions(rawValue: (1 << 3)) }
static var truncatesLastVisibleLine: NSStringDrawingOptions { NSStringDrawingOptions(rawValue: (1 << 5)) }

}

/// Expects `UIFont` value.
public let NSFontAttributeName = "NSFontAttributeName"
/// Expects `UIFont` value.
public let NSFontAttributeName = "NSFontAttributeName"

/// Expects `UIColor` value.
public let NSForegroundColorAttributeName = "NSForegroundColorAttributeName"
/// Expects `UIColor` value.
public let NSForegroundColorAttributeName = "NSForegroundColorAttributeName"

/// Expects `NSMutableParagraphStyle` value.
public let NSParagraphStyleAttributeName = "NSParagraphStyleAttributeName"
/// Expects `NSMutableParagraphStyle` value.
public let NSParagraphStyleAttributeName = "NSParagraphStyleAttributeName"
2 changes: 1 addition & 1 deletion Sources/Cacao/SDL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal func SDLEventRun() {

// run loop
let runLoopStartTime = SDL_GetTicks()
runloop.run(mode: .defaultRunLoopMode, before: Date() + (1.0 / TimeInterval(framesPerSecond)))
runloop.run(mode: .default, before: Date() + (1.0 / TimeInterval(framesPerSecond)))
//_UIApp.eventDispatcher.handleHIDEventFetcherDrain()
if eventCount > 0 { print("Runloop took (\(SDL_GetTicks() - runLoopStartTime)ms)") }

Expand Down
6 changes: 3 additions & 3 deletions Sources/Cacao/StyleKit/UISwitchStyleKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class UISwitchStyleKit {
//// Cache

private struct Cache {
static let defaultOnColor: UIColor = UIColor(red: 0.267, green: 0.859, blue: 0.369, alpha: 1.000)
static let defaultThumbColor: UIColor = UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
static let defaultStrokeColor: UIColor = UIColor(red: 0.687, green: 0.677, blue: 0.675, alpha: 1.000)
nonisolated(unsafe) static let defaultOnColor: UIColor = UIColor(red: 0.267, green: 0.859, blue: 0.369, alpha: 1.000)
nonisolated(unsafe) static let defaultThumbColor: UIColor = UIColor(red: 1.000, green: 1.000, blue: 1.000, alpha: 1.000)
nonisolated(unsafe) static let defaultStrokeColor: UIColor = UIColor(red: 0.687, green: 0.677, blue: 0.675, alpha: 1.000)
}

//// Colors
Expand Down
4 changes: 2 additions & 2 deletions Sources/Cacao/UIApplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct CacaoOptions {
public init() { }
}

internal private(set) var _UIApp: UIApplication!
internal nonisolated(unsafe) private(set) var _UIApp: UIApplication!

public final class UIApplication: UIResponder {

Expand Down Expand Up @@ -199,7 +199,7 @@ fileprivate extension UIApplication {
}
// MARK: - Supporting Types

public protocol UIApplicationDelegate: class {
public protocol UIApplicationDelegate: AnyObject {

func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]?) -> Bool

Expand Down
238 changes: 0 additions & 238 deletions Sources/Cacao/UIBezierPath.swift

This file was deleted.

Loading

0 comments on commit fa6b1f1

Please sign in to comment.