diff options
author | hlaaftana <10591326+hlaaftana@users.noreply.github.com> | 2020-05-03 00:51:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-02 23:51:59 +0200 |
commit | fbc97e712a67f30076f7633880383c8c4ae7866f (patch) | |
tree | 3eec30d015360011fdfbb9ef71cfc85b172c3d67 /lib | |
parent | 3be669be3255c6b47dd2542af9d2055a7d1207e3 (diff) | |
download | Nim-fbc97e712a67f30076f7633880383c8c4ae7866f.tar.gz |
move since from inclrtl to std/private/since (#14188)
* move since from inclrtl to std/private/since * move since import in system below for HCR
Diffstat (limited to 'lib')
-rw-r--r-- | lib/core/macros.nim | 1 | ||||
-rw-r--r-- | lib/js/dom.nim | 2 | ||||
-rw-r--r-- | lib/pure/asyncnet.nim | 8 | ||||
-rw-r--r-- | lib/pure/browsers.nim | 3 | ||||
-rw-r--r-- | lib/pure/collections/critbits.nim | 2 | ||||
-rw-r--r-- | lib/pure/collections/deques.nim | 2 | ||||
-rw-r--r-- | lib/pure/collections/sequtils.nim | 2 | ||||
-rw-r--r-- | lib/pure/collections/tables.nim | 4 | ||||
-rw-r--r-- | lib/pure/hashes.nim | 2 | ||||
-rw-r--r-- | lib/pure/httpclient.nim | 2 | ||||
-rw-r--r-- | lib/pure/math.nim | 2 | ||||
-rw-r--r-- | lib/pure/net.nim | 2 | ||||
-rw-r--r-- | lib/pure/os.nim | 1 | ||||
-rw-r--r-- | lib/pure/streams.nim | 2 | ||||
-rw-r--r-- | lib/pure/strtabs.nim | 1 | ||||
-rw-r--r-- | lib/pure/sugar.nim | 3 | ||||
-rw-r--r-- | lib/pure/times.nim | 3 | ||||
-rw-r--r-- | lib/pure/typetraits.nim | 9 | ||||
-rw-r--r-- | lib/pure/unittest.nim | 4 | ||||
-rw-r--r-- | lib/pure/uri.nim | 2 | ||||
-rw-r--r-- | lib/pure/xmltree.nim | 4 | ||||
-rw-r--r-- | lib/std/private/since.nim | 19 | ||||
-rw-r--r-- | lib/system.nim | 6 | ||||
-rw-r--r-- | lib/system/dollars.nim | 2 | ||||
-rw-r--r-- | lib/system/inclrtl.nim | 18 | ||||
-rw-r--r-- | lib/system/io.nim | 1 |
26 files changed, 54 insertions, 53 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 6e02ae42c..9e17b665a 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -8,6 +8,7 @@ # include "system/inclrtl" +import std/private/since ## This module contains the interface to the compiler's abstract syntax ## tree (`AST`:idx:). Macros operate on this tree. diff --git a/lib/js/dom.nim b/lib/js/dom.nim index 5a24ca38a..4a33668cd 100644 --- a/lib/js/dom.nim +++ b/lib/js/dom.nim @@ -9,7 +9,7 @@ ## Declaration of the Document Object Model for the `JavaScript backend ## <backends.html#backends-the-javascript-target>`_. -include "system/inclrtl" +import std/private/since when not defined(js) and not defined(Nimdoc): {.error: "This module only works on the JavaScript platform".} diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index 1e7c13413..93334d0e2 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -95,12 +95,8 @@ ## runForever() ## -include "system/inclrtl" - -import asyncdispatch -import nativesockets -import net -import os +import std/private/since +import asyncdispatch, nativesockets, net, os export SOBool diff --git a/lib/pure/browsers.nim b/lib/pure/browsers.nim index a70b767b7..2dc14b895 100644 --- a/lib/pure/browsers.nim +++ b/lib/pure/browsers.nim @@ -12,8 +12,9 @@ ## ## Unstable API. +import std/private/since + import strutils -include "system/inclrtl" when defined(windows): import winlean diff --git a/lib/pure/collections/critbits.nim b/lib/pure/collections/critbits.nim index 21c749afe..91c113988 100644 --- a/lib/pure/collections/critbits.nim +++ b/lib/pure/collections/critbits.nim @@ -12,7 +12,7 @@ ## by Adam Langley. ## (A crit bit tree is a form of `radix tree`:idx: or `patricia trie`:idx:.) -include "system/inclrtl" +import std/private/since type NodeObj[T] {.acyclic.} = object diff --git a/lib/pure/collections/deques.nim b/lib/pure/collections/deques.nim index 69a68c8f0..d096874a3 100644 --- a/lib/pure/collections/deques.nim +++ b/lib/pure/collections/deques.nim @@ -51,7 +51,7 @@ ## * `lists module <lists.html>`_ for singly and doubly linked lists and rings ## * `channels module <channels.html>`_ for inter-thread communication -include system/inclrtl +import std/private/since import math diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim index 02d48973e..94bce265a 100644 --- a/lib/pure/collections/sequtils.nim +++ b/lib/pure/collections/sequtils.nim @@ -73,7 +73,7 @@ ## heterogeneous members -include "system/inclrtl" +import std/private/since import macros diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index 131e0ad80..2ea58ce1f 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -217,9 +217,9 @@ ## * `hashes module<hashes.html>`_ for helper functions for hashing -import hashes, math, algorithm +import std/private/since -include "system/inclrtl" +import hashes, math, algorithm type KeyValuePair[A, B] = tuple[hcode: Hash, key: A, val: B] diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim index 9fd2a74d0..cd0841d2e 100644 --- a/lib/pure/hashes.nim +++ b/lib/pure/hashes.nim @@ -44,7 +44,7 @@ ## * `std/sha1 module <sha1.html>`_ for a sha1 encoder and decoder ## * `tables module <tables.html>`_ for hash tables -include "system/inclrtl" +import std/private/since type Hash* = int ## A hash value. Hash tables using these values should diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index baf81d77f..42735ad4e 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -200,7 +200,7 @@ ## let client = newHttpClient(maxRedirects = 0) ## -include "system/inclrtl" +import std/private/since import net, strutils, uri, parseutils, base64, os, mimetypes, streams, math, random, httpcore, times, tables, streams, std/monotimes diff --git a/lib/pure/math.nim b/lib/pure/math.nim index a718c3338..6291cddf1 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -52,7 +52,7 @@ ## are on system directly, to name a few ``shr``, ``shl``, ``xor``, ``clamp``, etc. -include "system/inclrtl" +import std/private/since {.push debugger: off.} # the user does not want to trace a part # of the standard library! diff --git a/lib/pure/net.nim b/lib/pure/net.nim index 9fa019b95..fad6e897d 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -64,7 +64,7 @@ ## socket.acceptAddr(client, address) ## echo("Client connected from: ", address) -include "system/inclrtl" +import std/private/since import nativesockets, os, strutils, times, sets, options, std/monotimes from ssl_certs import scanSSLCertificates diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 73fa76fbb..f267e4d01 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -42,6 +42,7 @@ ## * `streams module <streams.html>`_ include "system/inclrtl" +import std/private/since import strutils, pathnorm diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 8efe5b227..77f384a79 100644 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -94,7 +94,7 @@ ## * `asyncstreams module <asyncstreams.html>`_ ## * `io module <io.html>`_ for `FileMode enum <io.html#FileMode>`_ -include "system/inclrtl" +import std/private/since const taintMode = compileOption("taintmode") diff --git a/lib/pure/strtabs.nim b/lib/pure/strtabs.nim index 11aa851a1..375f212cd 100644 --- a/lib/pure/strtabs.nim +++ b/lib/pure/strtabs.nim @@ -48,6 +48,7 @@ runnableExamples: ## * `json module<json.html>`_ for table-like structure which allows ## heterogeneous members +import std/private/since import hashes, strutils diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim index 4b3db6782..062341ccb 100644 --- a/lib/pure/sugar.nim +++ b/lib/pure/sugar.nim @@ -10,8 +10,7 @@ ## This module implements nice syntactic sugar based on Nim's ## macro system. -include system/inclrtl - +import std/private/since import macros import typetraits diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 8a4c9cd20..2b98e5971 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -194,6 +194,7 @@ import strutils, math, options +import std/private/since include "system/inclrtl" when defined(js): @@ -980,7 +981,7 @@ proc low*(typ: typedesc[Time]): Time = # DateTime & Timezone # -proc isLeapDay*(t: DateTime): bool {.since: (1,1).} = +proc isLeapDay*(t: DateTime): bool {.since: (1, 1).} = ## returns whether `t` is a leap day, ie, Feb 29 in a leap year. This matters ## as it affects time offset calculations. runnableExamples: diff --git a/lib/pure/typetraits.nim b/lib/pure/typetraits.nim index 280233912..06bd1487f 100644 --- a/lib/pure/typetraits.nim +++ b/lib/pure/typetraits.nim @@ -12,10 +12,9 @@ ## ## Unstable API. +import std/private/since export system.`$` # for backward compatibility -include "system/inclrtl" - proc name*(t: typedesc): string {.magic: "TypeTrait".} ## Returns the name of the given type. ## @@ -79,15 +78,13 @@ since (1, 1): doAssert 12.MyInt.distinctBase == 12 distinctBase(type(a))(a) -proc tupleLen*(T: typedesc[tuple]): int {.magic: "TypeTrait", since: (1, 1).} - ## Return number of elements of `T` + proc tupleLen*(T: typedesc[tuple]): int {.magic: "TypeTrait".} + ## Return number of elements of `T` -since (1, 1): template tupleLen*(t: tuple): int = ## Return number of elements of `t` tupleLen(type(t)) -since (1, 1): template get*(T: typedesc[tuple], i: static int): untyped = ## Return `i`\th element of `T` # Note: `[]` currently gives: `Error: no generic parameters allowed for ...` diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 6c434bb19..bb4e2867c 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -93,11 +93,11 @@ ## ## echo "suite teardown: run once after the tests" +import std/private/since + import macros, strutils, streams, times, sets, sequtils -include "system/inclrtl" - when declared(stdout): import os diff --git a/lib/pure/uri.nim b/lib/pure/uri.nim index 27fbf2db2..b163a2ab4 100644 --- a/lib/pure/uri.nim +++ b/lib/pure/uri.nim @@ -44,7 +44,7 @@ ## doAssert getDataUri("Hello World", "text/plain") == "data:text/plain;charset=utf-8;base64,SGVsbG8gV29ybGQ=" ## doAssert getDataUri("Nim", "text/plain") == "data:text/plain;charset=utf-8;base64,Tmlt" -include "system/inclrtl" +import std/private/since import strutils, parseutils, base64 type diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim index 35010e602..9d2e4317e 100644 --- a/lib/pure/xmltree.nim +++ b/lib/pure/xmltree.nim @@ -34,8 +34,8 @@ ## * `parsexml module <parsexml.html>`_ for low-level XML parsing ## * `htmlgen module <htmlgen.html>`_ for html code generator +import std/private/since import macros, strtabs, strutils -include "system/inclrtl" type XmlNode* = ref XmlNodeObj ## An XML tree consisting of XML nodes. @@ -103,7 +103,7 @@ proc newText*(text: string): XmlNode = result = newXmlNode(xnText) result.fText = text -proc newVerbatimText*(text: string): XmlNode {.since:(1, 3).} = +proc newVerbatimText*(text: string): XmlNode {.since: (1, 3).} = ## Creates a new ``XmlNode`` of kind ``xnVerbatimText`` with the text `text`. ## **Since**: Version 1.3. result = newXmlNode(xnVerbatimText) diff --git a/lib/std/private/since.nim b/lib/std/private/since.nim new file mode 100644 index 000000000..e4aecb61a --- /dev/null +++ b/lib/std/private/since.nim @@ -0,0 +1,19 @@ +template since*(version: (int, int), body: untyped) {.dirty.} = + ## Evaluates `body` if the ``(NimMajor, NimMinor)`` is greater than + ## or equal to `version`. Usage: + ## + ## .. code-block:: Nim + ## proc fun*() {.since: (1, 3).} + ## since (1, 3): fun() + when (NimMajor, NimMinor) >= version: + body + +template since*(version: (int, int, int), body: untyped) {.dirty.} = + ## Evaluates `body` if ``(NimMajor, NimMinor, NimPatch)`` is greater than + ## or equal to `version`. Usage: + ## + ## .. code-block:: Nim + ## proc fun*() {.since: (1, 3, 1).} + ## since (1, 3, 1): fun() + when (NimMajor, NimMinor, NimPatch) >= version: + body \ No newline at end of file diff --git a/lib/system.nim b/lib/system.nim index 3698dc8de..6a22fe19b 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1124,6 +1124,8 @@ elif hostOS != "standalone": var programResult* {.compilerproc, exportc: "nim_program_result".}: int ## deprecated, prefer ``quit`` +import std/private/since + proc align(address, alignment: int): int = if alignment == 0: # Actually, this is illegal. This branch exists to actively # hide problems. @@ -2054,8 +2056,8 @@ const ## is the major number of Nim's version. Example: ## ## .. code-block:: Nim - ## when (NimMajor, NimMinor, NimPatch) >= (1, 3, 1): discard - # See also private symbol `since: (1, 3)` reserved for stdlib + ## when (NimMajor, NimMinor, NimPatch) >= (1, 3, 1): discard + # see also std/private/since NimMinor* {.intdefine.}: int = 3 ## is the minor number of Nim's version. diff --git a/lib/system/dollars.nim b/lib/system/dollars.nim index 836d5764c..b2f0186b3 100644 --- a/lib/system/dollars.nim +++ b/lib/system/dollars.nim @@ -1,4 +1,4 @@ -include system/inclrtl +import std/private/since proc `$`*(x: int): string {.magic: "IntToStr", noSideEffect.} ## The stringify operator for an integer argument. Returns `x` diff --git a/lib/system/inclrtl.nim b/lib/system/inclrtl.nim index 37cdb74d8..4193f2bdd 100644 --- a/lib/system/inclrtl.nim +++ b/lib/system/inclrtl.nim @@ -48,21 +48,3 @@ when defined(nimlocks): {.pragma: benign, gcsafe, locks: 0.} else: {.pragma: benign, gcsafe.} - -template isSince(version: (int, int)): bool = - (NimMajor, NimMinor) >= version -template isSince(version: (int, int, int)): bool = - (NimMajor, NimMinor, NimPatch) >= version - -template since(version, body: untyped) {.dirty, used.} = - ## Usage: - ## - ## .. code-block:: Nim - ## proc fun*() {since: (1, 3).} - ## proc fun*() {since: (1, 3, 1).} - ## - ## Limitation: can't be used to annotate a template (eg typetraits.get), would - ## error: cannot attach a custom pragma. - # `dirty` needed because `NimMajor` may not yet be defined in caller. - when isSince(version): - body diff --git a/lib/system/io.nim b/lib/system/io.nim index efa2f9475..ab415f40c 100644 --- a/lib/system/io.nim +++ b/lib/system/io.nim @@ -11,6 +11,7 @@ include inclrtl +import std/private/since import formatfloat # ----------------- IO Part ------------------------------------------------ |