| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- public struct URL: Equatable, Hashable {
- public var absoluteString: String
- public var path: String { absoluteString }
- public init?(string: String) {
- self.absoluteString = string
- }
- public init(fileURLWithPath path: String) {
- self.absoluteString = path
- }
- }
- public struct UUID: Equatable, Hashable {
- public let uuidString: String
-
- public init() {
- self.uuidString = "ark-uuid-mock" // Dummy for now
- }
- public init?(uuidString: String) {
- self.uuidString = uuidString
- }
- }
- public struct Date: Comparable, Hashable {
- public var timeIntervalSinceReferenceDate: Double
-
- public init() {
- self.timeIntervalSinceReferenceDate = 0 // Mock
- }
-
- public init(timeIntervalSinceReferenceDate: Double) {
- self.timeIntervalSinceReferenceDate = timeIntervalSinceReferenceDate
- }
-
- public static let distantPast = Date(timeIntervalSinceReferenceDate: -63114076800.0) // Year 0001
- public static let distantFuture = Date(timeIntervalSinceReferenceDate: 63113904000.0) // Year 4000
-
- public static func < (lhs: Date, rhs: Date) -> Bool {
- return lhs.timeIntervalSinceReferenceDate < rhs.timeIntervalSinceReferenceDate
- }
- }
- public struct Data: Equatable, Hashable, Codable {
- public var bytes: [UInt8]
- public var count: Int { bytes.count }
-
- public init() {
- self.bytes = []
- }
- public init(_ bytes: [UInt8]) {
- self.bytes = bytes
- }
-
- public mutating func append(_ newElements: [UInt8]) {
- bytes.append(contentsOf: newElements)
- }
- }
- public class JSONEncoder {
- public init() {}
- public func encode<T>(_ value: T) throws -> Data {
- return Data() // Dummy
- }
- }
- public class JSONDecoder {
- public init() {}
- public func decode<T>(_ type: T.Type, from data: Data) throws -> T {
- fatalError("Decoding not supported on baremetal")
- }
- }
- public class FileManager {
- public static let `default` = FileManager()
-
- public func fileExists(atPath path: String) -> Bool {
- return false // Dummy
- }
- }
- // MARK: - Dispatch & Foundation Utilities Mocks
- public typealias TimeInterval = Double
- public class DispatchQueue {
- public init(label: String) {}
- public func async(execute work: @escaping () -> Void) {
- // Execute inline for baremetal mock
- work()
- }
- }
- public class DispatchSemaphore {
- public init(value: Int) {}
- public enum WaitResult {
- case success
- case timedOut
- }
- public func wait(timeout: DispatchTime) -> WaitResult {
- return .success
- }
- public func wait() {
- _ = wait(timeout: DispatchTime.now())
- }
- public func signal() {}
- }
- public struct DispatchTime {
- public var uptimeNanoseconds: UInt64 = 0
- public static func now() -> DispatchTime {
- return DispatchTime()
- }
- }
- public class ProcessInfo {
- public static let processInfo = ProcessInfo()
- public var systemUptime: TimeInterval {
- // Return dummy time based on a counter
- return 0.0
- }
- public var processName: String {
- return "ArkApp"
- }
- }
- public class Thread {
- public static func sleep(forTimeInterval ti: TimeInterval) {
- // Do nothing in mock
- }
- }
- public class Mutex<T> {
- private var value: T
- public init(_ value: T) {
- self.value = value
- }
- public func withLock<R>(_ body: (inout T) throws -> R) rethrows -> R {
- return try body(&value)
- }
- }
- public struct Calendar: Equatable {
- public static let current = Calendar()
- }
- public struct TimeZone: Equatable {
- public static let current = TimeZone()
- }
- public struct Locale: Equatable {
- public static let current = Locale()
- }
- public class UserDefaults {
- public static let standard = UserDefaults()
- private var storage = [String: String]()
-
- public func set(_ value: String?, forKey key: String) {
- storage[key] = value
- }
-
- public func string(forKey key: String) -> String? {
- return storage[key]
- }
-
- public func synchronize() {}
- }
- public func sin(_ x: Double) -> Double {
- return 0.0 // Stub for baremetal
- }
- public func cos(_ x: Double) -> Double {
- return 1.0 // Stub for baremetal
- }
- public func atan2(_ y: Double, _ x: Double) -> Double {
- return 0.0 // Stub for baremetal
- }
|