Remove pointer type
This commit is contained in:
parent
bd6c9d6f6b
commit
cd4e4dff9d
8
Sources/Model/Extensions/OpaquePointer.swift
Normal file
8
Sources/Model/Extensions/OpaquePointer.swift
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//
|
||||||
|
// OpaquePointer.swift
|
||||||
|
// Meta
|
||||||
|
//
|
||||||
|
// Created by david-swift on 29.09.24.
|
||||||
|
//
|
||||||
|
|
||||||
|
extension OpaquePointer: @retroactive @unchecked Sendable { }
|
||||||
@ -26,9 +26,9 @@ public actor SceneStorage {
|
|||||||
public var previousState: SceneElement?
|
public var previousState: SceneElement?
|
||||||
|
|
||||||
/// The pointer as an opaque pointer, as this may be needed with backends interoperating with C or C++.
|
/// The pointer as an opaque pointer, as this may be needed with backends interoperating with C or C++.
|
||||||
public var opaquePointer: Pointer? {
|
public var opaquePointer: OpaquePointer? {
|
||||||
get {
|
get {
|
||||||
pointer as? Pointer
|
pointer as? OpaquePointer
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
pointer = newValue
|
pointer = newValue
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
//
|
|
||||||
// Pointer.swift
|
|
||||||
// Meta
|
|
||||||
//
|
|
||||||
// Created by david-swift on 10.07.24.
|
|
||||||
//
|
|
||||||
|
|
||||||
/// A sendable pointer type.
|
|
||||||
public struct Pointer: Sendable {
|
|
||||||
|
|
||||||
/// The pointer's bit pattern.
|
|
||||||
var bitPattern: Int
|
|
||||||
|
|
||||||
/// Get the opaque pointer.
|
|
||||||
public var opaquePointer: OpaquePointer? {
|
|
||||||
get {
|
|
||||||
.init(bitPattern: bitPattern)
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
bitPattern = .init(bitPattern: newValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initialize the pointer.
|
|
||||||
/// - Parameter pointer: The opaque pointer.
|
|
||||||
public init(_ pointer: OpaquePointer?) {
|
|
||||||
bitPattern = .init(bitPattern: pointer)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -21,23 +21,13 @@ public actor ViewStorage: Sendable {
|
|||||||
/// The previous state of the widget.
|
/// The previous state of the widget.
|
||||||
public var previousState: Widget?
|
public var previousState: Widget?
|
||||||
|
|
||||||
/// The pointer as an actual pointer, e.g. for interoperating with C or C++.
|
|
||||||
public var actualPointer: Pointer? {
|
|
||||||
get {
|
|
||||||
pointer as? Pointer
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
pointer = newValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The pointer as an opaque pointer, as this is needed with backends interoperating with C or C++.
|
/// The pointer as an opaque pointer, as this is needed with backends interoperating with C or C++.
|
||||||
public var opaquePointer: OpaquePointer? {
|
public var opaquePointer: OpaquePointer? {
|
||||||
get {
|
get {
|
||||||
actualPointer?.opaquePointer
|
pointer as? OpaquePointer
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
actualPointer?.opaquePointer = newValue
|
pointer = newValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +54,7 @@ public actor ViewStorage: Sendable {
|
|||||||
content: [String: [ViewStorage]] = [:],
|
content: [String: [ViewStorage]] = [:],
|
||||||
state: Widget? = nil
|
state: Widget? = nil
|
||||||
) {
|
) {
|
||||||
self.pointer = Pointer(pointer)
|
self.pointer = pointer
|
||||||
self.content = content
|
self.content = content
|
||||||
self.previousState = state
|
self.previousState = state
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user