Skip to content

Commit

Permalink
Fix build for embedded platforms around JSBigIntExtended existential
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Oct 14, 2024
1 parent 459d1e9 commit 0dbd39a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/JavaScriptKit/ConstructibleFromJSValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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
}
}
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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
}
}
Expand Down

0 comments on commit 0dbd39a

Please sign in to comment.