complete std prefixes for stdlib (#22887)

follow up https://github.com/nim-lang/Nim/pull/22851
follow up https://github.com/nim-lang/Nim/pull/22873
This commit is contained in:
ringabout
2023-10-31 00:03:04 +08:00
committed by GitHub
parent 403e0118ae
commit 4d11d0619d
142 changed files with 277 additions and 275 deletions

View File

@@ -893,7 +893,7 @@ on what keywords are present. Let's start with the simplest form.
Concrete syntax:
```nim
import math
import std/math
```
AST:
@@ -907,7 +907,7 @@ With ``except``, we get ``nnkImportExceptStmt``.
Concrete syntax:
```nim
import math except pow
import std/math except pow
```
AST:
@@ -916,13 +916,13 @@ AST:
nnkImportExceptStmt(nnkIdent("math"),nnkIdent("pow"))
```
Note that ``import math as m`` does not use a different node; rather,
Note that ``import std/math as m`` does not use a different node; rather,
we use ``nnkImportStmt`` with ``as`` as an infix operator.
Concrete syntax:
```nim
import strutils as su
import std/strutils as su
```
AST:
@@ -945,7 +945,7 @@ If we use ``from ... import``, the result is different, too.
Concrete syntax:
```nim
from math import pow
from std/math import pow
```
AST:
@@ -954,7 +954,7 @@ AST:
nnkFromStmt(nnkIdent("math"), nnkIdent("pow"))
```
Using ``from math as m import pow`` works identically to the ``as`` modifier
Using ``from std/math as m import pow`` works identically to the ``as`` modifier
with the ``import`` statement, but wrapped in ``nnkFromStmt``.
Export statement

View File

@@ -1,6 +1,6 @@
## This module is a sample.
import strutils
import std/strutils
proc helloWorld*(times: int) =
## Takes an integer and outputs

View File

@@ -28,7 +28,7 @@ Otherwise your program is profiled.
```nim
when compileOption("profiler"):
import nimprof
import std/nimprof
```
After your program has finished the profiler will create a

View File

@@ -655,7 +655,7 @@ string containing the literal. The callable identifier needs to be declared
with a special ``'`` prefix:
```nim
import strutils
import std/strutils
type u4 = distinct uint8 # a 4-bit unsigned integer aka "nibble"
proc `'u4`(n: string): u4 =
# The leading ' is required.
@@ -670,7 +670,7 @@ corresponds to this transformation. The transformation naturally handles
the case that additional parameters are passed to the callee:
```nim
import strutils
import std/strutils
type u4 = distinct uint8 # a 4-bit unsigned integer aka "nibble"
proc `'u4`(n: string; moreData: int): u4 =
result = (parseInt(n) and 0x0F).u4
@@ -5231,7 +5231,7 @@ conservative in its effect analysis:
```nim test = "nim c $1" status = 1
{.push warningAsError[Effect]: on.}
import algorithm
import std/algorithm
type
MyInt = distinct int

View File

@@ -1368,7 +1368,7 @@ to be computed dynamically.
```nim
{.experimental: "dynamicBindSym".}
import macros
import std/macros
macro callOp(opName, arg1, arg2): untyped =
result = newCall(bindSym($opName), arg1, arg2)

View File

@@ -11,7 +11,7 @@
when defined(hotcodereloading):
import
macros
std/macros
template beforeCodeReload*(body: untyped) =
hcrAddEventHandler(true, proc = body) {.executeOnReload.}

View File

@@ -2,5 +2,5 @@
{.deprecated: "Use the new 'sugar' module instead".}
import sugar
import std/sugar
export sugar

View File

@@ -11,7 +11,7 @@
{.deprecated: "use `std/os` instead".}
import os
import std/os
export ReadEnvEffect, WriteEnvEffect, ReadDirEffect, WriteDirEffect, OSErrorCode,
doslikeFileSystem, CurDir, ParDir, DirSep, AltSep, PathSep, FileSystemCaseSensitive,
ExeExt, ScriptExt, DynlibFormat, ExtSep, joinPath, `/`, splitPath, parentDir,

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
## This module is deprecated, `import os` instead.
{.deprecated: "import os.nim instead".}
import os
## This module is deprecated, `import std/os` instead.
{.deprecated: "import 'std/os' instead".}
import std/os
export PathComponent, walkDir, walkDirRec

View File

@@ -43,7 +43,7 @@ jkl"""
# "An O(ND) Difference Algorithm and its Variations" by Eugene Myers
# Algorithmica Vol. 1 No. 2, 1986, p 251.
import tables, strutils
import std/[tables, strutils]
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -61,12 +61,12 @@ runnableExamples:
assert find("uxabc", re"(?<=x|y)ab", start = 1).get.captures[-1] == "ab"
assert find("uxabc", re"ab", start = 3).isNone
from pcre import nil
from std/pcre import nil
import nre/private/util
import tables
from strutils import `%`
import options
from unicode import runeLenAt
import std/tables
from std/strutils import `%`
import std/options
from std/unicode import runeLenAt
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -1,5 +1,5 @@
## INTERNAL FILE FOR USE ONLY BY nre.nim.
import tables
import std/tables
const Ident = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\128'..'\255'}
const StartIdent = Ident - {'0'..'9'}

View File

@@ -55,7 +55,7 @@ elif defined(genode):
stdin.readLine(line)
else:
import linenoise
import std/linenoise
proc readLineFromStdin*(prompt: string, line: var string): bool {.
tags: [ReadIOEffect, WriteIOEffect].} =

View File

@@ -36,7 +36,7 @@ runnableExamples:
# can't match start of string since we're starting at 1
import
pcre, strutils, rtarrays
std/[pcre, strutils, rtarrays]
when defined(nimPreviewSlimSystem):
import std/syncio

View File

@@ -219,7 +219,7 @@ when defined(createNimHcr):
when system.appType != "lib":
{.error: "This file has to be compiled as a library!".}
import os, tables, sets, times, strutils, reservedmem, dynlib
import std/[os, tables, sets, times, strutils, reservedmem, dynlib]
template trace(args: varargs[untyped]) =
when defined(testNimHcr) or defined(traceHcr):

View File

@@ -36,5 +36,5 @@ when not defined(createNimRtl):
{.error: "This file has to be compiled with '-d:createNimRtl'".}
import
parseutils, strutils, parseopt, parsecfg, strtabs, unicode, pegs, ropes,
os, osproc, times, cstrutils
std/[parseutils, strutils, parseopt, parsecfg, strtabs, unicode, pegs, ropes,
os, osproc, times, cstrutils]

View File

@@ -13,7 +13,8 @@
## `type LangSymbol`_ in ``rst.nim``, while `match(generated, docLink)`_
## matches it with `generated`, produced from `PNode` by ``docgen.rst``.
import rstast, strutils
import rstast
import std/strutils
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]

View File

@@ -57,8 +57,8 @@
## as program output.
import
strutils
from algorithm import binarySearch
std/strutils
from std/algorithm import binarySearch
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]

View File

@@ -21,8 +21,10 @@
## turned on by passing ``options:`` [RstParseOptions] to [proc rstParse].
import
os, strutils, rstast, dochelpers, std/enumutils, algorithm, lists, sequtils,
std/private/miscdollars, tables, strscans, rstidx
std/[os, strutils, enumutils, algorithm, lists, sequtils,
tables, strscans]
import dochelpers, rstidx, rstast
import std/private/miscdollars
from highlite import SourceLanguage, getSourceLanguage
when defined(nimPreviewSlimSystem):

View File

@@ -9,7 +9,7 @@
## This module implements an AST for the `reStructuredText`:idx: parser.
import strutils, json
import std/[strutils, json]
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -39,10 +39,10 @@
## No backreferences are generated since finding all references of a footnote
## can be done by simply searching for ``[footnoteName]``.
import strutils, os, hashes, strtabs, rstast, rst, rstidx,
highlite, tables, sequtils,
algorithm, parseutils, std/strbasics
import std/[strutils, os, hashes, strtabs, tables, sequtils,
algorithm, parseutils, strbasics]
import rstast, rst, rstidx, highlite
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio, formatfloat]

View File

@@ -7,8 +7,8 @@
## Nim `idx`:idx: file format related definitions.
import strutils, std/syncio, hashes
from os import splitFile
import std/[strutils, syncio, hashes]
from std/os import splitFile
type
IndexEntryKind* = enum ## discriminator tag

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
from posix import SocketHandle
from std/posix import SocketHandle
const
EPOLLIN* = 0x00000001

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
from posix import Timespec
from std/posix import Timespec
when defined(macosx) or defined(freebsd) or defined(openbsd) or
defined(dragonfly):

View File

@@ -1,4 +1,4 @@
import posix
import std/posix
## Flags of `clone` syscall.
## See `clone syscall manual

View File

@@ -11,7 +11,7 @@
# Where possible, contribute OS-independent procs in `os <os.html>`_ instead.
import posix, parsecfg, os
import std/[posix, parsecfg, os]
import std/private/since
when defined(nimPreviewSlimSystem):

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
import posix
import std/posix
type
Speed* = cuint

View File

@@ -2,8 +2,8 @@
## and [asyncjs](asyncjs.html) on the JS backend.
when defined(js):
import asyncjs
import std/asyncjs
export asyncjs
else:
import asyncmacro, asyncfutures
import std/[asyncmacro, asyncfutures]
export asyncmacro, asyncfutures

View File

@@ -226,11 +226,11 @@
## ``none`` can be used when a library supports both a synchronous and
## asynchronous API, to disable the latter.
import os, tables, strutils, times, heapqueue, options, asyncstreams
import options, math, std/monotimes
import asyncfutures except callSoon
import std/[os, tables, strutils, times, heapqueue, options, asyncstreams]
import std/[math, monotimes]
import std/asyncfutures except callSoon
import nativesockets, net, deques
import std/[nativesockets, net, deques]
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
@@ -302,7 +302,7 @@ template implementSetInheritable() {.dirty.} =
fd.FileHandle.setInheritable(inheritable)
when defined(windows) or defined(nimdoc):
import winlean, sets, hashes
import std/[winlean, sets, hashes]
type
CompletionKey = ULONG_PTR
@@ -1166,11 +1166,11 @@ when defined(windows) or defined(nimdoc):
initAll()
else:
import selectors
from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
import std/selectors
from std/posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
MSG_NOSIGNAL
when declared(posix.accept4):
from posix import accept4, SOCK_CLOEXEC
from std/posix import accept4, SOCK_CLOEXEC
when defined(genode):
import genode/env # get the implicit Genode env
import genode/signals
@@ -1994,7 +1994,7 @@ proc send*(socket: AsyncFD, data: string,
return retFuture
# -- Await Macro
import asyncmacro
import std/asyncmacro
export asyncmacro
proc readAll*(future: FutureStream[string]): owned(Future[string]) {.async.} =
@@ -2032,7 +2032,7 @@ proc activeDescriptors*(): int {.inline.} =
result = getGlobalDispatcher().selector.count
when defined(posix):
import posix
import std/posix
when defined(linux) or defined(windows) or defined(macosx) or defined(bsd) or
defined(solaris) or defined(zephyr) or defined(freertos) or defined(nuttx) or defined(haiku):

View File

@@ -23,7 +23,7 @@
## waitFor main()
## ```
import asyncdispatch, os
import std/[asyncdispatch, os]
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
@@ -33,9 +33,9 @@ when defined(nimPreviewSlimSystem):
# TODO: Fix duplication introduced by PR #4683.
when defined(windows) or defined(nimdoc):
import winlean
import std/winlean
else:
import posix
import std/posix
type
AsyncFile* = ref object

View File

@@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#
import os, tables, strutils, times, heapqueue, options, deques, cstrutils
import std/[os, tables, strutils, times, heapqueue, options, deques, cstrutils]
import system/stacktraces
@@ -51,7 +51,7 @@ const
NimAsyncContinueSuffix* = "NimAsyncContinue" ## For internal usage. Do not use.
when isFutureLoggingEnabled:
import hashes
import std/hashes
type
FutureInfo* = object
stackTrace*: seq[StackTraceEntry]

View File

@@ -39,9 +39,9 @@ runnableExamples("-r:off"):
waitFor main()
import asyncnet, asyncdispatch, parseutils, uri, strutils
import httpcore
from nativesockets import getLocalAddr, Domain, AF_INET, AF_INET6
import std/[asyncnet, asyncdispatch, parseutils, uri, strutils]
import std/httpcore
from std/nativesockets import getLocalAddr, Domain, AF_INET, AF_INET6
import std/private/since
when defined(nimPreviewSlimSystem):

View File

@@ -9,7 +9,7 @@
## Implements the `async` and `multisync` macros for `asyncdispatch`.
import macros, strutils, asyncfutures
import std/[macros, strutils, asyncfutures]
type
Context = ref object

View File

@@ -99,7 +99,7 @@ import std/private/since
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
import asyncdispatch, nativesockets, net, os
import std/[asyncdispatch, nativesockets, net, os]
export SOBool
@@ -110,7 +110,7 @@ const useNimNetLite = defined(nimNetLite) or defined(freertos) or defined(zephyr
defined(nuttx)
when defineSsl:
import openssl
import std/openssl
type
# TODO: I would prefer to just do:

View File

@@ -9,12 +9,12 @@
## Unstable API.
import asyncfutures
import std/asyncfutures
when defined(nimPreviewSlimSystem):
import std/assertions
import deques
import std/deques
type
FutureStream*[T] = ref object ## Special future that acts as

View File

@@ -25,7 +25,7 @@
## At this time only `fastLog2`, `firstSetBit`, `countLeadingZeroBits` and `countTrailingZeroBits`
## may return undefined and/or platform dependent values if given invalid input.
import macros
import std/macros
import std/private/since
from std/private/bitops_utils import forwardImpl, castToUnsigned

View File

@@ -14,20 +14,20 @@
import std/private/since
import strutils
import std/strutils
when defined(nimPreviewSlimSystem):
import std/assertions
when defined(windows):
import winlean
import std/winlean
when defined(nimPreviewSlimSystem):
import std/widestrs
from os import absolutePath
from std/os import absolutePath
else:
import os
import std/os
when not defined(osx):
import osproc
import std/osproc
const osOpenCmd* =
when defined(macos) or defined(macosx) or defined(windows): "open" else: "xdg-open" ## \

View File

@@ -29,7 +29,7 @@
## writeLine(stdout, "</body></html>")
## ```
import strutils, os, strtabs, cookies, uri
import std/[strutils, os, strtabs, cookies, uri]
export uri.encodeUrl, uri.decodeUrl
when defined(nimPreviewSlimSystem):

View File

@@ -50,7 +50,7 @@ runnableExamples:
import std/private/since
import math
import std/math
type
Deque*[T] = object

View File

@@ -82,8 +82,8 @@ runnableExamples:
import std/private/since
import macros
from typetraits import supportsCopyMem
import std/macros
from std/typetraits import supportsCopyMem
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -50,7 +50,7 @@
import
hashes, math
std/[hashes, math]
when not defined(nimHasEffectsOf):
{.pragma: effectsOf.}

View File

@@ -16,7 +16,7 @@
{.push stackTrace: off.}
import
locks
std/locks
const
ElemsPerNode = 100

View File

@@ -17,7 +17,7 @@
{.deprecated.}
import
hashes, math, locks
std/[hashes, math, locks]
type
KeyValuePair[A, B] = tuple[hcode: Hash, key: A, val: B]

View File

@@ -194,7 +194,7 @@ runnableExamples:
import std/private/since
import hashes, math, algorithm
import std/[hashes, math, algorithm]
when not defined(nimHasEffectsOf):

View File

@@ -9,8 +9,8 @@
## This module implements color handling for Nim,
## namely color mixing and parsing the CSS color names.
import strutils
from algorithm import binarySearch
import std/strutils
from std/algorithm import binarySearch
type
Color* = distinct int ## A color stored as RGB, e.g. `0xff00cc`.

View File

@@ -36,7 +36,7 @@ runnableExamples:
{.push checks: off, line_dir: off, stack_trace: off, debugger: off.}
# the user does not want to trace a part of the standard library!
import math
import std/math
type
Complex*[T: SomeFloat] = object

View File

@@ -16,7 +16,7 @@ runnableExamples:
include "system/inclrtl"
when defined(posix) and not (defined(macosx) or defined(bsd)):
import posix
import std/posix
when defined(windows):
import std/private/win_getsysteminfo

View File

@@ -13,11 +13,11 @@
## Unstable API.
when defined(windows):
import winlean, os, strutils, math
import std/[winlean, os, strutils, math]
proc `-`(a, b: FILETIME): int64 = a.rdFileTime - b.rdFileTime
elif defined(linux):
from cpuinfo import countProcessors
from std/cpuinfo import countProcessors
when defined(nimPreviewSlimSystem):
import std/syncio
@@ -87,7 +87,7 @@ proc advice*(s: var ThreadPoolState): ThreadPoolAdvice =
inc s.calls
when not defined(testing) and isMainModule and not defined(nimdoc):
import random
import std/random
proc busyLoop() =
while true:

View File

@@ -22,7 +22,7 @@
when not compileOption("threads"):
{.error: "Threadpool requires --threads:on option.".}
import cpuinfo, cpuload, locks, os
import std/[cpuinfo, cpuload, locks, os]
when defined(nimPreviewSlimSystem):
import std/[assertions, typedthreads, sysatomics]

View File

@@ -9,7 +9,7 @@
## This module implements helper procs for parsing Cookies.
import strtabs, times, options
import std/[strtabs, times, options]
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -29,8 +29,7 @@ when not nimCoroutines and not defined(nimdoc):
else:
{.error: "Coroutines require -d:nimCoroutines".}
import os
import lists
import std/[os, lists]
include system/timers
when defined(nimPreviewSlimSystem):
@@ -68,7 +67,7 @@ else:
const coroBackend = CORO_BACKEND_UCONTEXT
when coroBackend == CORO_BACKEND_FIBERS:
import windows/winlean
import std/winlean
type
Context = pointer

View File

@@ -105,7 +105,7 @@ when defined(posix) and not defined(nintendoswitch):
# as an emulation layer on top of native functions.
# =========================================================================
#
import posix
import std/posix
proc loadLib(path: string, globalSymbols = false): LibHandle =
let flags =

View File

@@ -39,7 +39,7 @@ runnableExamples:
assert fromGB2312.convert(second) == "有白头如新,倾盖如故"
import os
import std/os
when defined(nimPreviewSlimSystem):
import std/assertions
@@ -59,7 +59,7 @@ type
## for encoding errors.
when defined(windows):
import parseutils, strutils
import std/[parseutils, strutils]
proc eqEncodingNames(a, b: string): bool =
var i = 0
var j = 0

View File

@@ -8,7 +8,7 @@
#
## Do yourself a favor and import the module
## as `from htmlgen import nil` and then fully qualify the macros.
## as `from std/htmlgen import nil` and then fully qualify the macros.
##
## *Note*: The Karax project (`nimble install karax`) has a better
## way to achieve the same, see https://github.com/pragmagic/karax/blob/master/tests/nativehtmlgen.nim
@@ -41,7 +41,7 @@
##
import
macros, strutils
std/[macros, strutils]
const
coreAttr* = " accesskey class contenteditable dir hidden id lang " &

View File

@@ -49,7 +49,7 @@
{.deprecated: "use `nimble install htmlparser` and import `pkg/htmlparser` instead".}
import strutils, streams, parsexml, xmltree, unicode, strtabs
import std/[strutils, streams, parsexml, xmltree, unicode, strtabs]
when defined(nimPreviewSlimSystem):
import std/syncio
@@ -2064,7 +2064,7 @@ proc loadHtml*(path: string): XmlNode =
result = loadHtml(path, errors)
when not defined(testing) and isMainModule:
import os
import std/os
var errors: seq[string] = @[]
var x = loadHtml(paramStr(1), errors)

View File

@@ -12,7 +12,7 @@
##
## Unstable API.
import std/private/since
import tables, strutils, parseutils
import std/[tables, strutils, parseutils]
type
HttpHeaders* = ref object

View File

@@ -9,7 +9,7 @@
# This module implements Linux epoll().
import posix, times, epoll
import std/[posix, times, epoll]
# Maximum number of events that can be returned
const MAX_EPOLL_EVENTS = 64

View File

@@ -9,7 +9,7 @@
# This module implements BSD kqueue().
import posix, times, kqueue, nativesockets
import std/[posix, times, kqueue, nativesockets]
const
# Maximum number of events that can be returned.

View File

@@ -9,7 +9,7 @@
# This module implements Posix poll().
import posix, times
import std/[posix, times]
# Maximum number of events that can be returned
const MAX_POLL_EVENTS = 64

View File

@@ -9,10 +9,10 @@
# This module implements Posix and Windows select().
import times, nativesockets
import std/[times, nativesockets]
when defined(windows):
import winlean
import std/winlean
when defined(gcc):
{.passl: "-lws2_32".}
elif defined(vcc):

View File

@@ -165,9 +165,9 @@ runnableExamples:
a1, a2, a0, a3, a4: int
doAssert $(%* Foo()) == """{"a1":0,"a2":0,"a0":0,"a3":0,"a4":0}"""
import hashes, tables, strutils, lexbase, streams, macros, parsejson
import std/[hashes, tables, strutils, lexbase, streams, macros, parsejson]
import options # xxx remove this dependency using same approach as https://github.com/nim-lang/Nim/pull/14563
import std/options # xxx remove this dependency using same approach as https://github.com/nim-lang/Nim/pull/14563
import std/private/since
when defined(nimPreviewSlimSystem):
@@ -549,7 +549,7 @@ proc `[]`*[U, V](a: JsonNode, x: HSlice[U, V]): JsonNode =
##
## Returns the inclusive range `[a[x.a], a[x.b]]`:
runnableExamples:
import json
import std/json
let arr = %[0,1,2,3,4,5]
doAssert arr[2..4] == %[2,3,4]
doAssert arr[2..^2] == %[2,3,4]
@@ -965,7 +965,7 @@ proc parseJson*(s: Stream, filename: string = ""; rawIntegers = false, rawFloats
p.close()
when defined(js):
from math import `mod`
from std/math import `mod`
from std/jsffi import JsObject, `[]`, to
from std/private/jsutils import getProtoName, isInteger, isSafeInteger
@@ -1366,7 +1366,7 @@ proc to*[T](node: JsonNode, t: typedesc[T]): T =
initFromJson(result, node, jsonPath)
when false:
import os
import std/os
var s = newFileStream(paramStr(1), fmRead)
if s == nil: quit("cannot open the file" & paramStr(1))
var x: JsonParser

View File

@@ -12,7 +12,7 @@
## needs refilling.
import
strutils, streams
std/[strutils, streams]
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -146,9 +146,9 @@
## * `strscans module<strscans.html>`_ for ``scanf`` and ``scanp`` macros, which
## offer easier substring extraction than regular expressions
import strutils, times
import std/[strutils, times]
when not defined(js):
import os
import std/os
when defined(nimPreviewSlimSystem):
import std/syncio

View File

@@ -54,7 +54,7 @@ Please use alternative packages for serialization.
It is possible to reimplement this module using generics and type traits.
Please contribute a new implementation.""".}
import streams, typeinfo, json, intsets, tables, unicode
import std/[streams, typeinfo, json, intsets, tables, unicode]
when defined(nimPreviewSlimSystem):
import std/[assertions, formatfloat]

View File

@@ -57,7 +57,7 @@ import std/private/since
{.push debugger: off.} # the user does not want to trace a part
# of the standard library!
import bitops, fenv
import std/[bitops, fenv]
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -16,15 +16,15 @@
## other "line-like", variable length, delimited records).
when defined(windows):
import winlean
import std/winlean
when defined(nimPreviewSlimSystem):
import std/widestrs
elif defined(posix):
import posix
import std/posix
else:
{.error: "the memfiles module is not supported on your operating system!".}
import streams
import std/streams
import std/oserrors
when defined(nimPreviewSlimSystem):

View File

@@ -26,8 +26,8 @@ runnableExamples:
doAssert m.getMimetype("fakext") == "text/fakelang"
doAssert m.getMimetype("FaKeXT") == "text/fakelang"
import tables
from strutils import startsWith, toLowerAscii, strip
import std/tables
from std/strutils import startsWith, toLowerAscii, strip
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -12,7 +12,7 @@
# TODO: Clean up the exports a bit and everything else in general.
import os, options
import std/[os, options]
import std/private/since
import std/strbasics
@@ -27,12 +27,12 @@ const useNimNetLite = defined(nimNetLite) or defined(freertos) or defined(zephyr
defined(nuttx)
when useWinVersion:
import winlean
import std/winlean
export WSAEWOULDBLOCK, WSAECONNRESET, WSAECONNABORTED, WSAENETRESET,
WSANOTINITIALISED, WSAENOTSOCK, WSAEINPROGRESS, WSAEINTR,
WSAEDISCON, ERROR_NETNAME_DELETED
else:
import posix
import std/posix
export fcntl, F_GETFL, O_NONBLOCK, F_SETFL, EAGAIN, EWOULDBLOCK, MSG_NOSIGNAL,
EINTR, EINPROGRESS, ECONNRESET, EPIPE, ENETRESET, EBADF
export Sockaddr_storage, Sockaddr_un, Sockaddr_un_path_length

View File

@@ -93,9 +93,9 @@ import std/private/since
when defined(nimPreviewSlimSystem):
import std/assertions
import nativesockets
import os, strutils, times, sets, options, std/monotimes
import ssl_config
import std/nativesockets
import std/[os, strutils, times, sets, options, monotimes]
import std/ssl_config
export nativesockets.Port, nativesockets.`$`, nativesockets.`==`
export Domain, SockType, Protocol
@@ -105,12 +105,12 @@ const useNimNetLite = defined(nimNetLite) or defined(freertos) or defined(zephyr
const defineSsl = defined(ssl) or defined(nimdoc)
when useWinVersion:
from winlean import WSAESHUTDOWN
from std/winlean import WSAESHUTDOWN
when defineSsl:
import openssl
import std/openssl
when not defined(nimDisableCertificateValidation):
from ssl_certs import scanSSLCertificates
from std/ssl_certs import scanSSLCertificates
# Note: The enumerations are mapped to Window's constants.
@@ -209,7 +209,7 @@ when defined(nimHasStyleChecks):
when defined(posix) and not defined(lwip):
from posix import TPollfd, POLLIN, POLLPRI, POLLOUT, POLLWRBAND, Tnfds
from std/posix import TPollfd, POLLIN, POLLPRI, POLLOUT, POLLWRBAND, Tnfds
template monitorPollEvent(x: var SocketHandle, y: cint, timeout: int): int =
var tpollfd: TPollfd
@@ -1154,7 +1154,7 @@ proc accept*(server: Socket, client: var owned(Socket),
acceptAddr(server, client, addrDummy, flags)
when defined(posix) and not defined(lwip):
from posix import Sigset, sigwait, sigismember, sigemptyset, sigaddset,
from std/posix import Sigset, sigwait, sigismember, sigemptyset, sigaddset,
sigprocmask, pthread_sigmask, SIGPIPE, SIG_BLOCK, SIG_UNBLOCK
template blockSigpipe(body: untyped): untyped =
@@ -1268,9 +1268,9 @@ proc close*(socket: Socket, flags = {SocketFlag.SafeDisconn}) =
socket.fd = osInvalidSocket
when defined(posix):
from posix import TCP_NODELAY
from std/posix import TCP_NODELAY
else:
from winlean import TCP_NODELAY
from std/winlean import TCP_NODELAY
proc toCInt*(opt: SOBool): cint =
## Converts a `SOBool` into its Socket Option cint representation.

View File

@@ -20,7 +20,7 @@ when not defined(profiler) and not defined(memProfiler):
# We don't want to profile the profiling code ...
{.push profiler: off.}
import hashes, algorithm, strutils, tables, sets
import std/[hashes, algorithm, strutils, tables, sets]
when defined(nimPreviewSlimSystem):
import std/[syncio, sysatomics]
@@ -69,7 +69,7 @@ when not defined(memProfiler):
else: interval = intervalInUs * 1000 - tickCountCorrection
when withThreads:
import locks
import std/locks
var
profilingLock: Lock

View File

@@ -14,7 +14,7 @@
## This implementation calls `initRand()` for the first call of
## `genOid`.
import hashes, times, endians, random
import std/[hashes, times, endians, random]
from std/private/decode_helpers import handleHexChar
when defined(nimPreviewSlimSystem):

View File

@@ -74,7 +74,7 @@ when defined(nimHasEffectsOf):
else:
{.pragma: effectsOf.}
import typetraits
import std/typetraits
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -52,7 +52,7 @@ import std/private/since
import std/cmdline
export cmdline
import strutils, pathnorm
import std/[strutils, pathnorm]
when defined(nimPreviewSlimSystem):
import std/[syncio, assertions, widestrs]
@@ -76,9 +76,9 @@ since (1, 1):
when weirdTarget:
discard
elif defined(windows):
import winlean, times
import std/[winlean, times]
elif defined(posix):
import posix, times
import std/[posix, times]
proc toTime(ts: Timespec): times.Time {.inline.} =
result = initTime(ts.tv_sec.int64, ts.tv_nsec.int)

View File

@@ -18,18 +18,18 @@
include "system/inclrtl"
import
strutils, os, strtabs, streams, cpuinfo, streamwrapper,
std/private/since
std/[strutils, os, strtabs, streams, cpuinfo, streamwrapper,
private/since]
export quoteShell, quoteShellWindows, quoteShellPosix
when defined(windows):
import winlean
import std/winlean
else:
import posix
import std/posix
when defined(linux) and defined(useClone):
import linux
import std/linux
when defined(nimPreviewSlimSystem):
import std/[syncio, assertions]
@@ -1231,7 +1231,7 @@ elif not defined(useNimRtl):
when defined(macosx) or defined(freebsd) or defined(netbsd) or
defined(openbsd) or defined(dragonfly):
import kqueue
import std/kqueue
proc waitForExit(p: Process, timeout: int = -1): int =
if p.exitFlag:
@@ -1353,7 +1353,7 @@ elif not defined(useNimRtl):
result = exitStatusLikeShell(p.exitStatus)
else:
import times
import std/times
const
hasThreadSupport = compileOption("threads") and not defined(nimscript)

View File

@@ -170,7 +170,7 @@ runnableExamples:
assert dict.getSectionValue(section4, "does_that_mean_anything_special") == "False"
assert dict.getSectionValue(section4, "purpose") == "formatting for readability"
import strutils, lexbase, streams, tables
import std/[strutils, lexbase, streams, tables]
import std/private/decode_helpers
import std/private/since

View File

@@ -67,7 +67,7 @@
## * `parsesql module <parsesql.html>`_ for a SQL parser
## * `other parsers <lib.html#pure-libraries-parsers>`_ for other parsers
import lexbase, streams
import std/[lexbase, streams]
when defined(nimPreviewSlimSystem):
import std/syncio
@@ -349,7 +349,7 @@ proc rowEntry*(self: var CsvParser, entry: string): var string =
raise newException(KeyError, "Entry `" & entry & "` doesn't exist")
when not defined(testing) and isMainModule:
import os
import std/os
var s = newFileStream(paramStr(1), fmRead)
if s == nil: quit("cannot open the file" & paramStr(1))
var x: CsvParser

View File

@@ -11,7 +11,7 @@
## and exported by the `json` standard library
## module, but can also be used in its own right.
import strutils, lexbase, streams, unicode
import std/[strutils, lexbase, streams, unicode]
import std/private/decode_helpers
when defined(nimPreviewSlimSystem):

View File

@@ -176,7 +176,7 @@
include "system/inclrtl"
import os
import std/os
type
CmdLineKind* = enum ## The detected command line token.

View File

@@ -12,7 +12,7 @@
##
## Unstable API.
import strutils, lexbase
import std/[strutils, lexbase]
import std/private/decode_helpers
when defined(nimPreviewSlimSystem):
@@ -1491,7 +1491,7 @@ proc treeRepr*(s: SqlNode): string =
result = newStringOfCap(128)
treeReprAux(s, 0, result)
import streams
import std/streams
proc open(L: var SqlLexer, input: Stream, filename: string) =
lexbase.open(L, input)

View File

@@ -41,7 +41,7 @@ document.
# This program reads an HTML file and writes its title to stdout.
# Errors and whitespace are ignored.
import os, streams, parsexml, strutils
import std/[os, streams, parsexml, strutils]
if paramCount() < 1:
quit("Usage: htmltitle filename[.html]")
@@ -90,7 +90,7 @@ an HTML document contains.
# This program reads an HTML file and writes all its used links to stdout.
# Errors and whitespace are ignored.
import os, streams, parsexml, strutils
import std/[os, streams, parsexml, strutils]
proc `=?=` (a, b: string): bool =
# little trick: define our own comparator that ignores case
@@ -147,7 +147,7 @@ an HTML document contains.
]##
import
strutils, lexbase, streams, unicode
std/[strutils, lexbase, streams, unicode]
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
@@ -792,7 +792,7 @@ proc next*(my: var XmlParser) =
my.state = stateNormal
when not defined(testing) and isMainModule:
import os
import std/os
var s = newFileStream(paramStr(1), fmRead)
if s == nil: quit("cannot open the file" & paramStr(1))
var x: XmlParser

View File

@@ -22,11 +22,11 @@ when defined(nimPreviewSlimSystem):
const
useUnicode = true ## change this to deactivate proper UTF-8 support
import strutils, macros
import std/[strutils, macros]
import std/private/decode_helpers
when useUnicode:
import unicode
import std/unicode
export unicode.`==`
const

View File

@@ -71,7 +71,7 @@ runnableExamples:
## * `list of cryptographic and hashing modules <lib.html#pure-libraries-hashing>`_
## in the standard library
import algorithm, math
import std/[algorithm, math]
import std/private/[since, jsutils]
when defined(nimPreviewSlimSystem):
@@ -670,7 +670,7 @@ when not defined(standalone):
import std/[hashes, os, sysrand, monotimes]
when compileOption("threads"):
import locks
import std/locks
var baseSeedLock: Lock
baseSeedLock.initLock

View File

@@ -21,7 +21,7 @@ runnableExamples:
doAssert r1 * r2 == -3 // 8
doAssert r1 / r2 == -2 // 3
import math, hashes
import std/[math, hashes]
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -44,7 +44,7 @@ type
mem: ReservedMem
when defined(windows):
import winlean
import std/winlean
import std/private/win_getsysteminfo
proc getAllocationGranularity: uint =
@@ -68,7 +68,7 @@ when defined(windows):
raiseOSError(osLastError())
else:
import posix
import std/posix
let allocationGranularity = sysconf(SC_PAGESIZE)

View File

@@ -17,7 +17,7 @@
## runtime efficiency.
include system/inclrtl
import streams
import std/streams
when defined(nimPreviewSlimSystem):
import std/[syncio, formatfloat, assertions]

View File

@@ -26,7 +26,7 @@ se.msg = "Could not access value because it is nil."
when defined(windows):
include "../system/ansi_c"
import winlean
import std/winlean
const
EXCEPTION_ACCESS_VIOLATION = DWORD(0xc0000005'i32)
@@ -65,7 +65,7 @@ when defined(windows):
c_signal(SIGSEGV, segfaultHandler)
else:
import posix
import std/posix
var sa: Sigaction

View File

@@ -27,7 +27,7 @@
##
## TODO: `/dev/poll`, `event ports` and filesystem events.
import nativesockets
import std/nativesockets
import std/oserrors
when defined(nimPreviewSlimSystem):
@@ -235,9 +235,9 @@ when defined(nimdoc):
## For *poll* and *select* selectors `-1` is returned.
else:
import strutils
import std/strutils
when hasThreadSupport:
import locks
import std/locks
type
SharedArray[T] = UncheckedArray[T]
@@ -288,7 +288,7 @@ else:
setBlocking(fd.SocketHandle, false)
when not defined(windows):
import posix
import std/posix
template setKey(s, pident, pevents, pparam, pdata: untyped) =
var skey = addr(s.fds[pident])

View File

@@ -10,7 +10,7 @@
## The default locations can be overridden using the SSL_CERT_FILE and
## SSL_CERT_DIR environment variables.
import os, strutils
import std/[os, strutils]
# FWIW look for files before scanning entire dirs.
@@ -150,7 +150,7 @@ iterator scanSSLCertificates*(useEnvVars = false): string =
# Certificates management on windows
# when defined(windows) or defined(nimdoc):
#
# import openssl
# import std/openssl
#
# type
# PCCertContext {.final, pure.} = pointer

View File

@@ -53,7 +53,7 @@ runnableExamples:
doAssert statistics.kurtosis() ~= -1.0
doAssert statistics.kurtosisS() ~= -0.7000000000000008
from math import FloatClass, sqrt, pow, round
from std/math import FloatClass, sqrt, pow, round
when defined(nimPreviewSlimSystem):
import std/[assertions, formatfloat]

View File

@@ -1482,7 +1482,7 @@ when false:
# do not import windows as this increases compile times:
discard
else:
import posix
import std/posix
proc hsSetPosition(s: FileHandleStream, pos: int) =
discard lseek(s.handle, pos, SEEK_SET)

View File

@@ -11,7 +11,7 @@
##
## **Since** version 1.2.
import deques, streams
import std/[deques, streams]
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -316,8 +316,8 @@ help with readability, since there is only so much you can cram into
single letter DSLs.
]##
import macros, parseutils, unicode
import strutils except format
import std/[macros, parseutils, unicode]
import std/strutils except format
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -283,7 +283,7 @@ efficiency and perform different checks.
]##
import macros, parseutils
import std/[macros, parseutils]
import std/private/since
when defined(nimPreviewSlimSystem):

View File

@@ -51,7 +51,7 @@ runnableExamples:
import std/private/since
import
hashes, strutils
std/[hashes, strutils]
when defined(nimPreviewSlimSystem):
import std/assertions

View File

@@ -70,12 +70,12 @@ runnableExamples:
## easier substring extraction than regular expressions
import parseutils
from math import pow, floor, log10
from algorithm import fill, reverse
import std/parseutils
from std/math import pow, floor, log10
from std/algorithm import fill, reverse
import std/enumutils
from unicode import toLower, toUpper
from std/unicode import toLower, toUpper
export toLower, toUpper
include "system/inclrtl"

View File

@@ -11,7 +11,7 @@
## macro system.
import std/private/since
import macros
import std/macros
proc checkPragma(ex, prag: var NimNode) =
since (1, 3):

View File

@@ -58,13 +58,13 @@ runnableExamples("-r:off"):
stdout.styledWriteLine(fgRed, "red text ", styleBright, "bold red", fgDefault, " bold text")
import macros
import strformat
from strutils import toLowerAscii, `%`, parseInt
import colors
import std/macros
import std/strformat
from std/strutils import toLowerAscii, `%`, parseInt
import std/colors
when defined(windows):
import winlean
import std/winlean
when defined(nimPreviewSlimSystem):
import std/[syncio, assertions]
@@ -100,7 +100,7 @@ const
stylePrefix = "\e["
when defined(windows):
import winlean, os
import std/[winlean, os]
const
DUPLICATE_SAME_ACCESS = 2
@@ -257,7 +257,7 @@ when defined(windows):
if f == stderr: term.hStderr else: term.hStdout
else:
import termios, posix, os, parseutils
import std/[termios, posix, os, parseutils]
proc setRaw(fd: FileHandle, time: cint = TCSAFLUSH) =
var mode: Termios
@@ -922,7 +922,7 @@ when defined(windows):
stdout.write "\n"
else:
import termios
import std/termios
proc readPasswordFromStdin*(prompt: string, password: var string):
bool {.tags: [ReadIOEffect, WriteIOEffect].} =
@@ -978,7 +978,7 @@ proc isTrueColorSupported*(): bool =
return getTerminal().trueColorIsSupported
when defined(windows):
import os
import std/os
proc enableTrueColors*() =
## Enables true color.

View File

@@ -203,7 +203,7 @@
* `monotimes module <monotimes.html>`_
]##
import strutils, math, options
import std/[strutils, math, options]
import std/private/since
include "system/inclrtl"
@@ -213,7 +213,7 @@ when defined(nimPreviewSlimSystem):
when defined(js):
import jscore
import std/jscore
# This is really bad, but overflow checks are broken badly for
# ints on the JS backend. See #6752.
@@ -237,7 +237,7 @@ when defined(js):
{.pop.}
elif defined(posix):
import posix
import std/posix
type CTime = posix.Time
@@ -246,7 +246,7 @@ elif defined(posix):
{.importc: "gettimeofday", header: "<sys/time.h>", sideEffect.}
elif defined(windows):
import winlean, std/time_t
import std/winlean, std/time_t
type
CTime = time_t.Time

View File

@@ -204,7 +204,7 @@ since (1, 3, 5):
typeof(block: (for ai in a: ai))
import macros
import std/macros
macro enumLen*(T: typedesc[enum]): int =
## Returns the number of items in the enum `T`.

View File

@@ -111,15 +111,15 @@ import std/exitprocs
when defined(nimPreviewSlimSystem):
import std/assertions
import macros, strutils, streams, times, sets, sequtils
import std/[macros, strutils, streams, times, sets, sequtils]
when declared(stdout):
import os
import std/os
const useTerminal = not defined(js)
when useTerminal:
import terminal
import std/terminal
type
TestStatus* = enum ## The status of a test when it is done.

Some files were not shown because too many files have changed in this diff Show More