Replace double backticks with single backticks - Part 1 out of ~6 (#17205)
This commit is contained in:
parent
56461c280f
commit
ac8166ab3d
10 changed files with 75 additions and 75 deletions
|
|
@ -218,15 +218,15 @@ proc GC_ref*[T](x: ref T) =
|
||||||
|
|
||||||
when not defined(gcOrc):
|
when not defined(gcOrc):
|
||||||
template GC_fullCollect* =
|
template GC_fullCollect* =
|
||||||
## Forces a full garbage collection pass. With ``--gc:arc`` a nop.
|
## Forces a full garbage collection pass. With `--gc:arc` a nop.
|
||||||
discard
|
discard
|
||||||
|
|
||||||
template setupForeignThreadGc* =
|
template setupForeignThreadGc* =
|
||||||
## With ``--gc:arc`` a nop.
|
## With `--gc:arc` a nop.
|
||||||
discard
|
discard
|
||||||
|
|
||||||
template tearDownForeignThreadGc* =
|
template tearDownForeignThreadGc* =
|
||||||
## With ``--gc:arc`` a nop.
|
## With `--gc:arc` a nop.
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc isObj(obj: PNimTypeV2, subclass: cstring): bool {.compilerRtl, inl.} =
|
proc isObj(obj: PNimTypeV2, subclass: cstring): bool {.compilerRtl, inl.} =
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,7 @@ proc `*`*(x, y: uint64): uint64 {.magic: "MulU", noSideEffect.}
|
||||||
|
|
||||||
proc `div`*(x, y: uint): uint {.magic: "DivU", noSideEffect.}
|
proc `div`*(x, y: uint): uint {.magic: "DivU", noSideEffect.}
|
||||||
## Computes the integer division for unsigned integers.
|
## Computes the integer division for unsigned integers.
|
||||||
## This is roughly the same as ``trunc(x/y)``.
|
## This is roughly the same as `trunc(x/y)`.
|
||||||
proc `div`*(x, y: uint8): uint8 {.magic: "DivU", noSideEffect.}
|
proc `div`*(x, y: uint8): uint8 {.magic: "DivU", noSideEffect.}
|
||||||
proc `div`*(x, y: uint16): uint16 {.magic: "DivU", noSideEffect.}
|
proc `div`*(x, y: uint16): uint16 {.magic: "DivU", noSideEffect.}
|
||||||
proc `div`*(x, y: uint32): uint32 {.magic: "DivU", noSideEffect.}
|
proc `div`*(x, y: uint32): uint32 {.magic: "DivU", noSideEffect.}
|
||||||
|
|
@ -393,7 +393,7 @@ proc `div`*(x, y: uint64): uint64 {.magic: "DivU", noSideEffect.}
|
||||||
|
|
||||||
proc `mod`*(x, y: uint): uint {.magic: "ModU", noSideEffect.}
|
proc `mod`*(x, y: uint): uint {.magic: "ModU", noSideEffect.}
|
||||||
## Computes the integer modulo operation (remainder) for unsigned integers.
|
## Computes the integer modulo operation (remainder) for unsigned integers.
|
||||||
## This is the same as ``x - (x div y) * y``.
|
## This is the same as `x - (x div y) * y`.
|
||||||
proc `mod`*(x, y: uint8): uint8 {.magic: "ModU", noSideEffect.}
|
proc `mod`*(x, y: uint8): uint8 {.magic: "ModU", noSideEffect.}
|
||||||
proc `mod`*(x, y: uint16): uint16 {.magic: "ModU", noSideEffect.}
|
proc `mod`*(x, y: uint16): uint16 {.magic: "ModU", noSideEffect.}
|
||||||
proc `mod`*(x, y: uint32): uint32 {.magic: "ModU", noSideEffect.}
|
proc `mod`*(x, y: uint32): uint32 {.magic: "ModU", noSideEffect.}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ type # we need to start a new type section here, so that ``0`` can have a type
|
||||||
false = 0, true = 1
|
false = 0, true = 1
|
||||||
|
|
||||||
const
|
const
|
||||||
on* = true ## Alias for ``true``.
|
on* = true ## Alias for `true`.
|
||||||
off* = false ## Alias for ``false``.
|
off* = false ## Alias for `false`.
|
||||||
|
|
||||||
type
|
type
|
||||||
SomeSignedInt* = int|int8|int16|int32|int64
|
SomeSignedInt* = int|int8|int16|int32|int64
|
||||||
|
|
@ -35,7 +35,7 @@ type
|
||||||
|
|
||||||
BiggestInt* = int64
|
BiggestInt* = int64
|
||||||
## is an alias for the biggest signed integer type the Nim compiler
|
## is an alias for the biggest signed integer type the Nim compiler
|
||||||
## supports. Currently this is ``int64``, but it is platform-dependent
|
## supports. Currently this is `int64`, but it is platform-dependent
|
||||||
## in general.
|
## in general.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -43,20 +43,20 @@ type
|
||||||
{.push hints: off.}
|
{.push hints: off.}
|
||||||
|
|
||||||
proc `not`*(x: bool): bool {.magic: "Not", noSideEffect.}
|
proc `not`*(x: bool): bool {.magic: "Not", noSideEffect.}
|
||||||
## Boolean not; returns true if ``x == false``.
|
## Boolean not; returns true if `x == false`.
|
||||||
|
|
||||||
proc `and`*(x, y: bool): bool {.magic: "And", noSideEffect.}
|
proc `and`*(x, y: bool): bool {.magic: "And", noSideEffect.}
|
||||||
## Boolean ``and``; returns true if ``x == y == true`` (if both arguments
|
## Boolean `and`; returns true if `x == y == true` (if both arguments
|
||||||
## are true).
|
## are true).
|
||||||
##
|
##
|
||||||
## Evaluation is lazy: if ``x`` is false, ``y`` will not even be evaluated.
|
## Evaluation is lazy: if `x` is false, `y` will not even be evaluated.
|
||||||
proc `or`*(x, y: bool): bool {.magic: "Or", noSideEffect.}
|
proc `or`*(x, y: bool): bool {.magic: "Or", noSideEffect.}
|
||||||
## Boolean ``or``; returns true if ``not (not x and not y)`` (if any of
|
## Boolean `or`; returns true if `not (not x and not y)` (if any of
|
||||||
## the arguments is true).
|
## the arguments is true).
|
||||||
##
|
##
|
||||||
## Evaluation is lazy: if ``x`` is true, ``y`` will not even be evaluated.
|
## Evaluation is lazy: if `x` is true, `y` will not even be evaluated.
|
||||||
proc `xor`*(x, y: bool): bool {.magic: "Xor", noSideEffect.}
|
proc `xor`*(x, y: bool): bool {.magic: "Xor", noSideEffect.}
|
||||||
## Boolean `exclusive or`; returns true if ``x != y`` (if either argument
|
## Boolean `exclusive or`; returns true if `x != y` (if either argument
|
||||||
## is true while the other is false).
|
## is true while the other is false).
|
||||||
|
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@
|
||||||
## Channel support for threads.
|
## Channel support for threads.
|
||||||
##
|
##
|
||||||
## **Note**: This is part of the system module. Do not import it directly.
|
## **Note**: This is part of the system module. Do not import it directly.
|
||||||
## To activate thread support compile with the ``--threads:on`` command line switch.
|
## To activate thread support compile with the `--threads:on` command line switch.
|
||||||
##
|
##
|
||||||
## **Note:** Channels are designed for the ``Thread`` type. They are unstable when
|
## **Note:** Channels are designed for the `Thread` type. They are unstable when
|
||||||
## used with ``spawn``
|
## used with `spawn`
|
||||||
##
|
##
|
||||||
## **Note:** The current implementation of message passing does
|
## **Note:** The current implementation of message passing does
|
||||||
## not work with cyclic data structures.
|
## not work with cyclic data structures.
|
||||||
|
|
@ -109,7 +109,7 @@
|
||||||
## in which case they will use a process-wide (thread-safe) shared heap.
|
## in which case they will use a process-wide (thread-safe) shared heap.
|
||||||
##
|
##
|
||||||
## However, it is possible to manually allocate shared memory for channels
|
## However, it is possible to manually allocate shared memory for channels
|
||||||
## using e.g. ``system.allocShared0`` and pass these pointers through thread
|
## using e.g. `system.allocShared0` and pass these pointers through thread
|
||||||
## arguments:
|
## arguments:
|
||||||
##
|
##
|
||||||
## .. code-block :: Nim
|
## .. code-block :: Nim
|
||||||
|
|
@ -410,8 +410,8 @@ proc tryRecv*[TMsg](c: var Channel[TMsg]): tuple[dataAvailable: bool,
|
||||||
## Tries to receive a message from the channel `c`, but this can fail
|
## Tries to receive a message from the channel `c`, but this can fail
|
||||||
## for all sort of reasons, including contention.
|
## for all sort of reasons, including contention.
|
||||||
##
|
##
|
||||||
## If it fails, it returns ``(false, default(msg))`` otherwise it
|
## If it fails, it returns `(false, default(msg))` otherwise it
|
||||||
## returns ``(true, msg)``.
|
## returns `(true, msg)`.
|
||||||
var q = cast[PRawChannel](addr(c))
|
var q = cast[PRawChannel](addr(c))
|
||||||
if q.mask != ChannelDeadMask:
|
if q.mask != ChannelDeadMask:
|
||||||
if tryAcquireSys(q.lock):
|
if tryAcquireSys(q.lock):
|
||||||
|
|
|
||||||
|
|
@ -126,15 +126,15 @@ proc `<`*[T](x, y: ptr T): bool {.magic: "LtPtr", noSideEffect.}
|
||||||
proc `<`*(x, y: pointer): bool {.magic: "LtPtr", noSideEffect.}
|
proc `<`*(x, y: pointer): bool {.magic: "LtPtr", noSideEffect.}
|
||||||
|
|
||||||
template `!=`*(x, y: untyped): untyped =
|
template `!=`*(x, y: untyped): untyped =
|
||||||
## Unequals operator. This is a shorthand for ``not (x == y)``.
|
## Unequals operator. This is a shorthand for `not (x == y)`.
|
||||||
not (x == y)
|
not (x == y)
|
||||||
|
|
||||||
template `>=`*(x, y: untyped): untyped =
|
template `>=`*(x, y: untyped): untyped =
|
||||||
## "is greater or equals" operator. This is the same as ``y <= x``.
|
## "is greater or equals" operator. This is the same as `y <= x`.
|
||||||
y <= x
|
y <= x
|
||||||
|
|
||||||
template `>`*(x, y: untyped): untyped =
|
template `>`*(x, y: untyped): untyped =
|
||||||
## "is greater" operator. This is the same as ``y < x``.
|
## "is greater" operator. This is the same as `y < x`.
|
||||||
y < x
|
y < x
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -160,14 +160,14 @@ proc `<`*(x, y: int32): bool {.magic: "LtI", noSideEffect.}
|
||||||
proc `<`*(x, y: int64): bool {.magic: "LtI", noSideEffect.}
|
proc `<`*(x, y: int64): bool {.magic: "LtI", noSideEffect.}
|
||||||
|
|
||||||
proc `<=`*(x, y: uint): bool {.magic: "LeU", noSideEffect.}
|
proc `<=`*(x, y: uint): bool {.magic: "LeU", noSideEffect.}
|
||||||
## Returns true if ``x <= y``.
|
## Returns true if `x <= y`.
|
||||||
proc `<=`*(x, y: uint8): bool {.magic: "LeU", noSideEffect.}
|
proc `<=`*(x, y: uint8): bool {.magic: "LeU", noSideEffect.}
|
||||||
proc `<=`*(x, y: uint16): bool {.magic: "LeU", noSideEffect.}
|
proc `<=`*(x, y: uint16): bool {.magic: "LeU", noSideEffect.}
|
||||||
proc `<=`*(x, y: uint32): bool {.magic: "LeU", noSideEffect.}
|
proc `<=`*(x, y: uint32): bool {.magic: "LeU", noSideEffect.}
|
||||||
proc `<=`*(x, y: uint64): bool {.magic: "LeU", noSideEffect.}
|
proc `<=`*(x, y: uint64): bool {.magic: "LeU", noSideEffect.}
|
||||||
|
|
||||||
proc `<`*(x, y: uint): bool {.magic: "LtU", noSideEffect.}
|
proc `<`*(x, y: uint): bool {.magic: "LtU", noSideEffect.}
|
||||||
## Returns true if ``x < y``.
|
## Returns true if `x < y`.
|
||||||
proc `<`*(x, y: uint8): bool {.magic: "LtU", noSideEffect.}
|
proc `<`*(x, y: uint8): bool {.magic: "LtU", noSideEffect.}
|
||||||
proc `<`*(x, y: uint16): bool {.magic: "LtU", noSideEffect.}
|
proc `<`*(x, y: uint16): bool {.magic: "LtU", noSideEffect.}
|
||||||
proc `<`*(x, y: uint32): bool {.magic: "LtU", noSideEffect.}
|
proc `<`*(x, y: uint32): bool {.magic: "LtU", noSideEffect.}
|
||||||
|
|
@ -175,7 +175,7 @@ proc `<`*(x, y: uint64): bool {.magic: "LtU", noSideEffect.}
|
||||||
|
|
||||||
proc `<=%`*(x, y: int): bool {.inline.} =
|
proc `<=%`*(x, y: int): bool {.inline.} =
|
||||||
## Treats `x` and `y` as unsigned and compares them.
|
## Treats `x` and `y` as unsigned and compares them.
|
||||||
## Returns true if ``unsigned(x) <= unsigned(y)``.
|
## Returns true if `unsigned(x) <= unsigned(y)`.
|
||||||
cast[uint](x) <= cast[uint](y)
|
cast[uint](x) <= cast[uint](y)
|
||||||
proc `<=%`*(x, y: int8): bool {.inline.} = cast[uint8](x) <= cast[uint8](y)
|
proc `<=%`*(x, y: int8): bool {.inline.} = cast[uint8](x) <= cast[uint8](y)
|
||||||
proc `<=%`*(x, y: int16): bool {.inline.} = cast[uint16](x) <= cast[uint16](y)
|
proc `<=%`*(x, y: int16): bool {.inline.} = cast[uint16](x) <= cast[uint16](y)
|
||||||
|
|
@ -184,7 +184,7 @@ proc `<=%`*(x, y: int64): bool {.inline.} = cast[uint64](x) <= cast[uint64](y)
|
||||||
|
|
||||||
proc `<%`*(x, y: int): bool {.inline.} =
|
proc `<%`*(x, y: int): bool {.inline.} =
|
||||||
## Treats `x` and `y` as unsigned and compares them.
|
## Treats `x` and `y` as unsigned and compares them.
|
||||||
## Returns true if ``unsigned(x) < unsigned(y)``.
|
## Returns true if `unsigned(x) < unsigned(y)`.
|
||||||
cast[uint](x) < cast[uint](y)
|
cast[uint](x) < cast[uint](y)
|
||||||
proc `<%`*(x, y: int8): bool {.inline.} = cast[uint8](x) < cast[uint8](y)
|
proc `<%`*(x, y: int8): bool {.inline.} = cast[uint8](x) < cast[uint8](y)
|
||||||
proc `<%`*(x, y: int16): bool {.inline.} = cast[uint16](x) < cast[uint16](y)
|
proc `<%`*(x, y: int16): bool {.inline.} = cast[uint16](x) < cast[uint16](y)
|
||||||
|
|
@ -193,11 +193,11 @@ proc `<%`*(x, y: int64): bool {.inline.} = cast[uint64](x) < cast[uint64](y)
|
||||||
|
|
||||||
template `>=%`*(x, y: untyped): untyped = y <=% x
|
template `>=%`*(x, y: untyped): untyped = y <=% x
|
||||||
## Treats `x` and `y` as unsigned and compares them.
|
## Treats `x` and `y` as unsigned and compares them.
|
||||||
## Returns true if ``unsigned(x) >= unsigned(y)``.
|
## Returns true if `unsigned(x) >= unsigned(y)`.
|
||||||
|
|
||||||
template `>%`*(x, y: untyped): untyped = y <% x
|
template `>%`*(x, y: untyped): untyped = y <% x
|
||||||
## Treats `x` and `y` as unsigned and compares them.
|
## Treats `x` and `y` as unsigned and compares them.
|
||||||
## Returns true if ``unsigned(x) > unsigned(y)``.
|
## Returns true if `unsigned(x) > unsigned(y)`.
|
||||||
|
|
||||||
proc `==`*(x, y: uint): bool {.magic: "EqI", noSideEffect.}
|
proc `==`*(x, y: uint): bool {.magic: "EqI", noSideEffect.}
|
||||||
## Compares two unsigned integers for equality.
|
## Compares two unsigned integers for equality.
|
||||||
|
|
@ -235,13 +235,13 @@ proc max*(x, y: int64): int64 {.magic: "MaxI", noSideEffect.} =
|
||||||
|
|
||||||
|
|
||||||
proc min*[T](x: openArray[T]): T =
|
proc min*[T](x: openArray[T]): T =
|
||||||
## The minimum value of `x`. ``T`` needs to have a ``<`` operator.
|
## The minimum value of `x`. `T` needs to have a `<` operator.
|
||||||
result = x[0]
|
result = x[0]
|
||||||
for i in 1..high(x):
|
for i in 1..high(x):
|
||||||
if x[i] < result: result = x[i]
|
if x[i] < result: result = x[i]
|
||||||
|
|
||||||
proc max*[T](x: openArray[T]): T =
|
proc max*[T](x: openArray[T]): T =
|
||||||
## The maximum value of `x`. ``T`` needs to have a ``<`` operator.
|
## The maximum value of `x`. `T` needs to have a `<` operator.
|
||||||
result = x[0]
|
result = x[0]
|
||||||
for i in 1..high(x):
|
for i in 1..high(x):
|
||||||
if result < x[i]: result = x[i]
|
if result < x[i]: result = x[i]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
proc `$`*(x: int): string {.magic: "IntToStr", noSideEffect.}
|
proc `$`*(x: int): string {.magic: "IntToStr", noSideEffect.}
|
||||||
## The stringify operator for an integer argument. Returns `x`
|
## The stringify operator for an integer argument. Returns `x`
|
||||||
## converted to a decimal string. ``$`` is Nim's general way of
|
## converted to a decimal string. `$` is Nim's general way of
|
||||||
## spelling `toString`:idx:.
|
## spelling `toString`:idx:.
|
||||||
|
|
||||||
template dollarImpl(x: uint | uint64, result: var string) =
|
template dollarImpl(x: uint | uint64, result: var string) =
|
||||||
|
|
@ -76,19 +76,19 @@ proc `$`*(x: cstring): string {.magic: "CStrToStr", noSideEffect.}
|
||||||
proc `$`*(x: string): string {.magic: "StrToStr", noSideEffect.}
|
proc `$`*(x: string): string {.magic: "StrToStr", noSideEffect.}
|
||||||
## The stringify operator for a string argument. Returns `x`
|
## The stringify operator for a string argument. Returns `x`
|
||||||
## as it is. This operator is useful for generic code, so
|
## as it is. This operator is useful for generic code, so
|
||||||
## that ``$expr`` also works if ``expr`` is already a string.
|
## that `$expr` also works if `expr` is already a string.
|
||||||
|
|
||||||
proc `$`*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect.}
|
proc `$`*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect.}
|
||||||
## The stringify operator for an enumeration argument. This works for
|
## The stringify operator for an enumeration argument. This works for
|
||||||
## any enumeration type thanks to compiler magic.
|
## any enumeration type thanks to compiler magic.
|
||||||
##
|
##
|
||||||
## If a ``$`` operator for a concrete enumeration is provided, this is
|
## If a `$` operator for a concrete enumeration is provided, this is
|
||||||
## used instead. (In other words: *Overwriting* is possible.)
|
## used instead. (In other words: *Overwriting* is possible.)
|
||||||
|
|
||||||
proc `$`*(t: typedesc): string {.magic: "TypeTrait".}
|
proc `$`*(t: typedesc): string {.magic: "TypeTrait".}
|
||||||
## Returns the name of the given type.
|
## Returns the name of the given type.
|
||||||
##
|
##
|
||||||
## For more procedures dealing with ``typedesc``, see
|
## For more procedures dealing with `typedesc`, see
|
||||||
## `typetraits module <typetraits.html>`_.
|
## `typetraits module <typetraits.html>`_.
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
|
|
@ -114,7 +114,7 @@ else:
|
||||||
|
|
||||||
|
|
||||||
proc `$`*[T: tuple|object](x: T): string =
|
proc `$`*[T: tuple|object](x: T): string =
|
||||||
## Generic ``$`` operator for tuples that is lifted from the components
|
## Generic `$` operator for tuples that is lifted from the components
|
||||||
## of `x`. Example:
|
## of `x`. Example:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
|
|
@ -164,7 +164,7 @@ proc collectionToString[T](x: T, prefix, separator, suffix: string): string =
|
||||||
result.add(suffix)
|
result.add(suffix)
|
||||||
|
|
||||||
proc `$`*[T](x: set[T]): string =
|
proc `$`*[T](x: set[T]): string =
|
||||||
## Generic ``$`` operator for sets that is lifted from the components
|
## Generic `$` operator for sets that is lifted from the components
|
||||||
## of `x`. Example:
|
## of `x`. Example:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
|
|
@ -172,7 +172,7 @@ proc `$`*[T](x: set[T]): string =
|
||||||
collectionToString(x, "{", ", ", "}")
|
collectionToString(x, "{", ", ", "}")
|
||||||
|
|
||||||
proc `$`*[T](x: seq[T]): string =
|
proc `$`*[T](x: seq[T]): string =
|
||||||
## Generic ``$`` operator for seqs that is lifted from the components
|
## Generic `$` operator for seqs that is lifted from the components
|
||||||
## of `x`. Example:
|
## of `x`. Example:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
|
|
@ -180,7 +180,7 @@ proc `$`*[T](x: seq[T]): string =
|
||||||
collectionToString(x, "@[", ", ", "]")
|
collectionToString(x, "@[", ", ", "]")
|
||||||
|
|
||||||
proc `$`*[T, U](x: HSlice[T, U]): string =
|
proc `$`*[T, U](x: HSlice[T, U]): string =
|
||||||
## Generic ``$`` operator for slices that is lifted from the components
|
## Generic `$` operator for slices that is lifted from the components
|
||||||
## of `x`. Example:
|
## of `x`. Example:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
|
|
@ -192,11 +192,11 @@ proc `$`*[T, U](x: HSlice[T, U]): string =
|
||||||
|
|
||||||
when not defined(nimNoArrayToString):
|
when not defined(nimNoArrayToString):
|
||||||
proc `$`*[T, IDX](x: array[IDX, T]): string =
|
proc `$`*[T, IDX](x: array[IDX, T]): string =
|
||||||
## Generic ``$`` operator for arrays that is lifted from the components.
|
## Generic `$` operator for arrays that is lifted from the components.
|
||||||
collectionToString(x, "[", ", ", "]")
|
collectionToString(x, "[", ", ", "]")
|
||||||
|
|
||||||
proc `$`*[T](x: openArray[T]): string =
|
proc `$`*[T](x: openArray[T]): string =
|
||||||
## Generic ``$`` operator for openarrays that is lifted from the components
|
## Generic `$` operator for openarrays that is lifted from the components
|
||||||
## of `x`. Example:
|
## of `x`. Example:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ type
|
||||||
parent*: ref Exception ## Parent exception (can be used as a stack).
|
parent*: ref Exception ## Parent exception (can be used as a stack).
|
||||||
name*: cstring ## The exception's name is its Nim identifier.
|
name*: cstring ## The exception's name is its Nim identifier.
|
||||||
## This field is filled automatically in the
|
## This field is filled automatically in the
|
||||||
## ``raise`` statement.
|
## `raise` statement.
|
||||||
msg* {.exportc: "message".}: string ## The exception's message. Not
|
msg* {.exportc: "message".}: string ## The exception's message. Not
|
||||||
## providing an exception message
|
## providing an exception message
|
||||||
## is bad style.
|
## is bad style.
|
||||||
|
|
@ -52,7 +52,7 @@ type
|
||||||
Defect* = object of Exception ## \
|
Defect* = object of Exception ## \
|
||||||
## Abstract base class for all exceptions that Nim's runtime raises
|
## Abstract base class for all exceptions that Nim's runtime raises
|
||||||
## but that are strictly uncatchable as they can also be mapped to
|
## but that are strictly uncatchable as they can also be mapped to
|
||||||
## a ``quit`` / ``trap`` / ``exit`` operation.
|
## a `quit` / `trap` / `exit` operation.
|
||||||
|
|
||||||
CatchableError* = object of Exception ## \
|
CatchableError* = object of Exception ## \
|
||||||
## Abstract class for all exceptions that are catchable.
|
## Abstract class for all exceptions that are catchable.
|
||||||
|
|
@ -110,13 +110,13 @@ type
|
||||||
## Raised if an object gets assigned to its parent's object.
|
## Raised if an object gets assigned to its parent's object.
|
||||||
ObjectConversionDefect* = object of Defect ## \
|
ObjectConversionDefect* = object of Defect ## \
|
||||||
## Raised if an object is converted to an incompatible object type.
|
## Raised if an object is converted to an incompatible object type.
|
||||||
## You can use ``of`` operator to check if conversion will succeed.
|
## You can use `of` operator to check if conversion will succeed.
|
||||||
FloatingPointDefect* = object of Defect ## \
|
FloatingPointDefect* = object of Defect ## \
|
||||||
## Base class for floating point exceptions.
|
## Base class for floating point exceptions.
|
||||||
FloatInvalidOpDefect* = object of FloatingPointDefect ## \
|
FloatInvalidOpDefect* = object of FloatingPointDefect ## \
|
||||||
## Raised by invalid operations according to IEEE.
|
## Raised by invalid operations according to IEEE.
|
||||||
##
|
##
|
||||||
## Raised by ``0.0/0.0``, for example.
|
## Raised by `0.0/0.0`, for example.
|
||||||
FloatDivByZeroDefect* = object of FloatingPointDefect ## \
|
FloatDivByZeroDefect* = object of FloatingPointDefect ## \
|
||||||
## Raised by division by zero.
|
## Raised by division by zero.
|
||||||
##
|
##
|
||||||
|
|
@ -134,13 +134,13 @@ type
|
||||||
## Raised for inexact results.
|
## Raised for inexact results.
|
||||||
##
|
##
|
||||||
## The operation produced a result that cannot be represented with infinite
|
## The operation produced a result that cannot be represented with infinite
|
||||||
## precision -- for example: ``2.0 / 3.0, log(1.1)``
|
## precision -- for example: `2.0 / 3.0, log(1.1)`
|
||||||
##
|
##
|
||||||
## **Note**: Nim currently does not detect these!
|
## **Note**: Nim currently does not detect these!
|
||||||
DeadThreadDefect* = object of Defect ## \
|
DeadThreadDefect* = object of Defect ## \
|
||||||
## Raised if it is attempted to send a message to a dead thread.
|
## Raised if it is attempted to send a message to a dead thread.
|
||||||
NilAccessDefect* = object of Defect ## \
|
NilAccessDefect* = object of Defect ## \
|
||||||
## Raised on dereferences of ``nil`` pointers.
|
## Raised on dereferences of `nil` pointers.
|
||||||
##
|
##
|
||||||
## This is only raised if the `segfaults module <segfaults.html>`_ was imported!
|
## This is only raised if the `segfaults module <segfaults.html>`_ was imported!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,7 @@ var onUnhandledException*: (proc (errorMsg: string) {.
|
||||||
nimcall, gcsafe.}) ## Set this error \
|
nimcall, gcsafe.}) ## Set this error \
|
||||||
## handler to override the existing behaviour on an unhandled exception.
|
## handler to override the existing behaviour on an unhandled exception.
|
||||||
##
|
##
|
||||||
## The default is to write a stacktrace to ``stderr`` and then call ``quit(1)``.
|
## The default is to write a stacktrace to `stderr` and then call `quit(1)`.
|
||||||
## Unstable API.
|
## Unstable API.
|
||||||
|
|
||||||
proc reportUnhandledErrorAux(e: ref Exception) {.nodestroy.} =
|
proc reportUnhandledErrorAux(e: ref Exception) {.nodestroy.} =
|
||||||
|
|
@ -424,7 +424,7 @@ when gotoBasedExceptions:
|
||||||
result = addr(nimInErrorMode)
|
result = addr(nimInErrorMode)
|
||||||
|
|
||||||
proc nimTestErrorFlag() {.compilerRtl.} =
|
proc nimTestErrorFlag() {.compilerRtl.} =
|
||||||
## This proc must be called before ``currException`` is destroyed.
|
## This proc must be called before `currException` is destroyed.
|
||||||
## It also must be called at the end of every thread to ensure no
|
## It also must be called at the end of every thread to ensure no
|
||||||
## error is swallowed.
|
## error is swallowed.
|
||||||
if nimInErrorMode and currException != nil:
|
if nimInErrorMode and currException != nil:
|
||||||
|
|
@ -527,8 +527,8 @@ proc getStackTrace(e: ref Exception): string =
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
proc getStackTraceEntries*(e: ref Exception): seq[StackTraceEntry] =
|
proc getStackTraceEntries*(e: ref Exception): seq[StackTraceEntry] =
|
||||||
## Returns the attached stack trace to the exception ``e`` as
|
## Returns the attached stack trace to the exception `e` as
|
||||||
## a ``seq``. This is not yet available for the JS backend.
|
## a `seq`. This is not yet available for the JS backend.
|
||||||
when not defined(nimSeqsV2):
|
when not defined(nimSeqsV2):
|
||||||
shallowCopy(result, e.trace)
|
shallowCopy(result, e.trace)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -166,16 +166,16 @@ when defined(nimdoc):
|
||||||
## this thread will only be initialized once per thread, no matter how often
|
## this thread will only be initialized once per thread, no matter how often
|
||||||
## it is called.
|
## it is called.
|
||||||
##
|
##
|
||||||
## This function is available only when ``--threads:on`` and ``--tlsEmulation:off``
|
## This function is available only when `--threads:on` and `--tlsEmulation:off`
|
||||||
## switches are used
|
## switches are used
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc tearDownForeignThreadGc*() {.gcsafe.} =
|
proc tearDownForeignThreadGc*() {.gcsafe.} =
|
||||||
## Call this to tear down the GC, previously initialized by ``setupForeignThreadGc``.
|
## Call this to tear down the GC, previously initialized by `setupForeignThreadGc`.
|
||||||
## If GC has not been previously initialized, or has already been torn down, the
|
## If GC has not been previously initialized, or has already been torn down, the
|
||||||
## call does nothing.
|
## call does nothing.
|
||||||
##
|
##
|
||||||
## This function is available only when ``--threads:on`` and ``--tlsEmulation:off``
|
## This function is available only when `--threads:on` and `--tlsEmulation:off`
|
||||||
## switches are used
|
## switches are used
|
||||||
discard
|
discard
|
||||||
elif declared(threadType):
|
elif declared(threadType):
|
||||||
|
|
@ -432,10 +432,10 @@ proc prepareDealloc(cell: PCell) =
|
||||||
decTypeSize(cell, t)
|
decTypeSize(cell, t)
|
||||||
|
|
||||||
proc deallocHeap*(runFinalizers = true; allowGcAfterwards = true) =
|
proc deallocHeap*(runFinalizers = true; allowGcAfterwards = true) =
|
||||||
## Frees the thread local heap. Runs every finalizer if ``runFinalizers``
|
## Frees the thread local heap. Runs every finalizer if `runFinalizers`
|
||||||
## is true. If ``allowGcAfterwards`` is true, a minimal amount of allocation
|
## is true. If `allowGcAfterwards` is true, a minimal amount of allocation
|
||||||
## happens to ensure the GC can continue to work after the call
|
## happens to ensure the GC can continue to work after the call
|
||||||
## to ``deallocHeap``.
|
## to `deallocHeap`.
|
||||||
template deallocCell(x) =
|
template deallocCell(x) =
|
||||||
if isCell(x):
|
if isCell(x):
|
||||||
# cast to PCell is correct here:
|
# cast to PCell is correct here:
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
## This is a part of ``system.nim``, you should not manually import it.
|
## This is a part of `system.nim`, you should not manually import it.
|
||||||
|
|
||||||
|
|
||||||
include inclrtl
|
include inclrtl
|
||||||
|
|
@ -169,7 +169,7 @@ proc readBuffer*(f: File, buffer: pointer, len: Natural): int {.
|
||||||
|
|
||||||
proc readBytes*(f: File, a: var openArray[int8|uint8], start, len: Natural): int {.
|
proc readBytes*(f: File, a: var openArray[int8|uint8], start, len: Natural): int {.
|
||||||
tags: [ReadIOEffect], benign.} =
|
tags: [ReadIOEffect], benign.} =
|
||||||
## reads `len` bytes into the buffer `a` starting at ``a[start]``. Returns
|
## reads `len` bytes into the buffer `a` starting at `a[start]`. Returns
|
||||||
## the actual number of bytes that have been read which may be less than
|
## the actual number of bytes that have been read which may be less than
|
||||||
## `len` (if not as many bytes are remaining), but not greater.
|
## `len` (if not as many bytes are remaining), but not greater.
|
||||||
result = readBuffer(f, addr(a[start]), len)
|
result = readBuffer(f, addr(a[start]), len)
|
||||||
|
|
@ -183,7 +183,7 @@ proc readChars*(f: File, a: var openArray[char]): int {.tags: [ReadIOEffect], be
|
||||||
proc readChars*(f: File, a: var openArray[char], start, len: Natural): int {.
|
proc readChars*(f: File, a: var openArray[char], start, len: Natural): int {.
|
||||||
tags: [ReadIOEffect], benign, deprecated:
|
tags: [ReadIOEffect], benign, deprecated:
|
||||||
"use other `readChars` overload, possibly via: readChars(toOpenArray(buf, start, len-1))".} =
|
"use other `readChars` overload, possibly via: readChars(toOpenArray(buf, start, len-1))".} =
|
||||||
## reads `len` bytes into the buffer `a` starting at ``a[start]``. Returns
|
## reads `len` bytes into the buffer `a` starting at `a[start]`. Returns
|
||||||
## the actual number of bytes that have been read which may be less than
|
## the actual number of bytes that have been read which may be less than
|
||||||
## `len` (if not as many bytes are remaining), but not greater.
|
## `len` (if not as many bytes are remaining), but not greater.
|
||||||
if (start + len) > len(a):
|
if (start + len) > len(a):
|
||||||
|
|
@ -205,7 +205,7 @@ proc writeBuffer*(f: File, buffer: pointer, len: Natural): int {.
|
||||||
|
|
||||||
proc writeBytes*(f: File, a: openArray[int8|uint8], start, len: Natural): int {.
|
proc writeBytes*(f: File, a: openArray[int8|uint8], start, len: Natural): int {.
|
||||||
tags: [WriteIOEffect], benign.} =
|
tags: [WriteIOEffect], benign.} =
|
||||||
## writes the bytes of ``a[start..start+len-1]`` to the file `f`. Returns
|
## writes the bytes of `a[start..start+len-1]` to the file `f`. Returns
|
||||||
## the number of actual written bytes, which may be less than `len` in case
|
## the number of actual written bytes, which may be less than `len` in case
|
||||||
## of an error.
|
## of an error.
|
||||||
var x = cast[ptr UncheckedArray[int8]](a)
|
var x = cast[ptr UncheckedArray[int8]](a)
|
||||||
|
|
@ -213,7 +213,7 @@ proc writeBytes*(f: File, a: openArray[int8|uint8], start, len: Natural): int {.
|
||||||
|
|
||||||
proc writeChars*(f: File, a: openArray[char], start, len: Natural): int {.
|
proc writeChars*(f: File, a: openArray[char], start, len: Natural): int {.
|
||||||
tags: [WriteIOEffect], benign.} =
|
tags: [WriteIOEffect], benign.} =
|
||||||
## writes the bytes of ``a[start..start+len-1]`` to the file `f`. Returns
|
## writes the bytes of `a[start..start+len-1]` to the file `f`. Returns
|
||||||
## the number of actual written bytes, which may be less than `len` in case
|
## the number of actual written bytes, which may be less than `len` in case
|
||||||
## of an error.
|
## of an error.
|
||||||
var x = cast[ptr UncheckedArray[int8]](a)
|
var x = cast[ptr UncheckedArray[int8]](a)
|
||||||
|
|
@ -325,7 +325,7 @@ proc flushFile*(f: File) {.tags: [WriteIOEffect].} =
|
||||||
discard c_fflush(f)
|
discard c_fflush(f)
|
||||||
|
|
||||||
proc getFileHandle*(f: File): FileHandle =
|
proc getFileHandle*(f: File): FileHandle =
|
||||||
## returns the file handle of the file ``f``. This is only useful for
|
## returns the file handle of the file `f`. This is only useful for
|
||||||
## platform specific programming.
|
## platform specific programming.
|
||||||
## Note that on Windows this doesn't return the Windows-specific handle,
|
## Note that on Windows this doesn't return the Windows-specific handle,
|
||||||
## but the C library's notion of a handle, whatever that means.
|
## but the C library's notion of a handle, whatever that means.
|
||||||
|
|
@ -333,7 +333,7 @@ proc getFileHandle*(f: File): FileHandle =
|
||||||
c_fileno(f)
|
c_fileno(f)
|
||||||
|
|
||||||
proc getOsFileHandle*(f: File): FileHandle =
|
proc getOsFileHandle*(f: File): FileHandle =
|
||||||
## returns the OS file handle of the file ``f``. This is only useful for
|
## returns the OS file handle of the file `f`. This is only useful for
|
||||||
## platform specific programming.
|
## platform specific programming.
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
result = FileHandle getOsfhandle(cint getFileHandle(f))
|
result = FileHandle getOsfhandle(cint getFileHandle(f))
|
||||||
|
|
@ -343,7 +343,7 @@ proc getOsFileHandle*(f: File): FileHandle =
|
||||||
when defined(nimdoc) or (defined(posix) and not defined(nimscript)) or defined(windows):
|
when defined(nimdoc) or (defined(posix) and not defined(nimscript)) or defined(windows):
|
||||||
proc setInheritable*(f: FileHandle, inheritable: bool): bool =
|
proc setInheritable*(f: FileHandle, inheritable: bool): bool =
|
||||||
## control whether a file handle can be inherited by child processes. Returns
|
## control whether a file handle can be inherited by child processes. Returns
|
||||||
## ``true`` on success. This requires the OS file handle, which can be
|
## `true` on success. This requires the OS file handle, which can be
|
||||||
## retrieved via `getOsFileHandle <#getOsFileHandle,File>`_.
|
## retrieved via `getOsFileHandle <#getOsFileHandle,File>`_.
|
||||||
##
|
##
|
||||||
## This procedure is not guaranteed to be available for all platforms. Test for
|
## This procedure is not guaranteed to be available for all platforms. Test for
|
||||||
|
|
@ -366,10 +366,10 @@ proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect],
|
||||||
benign.} =
|
benign.} =
|
||||||
## reads a line of text from the file `f` into `line`. May throw an IO
|
## reads a line of text from the file `f` into `line`. May throw an IO
|
||||||
## exception.
|
## exception.
|
||||||
## A line of text may be delimited by ``LF`` or ``CRLF``. The newline
|
## A line of text may be delimited by `LF` or `CRLF`. The newline
|
||||||
## character(s) are not part of the returned string. Returns ``false``
|
## character(s) are not part of the returned string. Returns `false`
|
||||||
## if the end of the file has been reached, ``true`` otherwise. If
|
## if the end of the file has been reached, `true` otherwise. If
|
||||||
## ``false`` is returned `line` contains no new data.
|
## `false` is returned `line` contains no new data.
|
||||||
proc c_memchr(s: pointer, c: cint, n: csize_t): pointer {.
|
proc c_memchr(s: pointer, c: cint, n: csize_t): pointer {.
|
||||||
importc: "memchr", header: "<string.h>".}
|
importc: "memchr", header: "<string.h>".}
|
||||||
|
|
||||||
|
|
@ -485,7 +485,7 @@ proc readLine*(f: File, line: var string): bool {.tags: [ReadIOEffect],
|
||||||
|
|
||||||
proc readLine*(f: File): string {.tags: [ReadIOEffect], benign.} =
|
proc readLine*(f: File): string {.tags: [ReadIOEffect], benign.} =
|
||||||
## reads a line of text from the file `f`. May throw an IO exception.
|
## reads a line of text from the file `f`. May throw an IO exception.
|
||||||
## A line of text may be delimited by ``LF`` or ``CRLF``. The newline
|
## A line of text may be delimited by `LF` or `CRLF`. The newline
|
||||||
## character(s) are not part of the returned string.
|
## character(s) are not part of the returned string.
|
||||||
result = newStringOfCap(80)
|
result = newStringOfCap(80)
|
||||||
if not readLine(f, result): raiseEOF()
|
if not readLine(f, result): raiseEOF()
|
||||||
|
|
@ -680,7 +680,7 @@ proc open*(f: var File, filename: string,
|
||||||
## Default mode is readonly. Returns true if the file could be opened.
|
## Default mode is readonly. Returns true if the file could be opened.
|
||||||
## This throws no exception if the file could not be opened.
|
## This throws no exception if the file could not be opened.
|
||||||
##
|
##
|
||||||
## The file handle associated with the resulting ``File`` is not inheritable.
|
## The file handle associated with the resulting `File` is not inheritable.
|
||||||
var p = fopen(filename, FormatOpen[mode])
|
var p = fopen(filename, FormatOpen[mode])
|
||||||
if p != nil:
|
if p != nil:
|
||||||
var f2 = cast[File](p)
|
var f2 = cast[File](p)
|
||||||
|
|
@ -724,7 +724,7 @@ proc reopen*(f: File, filename: string, mode: FileMode = fmRead): bool {.
|
||||||
|
|
||||||
proc open*(f: var File, filehandle: FileHandle,
|
proc open*(f: var File, filehandle: FileHandle,
|
||||||
mode: FileMode = fmRead): bool {.tags: [], raises: [], benign.} =
|
mode: FileMode = fmRead): bool {.tags: [], raises: [], benign.} =
|
||||||
## Creates a ``File`` from a `filehandle` with given `mode`.
|
## Creates a `File` from a `filehandle` with given `mode`.
|
||||||
##
|
##
|
||||||
## Default mode is readonly. Returns true if the file could be opened.
|
## Default mode is readonly. Returns true if the file could be opened.
|
||||||
##
|
##
|
||||||
|
|
@ -740,10 +740,10 @@ proc open*(filename: string,
|
||||||
mode: FileMode = fmRead, bufSize: int = -1): File =
|
mode: FileMode = fmRead, bufSize: int = -1): File =
|
||||||
## Opens a file named `filename` with given `mode`.
|
## Opens a file named `filename` with given `mode`.
|
||||||
##
|
##
|
||||||
## Default mode is readonly. Raises an ``IOError`` if the file
|
## Default mode is readonly. Raises an `IOError` if the file
|
||||||
## could not be opened.
|
## could not be opened.
|
||||||
##
|
##
|
||||||
## The file handle associated with the resulting ``File`` is not inheritable.
|
## The file handle associated with the resulting `File` is not inheritable.
|
||||||
if not open(result, filename, mode, bufSize):
|
if not open(result, filename, mode, bufSize):
|
||||||
sysFatal(IOError, "cannot open: " & filename)
|
sysFatal(IOError, "cannot open: " & filename)
|
||||||
|
|
||||||
|
|
@ -889,7 +889,7 @@ proc writeFile*(filename: string, content: openArray[byte]) {.since: (1, 1).} =
|
||||||
proc readLines*(filename: string, n: Natural): seq[string] =
|
proc readLines*(filename: string, n: Natural): seq[string] =
|
||||||
## read `n` lines from the file named `filename`. Raises an IO exception
|
## read `n` lines from the file named `filename`. Raises an IO exception
|
||||||
## in case of an error. Raises EOF if file does not contain at least `n` lines.
|
## in case of an error. Raises EOF if file does not contain at least `n` lines.
|
||||||
## Available at compile time. A line of text may be delimited by ``LF`` or ``CRLF``.
|
## Available at compile time. A line of text may be delimited by `LF` or `CRLF`.
|
||||||
## The newline character(s) are not part of the returned strings.
|
## The newline character(s) are not part of the returned strings.
|
||||||
var f: File = nil
|
var f: File = nil
|
||||||
if open(f, filename):
|
if open(f, filename):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue