78 lines
1.8 KiB
Swift
78 lines
1.8 KiB
Swift
//
|
|
// Wrapper.swift
|
|
// SHECommunity
|
|
//
|
|
// Created by 林 on 2024/11/25.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public class DL {}
|
|
|
|
public class DLWrapper<Base> {
|
|
|
|
/// 原始对象
|
|
public private(set) var base: Base
|
|
|
|
/// 初始化方法
|
|
public init(_ base: Base) {
|
|
self.base = base
|
|
}
|
|
|
|
}
|
|
|
|
public protocol DLWrapperCompatible {
|
|
|
|
/// 关联类型
|
|
associatedtype WrapperBase
|
|
|
|
/// 类包装器属性
|
|
static var dl: DLWrapper<WrapperBase>.Type { get set }
|
|
|
|
/// 对象包装器属性
|
|
var dl: DLWrapper<WrapperBase> { get set }
|
|
|
|
}
|
|
|
|
|
|
extension DLWrapperCompatible {
|
|
|
|
/// 类包装器属性
|
|
public static var dl: DLWrapper<Self>.Type {
|
|
get { DLWrapper<Self>.self }
|
|
set {}
|
|
}
|
|
|
|
/// 对象包装器属性
|
|
public var dl: DLWrapper<Self> {
|
|
get { DLWrapper(self) }
|
|
set {}
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - DLWrapperCompatible
|
|
extension Int: DLWrapperCompatible {}
|
|
extension Int8: DLWrapperCompatible {}
|
|
extension Int16: DLWrapperCompatible {}
|
|
extension Int32: DLWrapperCompatible {}
|
|
extension Int64: DLWrapperCompatible {}
|
|
extension UInt: DLWrapperCompatible {}
|
|
extension UInt8: DLWrapperCompatible {}
|
|
extension UInt16: DLWrapperCompatible {}
|
|
extension UInt32: DLWrapperCompatible {}
|
|
extension UInt64: DLWrapperCompatible {}
|
|
extension Float: DLWrapperCompatible {}
|
|
extension Double: DLWrapperCompatible {}
|
|
extension Bool: DLWrapperCompatible {}
|
|
extension String: DLWrapperCompatible {}
|
|
extension Data: DLWrapperCompatible {}
|
|
extension Date: DLWrapperCompatible {}
|
|
extension URL: DLWrapperCompatible {}
|
|
extension URLRequest: DLWrapperCompatible {}
|
|
extension Array: DLWrapperCompatible {}
|
|
extension Set: DLWrapperCompatible {}
|
|
extension Dictionary: DLWrapperCompatible {}
|
|
extension CGFloat: DLWrapperCompatible {}
|
|
extension NSObject: DLWrapperCompatible {}
|