Remove pointer type

This commit is contained in:
david-swift 2024-09-29 16:44:14 +02:00
parent bd6c9d6f6b
commit cd4e4dff9d
4 changed files with 13 additions and 45 deletions

View File

@ -0,0 +1,8 @@
//
// OpaquePointer.swift
// Meta
//
// Created by david-swift on 29.09.24.
//
extension OpaquePointer: @retroactive @unchecked Sendable { }

View File

@ -26,9 +26,9 @@ public actor SceneStorage {
public var previousState: SceneElement?
/// 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 {
pointer as? Pointer
pointer as? OpaquePointer
}
set {
pointer = newValue

View File

@ -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)
}
}

View File

@ -21,23 +21,13 @@ public actor ViewStorage: Sendable {
/// The previous state of the 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++.
public var opaquePointer: OpaquePointer? {
get {
actualPointer?.opaquePointer
pointer as? OpaquePointer
}
set {
actualPointer?.opaquePointer = newValue
pointer = newValue
}
}
@ -64,7 +54,7 @@ public actor ViewStorage: Sendable {
content: [String: [ViewStorage]] = [:],
state: Widget? = nil
) {
self.pointer = Pointer(pointer)
self.pointer = pointer
self.content = content
self.previousState = state
}