Nimrod renamed to Nim
This commit is contained in:
parent
2781fea9e2
commit
d05df2173b
56 changed files with 116 additions and 116 deletions
|
|
@ -1,13 +1,13 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
## This module contains Nimrod's support for locks and condition vars.
|
## This module contains Nim's support for locks and condition vars.
|
||||||
## If the symbol ``preventDeadlocks`` is defined
|
## If the symbol ``preventDeadlocks`` is defined
|
||||||
## (compiled with ``-d:preventDeadlocks``) special logic is added to
|
## (compiled with ``-d:preventDeadlocks``) special logic is added to
|
||||||
## every ``acquire``, ``tryAcquire`` and ``release`` action that ensures at
|
## every ``acquire``, ``tryAcquire`` and ``release`` action that ensures at
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
include "system/syslocks"
|
include "system/syslocks"
|
||||||
|
|
||||||
type
|
type
|
||||||
TLock* = TSysLock ## Nimrod lock; whether this is re-entrant
|
TLock* = TSysLock ## Nim lock; whether this is re-entrant
|
||||||
## or not is unspecified! However, compilation
|
## or not is unspecified! However, compilation
|
||||||
## in preventDeadlocks-mode guarantees re-entrancy.
|
## in preventDeadlocks-mode guarantees re-entrancy.
|
||||||
TCond* = TSysCond ## Nimrod condition variable
|
TCond* = TSysCond ## Nim condition variable
|
||||||
|
|
||||||
FLock* = object of TEffect ## effect that denotes that some lock operation
|
FLock* = object of TEffect ## effect that denotes that some lock operation
|
||||||
## is performed
|
## is performed
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2013 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -585,7 +585,7 @@ proc assign*(x, y: TAny) =
|
||||||
genericAssign(x.value, y.value, y.rawType)
|
genericAssign(x.value, y.value, y.rawType)
|
||||||
|
|
||||||
iterator elements*(x: TAny): int =
|
iterator elements*(x: TAny): int =
|
||||||
## iterates over every element of `x` that represents a Nimrod bitset.
|
## iterates over every element of `x` that represents a Nim bitset.
|
||||||
assert x.rawType.kind == tySet
|
assert x.rawType.kind == tySet
|
||||||
var typ = x.rawType
|
var typ = x.rawType
|
||||||
var p = x.value
|
var p = x.value
|
||||||
|
|
@ -607,7 +607,7 @@ iterator elements*(x: TAny): int =
|
||||||
yield i+typ.node.len
|
yield i+typ.node.len
|
||||||
|
|
||||||
proc inclSetElement*(x: TAny, elem: int) =
|
proc inclSetElement*(x: TAny, elem: int) =
|
||||||
## includes an element `elem` in `x`. `x` needs to represent a Nimrod bitset.
|
## includes an element `elem` in `x`. `x` needs to represent a Nim bitset.
|
||||||
assert x.rawType.kind == tySet
|
assert x.rawType.kind == tySet
|
||||||
var typ = x.rawType
|
var typ = x.rawType
|
||||||
var p = x.value
|
var p = x.value
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
## This module implements portable dialogs for Nimrod; the implementation
|
## This module implements portable dialogs for Nim; the implementation
|
||||||
## builds on the GTK interface. On Windows, native dialogs are shown instead.
|
## builds on the GTK interface. On Windows, native dialogs are shown instead.
|
||||||
|
|
||||||
import
|
import
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf, Dominik Picheta
|
# (c) Copyright 2012 Andreas Rumpf, Dominik Picheta
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
## This module implements graphical output for Nimrod; the current
|
## This module implements graphical output for Nim; the current
|
||||||
## implementation uses SDL but the interface is meant to support multiple
|
## implementation uses SDL but the interface is meant to support multiple
|
||||||
## backends some day. There is no need to init SDL as this module does that
|
## backends some day. There is no need to init SDL as this module does that
|
||||||
## implicitly.
|
## implicitly.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
## Regular expression support for Nimrod. Consider using the pegs module
|
## Regular expression support for Nim. Consider using the pegs module
|
||||||
## instead.
|
## instead.
|
||||||
## This module is implemented by providing a wrapper around the
|
## This module is implemented by providing a wrapper around the
|
||||||
## `PRCE (Perl-Compatible Regular Expressions) <http://www.pcre.org>`_
|
## `PRCE (Perl-Compatible Regular Expressions) <http://www.pcre.org>`_
|
||||||
|
|
@ -68,7 +68,7 @@ proc finalizeRegEx(x: TRegex) =
|
||||||
pcre.free_substring(cast[cstring](x.e))
|
pcre.free_substring(cast[cstring](x.e))
|
||||||
|
|
||||||
proc re*(s: string, flags = {reExtended, reStudy}): TRegex =
|
proc re*(s: string, flags = {reExtended, reStudy}): TRegex =
|
||||||
## Constructor of regular expressions. Note that Nimrod's
|
## Constructor of regular expressions. Note that Nim's
|
||||||
## extended raw string literals support this syntax ``re"[abc]"`` as
|
## extended raw string literals support this syntax ``re"[abc]"`` as
|
||||||
## a short form for ``re(r"[abc]")``.
|
## a short form for ``re(r"[abc]")``.
|
||||||
new(result, finalizeRegEx)
|
new(result, finalizeRegEx)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Dominik Picheta
|
# (c) Copyright 2012 Dominik Picheta
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2010 Andreas Rumpf
|
# (c) Copyright 2010 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
@ -17,7 +17,7 @@ import
|
||||||
type
|
type
|
||||||
TRstParseOption* = enum ## options for the RST parser
|
TRstParseOption* = enum ## options for the RST parser
|
||||||
roSkipPounds, ## skip ``#`` at line beginning (documentation
|
roSkipPounds, ## skip ``#`` at line beginning (documentation
|
||||||
## embedded in Nimrod comments)
|
## embedded in Nim comments)
|
||||||
roSupportSmilies, ## make the RST parser support smilies like ``:)``
|
roSupportSmilies, ## make the RST parser support smilies like ``:)``
|
||||||
roSupportRawDirective, ## support the ``raw`` directive (don't support
|
roSupportRawDirective, ## support the ``raw`` directive (don't support
|
||||||
## it for sandboxing)
|
## it for sandboxing)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2013 Dominik Picheta
|
# (c) Copyright 2013 Dominik Picheta
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Dominik Picheta
|
# (c) Copyright 2012 Dominik Picheta
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,14 @@
|
||||||
# net/if, sys/socket, sys/uio, netinet/in, netinet/tcp, netdb
|
# net/if, sys/socket, sys/uio, netinet/in, netinet/tcp, netdb
|
||||||
|
|
||||||
## This is a raw POSIX interface module. It does not not provide any
|
## This is a raw POSIX interface module. It does not not provide any
|
||||||
## convenience: cstrings are used instead of proper Nimrod strings and
|
## convenience: cstrings are used instead of proper Nim strings and
|
||||||
## return codes indicate errors. If you want exceptions
|
## return codes indicate errors. If you want exceptions
|
||||||
## and a proper Nimrod-like interface, use the OS module or write a wrapper.
|
## and a proper Nim-like interface, use the OS module or write a wrapper.
|
||||||
|
|
||||||
## Coding conventions:
|
## Coding conventions:
|
||||||
## ALL types are named the same as in the POSIX standard except that they start
|
## ALL types are named the same as in the POSIX standard except that they start
|
||||||
## with 'T' or 'P' (if they are pointers) and without the '_t' suffix to be
|
## with 'T' or 'P' (if they are pointers) and without the '_t' suffix to be
|
||||||
## consistent with Nimrod conventions. If an identifier is a Nimrod keyword
|
## consistent with Nim conventions. If an identifier is a Nim keyword
|
||||||
## the \`identifier\` notation is used.
|
## the \`identifier\` notation is used.
|
||||||
##
|
##
|
||||||
## This library relies on the header files of your C compiler. The
|
## This library relies on the header files of your C compiler. The
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
|
|
||||||
## `Actor`:idx: support for Nimrod. An actor is implemented as a thread with
|
## `Actor`:idx: support for Nim. An actor is implemented as a thread with
|
||||||
## a channel as its inbox. This module requires the ``--threads:on``
|
## a channel as its inbox. This module requires the ``--threads:on``
|
||||||
## command line switch.
|
## command line switch.
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -151,11 +151,11 @@ proc merge[T](a, b: var openArray[T], lo, m, hi: int,
|
||||||
proc sort*[T](a: var openArray[T],
|
proc sort*[T](a: var openArray[T],
|
||||||
cmp: proc (x, y: T): int {.closure.},
|
cmp: proc (x, y: T): int {.closure.},
|
||||||
order = SortOrder.Ascending) =
|
order = SortOrder.Ascending) =
|
||||||
## Default Nimrod sort. The sorting is guaranteed to be stable and
|
## Default Nim sort. The sorting is guaranteed to be stable and
|
||||||
## the worst case is guaranteed to be O(n log n).
|
## the worst case is guaranteed to be O(n log n).
|
||||||
## The current implementation uses an iterative
|
## The current implementation uses an iterative
|
||||||
## mergesort to achieve this. It uses a temporary sequence of
|
## mergesort to achieve this. It uses a temporary sequence of
|
||||||
## length ``a.len div 2``. Currently Nimrod does not support a
|
## length ``a.len div 2``. Currently Nim does not support a
|
||||||
## sensible default argument for ``cmp``, so you have to provide one
|
## sensible default argument for ``cmp``, so you have to provide one
|
||||||
## of your own. However, the ``system.cmp`` procs can be used:
|
## of your own. However, the ``system.cmp`` procs can be used:
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ proc setTestData*(keysvalues: varargs[string]) =
|
||||||
## This can only simulate the 'GET' request method. `keysvalues` should
|
## This can only simulate the 'GET' request method. `keysvalues` should
|
||||||
## provide embedded (name, value)-pairs. Example:
|
## provide embedded (name, value)-pairs. Example:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## setTestData("name", "Hanz", "password", "12345")
|
## setTestData("name", "Hanz", "password", "12345")
|
||||||
putEnv("REQUEST_METHOD", "GET")
|
putEnv("REQUEST_METHOD", "GET")
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
@ -342,7 +342,7 @@ proc writeContentType*() =
|
||||||
## call this before starting to send your HTML data to `stdout`. This
|
## call this before starting to send your HTML data to `stdout`. This
|
||||||
## implements this part of the CGI protocol:
|
## implements this part of the CGI protocol:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## write(stdout, "Content-type: text/html\n\n")
|
## write(stdout, "Content-type: text/html\n\n")
|
||||||
write(stdout, "Content-type: text/html\n\n")
|
write(stdout, "Content-type: text/html\n\n")
|
||||||
|
|
||||||
|
|
@ -366,11 +366,11 @@ proc writeErrorMessage*(data: string) =
|
||||||
stdout.write(data)
|
stdout.write(data)
|
||||||
|
|
||||||
proc setStackTraceStdout*() =
|
proc setStackTraceStdout*() =
|
||||||
## Makes Nimrod output stacktraces to stdout, instead of server log.
|
## Makes Nim output stacktraces to stdout, instead of server log.
|
||||||
errorMessageWriter = writeErrorMessage
|
errorMessageWriter = writeErrorMessage
|
||||||
|
|
||||||
proc setStackTraceNewLine*() {.deprecated.} =
|
proc setStackTraceNewLine*() {.deprecated.} =
|
||||||
## Makes Nimrod output stacktraces to stdout, instead of server log.
|
## Makes Nim output stacktraces to stdout, instead of server log.
|
||||||
## Depracated alias for setStackTraceStdout.
|
## Depracated alias for setStackTraceStdout.
|
||||||
setStackTraceStdout()
|
setStackTraceStdout()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2014 Andreas Rumpf
|
# (c) Copyright 2014 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ proc nimFlowVarSignal(fv: FlowVarBase) {.compilerProc.} =
|
||||||
|
|
||||||
proc awaitAndThen*[T](fv: FlowVar[T]; action: proc (x: T) {.closure.}) =
|
proc awaitAndThen*[T](fv: FlowVar[T]; action: proc (x: T) {.closure.}) =
|
||||||
## blocks until the ``fv`` is available and then passes its value
|
## blocks until the ``fv`` is available and then passes its value
|
||||||
## to ``action``. Note that due to Nimrod's parameter passing semantics this
|
## to ``action``. Note that due to Nim's parameter passing semantics this
|
||||||
## means that ``T`` doesn't need to be copied and so ``awaitAndThen`` can
|
## means that ``T`` doesn't need to be copied and so ``awaitAndThen`` can
|
||||||
## sometimes be more efficient than ``^``.
|
## sometimes be more efficient than ``^``.
|
||||||
await(fv)
|
await(fv)
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ type
|
||||||
csock: Socket # Command connection socket
|
csock: Socket # Command connection socket
|
||||||
dsock: Socket # Data connection socket
|
dsock: Socket # Data connection socket
|
||||||
else:
|
else:
|
||||||
dummyA, dummyB: pointer # workaround a Nimrod API issue
|
dummyA, dummyB: pointer # workaround a Nim API issue
|
||||||
asyncCSock: AsyncSocket
|
asyncCSock: AsyncSocket
|
||||||
asyncDSock: AsyncSocket
|
asyncDSock: AsyncSocket
|
||||||
handleEvent*: proc (ftp: AsyncFTPClient, ev: FTPEvent){.closure,gcsafe.}
|
handleEvent*: proc (ftp: AsyncFTPClient, ev: FTPEvent){.closure,gcsafe.}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
## The ``gentabs`` module implements an efficient hash table that is a
|
## The ``gentabs`` module implements an efficient hash table that is a
|
||||||
## key-value mapping. The keys are required to be strings, but the values
|
## key-value mapping. The keys are required to be strings, but the values
|
||||||
## may be any Nimrod or user defined type. This module supports matching
|
## may be any Nim or user defined type. This module supports matching
|
||||||
## of keys in case-sensitive, case-insensitive and style-insensitive modes.
|
## of keys in case-sensitive, case-insensitive and style-insensitive modes.
|
||||||
|
|
||||||
{.deprecated.}
|
{.deprecated.}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf, Dominik Picheta
|
# (c) Copyright 2012 Andreas Rumpf, Dominik Picheta
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -30,15 +30,15 @@ const
|
||||||
E* = 2.71828182845904523536028747 ## Euler's number
|
E* = 2.71828182845904523536028747 ## Euler's number
|
||||||
|
|
||||||
MaxFloat64Precision* = 16 ## maximum number of meaningful digits
|
MaxFloat64Precision* = 16 ## maximum number of meaningful digits
|
||||||
## after the decimal point for Nimrod's
|
## after the decimal point for Nim's
|
||||||
## ``float64`` type.
|
## ``float64`` type.
|
||||||
MaxFloat32Precision* = 8 ## maximum number of meaningful digits
|
MaxFloat32Precision* = 8 ## maximum number of meaningful digits
|
||||||
## after the decimal point for Nimrod's
|
## after the decimal point for Nim's
|
||||||
## ``float32`` type.
|
## ``float32`` type.
|
||||||
MaxFloatPrecision* = MaxFloat64Precision ## maximum number of
|
MaxFloatPrecision* = MaxFloat64Precision ## maximum number of
|
||||||
## meaningful digits
|
## meaningful digits
|
||||||
## after the decimal point
|
## after the decimal point
|
||||||
## for Nimrod's ``float`` type.
|
## for Nim's ``float`` type.
|
||||||
|
|
||||||
type
|
type
|
||||||
FloatClass* = enum ## describes the class a floating point value belongs to.
|
FloatClass* = enum ## describes the class a floating point value belongs to.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nim's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2014 Nimrod Contributors
|
# (c) Copyright 2014 Nim Contributors
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
|
|
@ -1245,7 +1245,7 @@ iterator walkDir*(dir: string): tuple[kind: TPathComponent, path: string] {.
|
||||||
##
|
##
|
||||||
## and this code:
|
## and this code:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## for kind, path in walkDir("dirA"):
|
## for kind, path in walkDir("dirA"):
|
||||||
## echo(path)
|
## echo(path)
|
||||||
##
|
##
|
||||||
|
|
@ -1657,7 +1657,7 @@ when defined(nimdoc):
|
||||||
## # Do something else!
|
## # Do something else!
|
||||||
|
|
||||||
elif defined(windows):
|
elif defined(windows):
|
||||||
# Since we support GUI applications with Nimrod, we sometimes generate
|
# Since we support GUI applications with Nim, we sometimes generate
|
||||||
# a WinMain entry proc. But a WinMain proc has no access to the parsed
|
# a WinMain entry proc. But a WinMain proc has no access to the parsed
|
||||||
# command line arguments. The way to get them differs. Thus we parse them
|
# command line arguments. The way to get them differs. Thus we parse them
|
||||||
# ourselves. This has the additional benefit that the program's behaviour
|
# ourselves. This has the additional benefit that the program's behaviour
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ proc execProcesses*(cmds: openArray[string],
|
||||||
close(p)
|
close(p)
|
||||||
|
|
||||||
proc select*(readfds: var seq[PProcess], timeout = 500): int
|
proc select*(readfds: var seq[PProcess], timeout = 500): int
|
||||||
## `select` with a sensible Nimrod interface. `timeout` is in miliseconds.
|
## `select` with a sensible Nim interface. `timeout` is in miliseconds.
|
||||||
## Specify -1 for no timeout. Returns the number of processes that are
|
## Specify -1 for no timeout. Returns the number of processes that are
|
||||||
## ready to read from. The processes that are ready to be read from are
|
## ready to read from. The processes that are ready to be read from are
|
||||||
## removed from `readfds`.
|
## removed from `readfds`.
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
## parser. The configuration file's syntax is similar to the Windows ``.ini``
|
## parser. The configuration file's syntax is similar to the Windows ``.ini``
|
||||||
## format, but much more powerful, as it is not a line based parser. String
|
## format, but much more powerful, as it is not a line based parser. String
|
||||||
## literals, raw string literals and triple quoted string literals are supported
|
## literals, raw string literals and triple quoted string literals are supported
|
||||||
## as in the Nimrod programming language.
|
## as in the Nim programming language.
|
||||||
|
|
||||||
## This is an example of how a configuration file may look like:
|
## This is an example of how a configuration file may look like:
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
## This module contains support for a `rope`:idx: data type.
|
## This module contains support for a `rope`:idx: data type.
|
||||||
## Ropes can represent very long strings efficiently; especially concatenation
|
## Ropes can represent very long strings efficiently; especially concatenation
|
||||||
## is done in O(1) instead of O(n). They are essentially concatenation
|
## is done in O(1) instead of O(n). They are essentially concatenation
|
||||||
## trees that are only flattened when converting to a native Nimrod
|
## trees that are only flattened when converting to a native Nim
|
||||||
## string. The empty string is represented by ``nil``. Ropes are immutable and
|
## string. The empty string is represented by ``nil``. Ropes are immutable and
|
||||||
## subtrees can be shared without copying.
|
## subtrees can be shared without copying.
|
||||||
## Leaves can be cached for better memory efficiency at the cost of
|
## Leaves can be cached for better memory efficiency at the cost of
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
## This module provides a stream interface and two implementations thereof:
|
## This module provides a stream interface and two implementations thereof:
|
||||||
## the `FileStream` and the `StringStream` which implement the stream
|
## the `FileStream` and the `StringStream` which implement the stream
|
||||||
## interface for Nimrod file objects (`File`) and strings. Other modules
|
## interface for Nim file objects (`File`) and strings. Other modules
|
||||||
## may provide other implementations for this standard stream interface.
|
## may provide other implementations for this standard stream interface.
|
||||||
|
|
||||||
include "system/inclrtl"
|
include "system/inclrtl"
|
||||||
|
|
@ -98,7 +98,7 @@ proc writeData*(s, unused: Stream, buffer: pointer,
|
||||||
proc write*[T](s: Stream, x: T) =
|
proc write*[T](s: Stream, x: T) =
|
||||||
## generic write procedure. Writes `x` to the stream `s`. Implementation:
|
## generic write procedure. Writes `x` to the stream `s`. Implementation:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
##
|
##
|
||||||
## s.writeData(s, addr(x), sizeof(x))
|
## s.writeData(s, addr(x), sizeof(x))
|
||||||
var y: T
|
var y: T
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ proc normalize*(s: string): string {.noSideEffect, procvar,
|
||||||
## Normalizes the string `s`.
|
## Normalizes the string `s`.
|
||||||
##
|
##
|
||||||
## That means to convert it to lower case and remove any '_'. This is needed
|
## That means to convert it to lower case and remove any '_'. This is needed
|
||||||
## for Nimrod identifiers for example.
|
## for Nim identifiers for example.
|
||||||
result = newString(s.len)
|
result = newString(s.len)
|
||||||
var j = 0
|
var j = 0
|
||||||
for i in 0..len(s) - 1:
|
for i in 0..len(s) - 1:
|
||||||
|
|
@ -1155,7 +1155,7 @@ proc formatBiggestFloat*(f: BiggestFloat, format: FloatFormatMode = ffDefault,
|
||||||
## If ``format == ffScientific`` then precision is the maximum number
|
## If ``format == ffScientific`` then precision is the maximum number
|
||||||
## of significant digits to be printed.
|
## of significant digits to be printed.
|
||||||
## `precision`'s default value is the maximum number of meaningful digits
|
## `precision`'s default value is the maximum number of meaningful digits
|
||||||
## after the decimal point for Nimrod's ``biggestFloat`` type.
|
## after the decimal point for Nim's ``biggestFloat`` type.
|
||||||
##
|
##
|
||||||
## If ``precision == 0``, it tries to format it nicely.
|
## If ``precision == 0``, it tries to format it nicely.
|
||||||
const floatFormatToChar: array[FloatFormatMode, char] = ['g', 'f', 'e']
|
const floatFormatToChar: array[FloatFormatMode, char] = ['g', 'f', 'e']
|
||||||
|
|
@ -1186,7 +1186,7 @@ proc formatFloat*(f: float, format: FloatFormatMode = ffDefault,
|
||||||
## If ``format == ffScientific`` then precision is the maximum number
|
## If ``format == ffScientific`` then precision is the maximum number
|
||||||
## of significant digits to be printed.
|
## of significant digits to be printed.
|
||||||
## `precision`'s default value is the maximum number of meaningful digits
|
## `precision`'s default value is the maximum number of meaningful digits
|
||||||
## after the decimal point for Nimrod's ``float`` type.
|
## after the decimal point for Nim's ``float`` type.
|
||||||
result = formatBiggestFloat(f, format, precision)
|
result = formatBiggestFloat(f, format, precision)
|
||||||
|
|
||||||
proc formatSize*(bytes: BiggestInt, decimalSep = '.'): string =
|
proc formatSize*(bytes: BiggestInt, decimalSep = '.'): string =
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nim's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Nimrod Contributors
|
# (c) Copyright 2012 Nim Contributors
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nim's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Nimrod Contributors
|
# (c) Copyright 2012 Nim Contributors
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
|
|
@ -276,11 +276,11 @@ macro `<>`*(x: expr): expr {.immediate.} =
|
||||||
## Constructor macro for XML. Example usage:
|
## Constructor macro for XML. Example usage:
|
||||||
##
|
##
|
||||||
## .. code-block:: nimrod
|
## .. code-block:: nimrod
|
||||||
## <>a(href="http://nimrod-code.org", newText("Nimrod rules."))
|
## <>a(href="http://nimrod-code.org", newText("Nim rules."))
|
||||||
##
|
##
|
||||||
## Produces an XML tree for::
|
## Produces an XML tree for::
|
||||||
##
|
##
|
||||||
## <a href="http://nimrod-code.org">Nimrod rules.</a>
|
## <a href="http://nimrod-code.org">Nim rules.</a>
|
||||||
##
|
##
|
||||||
let x = callsite()
|
let x = callsite()
|
||||||
result = xmlConstructor(x)
|
result = xmlConstructor(x)
|
||||||
|
|
@ -339,5 +339,5 @@ proc findAll*(n: XmlNode, tag: string): seq[XmlNode] =
|
||||||
findAll(n, tag, result)
|
findAll(n, tag, result)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
assert """<a href="http://nimrod-code.org">Nimrod rules.</a>""" ==
|
assert """<a href="http://nimrod-code.org">Nim rules.</a>""" ==
|
||||||
$(<>a(href="http://nimrod-code.org", newText("Nimrod rules.")))
|
$(<>a(href="http://nimrod-code.org", newText("Nim rules.")))
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ proc defined*(x: expr): bool {.magic: "Defined", noSideEffect.}
|
||||||
## `-d:x switch <nimrodc.html#compile-time-symbols>`_ to enable build time
|
## `-d:x switch <nimrodc.html#compile-time-symbols>`_ to enable build time
|
||||||
## conditionals:
|
## conditionals:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## when not defined(release):
|
## when not defined(release):
|
||||||
## # Do here programmer friendly expensive sanity checks.
|
## # Do here programmer friendly expensive sanity checks.
|
||||||
## # Put here the normal code
|
## # Put here the normal code
|
||||||
|
|
@ -123,7 +123,7 @@ proc declared*(x: expr): bool {.magic: "Defined", noSideEffect.}
|
||||||
## This can be used to check whether a library provides a certain
|
## This can be used to check whether a library provides a certain
|
||||||
## feature or not:
|
## feature or not:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## when not defined(strutils.toUpper):
|
## when not defined(strutils.toUpper):
|
||||||
## # provide our own toUpper proc here, because strutils is
|
## # provide our own toUpper proc here, because strutils is
|
||||||
## # missing it.
|
## # missing it.
|
||||||
|
|
@ -320,7 +320,7 @@ type
|
||||||
## of an int. This type is often useful for documentation and debugging.
|
## of an int. This type is often useful for documentation and debugging.
|
||||||
|
|
||||||
RootObj* {.exportc: "TNimObject", inheritable.} =
|
RootObj* {.exportc: "TNimObject", inheritable.} =
|
||||||
object ## the root of Nimrod's object hierarchy. Objects should
|
object ## the root of Nim's object hierarchy. Objects should
|
||||||
## inherit from TObject or one of its descendants. However,
|
## inherit from TObject or one of its descendants. However,
|
||||||
## objects that have no ancestor are allowed.
|
## objects that have no ancestor are allowed.
|
||||||
RootRef* = ref RootObj ## reference to RootObj
|
RootRef* = ref RootObj ## reference to RootObj
|
||||||
|
|
@ -465,7 +465,7 @@ type
|
||||||
## 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**: Nimrod currently does not detect these! See the full
|
## **NOTE**: Nim currently does not detect these! See the full
|
||||||
## `exception hierarchy`_.
|
## `exception hierarchy`_.
|
||||||
DeadThreadError* = object of Exception ## \
|
DeadThreadError* = object of Exception ## \
|
||||||
## 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.
|
||||||
|
|
@ -691,7 +691,7 @@ proc `div` *(x, y: int32): int32 {.magic: "DivI", noSideEffect.}
|
||||||
proc `div` *(x, y: int64): int64 {.magic: "DivI64", noSideEffect.}
|
proc `div` *(x, y: int64): int64 {.magic: "DivI64", noSideEffect.}
|
||||||
## computes the integer division. This is roughly the same as
|
## computes the integer division. This is roughly the same as
|
||||||
## ``floor(x/y)``.
|
## ``floor(x/y)``.
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## 1 div 2 == 0
|
## 1 div 2 == 0
|
||||||
## 2 div 2 == 1
|
## 2 div 2 == 1
|
||||||
## 3 div 2 == 1
|
## 3 div 2 == 1
|
||||||
|
|
@ -710,7 +710,7 @@ proc `shr` *(x, y: int16): int16 {.magic: "ShrI", noSideEffect.}
|
||||||
proc `shr` *(x, y: int32): int32 {.magic: "ShrI", noSideEffect.}
|
proc `shr` *(x, y: int32): int32 {.magic: "ShrI", noSideEffect.}
|
||||||
proc `shr` *(x, y: int64): int64 {.magic: "ShrI64", noSideEffect.}
|
proc `shr` *(x, y: int64): int64 {.magic: "ShrI64", noSideEffect.}
|
||||||
## computes the `shift right` operation of `x` and `y`.
|
## computes the `shift right` operation of `x` and `y`.
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## 0b0001_0000'i8 shr 2 == 0b0100_0000'i8
|
## 0b0001_0000'i8 shr 2 == 0b0100_0000'i8
|
||||||
## 0b1000_0000'i8 shr 2 == 0b0000_0000'i8
|
## 0b1000_0000'i8 shr 2 == 0b0000_0000'i8
|
||||||
## 0b0000_0001'i8 shr 9 == 0b0000_0000'i8
|
## 0b0000_0001'i8 shr 9 == 0b0000_0000'i8
|
||||||
|
|
@ -849,12 +849,12 @@ proc contains*[T](x: set[T], y: T): bool {.magic: "InSet", noSideEffect.}
|
||||||
## One should overload this proc if one wants to overload the ``in`` operator.
|
## One should overload this proc if one wants to overload the ``in`` operator.
|
||||||
## The parameters are in reverse order! ``a in b`` is a template for
|
## The parameters are in reverse order! ``a in b`` is a template for
|
||||||
## ``contains(b, a)``.
|
## ``contains(b, a)``.
|
||||||
## This is because the unification algorithm that Nimrod uses for overload
|
## This is because the unification algorithm that Nim uses for overload
|
||||||
## resolution works from left to right.
|
## resolution works from left to right.
|
||||||
## But for the ``in`` operator that would be the wrong direction for this
|
## But for the ``in`` operator that would be the wrong direction for this
|
||||||
## piece of code:
|
## piece of code:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## var s: set[range['a'..'z']] = {'a'..'c'}
|
## var s: set[range['a'..'z']] = {'a'..'c'}
|
||||||
## writeln(stdout, 'b' in s)
|
## writeln(stdout, 'b' in s)
|
||||||
##
|
##
|
||||||
|
|
@ -868,7 +868,7 @@ proc contains*[T](s: Slice[T], value: T): bool {.noSideEffect, inline.} =
|
||||||
## Checks if `value` is withing the range of `s`; returns true iff
|
## Checks if `value` is withing the range of `s`; returns true iff
|
||||||
## `value >= s.a and value <= s.b`
|
## `value >= s.a and value <= s.b`
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert((1..3).contains(1) == true)
|
## assert((1..3).contains(1) == true)
|
||||||
## assert((1..3).contains(2) == true)
|
## assert((1..3).contains(2) == true)
|
||||||
## assert((1..3).contains(4) == false)
|
## assert((1..3).contains(4) == false)
|
||||||
|
|
@ -877,20 +877,20 @@ proc contains*[T](s: Slice[T], value: T): bool {.noSideEffect, inline.} =
|
||||||
template `in` * (x, y: expr): expr {.immediate.} = contains(y, x)
|
template `in` * (x, y: expr): expr {.immediate.} = contains(y, x)
|
||||||
## Sugar for contains
|
## Sugar for contains
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert(1 in (1..3) == true)
|
## assert(1 in (1..3) == true)
|
||||||
## assert(5 in (1..3) == false)
|
## assert(5 in (1..3) == false)
|
||||||
template `notin` * (x, y: expr): expr {.immediate.} = not contains(y, x)
|
template `notin` * (x, y: expr): expr {.immediate.} = not contains(y, x)
|
||||||
## Sugar for not containing
|
## Sugar for not containing
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert(1 notin (1..3) == false)
|
## assert(1 notin (1..3) == false)
|
||||||
## assert(5 notin (1..3) == true)
|
## assert(5 notin (1..3) == true)
|
||||||
|
|
||||||
proc `is` *[T, S](x: T, y: S): bool {.magic: "Is", noSideEffect.}
|
proc `is` *[T, S](x: T, y: S): bool {.magic: "Is", noSideEffect.}
|
||||||
## Checks if T is of the same type as S
|
## Checks if T is of the same type as S
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## proc test[T](a: T): int =
|
## proc test[T](a: T): int =
|
||||||
## when (T is int):
|
## when (T is int):
|
||||||
## return a
|
## return a
|
||||||
|
|
@ -905,7 +905,7 @@ template `isnot` *(x, y: expr): expr {.immediate.} = not (x is y)
|
||||||
proc `of` *[T, S](x: T, y: S): bool {.magic: "Of", noSideEffect.}
|
proc `of` *[T, S](x: T, y: S): bool {.magic: "Of", noSideEffect.}
|
||||||
## Checks if `x` has a type of `y`
|
## Checks if `x` has a type of `y`
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert(EFloatingPoint of EBase)
|
## assert(EFloatingPoint of EBase)
|
||||||
## assert(EIO of ESystem)
|
## assert(EIO of ESystem)
|
||||||
## assert(EDivByZero of EBase)
|
## assert(EDivByZero of EBase)
|
||||||
|
|
@ -961,25 +961,25 @@ proc `&` * (x: string, y: char): string {.
|
||||||
magic: "ConStrStr", noSideEffect, merge.}
|
magic: "ConStrStr", noSideEffect, merge.}
|
||||||
## Concatenates `x` with `y`
|
## Concatenates `x` with `y`
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert("ab" & 'c' == "abc")
|
## assert("ab" & 'c' == "abc")
|
||||||
proc `&` * (x: char, y: char): string {.
|
proc `&` * (x: char, y: char): string {.
|
||||||
magic: "ConStrStr", noSideEffect, merge.}
|
magic: "ConStrStr", noSideEffect, merge.}
|
||||||
## Concatenates `x` and `y` into a string
|
## Concatenates `x` and `y` into a string
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert('a' & 'b' == "ab")
|
## assert('a' & 'b' == "ab")
|
||||||
proc `&` * (x, y: string): string {.
|
proc `&` * (x, y: string): string {.
|
||||||
magic: "ConStrStr", noSideEffect, merge.}
|
magic: "ConStrStr", noSideEffect, merge.}
|
||||||
## Concatenates `x` and `y`
|
## Concatenates `x` and `y`
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert("ab" & "cd" == "abcd")
|
## assert("ab" & "cd" == "abcd")
|
||||||
proc `&` * (x: char, y: string): string {.
|
proc `&` * (x: char, y: string): string {.
|
||||||
magic: "ConStrStr", noSideEffect, merge.}
|
magic: "ConStrStr", noSideEffect, merge.}
|
||||||
## Concatenates `x` with `y`
|
## Concatenates `x` with `y`
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert('a' & "bc" == "abc")
|
## assert('a' & "bc" == "abc")
|
||||||
|
|
||||||
# implementation note: These must all have the same magic value "ConStrStr" so
|
# implementation note: These must all have the same magic value "ConStrStr" so
|
||||||
|
|
@ -988,7 +988,7 @@ proc `&` * (x: char, y: string): string {.
|
||||||
proc add*(x: var string, y: char) {.magic: "AppendStrCh", noSideEffect.}
|
proc add*(x: var string, y: char) {.magic: "AppendStrCh", noSideEffect.}
|
||||||
## Appends `y` to `x` in place
|
## Appends `y` to `x` in place
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## var tmp = ""
|
## var tmp = ""
|
||||||
## tmp.add('a')
|
## tmp.add('a')
|
||||||
## tmp.add('b')
|
## tmp.add('b')
|
||||||
|
|
@ -996,7 +996,7 @@ proc add*(x: var string, y: char) {.magic: "AppendStrCh", noSideEffect.}
|
||||||
proc add*(x: var string, y: string) {.magic: "AppendStrStr", noSideEffect.}
|
proc add*(x: var string, y: string) {.magic: "AppendStrStr", noSideEffect.}
|
||||||
## Concatenates `x` and `y` in place
|
## Concatenates `x` and `y` in place
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## var tmp = ""
|
## var tmp = ""
|
||||||
## tmp.add("ab")
|
## tmp.add("ab")
|
||||||
## tmp.add("cd")
|
## tmp.add("cd")
|
||||||
|
|
@ -1020,19 +1020,19 @@ const
|
||||||
## ``HH:MM:SS``. This works thanks to compiler magic.
|
## ``HH:MM:SS``. This works thanks to compiler magic.
|
||||||
|
|
||||||
NimVersion* {.magic: "NimrodVersion"}: string = "0.0.0"
|
NimVersion* {.magic: "NimrodVersion"}: string = "0.0.0"
|
||||||
## is the version of Nimrod as a string.
|
## is the version of Nim as a string.
|
||||||
## This works thanks to compiler magic.
|
## This works thanks to compiler magic.
|
||||||
|
|
||||||
NimMajor* {.magic: "NimrodMajor"}: int = 0
|
NimMajor* {.magic: "NimrodMajor"}: int = 0
|
||||||
## is the major number of Nimrod's version.
|
## is the major number of Nim's version.
|
||||||
## This works thanks to compiler magic.
|
## This works thanks to compiler magic.
|
||||||
|
|
||||||
NimMinor* {.magic: "NimrodMinor"}: int = 0
|
NimMinor* {.magic: "NimrodMinor"}: int = 0
|
||||||
## is the minor number of Nimrod's version.
|
## is the minor number of Nim's version.
|
||||||
## This works thanks to compiler magic.
|
## This works thanks to compiler magic.
|
||||||
|
|
||||||
NimPatch* {.magic: "NimrodPatch"}: int = 0
|
NimPatch* {.magic: "NimrodPatch"}: int = 0
|
||||||
## is the patch number of Nimrod's version.
|
## is the patch number of Nim's version.
|
||||||
## This works thanks to compiler magic.
|
## This works thanks to compiler magic.
|
||||||
|
|
||||||
cpuEndian* {.magic: "CpuEndian"}: Endianness = littleEndian
|
cpuEndian* {.magic: "CpuEndian"}: Endianness = littleEndian
|
||||||
|
|
@ -1145,7 +1145,7 @@ proc add *[T](x: var seq[T], y: openArray[T]) {.noSideEffect.} =
|
||||||
## Generic proc for adding a data item `y` to a container `x`.
|
## Generic proc for adding a data item `y` to a container `x`.
|
||||||
## For containers that have an order, `add` means *append*. New generic
|
## For containers that have an order, `add` means *append*. New generic
|
||||||
## containers should also call their adding proc `add` for consistency.
|
## containers should also call their adding proc `add` for consistency.
|
||||||
## Generic code becomes much easier to write if the Nimrod naming scheme is
|
## Generic code becomes much easier to write if the Nim naming scheme is
|
||||||
## respected.
|
## respected.
|
||||||
let xl = x.len
|
let xl = x.len
|
||||||
setLen(x, xl + y.len)
|
setLen(x, xl + y.len)
|
||||||
|
|
@ -1183,7 +1183,7 @@ proc insert*[T](x: var seq[T], item: T, i = 0) {.noSideEffect.} =
|
||||||
x[i] = item
|
x[i] = item
|
||||||
|
|
||||||
proc repr*[T](x: T): string {.magic: "Repr", noSideEffect.}
|
proc repr*[T](x: T): string {.magic: "Repr", noSideEffect.}
|
||||||
## takes any Nimrod variable and returns its string representation. It
|
## takes any Nim variable and returns its string representation. It
|
||||||
## works even for complex data graphs with cycles. This is a great
|
## works even for complex data graphs with cycles. This is a great
|
||||||
## debugging tool.
|
## debugging tool.
|
||||||
|
|
||||||
|
|
@ -1193,12 +1193,12 @@ type
|
||||||
## pointers to integer addresses for readability.
|
## pointers to integer addresses for readability.
|
||||||
|
|
||||||
BiggestInt* = int64
|
BiggestInt* = int64
|
||||||
## is an alias for the biggest signed integer type the Nimrod compiler
|
## is an alias for the biggest signed integer type the Nim compiler
|
||||||
## supports. Currently this is ``int64``, but it is platform-dependant
|
## supports. Currently this is ``int64``, but it is platform-dependant
|
||||||
## in general.
|
## in general.
|
||||||
|
|
||||||
BiggestFloat* = float64
|
BiggestFloat* = float64
|
||||||
## is an alias for the biggest floating point type the Nimrod
|
## is an alias for the biggest floating point type the Nim
|
||||||
## compiler supports. Currently this is ``float64``, but it is
|
## compiler supports. Currently this is ``float64``, but it is
|
||||||
## platform-dependant in general.
|
## platform-dependant in general.
|
||||||
|
|
||||||
|
|
@ -1236,7 +1236,7 @@ type # these work for most platforms:
|
||||||
## This is the same as the type ``double`` in *C*.
|
## This is the same as the type ``double`` in *C*.
|
||||||
clongdouble* {.importc: "long double", nodecl.} = BiggestFloat
|
clongdouble* {.importc: "long double", nodecl.} = BiggestFloat
|
||||||
## This is the same as the type ``long double`` in *C*.
|
## This is the same as the type ``long double`` in *C*.
|
||||||
## This C type is not supported by Nimrod's code generator
|
## This C type is not supported by Nim's code generator
|
||||||
|
|
||||||
cuchar* {.importc: "unsigned char", nodecl.} = char
|
cuchar* {.importc: "unsigned char", nodecl.} = char
|
||||||
## This is the same as the type ``unsigned char`` in *C*.
|
## This is the same as the type ``unsigned char`` in *C*.
|
||||||
|
|
@ -1590,7 +1590,7 @@ iterator `||`*[S, T](a: S, b: T, annotation=""): T {.
|
||||||
## Note that the compiler maps that to
|
## Note that the compiler maps that to
|
||||||
## the ``#pragma omp parallel for`` construct of `OpenMP`:idx: and as
|
## the ``#pragma omp parallel for`` construct of `OpenMP`:idx: and as
|
||||||
## such isn't aware of the parallelism in your code! Be careful! Later
|
## such isn't aware of the parallelism in your code! Be careful! Later
|
||||||
## versions of ``||`` will get proper support by Nimrod's code generator
|
## versions of ``||`` will get proper support by Nim's code generator
|
||||||
## and GC.
|
## and GC.
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
|
@ -1642,7 +1642,7 @@ proc max*(x, y: float): float {.magic: "MaxF64", noSideEffect.} =
|
||||||
proc clamp*[T](x, a, b: T): T =
|
proc clamp*[T](x, a, b: T): T =
|
||||||
## limits the value ``x`` within the interval [a, b]
|
## limits the value ``x`` within the interval [a, b]
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert((1.4).clamp(0.0, 1.0) == 1.0)
|
## assert((1.4).clamp(0.0, 1.0) == 1.0)
|
||||||
## assert((0.5).clamp(0.0, 1.0) == 0.5)
|
## assert((0.5).clamp(0.0, 1.0) == 0.5)
|
||||||
if x < a: return a
|
if x < a: return a
|
||||||
|
|
@ -1746,7 +1746,7 @@ proc `&` *[T](x, y: seq[T]): seq[T] {.noSideEffect.} =
|
||||||
## Concatenates two sequences.
|
## Concatenates two sequences.
|
||||||
## Requires copying of the sequences.
|
## Requires copying of the sequences.
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert(@[1, 2, 3, 4] & @[5, 6] == @[1, 2, 3, 4, 5, 6])
|
## assert(@[1, 2, 3, 4] & @[5, 6] == @[1, 2, 3, 4, 5, 6])
|
||||||
newSeq(result, x.len + y.len)
|
newSeq(result, x.len + y.len)
|
||||||
for i in 0..x.len-1:
|
for i in 0..x.len-1:
|
||||||
|
|
@ -1758,7 +1758,7 @@ proc `&` *[T](x: seq[T], y: T): seq[T] {.noSideEffect.} =
|
||||||
## Appends element y to the end of the sequence.
|
## Appends element y to the end of the sequence.
|
||||||
## Requires copying of the sequence
|
## Requires copying of the sequence
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert(@[1, 2, 3] & 4 == @[1, 2, 3, 4])
|
## assert(@[1, 2, 3] & 4 == @[1, 2, 3, 4])
|
||||||
newSeq(result, x.len + 1)
|
newSeq(result, x.len + 1)
|
||||||
for i in 0..x.len-1:
|
for i in 0..x.len-1:
|
||||||
|
|
@ -1769,7 +1769,7 @@ proc `&` *[T](x: T, y: seq[T]): seq[T] {.noSideEffect.} =
|
||||||
## Prepends the element x to the beginning of the sequence.
|
## Prepends the element x to the beginning of the sequence.
|
||||||
## Requires copying of the sequence
|
## Requires copying of the sequence
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## assert(1 & @[2, 3, 4] == @[1, 2, 3, 4])
|
## assert(1 & @[2, 3, 4] == @[1, 2, 3, 4])
|
||||||
newSeq(result, y.len + 1)
|
newSeq(result, y.len + 1)
|
||||||
result[0] = x
|
result[0] = x
|
||||||
|
|
@ -1883,7 +1883,7 @@ iterator fieldPairs*[T: tuple|object](x: T): RootObj {.
|
||||||
## you want to run for each type. To perform the comparison use the `is
|
## you want to run for each type. To perform the comparison use the `is
|
||||||
## operator <manual.html#is-operator>`_. Example:
|
## operator <manual.html#is-operator>`_. Example:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
##
|
##
|
||||||
## type
|
## type
|
||||||
## Custom = object
|
## Custom = object
|
||||||
|
|
@ -2946,7 +2946,7 @@ when true:
|
||||||
template assert*(cond: bool, msg = "") =
|
template assert*(cond: bool, msg = "") =
|
||||||
## Raises ``EAssertionFailure`` with `msg` if `cond` is false.
|
## Raises ``EAssertionFailure`` with `msg` if `cond` is false.
|
||||||
##
|
##
|
||||||
## Provides a means to implement `programming by contracts`:idx: in Nimrod.
|
## Provides a means to implement `programming by contracts`:idx: in Nim.
|
||||||
## ``assert`` evaluates expression ``cond`` and if ``cond`` is false, it
|
## ``assert`` evaluates expression ``cond`` and if ``cond`` is false, it
|
||||||
## raises an ``EAssertionFailure`` exception. However, the compiler may not
|
## raises an ``EAssertionFailure`` exception. However, the compiler may not
|
||||||
## generate any code at all for ``assert`` if it is advised to do so through
|
## generate any code at all for ``assert`` if it is advised to do so through
|
||||||
|
|
@ -3031,7 +3031,7 @@ proc shallow*(s: var string) {.noSideEffect, inline.} =
|
||||||
type
|
type
|
||||||
TNimrodNode {.final.} = object
|
TNimrodNode {.final.} = object
|
||||||
PNimrodNode* {.magic: "PNimrodNode".} = ref TNimrodNode
|
PNimrodNode* {.magic: "PNimrodNode".} = ref TNimrodNode
|
||||||
## represents a Nimrod AST node. Macros operate on this type.
|
## represents a Nim AST node. Macros operate on this type.
|
||||||
|
|
||||||
when false:
|
when false:
|
||||||
template eval*(blk: stmt): stmt =
|
template eval*(blk: stmt): stmt =
|
||||||
|
|
@ -3060,7 +3060,7 @@ proc compiles*(x): bool {.magic: "Compiles", noSideEffect.} =
|
||||||
## without any semantic error.
|
## without any semantic error.
|
||||||
## This can be used to check whether a type supports some operation:
|
## This can be used to check whether a type supports some operation:
|
||||||
##
|
##
|
||||||
## .. code-block:: Nimrod
|
## .. code-block:: Nim
|
||||||
## when not compiles(3 + 4):
|
## when not compiles(3 + 4):
|
||||||
## echo "'+' for integers is available"
|
## echo "'+' for integers is available"
|
||||||
discard
|
discard
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2006 Andreas Rumpf
|
# (c) Copyright 2006 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2006 Andreas Rumpf
|
# (c) Copyright 2006 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2009 Andreas Rumpf
|
# (c) Copyright 2009 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2006 Andreas Rumpf
|
# (c) Copyright 2006 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2006 Andreas Rumpf
|
# (c) Copyright 2006 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2010 Andreas Rumpf
|
# (c) Copyright 2010 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
## This module implements a small wrapper for some needed Win API procedures,
|
## This module implements a small wrapper for some needed Win API procedures,
|
||||||
## so that the Nimrod compiler does not depend on the huge Windows module.
|
## so that the Nim compiler does not depend on the huge Windows module.
|
||||||
|
|
||||||
const
|
const
|
||||||
useWinUnicode* = not defined(useWinAnsi)
|
useWinUnicode* = not defined(useWinAnsi)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2010 Andreas Rumpf
|
# (c) Copyright 2010 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
# did not, you can find it at http://www.gnu.org/
|
# did not, you can find it at http://www.gnu.org/
|
||||||
#
|
#
|
||||||
|
|
||||||
## Nimrod wrapper for ``sphinx``.
|
## Nim wrapper for ``sphinx``.
|
||||||
|
|
||||||
{.deadCodeElim: on.}
|
{.deadCodeElim: on.}
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2012 Andreas Rumpf
|
# (c) Copyright 2012 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2010 Andreas Rumpf
|
# (c) Copyright 2010 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2013 Andreas Rumpf
|
# (c) Copyright 2013 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Nimrod's Runtime Library
|
# Nim's Runtime Library
|
||||||
# (c) Copyright 2008 Andreas Rumpf
|
# (c) Copyright 2008 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue