From f853d6b6b8b4bdad2231d1fb0fbe9980f7fbd39b Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Wed, 17 Mar 2021 15:29:55 +0100 Subject: [PATCH 1/3] Make parent and sub properties on ASN1Object public --- ASN1Decoder/ASN1Object.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ASN1Decoder/ASN1Object.swift b/ASN1Decoder/ASN1Object.swift index 90da609..8773c28 100644 --- a/ASN1Decoder/ASN1Object.swift +++ b/ASN1Decoder/ASN1Object.swift @@ -33,9 +33,9 @@ public class ASN1Object: CustomStringConvertible { public var identifier: ASN1Identifier? - var sub: [ASN1Object]? + public var sub: [ASN1Object]? - weak var parent: ASN1Object? + public weak var parent: ASN1Object? public func sub(_ index: Int) -> ASN1Object? { if let sub = self.sub, index >= 0, index < sub.count { From 1e33e83b8cec79e2a221ec3adf50e4bb4677bd5a Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Wed, 17 Mar 2021 15:34:34 +0100 Subject: [PATCH 2/3] Only allow read access to parent and sub properties --- ASN1Decoder/ASN1Object.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ASN1Decoder/ASN1Object.swift b/ASN1Decoder/ASN1Object.swift index 8773c28..43e0f3b 100644 --- a/ASN1Decoder/ASN1Object.swift +++ b/ASN1Decoder/ASN1Object.swift @@ -33,9 +33,9 @@ public class ASN1Object: CustomStringConvertible { public var identifier: ASN1Identifier? - public var sub: [ASN1Object]? + public internal(set) var sub: [ASN1Object]? - public weak var parent: ASN1Object? + public internal(set) weak var parent: ASN1Object? public func sub(_ index: Int) -> ASN1Object? { if let sub = self.sub, index >= 0, index < sub.count { From 4b7a3efbdefad0677dc77c3fdbcb97ca5f9ba703 Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Wed, 17 Mar 2021 15:40:31 +0100 Subject: [PATCH 3/3] Expose toIntValue helper --- ASN1Decoder/ASN1Decoder.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ASN1Decoder/ASN1Decoder.swift b/ASN1Decoder/ASN1Decoder.swift index 690ac21..26b8126 100644 --- a/ASN1Decoder/ASN1Decoder.swift +++ b/ASN1Decoder/ASN1Decoder.swift @@ -199,7 +199,7 @@ enum ASN1Error: Error { } extension Data { - func toIntValue() -> UInt64? { + public func toIntValue() -> UInt64? { if self.count > 8 { // check if suitable for UInt64 return nil }