Export string parsing shortcut "u256"

This commit is contained in:
mratsim 2018-05-06 22:41:49 +02:00
parent 1ff544eabf
commit 7dad3f89d8
3 changed files with 24 additions and 22 deletions

View File

@ -10,17 +10,6 @@
import ./private/datatypes, macros
export StInt, IntImpl, intImpl # TODO remove the need to export intImpl and this macro
type
Int128* = Stint[128]
Int256* = Stint[256]
template make_conv(conv_name: untyped, size: int): untyped =
func `convname`*(n: SomeInteger): Stint[size] {.inline.}=
n.stint(size)
make_conv(i128, 128)
make_conv(i256, 256)
template make_unary(op, ResultTy): untyped =
func `op`*(x: Stint): ResultTy {.inline.} =
when ResultTy is Stint:

View File

@ -9,3 +9,27 @@
import ./uint_public, ./int_public, ./io
export uint_public, int_public, io
type
Int128* = Stint[128]
Int256* = Stint[256]
UInt128* = StUint[128]
UInt256* = StUint[256]
template make_conv(conv_name: untyped, size: int): untyped =
func `convname`*(n: SomeInteger): StUint[size] {.inline.}=
n.stuint(size)
func `convname`*(input: string): StUint[size] {.inline.}=
parse(Stuint[size], input)
make_conv(u128, 128)
make_conv(u256, 256)
template make_conv(conv_name: untyped, size: int): untyped =
func `convname`*(n: SomeInteger): Stint[size] {.inline.}=
n.stint(size)
func `convname`*(input: string): Stint[size] {.inline.}=
parse(Stint[size], input)
make_conv(i128, 128)
make_conv(i256, 256)

View File

@ -10,17 +10,6 @@
import ./private/datatypes, macros
export StUint, UintImpl, uintImpl # TODO remove the need to export UintImpl and this macro
type
UInt128* = StUint[128]
UInt256* = StUint[256]
template make_conv(conv_name: untyped, size: int): untyped =
func `convname`*(n: SomeInteger): StUint[size] {.inline.}=
n.stuint(size)
make_conv(u128, 128)
make_conv(u256, 256)
template make_unary(op, ResultTy): untyped =
func `op`*(x: StUint): ResultTy {.inline.} =
when ResultTy is StUint: