-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
992 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export RUSTC_WRAPPER=/opt/homebrew/bin/sccache | ||
export JAVA_OPTS="-Xmx8g" | ||
export CLASSPATH=$PWD/jna-5.13.0.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
[all] | ||
exclude-files = [ | ||
"tests/*", | ||
"src/wrapped_radix_engine_toolkit/dummy_types.rs", | ||
"example/*", | ||
"target/*", | ||
"apple/*", | ||
".swiftpm/*", | ||
"scripts/*", | ||
".build/*", | ||
"Package.swift", | ||
] | ||
verbose = false | ||
all-features = true | ||
timeout = "1800s" | ||
timeout = "5m" | ||
skip-clean = true | ||
out = ["Xml"] | ||
force-clean = false |
12 changes: 11 additions & 1 deletion
12
apple/Sources/Sargon/Extensions/Methods/Decimal192+Wrap+Functions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
//extension Decimal192: Comparable {} | ||
extension Decimal192 { | ||
public init(_ string: String) throws { | ||
self = try newDecimalFromString(string: string) | ||
} | ||
} | ||
|
||
extension Decimal192: CustomStringConvertible { | ||
public var description: String { | ||
decimalToString(decimal: self) | ||
} | ||
} |
85 changes: 75 additions & 10 deletions
85
apple/Sources/Sargon/Extensions/Swiftified/Decimal192+Swiftified.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,76 @@ | ||
extension Decimal192: Sendable {} | ||
//extension Decimal192: ExpressibleByStringLiteral { | ||
// | ||
//} | ||
//extension Decimal192: ExpressibleByFloatLiteral { | ||
// | ||
//} | ||
//extension Decimal192: SignedNumeric /* Numeric, ExpressibleByIntegerLiteral AdditiveArithmetic */ | ||
//{ | ||
// | ||
//} | ||
|
||
extension Decimal192 { | ||
public init(_ string: String) throws { | ||
self = try newDecimalFromString(string: string) | ||
} | ||
} | ||
|
||
extension Decimal192: CustomStringConvertible { | ||
public var description: String { | ||
decimalToString(decimal: self) | ||
} | ||
} | ||
|
||
extension Decimal192: ExpressibleByStringLiteral { | ||
public init(stringLiteral string: String) { | ||
try! self.init(string) | ||
} | ||
} | ||
extension Decimal192: ExpressibleByIntegerLiteral { | ||
public init(integerLiteral i64: Int64) { | ||
self = newDecimalFromI64(value: i64) | ||
} | ||
} | ||
|
||
extension Decimal192: ExpressibleByFloatLiteral { | ||
public init(floatLiteral value: Double) { | ||
let formatter = NumberFormatter() | ||
formatter.numberStyle = .decimal | ||
formatter.decimalSeparator = "." // Sargon ALWAYS uses "." | ||
formatter.maximumFractionDigits = 18 | ||
let string = formatter.string(from: NSNumber(value: value))! | ||
try! self.init(string) | ||
} | ||
} | ||
extension Decimal192: AdditiveArithmetic { | ||
public static var zero: Self { | ||
newDecimalFromU64(value: 0) | ||
} | ||
public static func + (lhs: Self, rhs: Self) -> Self { | ||
decimalAdd(lhs: lhs, rhs: rhs) | ||
} | ||
public static func - (lhs: Self, rhs: Self) -> Self { | ||
decimalSub(lhs, rhs) | ||
} | ||
} | ||
extension Decimal192: SignedNumeric { | ||
public static func - (operand: Self) -> Self { | ||
decimalNeg(decimal: operand) | ||
} | ||
} | ||
extension Decimal192: Numeric { | ||
public typealias Magnitude = Self | ||
|
||
public var magnitude: Magnitude { | ||
decimalAbs(self) | ||
} | ||
|
||
public static func * (lhs: Self, rhs: Self) -> Self { | ||
decimalMul(lhs: lhs, rhs: rhs) | ||
} | ||
|
||
public static func *= (lhs: inout Self, rhs: Self) { | ||
lhs = lhs * rhs | ||
} | ||
|
||
public init?<T>(exactly source: T) where T: BinaryInteger { | ||
if let i64 = Int64(exactly: source) { | ||
self = newDecimalFromI64(value: i64) | ||
} else if let u64 = UInt64(exactly: source) { | ||
self = newDecimalFromU64(value: u64) | ||
} else { | ||
return nil | ||
} | ||
} | ||
} |
Oops, something went wrong.