Skip to content

Commit

Permalink
Add DescriptiveDynamicProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Jan 31, 2024
1 parent 72be177 commit 14b97f1
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions Sources/OpenSwiftUI/Internal/Other/Tracing.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// Tracing.swift
//
//
// Created by Kyle on 2024/2/1.
// Lastest Version: iOS 15.5
// Status: WIP
// ID: D59B7A281FFF29619A43A3D8F551CCE1

// MARK: - Tracing

enum Tracing {
static func libraryName(defining _: Any.Type) -> String {
// TODO:
""
}
// private static moduleLookupCache: ThreadSpecific<[UnsafeRawPointer : String]>
}

// MARK: - DescriptiveDynamicProperty

private protocol DescriptiveDynamicProperty {
var _linkValue: Any { get }
}

extension DescriptiveDynamicProperty {
var linkValueDescription: String {
if let descriptiveDynamicProperty = _linkValue as? DescriptiveDynamicProperty {
descriptiveDynamicProperty.linkValueDescription
} else {
String(describing: _linkValue)
}
}
}

extension DynamicProperty {
fileprivate var linkValueDescription: String {
if let descriptiveDynamicProperty = self as? DescriptiveDynamicProperty {
descriptiveDynamicProperty.linkValueDescription
} else {
String(describing: self)
}
}
}

extension State: DescriptiveDynamicProperty {
fileprivate var _linkValue: Any {
projectedValue.wrappedValue
}
}

extension Binding: DescriptiveDynamicProperty {
fileprivate var _linkValue: Any {
wrappedValue
}
}

extension Environment: DescriptiveDynamicProperty {
fileprivate var _linkValue: Any {
wrappedValue
}
}

0 comments on commit 14b97f1

Please sign in to comment.