Skip to content

Commit

Permalink
[Package] Lower platform requirements (#61) (#62).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Aug 18, 2023
1 parent 9ff2ece commit 750833a
Show file tree
Hide file tree
Showing 60 changed files with 561 additions and 60 deletions.
1 change: 0 additions & 1 deletion .utilities/update-gh-pages-docs-no-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# │ └─── SCRIPT.sh
#
# └─── .swiftpm/xcode/xcshareddata/PROJECT.xcscheme
#
#=-----------------------------------------------------------------------------=

set -eu
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import PackageDescription
// MARK: * Numberick
//*============================================================================*

let withStaticBigInt = true
let withStaticBigInt = false

//=----------------------------------------------------------------------------=
// MARK: + Version < iOS 16.4, macOS 13.3
Expand Down
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

✨ An arithmagick overhaul in Swift.

| Package | Swift | iOS | iPadOS | Mac Catalyst | macOS | tvOS | watchOS |
|:-------:|:-----:|:----:|:------:|:------------:|:-----:|:----:|:-------:|
| 0.9.0 | 5.7 | 16.4 | 16.4 | 16.4 | 13.3 | 16.4 | 9.4 |
| Package | Swift | iOS | Mac Catalyst | macOS | tvOS | watchOS |
|:-------:|:-----:|:-----:|:------------:|:-----:|:-----:|:-------:|
| 0.10.0 | 5.7+ | 14.0+ | 14.0+ | 11.0+ | 14.0+ | 7.0+ |
| 0.9.0 | 5.7+ | 16.4+ | 16.4+ | 13.3+ | 16.4+ | 9.4+ |

## NBKCoreKit ([Sources][COR/S], [Tests][COR/T], [Benchmarks][COR/B])

Expand Down Expand Up @@ -89,6 +90,19 @@ Int256(5) % Int(5), UInt256(5) % UInt(5)

> **Note**: The `Digit` type is `Int` when `Self` is signed, and `UInt` otherwise.
### Feature: StaticBigInt (v0.10.0+)

Because `StaticBigInt` [does not back-deploy][Apple/StaticBigInt/SE], it is gated
by [availability][Apple/StaticBigInt] and the compiler flag `SBI`. Setting the
constant `withStaticBigInt` to `true` in `Package.swift` enables it. Alternatively,
you can use the command line:

```
swift build -Xswiftc -DSBI
```

> **Note**: You can use `init(stringLiteral:)` until `StaticBigInt` becomes available.
## Acknowledgements

This project is inspired by [**Int128**][Apple/Int128] and [**DoubleWidth**][Apple/DoubleWidth] by Apple.
Expand All @@ -107,6 +121,11 @@ This project is inspired by [**Int128**][Apple/Int128] and [**DoubleWidth**][App
[COR/B]: Tests/NBKCoreKitBenchmarks
[DBL/B]: Tests/NBKDoubleWidthKitBenchmarks

<!-- Links x Features -->

[Apple/StaticBigInt]: https://developer.apple.com/documentation/swift/staticbigint
[Apple/StaticBigInt/SE]: https://github.com/apple/swift-evolution/blob/main/proposals/0368-staticbigint.md

<!-- Links x Acknowledgements -->

[Apple/Int128]: https://github.com/apple/swift/blob/main/stdlib/public/core/Int128.swift.gyb
Expand Down
3 changes: 3 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Addition+Digit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Addition x Digit
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
3 changes: 3 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Addition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Addition
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
3 changes: 3 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Bits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Bits
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
3 changes: 3 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Comparisons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Comparisons
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
3 changes: 3 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Complements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Complements
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
6 changes: 6 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Division+Digit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Division x Digit
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down Expand Up @@ -68,6 +71,9 @@ extension NBKDoubleWidth {
// MARK: + Unsigned
//=----------------------------------------------------------------------------=

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth where High == High.Magnitude {

//=------------------------------------------------------------------------=
Expand Down
6 changes: 6 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Division.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Division
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down Expand Up @@ -114,6 +117,9 @@ extension NBKDoubleWidth {
// MARK: + Unsigned
//=----------------------------------------------------------------------------=

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth where High == High.Magnitude {

//=------------------------------------------------------------------------=
Expand Down
3 changes: 3 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Endianness.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Endianness
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
86 changes: 35 additions & 51 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Literals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,47 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Literals
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=-------------------------------------------------------------------------=
// MARK: Details x Integer Literal Type
//=-------------------------------------------------------------------------=
#if SBI && swift(>=5.8)

@inlinable public init(integerLiteral source: StaticBigInt) {
if let value = Self(exactlyIntegerLiteral: source) { self = value } else {
preconditionFailure("\(Self.description) cannot represent \(source)")
}
}

@inlinable init?(exactlyIntegerLiteral source: StaticBigInt) {
guard Self.isSigned
? source.bitWidth <= Self.bitWidth
: source.bitWidth <= Self.bitWidth + 1 && source.signum() >= 0
else { return nil }

self = Self.uninitialized { value in
for index in value.indices {
value[unchecked: index] = source[index]
}
}
}

#else

@inlinable public init(integerLiteral source: Swift.Int64) {
self.init(source)
}

#endif
//=------------------------------------------------------------------------=
// MARK: Details x String Literal Type
//=------------------------------------------------------------------------=

#if swift(>=5.8) && SBI
#if SBI && swift(>=5.8)
@available(swift, deprecated: 5.8, message: "Use an integer literal instead.")
#endif
@inlinable public init(stringLiteral source: StringLiteralType) {
Expand All @@ -29,7 +62,7 @@ extension NBKDoubleWidth {
}
}

#if swift(>=5.8) && SBI
#if SBI && swift(>=5.8)
@available(swift, deprecated: 5.8, message: "Use an integer literal instead.")
#endif
@inlinable init?(exactlyStringLiteral source: StringLiteralType) {
Expand All @@ -46,52 +79,3 @@ extension NBKDoubleWidth {
if let value { self = value } else { return nil }
}
}

//=----------------------------------------------------------------------------=
// MARK: + Version ≥ iOS 16.4, macOS 13.3
//=----------------------------------------------------------------------------=
#if swift(>=5.8) && SBI

extension NBKDoubleWidth {

//=-------------------------------------------------------------------------=
// MARK: Details x Integer Literal Type
//=-------------------------------------------------------------------------=

@inlinable public init(integerLiteral source: StaticBigInt) {
if let value = Self(exactlyIntegerLiteral: source) { self = value } else {
preconditionFailure("\(Self.description) cannot represent \(source)")
}
}

@inlinable init?(exactlyIntegerLiteral source: StaticBigInt) {
guard Self.isSigned
? source.bitWidth <= Self.bitWidth
: source.bitWidth <= Self.bitWidth + 1 && source.signum() >= 0
else { return nil }

self = Self.uninitialized { value in
for index in value.indices {
value[unchecked: index] = source[index]
}
}
}
}

#else
//=----------------------------------------------------------------------------=
// MARK: + Version < iOS 16.4, macOS 13.3
//=----------------------------------------------------------------------------=

extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
// MARK: Initializers x Integer Literal Type
//=------------------------------------------------------------------------=

@inlinable public init(integerLiteral source: Int64) {
self.init(source)
}
}

#endif
3 changes: 3 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Logic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Logic
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Multiplication x Digit
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down Expand Up @@ -72,6 +75,9 @@ extension NBKDoubleWidth {
// MARK: * NBK x Double Width x Multiplication x Digit x Unsigned
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth where High == High.Magnitude {

//=------------------------------------------------------------------------=
Expand Down
6 changes: 6 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Multiplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Multiplication
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down Expand Up @@ -72,6 +75,9 @@ extension NBKDoubleWidth {
// MARK: + Unsigned
//=----------------------------------------------------------------------------=

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth where High == High.Magnitude {

//=------------------------------------------------------------------------=
Expand Down
3 changes: 3 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Numbers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Numbers
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
6 changes: 6 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Rotations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Rotations x Left
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down Expand Up @@ -123,6 +126,9 @@ extension NBKDoubleWidth {
// MARK: * NBK x Double Width x Rotations x Right
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
6 changes: 6 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Shifts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Shifts x Left
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down Expand Up @@ -134,6 +137,9 @@ extension NBKDoubleWidth {
// MARK: * NBK x Double Width x Shifts x Right
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
3 changes: 3 additions & 0 deletions Sources/NBKDoubleWidthKit/NBKDoubleWidth+Strides.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Strides
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import NBKCoreKit
// MARK: * NBK x Double Width x Subtraction x Digit
//*============================================================================*

#if SBI && swift(>=5.8)
@available(iOS 16.4, macCatalyst 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *)
#endif
extension NBKDoubleWidth {

//=------------------------------------------------------------------------=
Expand Down
Loading

0 comments on commit 750833a

Please sign in to comment.