From afd0838f1d028021337caea6cdcf37dd526130d0 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Thu, 4 Sep 2025 16:28:45 -0400 Subject: [PATCH] Make Data conform to Sequence --- Sources/SkipFoundation/Data.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/SkipFoundation/Data.swift b/Sources/SkipFoundation/Data.swift index 2e12a4b..8abac3c 100644 --- a/Sources/SkipFoundation/Data.swift +++ b/Sources/SkipFoundation/Data.swift @@ -9,7 +9,7 @@ public protocol DataProtocol { var platformData: PlatformData { get } } -public struct Data : DataProtocol, Hashable, CustomStringConvertible, Codable, KotlinConverting, SwiftCustomBridged { +public struct Data : DataProtocol, Hashable, CustomStringConvertible, Codable, Sequence, KotlinConverting, SwiftCustomBridged { public var platformValue: PlatformData public init(platformValue: PlatformData) { @@ -149,6 +149,10 @@ public struct Data : DataProtocol, Hashable, CustomStringConvertible, Codable, K return Array(platformValue.map { $0.toUByte() }) } + public override var iterable: kotlin.collections.Iterable { + return platformValue.map { $0.toUByte() } + } + // Platform declaration clash: The following declarations have the same JVM signature ((Lskip/lib/Array;)V): //public init(_ bytes: [Int]) { // self.platformValue = PlatformData(size: bytes.count, init: { @@ -224,6 +228,8 @@ public struct Data : DataProtocol, Hashable, CustomStringConvertible, Codable, K // public mutating func append(_ buffer: UnsafeBufferPointer) + // without declaring this, the contains() gets incorrectly marked with "override", which is incorrect for the Data type + // SKIP DECLARE: fun contains(other: Data): Boolean public func contains(_ other: Data) -> Bool { if (other.isEmpty) { return true