* fixes #20244; fixes castSizes warnings * fixes js * fixes js * fixes js * fixes * typo * extend using uint64 * Update lib/std/syncio.nim
This commit is contained in:
parent
70fe360456
commit
93b59da490
4 changed files with 20 additions and 3 deletions
|
|
@ -53,7 +53,7 @@ proc hashString*(conf: ConfigRef; s: string): BiggestInt =
|
||||||
a = a + (a shl 3)
|
a = a + (a shl 3)
|
||||||
a = a xor (a shr 11)
|
a = a xor (a shr 11)
|
||||||
a = a + (a shl 15)
|
a = a + (a shl 15)
|
||||||
result = cast[Hash](a)
|
result = cast[Hash](uint(a))
|
||||||
|
|
||||||
template getUniqueType*(key: PType): PType = key
|
template getUniqueType*(key: PType): PType = key
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ proc initDefines*(symbols: StringTableRef) =
|
||||||
defineSymbol("nimHasCallsitePragma")
|
defineSymbol("nimHasCallsitePragma")
|
||||||
defineSymbol("nimHasAmbiguousEnumHint")
|
defineSymbol("nimHasAmbiguousEnumHint")
|
||||||
|
|
||||||
|
defineSymbol("nimHasWarnCastSizes")
|
||||||
defineSymbol("nimHasOutParams")
|
defineSymbol("nimHasOutParams")
|
||||||
defineSymbol("nimHasSystemRaisesDefect")
|
defineSymbol("nimHasSystemRaisesDefect")
|
||||||
defineSymbol("nimHasWarnUnnamedBreak")
|
defineSymbol("nimHasWarnUnnamedBreak")
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ define:useStdoutAsStdmsg
|
||||||
warning[ObservableStores]:off
|
warning[ObservableStores]:off
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@if nimHasWarnCastSizes:
|
||||||
|
warning[CastSizes]:on
|
||||||
|
@end
|
||||||
|
|
||||||
@if nimHasWarningAsError:
|
@if nimHasWarningAsError:
|
||||||
warningAsError[GcUnsafe2]:on
|
warningAsError[GcUnsafe2]:on
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -944,14 +944,26 @@ func toHex*[T: SomeInteger](x: T, len: Positive): string =
|
||||||
doAssert b.toHex(4) == "1001"
|
doAssert b.toHex(4) == "1001"
|
||||||
doAssert toHex(62, 3) == "03E"
|
doAssert toHex(62, 3) == "03E"
|
||||||
doAssert toHex(-8, 6) == "FFFFF8"
|
doAssert toHex(-8, 6) == "FFFFF8"
|
||||||
|
when defined(js):
|
||||||
toHexImpl(cast[BiggestUInt](x), len, x < 0)
|
toHexImpl(cast[BiggestUInt](x), len, x < 0)
|
||||||
|
else:
|
||||||
|
when T is SomeSignedInt:
|
||||||
|
toHexImpl(cast[BiggestUInt](BiggestInt(x)), len, x < 0)
|
||||||
|
else:
|
||||||
|
toHexImpl(BiggestUInt(x), len, x < 0)
|
||||||
|
|
||||||
func toHex*[T: SomeInteger](x: T): string =
|
func toHex*[T: SomeInteger](x: T): string =
|
||||||
## Shortcut for `toHex(x, T.sizeof * 2)`
|
## Shortcut for `toHex(x, T.sizeof * 2)`
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
doAssert toHex(1984'i64) == "00000000000007C0"
|
doAssert toHex(1984'i64) == "00000000000007C0"
|
||||||
doAssert toHex(1984'i16) == "07C0"
|
doAssert toHex(1984'i16) == "07C0"
|
||||||
|
when defined(js):
|
||||||
toHexImpl(cast[BiggestUInt](x), 2*sizeof(T), x < 0)
|
toHexImpl(cast[BiggestUInt](x), 2*sizeof(T), x < 0)
|
||||||
|
else:
|
||||||
|
when T is SomeSignedInt:
|
||||||
|
toHexImpl(cast[BiggestUInt](BiggestInt(x)), 2*sizeof(T), x < 0)
|
||||||
|
else:
|
||||||
|
toHexImpl(BiggestUInt(x), 2*sizeof(T), x < 0)
|
||||||
|
|
||||||
func toHex*(s: string): string {.rtl.} =
|
func toHex*(s: string): string {.rtl.} =
|
||||||
## Converts a bytes string to its hexadecimal representation.
|
## Converts a bytes string to its hexadecimal representation.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue