Skip to content

Commit

Permalink
Markup for Sendable
Browse files Browse the repository at this point in the history
  • Loading branch information
rustle committed Nov 14, 2023
1 parent 1b37967 commit ee9011a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ let package = Package(
targets: [
.target(
name: "AX",
dependencies: []),
dependencies: []/*,
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
]*/),
.executableTarget(
name: "ObserverExample",
dependencies: ["AX"]),
Expand Down
6 changes: 5 additions & 1 deletion Sources/AX/AX.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ public func isTrusted() -> Bool {
///
/// See also `public func AXIsProcessTrustedWithOptions(_ options: CFDictionary?) -> Bool`
@available(macOS 10.9, *)
@Sendable
public func isTrusted(promptIfNeeded: Bool) -> Bool {
AXIsProcessTrustedWithOptions(optionsDictionary(promptIfNeeded: promptIfNeeded))
}
private struct AXKey: Sendable {
static let trustedCheckOptionPrompt = kAXTrustedCheckOptionPrompt.takeUnretainedValue()
}
private func optionsDictionary(promptIfNeeded: Bool) -> CFDictionary {
guard promptIfNeeded else {
return [CFString:CFTypeRef]() as CFDictionary
}
return [kAXTrustedCheckOptionPrompt.takeUnretainedValue():kCFBooleanTrue] as CFDictionary
return [AXKey.trustedCheckOptionPrompt:kCFBooleanTrue] as CFDictionary
}
2 changes: 1 addition & 1 deletion Sources/AX/AXError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ApplicationServices.HIServices
// but we want to drop the `success` case

@available(macOS 10.2, *)
public enum AXError: Error {
public enum AXError: Error, Sendable {
/// The action is not supported by the UIElement.
case actionUnsupported
/// The accessibility API is disabled.
Expand Down
2 changes: 1 addition & 1 deletion Sources/AX/AXObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import AppKit

@available(macOS 10.2, *)
public struct Observer: CustomStringConvertible, CustomDebugStringConvertible {
public struct Observer: @unchecked Sendable, CustomStringConvertible, CustomDebugStringConvertible {

// MARK: Init

Expand Down
4 changes: 2 additions & 2 deletions Sources/AX/AXTextMarker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ApplicationServices
import Cocoa

@available(macOS 11, *)
public struct TextMarker: CustomStringConvertible, CustomDebugStringConvertible {
public struct TextMarker: @unchecked Sendable, CustomStringConvertible, CustomDebugStringConvertible {

// MARK: Init

Expand Down Expand Up @@ -51,7 +51,7 @@ public struct TextMarker: CustomStringConvertible, CustomDebugStringConvertible
}

@available(macOS 11, *)
public struct TextMarkerRange: CustomStringConvertible, CustomDebugStringConvertible {
public struct TextMarkerRange: @unchecked Sendable, CustomStringConvertible, CustomDebugStringConvertible {

// MARK: Init

Expand Down
5 changes: 2 additions & 3 deletions Sources/AX/AXUIElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
//

import AppKit
import ApplicationServices
import Cocoa
@preconcurrency import ApplicationServices

@available(macOS 10.0, *)
public struct UIElement: CustomStringConvertible, CustomDebugStringConvertible {
public struct UIElement: Sendable, CustomStringConvertible, CustomDebugStringConvertible {

// MARK: Init

Expand Down
2 changes: 1 addition & 1 deletion Sources/AX/AXValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ApplicationServices
import Cocoa

@available(macOS 10.11, *)
public enum Value: Equatable {
public enum Value: Equatable, Sendable {
case point(CGPoint)
case size(CGSize)
case rect(CGRect)
Expand Down

0 comments on commit ee9011a

Please sign in to comment.