From 0dbd39a79770c9b9ca4d952b074f188bd26fee21 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 15 Oct 2024 07:28:40 +0900 Subject: [PATCH] Fix build for embedded platforms around JSBigIntExtended existential --- Sources/JavaScriptKit/ConstructibleFromJSValue.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/JavaScriptKit/ConstructibleFromJSValue.swift b/Sources/JavaScriptKit/ConstructibleFromJSValue.swift index ce1e1c25..f0e0ad43 100644 --- a/Sources/JavaScriptKit/ConstructibleFromJSValue.swift +++ b/Sources/JavaScriptKit/ConstructibleFromJSValue.swift @@ -40,7 +40,7 @@ extension SignedInteger where Self: ConstructibleFromJSValue { /// If the value is too large to fit in the `Self` type, `nil` is returned. /// /// - Parameter bigInt: The `JSBigIntExtended` to decode - public init?(exactly bigInt: JSBigIntExtended) { + public init?(exactly bigInt: some JSBigIntExtended) { self.init(exactly: bigInt.int64Value) } @@ -49,7 +49,7 @@ extension SignedInteger where Self: ConstructibleFromJSValue { /// Crash if the value is too large to fit in the `Self` type. /// /// - Parameter bigInt: The `JSBigIntExtended` to decode - public init(_ bigInt: JSBigIntExtended) { + public init(_ bigInt: some JSBigIntExtended) { self.init(bigInt.int64Value) } @@ -68,9 +68,11 @@ extension SignedInteger where Self: ConstructibleFromJSValue { if let number = value.number { return Self(exactly: number.rounded(.towardZero)) } +#if !hasFeature(Embedded) if let bigInt = value.bigInt as? JSBigIntExtended { return Self(exactly: bigInt) } +#endif return nil } } @@ -87,7 +89,7 @@ extension UnsignedInteger where Self: ConstructibleFromJSValue { /// Returns `nil` if the value is negative or too large to fit in the `Self` type. /// /// - Parameter bigInt: The `JSBigIntExtended` to decode - public init?(exactly bigInt: JSBigIntExtended) { + public init?(exactly bigInt: some JSBigIntExtended) { self.init(exactly: bigInt.uInt64Value) } @@ -96,7 +98,7 @@ extension UnsignedInteger where Self: ConstructibleFromJSValue { /// Crash if the value is negative or too large to fit in the `Self` type. /// /// - Parameter bigInt: The `JSBigIntExtended` to decode - public init(_ bigInt: JSBigIntExtended) { + public init(_ bigInt: some JSBigIntExtended) { self.init(bigInt.uInt64Value) } @@ -114,9 +116,11 @@ extension UnsignedInteger where Self: ConstructibleFromJSValue { if let number = value.number { return Self(exactly: number.rounded(.towardZero)) } +#if !hasFeature(Embedded) if let bigInt = value.bigInt as? JSBigIntExtended { return Self(exactly: bigInt) } +#endif return nil } }