mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-04 02:44:44 +00:00
remove deprecated stuff from the stdlib; introduce better deprecation warnings
This commit is contained in:
@@ -12,7 +12,7 @@ import sockets, strutils, parseutils, times, os, asyncio
|
||||
|
||||
from asyncnet import nil
|
||||
from nativesockets import nil
|
||||
from asyncdispatch import PFuture
|
||||
from asyncdispatch import Future
|
||||
## **Note**: This module is deprecated since version 0.11.3.
|
||||
## You should use the async version of this module
|
||||
## `asyncftpclient <asyncftpclient.html>`_.
|
||||
|
||||
@@ -853,7 +853,6 @@ type
|
||||
DirKind = enum # must be ordered alphabetically!
|
||||
dkNone, dkAuthor, dkAuthors, dkCode, dkCodeBlock, dkContainer, dkContents,
|
||||
dkFigure, dkImage, dkInclude, dkIndex, dkRaw, dkTitle
|
||||
{.deprecated: [TDirKind: DirKind].}
|
||||
|
||||
const
|
||||
DirIds: array[0..12, string] = ["", "author", "authors", "code",
|
||||
@@ -1114,7 +1113,6 @@ proc parseHeadline(p: var RstParser): PRstNode =
|
||||
|
||||
type
|
||||
IntSeq = seq[int]
|
||||
{.deprecated: [TIntSeq: IntSeq].}
|
||||
|
||||
proc tokEnd(p: RstParser): int =
|
||||
result = p.tok[p.idx].col + len(p.tok[p.idx].symbol) - 1
|
||||
@@ -1408,8 +1406,6 @@ type
|
||||
hasArg, hasOptions, argIsFile, argIsWord
|
||||
DirFlags = set[DirFlag]
|
||||
SectionParser = proc (p: var RstParser): PRstNode {.nimcall.}
|
||||
{.deprecated: [TDirFlag: DirFlag, TDirFlags: DirFlags,
|
||||
TSectionParser: SectionParser].}
|
||||
|
||||
proc parseDirective(p: var RstParser, flags: DirFlags): PRstNode =
|
||||
## Parses arguments and options for a directive block.
|
||||
|
||||
@@ -70,8 +70,6 @@ type
|
||||
## the document or the section
|
||||
level*: int ## valid for some node kinds
|
||||
sons*: RstNodeSeq ## the node's sons
|
||||
{.deprecated: [TRstNodeKind: RstNodeKind, TRstNodeSeq: RstNodeSeq,
|
||||
TRstNode: RstNode].}
|
||||
|
||||
proc len*(n: PRstNode): int =
|
||||
result = len(n.sons)
|
||||
@@ -99,7 +97,6 @@ type
|
||||
RenderContext {.pure.} = object
|
||||
indent: int
|
||||
verbatim: int
|
||||
{.deprecated: [TRenderContext: RenderContext].}
|
||||
|
||||
proc renderRstToRst(d: var RenderContext, n: PRstNode,
|
||||
result: var string) {.gcsafe.}
|
||||
|
||||
@@ -13,9 +13,6 @@ type
|
||||
SortOrder* = enum ## sort order
|
||||
Descending, Ascending
|
||||
|
||||
{.deprecated: [TSortOrder: SortOrder].}
|
||||
|
||||
|
||||
proc `*`*(x: int, order: SortOrder): int {.inline.} =
|
||||
## flips `x` if ``order == Descending``;
|
||||
## if ``order == Ascending`` then `x` is returned.
|
||||
|
||||
@@ -27,8 +27,6 @@ type
|
||||
FutureError* = object of Exception
|
||||
cause*: FutureBase
|
||||
|
||||
{.deprecated: [PFutureBase: FutureBase, PFuture: Future].}
|
||||
|
||||
when not defined(release):
|
||||
var currentID = 0
|
||||
|
||||
|
||||
@@ -60,9 +60,6 @@ type
|
||||
reusePort: bool
|
||||
maxBody: int ## The maximum content-length that will be read for the body.
|
||||
|
||||
{.deprecated: [TRequest: Request, PAsyncHttpServer: AsyncHttpServer,
|
||||
THttpCode: HttpCode, THttpVersion: HttpVersion].}
|
||||
|
||||
proc newAsyncHttpServer*(reuseAddr = true, reusePort = false,
|
||||
maxBody = 8388608): AsyncHttpServer =
|
||||
## Creates a new ``AsyncHttpServer`` instance.
|
||||
|
||||
@@ -134,8 +134,6 @@ type
|
||||
protocol: Protocol
|
||||
AsyncSocket* = ref AsyncSocketDesc
|
||||
|
||||
{.deprecated: [PAsyncSocket: AsyncSocket].}
|
||||
|
||||
proc newAsyncSocket*(fd: AsyncFD, domain: Domain = AF_INET,
|
||||
sockType: SockType = SOCK_STREAM,
|
||||
protocol: Protocol = IPPROTO_TCP, buffered = true): AsyncSocket =
|
||||
|
||||
@@ -64,8 +64,6 @@ type
|
||||
methodPost, ## query uses the POST method
|
||||
methodGet ## query uses the GET method
|
||||
|
||||
{.deprecated: [TRequestMethod: RequestMethod, ECgi: CgiError].}
|
||||
|
||||
proc cgiError*(msg: string) {.noreturn.} =
|
||||
## raises an ECgi exception with message `msg`.
|
||||
var e: ref CgiError
|
||||
|
||||
@@ -14,8 +14,6 @@ import strutils
|
||||
type
|
||||
Color* = distinct int ## a color stored as RGB
|
||||
|
||||
{.deprecated: [TColor: Color].}
|
||||
|
||||
proc `==` *(a, b: Color): bool {.borrow.}
|
||||
## compares two colors.
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@ type
|
||||
Complex* = tuple[re, im: float]
|
||||
## a complex number, consisting of a real and an imaginary part
|
||||
|
||||
{.deprecated: [TComplex: Complex].}
|
||||
|
||||
proc toComplex*(x: SomeInteger): Complex =
|
||||
## Convert some integer ``x`` to a complex number.
|
||||
result.re = x
|
||||
|
||||
@@ -83,9 +83,6 @@ type
|
||||
foreignKey*: bool ## is this a foreign key?
|
||||
DbColumns* = seq[DbColumn]
|
||||
|
||||
{.deprecated: [EDb: DbError, TSqlQuery: SqlQuery, FDb: DbEffect,
|
||||
FReadDb: ReadDbEffect, FWriteDb: WriteDbEffect].}
|
||||
|
||||
template sql*(query: string): SqlQuery =
|
||||
## constructs a SqlQuery from the string `query`. This is supposed to be
|
||||
## used as a raw-string-literal modifier:
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
## Loading a simple C function
|
||||
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
##
|
||||
## The following example demonstrates loading a function called 'greet'
|
||||
## The following example demonstrates loading a function called 'greet'
|
||||
## from a library that is determined at runtime based upon a language choice.
|
||||
## If the library fails to load or the function 'greet' is not found,
|
||||
## If the library fails to load or the function 'greet' is not found,
|
||||
## it quits with a failure error code.
|
||||
##
|
||||
## .. code-block::nim
|
||||
@@ -59,8 +59,6 @@ import strutils
|
||||
type
|
||||
LibHandle* = pointer ## a handle to a dynamically loaded library
|
||||
|
||||
{.deprecated: [TLibHandle: LibHandle].}
|
||||
|
||||
proc loadLib*(path: string, global_symbols=false): LibHandle {.gcsafe.}
|
||||
## loads a library from `path`. Returns nil if the library could not
|
||||
## be loaded.
|
||||
|
||||
@@ -27,8 +27,6 @@ type
|
||||
EncodingError* = object of ValueError ## exception that is raised
|
||||
## for encoding errors
|
||||
|
||||
{.deprecated: [EInvalidEncoding: EncodingError, PConverter: EncodingConverter].}
|
||||
|
||||
when defined(windows):
|
||||
proc eqEncodingNames(a, b: string): bool =
|
||||
var i = 0
|
||||
|
||||
@@ -43,9 +43,6 @@ type
|
||||
s: seq[EventHandler]
|
||||
EventError* = object of ValueError
|
||||
|
||||
{.deprecated: [TEventArgs: EventArgs, TEventHandler: EventHandler,
|
||||
TEventEmitter: EventEmitter, EInvalidEvent: EventError].}
|
||||
|
||||
proc initEventHandler*(name: string): EventHandler =
|
||||
## Initializes an EventHandler with the specified name and returns it.
|
||||
result.handlers = @[]
|
||||
|
||||
@@ -45,7 +45,6 @@ type
|
||||
Hash* = int ## a hash value; hash tables using these values should
|
||||
## always have a size of a power of two and can use the ``and``
|
||||
## operator instead of ``mod`` for truncation of the hash value.
|
||||
{.deprecated: [THash: Hash].}
|
||||
|
||||
proc `!&`*(h: Hash, val: int): Hash {.inline.} =
|
||||
## mixes a hash value `h` with `val` to produce a new hash value. This is
|
||||
|
||||
@@ -178,7 +178,6 @@ type
|
||||
tagVar, ## the HTML ``var`` element
|
||||
tagVideo, ## the HTML ``video`` element
|
||||
tagWbr ## the HTML ``wbr`` element
|
||||
{.deprecated: [THtmlTag: HtmlTag].}
|
||||
|
||||
const
|
||||
tagToStr* = [
|
||||
|
||||
@@ -219,10 +219,6 @@ type
|
||||
## and ``postContent`` proc,
|
||||
## when the server returns an error
|
||||
|
||||
{.deprecated: [TResponse: Response, PProxy: Proxy,
|
||||
EInvalidProtocol: ProtocolError, EHttpRequestErr: HttpRequestError
|
||||
].}
|
||||
|
||||
const defUserAgent* = "Nim httpclient/" & NimVersion
|
||||
|
||||
proc httpError(msg: string) =
|
||||
@@ -362,8 +358,6 @@ proc parseResponse(s: Socket, getBody: bool, timeout: int): Response =
|
||||
else:
|
||||
result.body = ""
|
||||
|
||||
{.deprecated: [THttpMethod: HttpMethod].}
|
||||
|
||||
when not defined(ssl):
|
||||
type SSLContext = ref object
|
||||
var defaultSSLContext {.threadvar.}: SSLContext
|
||||
@@ -585,7 +579,7 @@ proc request*(url: string, httpMethod: string, extraHeaders = "",
|
||||
|
||||
result = parseResponse(s, httpMethod != "HEAD", timeout)
|
||||
|
||||
proc request*(url: string, httpMethod = httpGET, extraHeaders = "",
|
||||
proc request*(url: string, httpMethod = HttpGET, extraHeaders = "",
|
||||
body = "", sslContext = defaultSSLContext, timeout = -1,
|
||||
userAgent = defUserAgent, proxy: Proxy = nil): Response
|
||||
{.deprecated.} =
|
||||
@@ -627,13 +621,13 @@ proc get*(url: string, extraHeaders = "", maxRedirects = 5,
|
||||
## server takes longer than specified an ETimeout exception will be raised.
|
||||
##
|
||||
## **Deprecated since version 0.15.0**: use ``HttpClient.get`` instead.
|
||||
result = request(url, httpGET, extraHeaders, "", sslContext, timeout,
|
||||
result = request(url, HttpGET, extraHeaders, "", sslContext, timeout,
|
||||
userAgent, proxy)
|
||||
var lastURL = url
|
||||
for i in 1..maxRedirects:
|
||||
if result.status.redirection():
|
||||
let redirectTo = getNewLocation(lastURL, result.headers)
|
||||
result = request(redirectTo, httpGET, extraHeaders, "", sslContext,
|
||||
result = request(redirectTo, HttpGET, extraHeaders, "", sslContext,
|
||||
timeout, userAgent, proxy)
|
||||
lastURL = redirectTo
|
||||
|
||||
@@ -687,13 +681,13 @@ proc post*(url: string, extraHeaders = "", body = "",
|
||||
if not multipart.isNil:
|
||||
xh.add(withNewLine("Content-Type: " & mpContentType))
|
||||
|
||||
result = request(url, httpPOST, xh, xb, sslContext, timeout, userAgent,
|
||||
result = request(url, HttpPOST, xh, xb, sslContext, timeout, userAgent,
|
||||
proxy)
|
||||
var lastURL = url
|
||||
for i in 1..maxRedirects:
|
||||
if result.status.redirection():
|
||||
let redirectTo = getNewLocation(lastURL, result.headers)
|
||||
var meth = if result.status != "307": httpGet else: httpPost
|
||||
var meth = if result.status != "307": HttpGet else: HttpPost
|
||||
result = request(redirectTo, meth, xh, xb, sslContext, timeout,
|
||||
userAgent, proxy)
|
||||
lastURL = redirectTo
|
||||
|
||||
@@ -45,10 +45,6 @@ type
|
||||
## TCP/IP tunnel, usually used for proxies.
|
||||
HttpPatch ## Applies partial modifications to a resource.
|
||||
|
||||
{.deprecated: [httpGet: HttpGet, httpHead: HttpHead, httpPost: HttpPost,
|
||||
httpPut: HttpPut, httpDelete: HttpDelete, httpTrace: HttpTrace,
|
||||
httpOptions: HttpOptions, httpConnect: HttpConnect].}
|
||||
|
||||
|
||||
const
|
||||
Http100* = HttpCode(100)
|
||||
|
||||
@@ -110,7 +110,6 @@ when false:
|
||||
# TODO: Fix this, or get rid of it.
|
||||
type
|
||||
RequestMethod = enum reqGet, reqPost
|
||||
{.deprecated: [TRequestMethod: RequestMethod].}
|
||||
|
||||
proc executeCgi(client: Socket, path, query: string, meth: RequestMethod) =
|
||||
var env = newStringTable(modeCaseInsensitive)
|
||||
@@ -225,7 +224,6 @@ type
|
||||
PAsyncHTTPServer* = ref AsyncHTTPServer
|
||||
AsyncHTTPServer = object of Server
|
||||
asyncSocket: AsyncSocket
|
||||
{.deprecated: [TAsyncHTTPServer: AsyncHTTPServer, TServer: Server].}
|
||||
|
||||
proc open*(s: var Server, port = Port(80), reuseAddr = false) =
|
||||
## creates a new server at port `port`. If ``port == 0`` a free port is
|
||||
|
||||
@@ -18,13 +18,13 @@ proc createAsyncNativeSocket*(domain: Domain = Domain.AF_INET,
|
||||
createAsyncNativeSocketImpl(domain, sockType, protocol)
|
||||
|
||||
proc newAsyncNativeSocket*(domain: cint, sockType: cint,
|
||||
protocol: cint): AsyncFD {.deprecated.} =
|
||||
protocol: cint): AsyncFD {.deprecated: "use createAsyncNativeSocket instead".} =
|
||||
createAsyncNativeSocketImpl(domain, sockType, protocol)
|
||||
|
||||
proc newAsyncNativeSocket*(domain: Domain = Domain.AF_INET,
|
||||
sockType: SockType = SOCK_STREAM,
|
||||
protocol: Protocol = IPPROTO_TCP): AsyncFD
|
||||
{.deprecated.} =
|
||||
{.deprecated: "use createAsyncNativeSocket instead".} =
|
||||
createAsyncNativeSocketImpl(domain, sockType, protocol)
|
||||
|
||||
when defined(windows) or defined(nimdoc):
|
||||
|
||||
@@ -12,50 +12,6 @@ when not defined(nimscript):
|
||||
when defined(windows):
|
||||
import winlean
|
||||
|
||||
proc osErrorMsg*(): string {.rtl, extern: "nos$1", deprecated.} =
|
||||
## Retrieves the operating system's error flag, ``errno``.
|
||||
## On Windows ``GetLastError`` is checked before ``errno``.
|
||||
## Returns "" if no error occurred.
|
||||
##
|
||||
## **Deprecated since version 0.9.4**: use the other ``osErrorMsg`` proc.
|
||||
|
||||
result = ""
|
||||
when defined(Windows) and not defined(nimscript):
|
||||
var err = getLastError()
|
||||
if err != 0'i32:
|
||||
when useWinUnicode:
|
||||
var msgbuf: WideCString
|
||||
if formatMessageW(0x00000100 or 0x00001000 or 0x00000200 or 0x000000FF,
|
||||
nil, err, 0, addr(msgbuf), 0, nil) != 0'i32:
|
||||
result = $msgbuf
|
||||
if msgbuf != nil: localFree(cast[pointer](msgbuf))
|
||||
else:
|
||||
var msgbuf: cstring
|
||||
if formatMessageA(0x00000100 or 0x00001000 or 0x00000200 or 0x000000FF,
|
||||
nil, err, 0, addr(msgbuf), 0, nil) != 0'i32:
|
||||
result = $msgbuf
|
||||
if msgbuf != nil: localFree(msgbuf)
|
||||
when not defined(nimscript):
|
||||
if errno != 0'i32:
|
||||
result = $c_strerror(errno)
|
||||
|
||||
{.push warning[deprecated]: off.}
|
||||
proc raiseOSError*(msg: string = "") {.noinline, rtl, extern: "nos$1",
|
||||
deprecated.} =
|
||||
## raises an OSError exception with the given message ``msg``.
|
||||
## If ``msg == ""``, the operating system's error flag
|
||||
## (``errno``) is converted to a readable error message. On Windows
|
||||
## ``GetLastError`` is checked before ``errno``.
|
||||
## If no error flag is set, the message ``unknown OS error`` is used.
|
||||
##
|
||||
## **Deprecated since version 0.9.4**: use the other ``raiseOSError`` proc.
|
||||
if len(msg) == 0:
|
||||
var m = osErrorMsg()
|
||||
raise newException(OSError, if m.len > 0: m else: "unknown OS error")
|
||||
else:
|
||||
raise newException(OSError, msg)
|
||||
{.pop.}
|
||||
|
||||
proc `==`*(err1, err2: OSErrorCode): bool {.borrow.}
|
||||
proc `$`*(err: OSErrorCode): string {.borrow.}
|
||||
|
||||
|
||||
@@ -158,9 +158,6 @@ type
|
||||
JsonKindError* = object of ValueError ## raised by the ``to`` macro if the
|
||||
## JSON kind is incorrect.
|
||||
|
||||
{.deprecated: [TJsonEventKind: JsonEventKind, TJsonError: JsonError,
|
||||
TJsonParser: JsonParser, TTokKind: TokKind].}
|
||||
|
||||
const
|
||||
errorMessages: array[JsonError, string] = [
|
||||
"no error",
|
||||
@@ -622,9 +619,6 @@ type
|
||||
|
||||
JsonParsingError* = object of ValueError ## is raised for a JSON error
|
||||
|
||||
{.deprecated: [EJsonParsingError: JsonParsingError, TJsonNode: JsonNodeObj,
|
||||
PJsonNode: JsonNode, TJsonNodeKind: JsonNodeKind].}
|
||||
|
||||
proc raiseParseErr*(p: JsonParser, msg: string) {.noinline, noreturn.} =
|
||||
## raises an `EJsonParsingError` exception.
|
||||
raise newException(JsonParsingError, errorMsgExpected(p, msg))
|
||||
@@ -695,7 +689,7 @@ proc getBiggestInt*(n: JsonNode, default: BiggestInt = 0): BiggestInt =
|
||||
if n.isNil or n.kind != JInt: return default
|
||||
else: return n.num
|
||||
|
||||
proc getNum*(n: JsonNode, default: BiggestInt = 0): BiggestInt {.deprecated.} =
|
||||
proc getNum*(n: JsonNode, default: BiggestInt = 0): BiggestInt {.deprecated: "use getInt or getBiggestInt instead".} =
|
||||
## **Deprecated since v0.18.2:** use ``getInt`` or ``getBiggestInt`` instead.
|
||||
getBiggestInt(n, default)
|
||||
|
||||
@@ -709,7 +703,7 @@ proc getFloat*(n: JsonNode, default: float = 0.0): float =
|
||||
of JInt: return float(n.num)
|
||||
else: return default
|
||||
|
||||
proc getFNum*(n: JsonNode, default: float = 0.0): float {.deprecated.} =
|
||||
proc getFNum*(n: JsonNode, default: float = 0.0): float {.deprecated: "use getFloat instead".} =
|
||||
## **Deprecated since v0.18.2:** use ``getFloat`` instead.
|
||||
getFloat(n, default)
|
||||
|
||||
@@ -720,7 +714,7 @@ proc getBool*(n: JsonNode, default: bool = false): bool =
|
||||
if n.isNil or n.kind != JBool: return default
|
||||
else: return n.bval
|
||||
|
||||
proc getBVal*(n: JsonNode, default: bool = false): bool {.deprecated.} =
|
||||
proc getBVal*(n: JsonNode, default: bool = false): bool {.deprecated: "use getBool instead".} =
|
||||
## **Deprecated since v0.18.2:** use ``getBool`` instead.
|
||||
getBool(n, default)
|
||||
|
||||
@@ -946,7 +940,7 @@ proc contains*(node: JsonNode, val: JsonNode): bool =
|
||||
assert(node.kind == JArray)
|
||||
find(node.elems, val) >= 0
|
||||
|
||||
proc existsKey*(node: JsonNode, key: string): bool {.deprecated.} = node.hasKey(key)
|
||||
proc existsKey*(node: JsonNode, key: string): bool {.deprecated: "use hasKey instead".} = node.hasKey(key)
|
||||
## **Deprecated:** use `hasKey` instead.
|
||||
|
||||
proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} =
|
||||
@@ -1277,7 +1271,6 @@ else:
|
||||
from math import `mod`
|
||||
type
|
||||
JSObject = object
|
||||
{.deprecated: [TJSObject: JSObject].}
|
||||
|
||||
proc parseNativeJson(x: cstring): JSObject {.importc: "JSON.parse".}
|
||||
|
||||
|
||||
@@ -40,8 +40,6 @@ type
|
||||
offsetBase*: int # use ``offsetBase + bufpos`` to get the offset
|
||||
refillChars: set[char]
|
||||
|
||||
{.deprecated: [TBaseLexer: BaseLexer].}
|
||||
|
||||
const
|
||||
chrSize = sizeof(char)
|
||||
|
||||
|
||||
@@ -96,10 +96,6 @@ when not defined(js):
|
||||
logFiles: int # how many log files already created, e.g. basename.1, basename.2...
|
||||
bufSize: int # size of output buffer (-1: use system defaults, 0: unbuffered, >0: fixed buffer size)
|
||||
|
||||
{.deprecated: [PFileLogger: FileLogger, PRollingFileLogger: RollingFileLogger].}
|
||||
|
||||
{.deprecated: [TLevel: Level, PLogger: Logger, PConsoleLogger: ConsoleLogger].}
|
||||
|
||||
var
|
||||
level {.threadvar.}: Level ## global log filter
|
||||
handlers {.threadvar.}: seq[Logger] ## handlers with their own log levels
|
||||
|
||||
@@ -309,7 +309,6 @@ when not defined(testing) and isMainModule:
|
||||
Node = object
|
||||
next, prev: PNode
|
||||
data: string
|
||||
{.deprecated: [TNode: Node].}
|
||||
|
||||
proc buildList(): PNode =
|
||||
new(result)
|
||||
|
||||
@@ -38,8 +38,6 @@ type
|
||||
else:
|
||||
handle: cint
|
||||
|
||||
{.deprecated: [TMemFile: MemFile].}
|
||||
|
||||
proc mapMem*(m: var MemFile, mode: FileMode = fmRead,
|
||||
mappedSize = -1, offset = 0): pointer =
|
||||
## returns a pointer to a mapped portion of MemFile `m`
|
||||
|
||||
@@ -12,8 +12,6 @@ type
|
||||
mt: array[0..623, uint32]
|
||||
index: int
|
||||
|
||||
{.deprecated: [TMersenneTwister: MersenneTwister].}
|
||||
|
||||
proc newMersenneTwister*(seed: uint32): MersenneTwister =
|
||||
result.index = 0
|
||||
result.mt[0] = seed
|
||||
|
||||
@@ -13,8 +13,6 @@ type
|
||||
MimeDB* = object
|
||||
mimes: StringTableRef
|
||||
|
||||
{.deprecated: [TMimeDB: MimeDB].}
|
||||
|
||||
const mimes* = {
|
||||
"ez": "application/andrew-inset",
|
||||
"anx": "application/annodex",
|
||||
|
||||
@@ -85,9 +85,6 @@ type
|
||||
length*: int
|
||||
addrList*: seq[string]
|
||||
|
||||
{.deprecated: [TPort: Port, TDomain: Domain, TType: SockType,
|
||||
TProtocol: Protocol, TServent: Servent, THostent: Hostent].}
|
||||
|
||||
when useWinVersion:
|
||||
let
|
||||
osInvalidSocket* = winlean.INVALID_SOCKET
|
||||
@@ -640,7 +637,7 @@ proc pruneSocketSet(s: var seq[SocketHandle], fd: var TFdSet) =
|
||||
inc(i)
|
||||
setLen(s, L)
|
||||
|
||||
proc select*(readfds: var seq[SocketHandle], timeout = 500): int {.deprecated.} =
|
||||
proc select*(readfds: var seq[SocketHandle], timeout = 500): int {.deprecated: "use selectRead instead".} =
|
||||
## When a socket in ``readfds`` is ready to be read from then a non-zero
|
||||
## value will be returned specifying the count of the sockets which can be
|
||||
## read from. The sockets which can be read from will also be removed
|
||||
|
||||
@@ -110,9 +110,6 @@ when defineSsl:
|
||||
serverGetPskFunc: SslServerGetPskFunc
|
||||
clientGetPskFunc: SslClientGetPskFunc
|
||||
|
||||
{.deprecated: [ESSL: SSLError, TSSLCVerifyMode: SSLCVerifyMode,
|
||||
TSSLProtVersion: SSLProtVersion, PSSLContext: SSLContext,
|
||||
TSSLAcceptResult: SSLAcceptResult].}
|
||||
else:
|
||||
type
|
||||
SslContext* = void # TODO: Workaround #4797.
|
||||
@@ -159,10 +156,6 @@ type
|
||||
Peek,
|
||||
SafeDisconn ## Ensures disconnection exceptions (ECONNRESET, EPIPE etc) are not thrown.
|
||||
|
||||
{.deprecated: [TSocketFlags: SocketFlag, ETimeout: TimeoutError,
|
||||
TReadLineResult: ReadLineResult, TSOBool: SOBool, PSocket: Socket,
|
||||
TSocketImpl: SocketImpl].}
|
||||
|
||||
type
|
||||
IpAddressFamily* {.pure.} = enum ## Describes the type of an IP address
|
||||
IPv6, ## IPv6 address
|
||||
@@ -176,8 +169,6 @@ type
|
||||
of IpAddressFamily.IPv4:
|
||||
address_v4*: array[0..3, uint8] ## Contains the IP address in bytes in
|
||||
## case of IPv4
|
||||
{.deprecated: [TIpAddress: IpAddress].}
|
||||
|
||||
|
||||
proc socketError*(socket: Socket, err: int = -1, async = false,
|
||||
lastError = (-1).OSErrorCode): void {.gcsafe.}
|
||||
|
||||
@@ -30,7 +30,6 @@ when not declared(system.StackTrace):
|
||||
type StackTrace = object
|
||||
lines: array[0..20, cstring]
|
||||
files: array[0..20, cstring]
|
||||
{.deprecated: [TStackTrace: StackTrace].}
|
||||
proc `[]`*(st: StackTrace, i: int): cstring = st.lines[i]
|
||||
|
||||
# We use a simple hash table of bounded size to keep track of the stack traces:
|
||||
@@ -39,7 +38,6 @@ type
|
||||
total: int
|
||||
st: StackTrace
|
||||
ProfileData = array[0..64*1024-1, ptr ProfileEntry]
|
||||
{.deprecated: [TProfileEntry: ProfileEntry, TProfileData: ProfileData].}
|
||||
|
||||
proc `==`(a, b: StackTrace): bool =
|
||||
for i in 0 .. high(a.lines):
|
||||
|
||||
@@ -23,11 +23,9 @@ type
|
||||
fuzz: int32 ##
|
||||
count: int32 ##
|
||||
|
||||
{.deprecated: [Toid: Oid].}
|
||||
|
||||
proc `==`*(oid1: Oid, oid2: Oid): bool =
|
||||
## Compare two Mongo Object IDs for equality
|
||||
return (oid1.time == oid2.time) and (oid1.fuzz == oid2.fuzz) and (oid1.count == oid2.count)
|
||||
## Compare two Mongo Object IDs for equality
|
||||
return (oid1.time == oid2.time) and (oid1.fuzz == oid2.fuzz) and (oid1.count == oid2.count)
|
||||
|
||||
proc hexbyte*(hex: char): int =
|
||||
case hex
|
||||
|
||||
@@ -431,8 +431,6 @@ type
|
||||
fpOthersWrite, ## write access for others
|
||||
fpOthersRead ## read access for others
|
||||
|
||||
{.deprecated: [TFilePermission: FilePermission].}
|
||||
|
||||
proc getFilePermissions*(filename: string): set[FilePermission] {.
|
||||
rtl, extern: "nos$1", tags: [ReadDirEffect].} =
|
||||
## retrieves file permissions for `filename`. `OSError` is raised in case of
|
||||
@@ -730,8 +728,6 @@ type
|
||||
pcDir, ## path refers to a directory
|
||||
pcLinkToDir ## path refers to a symbolic link to a directory
|
||||
|
||||
{.deprecated: [TPathComponent: PathComponent].}
|
||||
|
||||
|
||||
when defined(posix):
|
||||
proc getSymlinkFileKind(path: string): PathComponent =
|
||||
@@ -1441,18 +1437,6 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =
|
||||
if result.len == 0:
|
||||
result = getApplHeuristic()
|
||||
|
||||
proc getApplicationFilename*(): string {.rtl, extern: "nos$1", deprecated.} =
|
||||
## Returns the filename of the application's executable.
|
||||
## **Deprecated since version 0.8.12**: use ``getAppFilename``
|
||||
## instead.
|
||||
result = getAppFilename()
|
||||
|
||||
proc getApplicationDir*(): string {.rtl, extern: "nos$1", deprecated.} =
|
||||
## Returns the directory of the application's executable.
|
||||
## **Deprecated since version 0.8.12**: use ``getAppDir``
|
||||
## instead.
|
||||
result = splitFile(getAppFilename()).dir
|
||||
|
||||
proc getAppDir*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =
|
||||
## Returns the directory of the application's executable.
|
||||
result = splitFile(getAppFilename()).dir
|
||||
|
||||
@@ -29,11 +29,6 @@ type
|
||||
|
||||
OSErrorCode* = distinct int32 ## Specifies an OS Error Code.
|
||||
|
||||
{.deprecated: [FReadEnv: ReadEnvEffect, FWriteEnv: WriteEnvEffect,
|
||||
FReadDir: ReadDirEffect,
|
||||
FWriteDir: WriteDirEffect,
|
||||
TOSErrorCode: OSErrorCode
|
||||
].}
|
||||
const
|
||||
doslikeFileSystem* = defined(windows) or defined(OS2) or defined(DOS)
|
||||
|
||||
|
||||
@@ -61,9 +61,6 @@ type
|
||||
Process* = ref ProcessObj ## represents an operating system process
|
||||
|
||||
|
||||
{.deprecated: [TProcess: ProcessObj, PProcess: Process,
|
||||
TProcessOption: ProcessOption].}
|
||||
|
||||
const poUseShell* {.deprecated.} = poUsePath
|
||||
## Deprecated alias for poUsePath.
|
||||
|
||||
@@ -373,17 +370,15 @@ template streamAccess(p) =
|
||||
when defined(Windows) and not defined(useNimRtl):
|
||||
# We need to implement a handle stream for Windows:
|
||||
type
|
||||
PFileHandleStream = ref FileHandleStream
|
||||
FileHandleStream = object of StreamObj
|
||||
FileHandleStream = ref object of StreamObj
|
||||
handle: Handle
|
||||
atTheEnd: bool
|
||||
{.deprecated: [TFileHandleStream: FileHandleStream].}
|
||||
|
||||
proc hsClose(s: Stream) = discard # nothing to do here
|
||||
proc hsAtEnd(s: Stream): bool = return PFileHandleStream(s).atTheEnd
|
||||
proc hsAtEnd(s: Stream): bool = return FileHandleStream(s).atTheEnd
|
||||
|
||||
proc hsReadData(s: Stream, buffer: pointer, bufLen: int): int =
|
||||
var s = PFileHandleStream(s)
|
||||
var s = FileHandleStream(s)
|
||||
if s.atTheEnd: return 0
|
||||
var br: int32
|
||||
var a = winlean.readFile(s.handle, buffer, bufLen.cint, addr br, nil)
|
||||
@@ -395,13 +390,13 @@ when defined(Windows) and not defined(useNimRtl):
|
||||
result = br
|
||||
|
||||
proc hsWriteData(s: Stream, buffer: pointer, bufLen: int) =
|
||||
var s = PFileHandleStream(s)
|
||||
var s = FileHandleStream(s)
|
||||
var bytesWritten: int32
|
||||
var a = winlean.writeFile(s.handle, buffer, bufLen.cint,
|
||||
addr bytesWritten, nil)
|
||||
if a == 0: raiseOSError(osLastError())
|
||||
|
||||
proc newFileHandleStream(handle: Handle): PFileHandleStream =
|
||||
proc newFileHandleStream(handle: Handle): FileHandleStream =
|
||||
new(result)
|
||||
result.handle = handle
|
||||
result.closeImpl = hsClose
|
||||
@@ -527,7 +522,7 @@ when defined(Windows) and not defined(useNimRtl):
|
||||
if setHandleInformation(he, DWORD(1), DWORD(0)) == 0'i32:
|
||||
raiseOsError(osLastError())
|
||||
if setHandleInformation(hi, DWORD(1), DWORD(0)) == 0'i32:
|
||||
raiseOsError(osLastError())
|
||||
raiseOsError(osLastError())
|
||||
if setHandleInformation(ho, DWORD(1), DWORD(0)) == 0'i32:
|
||||
raiseOsError(osLastError())
|
||||
else:
|
||||
@@ -752,14 +747,14 @@ elif not defined(useNimRtl):
|
||||
copyMem(result[i], addr(x[0]), x.len+1)
|
||||
inc(i)
|
||||
|
||||
type StartProcessData = object
|
||||
sysCommand: string
|
||||
sysArgs: cstringArray
|
||||
sysEnv: cstringArray
|
||||
workingDir: cstring
|
||||
pStdin, pStdout, pStderr, pErrorPipe: array[0..1, cint]
|
||||
options: set[ProcessOption]
|
||||
{.deprecated: [TStartProcessData: StartProcessData].}
|
||||
type
|
||||
StartProcessData = object
|
||||
sysCommand: string
|
||||
sysArgs: cstringArray
|
||||
sysEnv: cstringArray
|
||||
workingDir: cstring
|
||||
pStdin, pStdout, pStderr, pErrorPipe: array[0..1, cint]
|
||||
options: set[ProcessOption]
|
||||
|
||||
const useProcessAuxSpawn = declared(posix_spawn) and not defined(useFork) and
|
||||
not defined(useClone) and not defined(linux)
|
||||
|
||||
@@ -125,9 +125,6 @@ type
|
||||
tok: Token
|
||||
filename: string
|
||||
|
||||
{.deprecated: [TCfgEventKind: CfgEventKind, TCfgEvent: CfgEvent,
|
||||
TTokKind: TokKind, TToken: Token, TCfgParser: CfgParser].}
|
||||
|
||||
# implementation
|
||||
|
||||
const
|
||||
|
||||
@@ -66,8 +66,6 @@ type
|
||||
CsvError* = object of IOError ## exception that is raised if
|
||||
## a parsing error occurs
|
||||
|
||||
{.deprecated: [TCsvRow: CsvRow, TCsvParser: CsvParser, EInvalidCsv: CsvError].}
|
||||
|
||||
proc raiseEInvalidCsv(filename: string, line, col: int,
|
||||
msg: string) {.noreturn.} =
|
||||
var e: ref CsvError
|
||||
|
||||
@@ -54,8 +54,6 @@ type
|
||||
## or the argument, ``value`` is not "" if
|
||||
## the option was given a value
|
||||
|
||||
{.deprecated: [TCmdLineKind: CmdLineKind, TOptParser: OptParser].}
|
||||
|
||||
proc parseWord(s: string, i: int, w: var string,
|
||||
delim: set[char] = {'\x09', ' '}): int =
|
||||
result = i
|
||||
|
||||
@@ -41,8 +41,6 @@ type
|
||||
## or the argument, ``value`` is not "" if
|
||||
## the option was given a value
|
||||
|
||||
{.deprecated: [TCmdLineKind: CmdLineKind, TOptParser: OptParser].}
|
||||
|
||||
proc initOptParser*(cmdline: seq[string]): OptParser {.rtl.} =
|
||||
## Initalizes option parses with cmdline. cmdline should not contain
|
||||
## argument 0 - program name.
|
||||
@@ -122,8 +120,6 @@ proc cmdLineRest*(p: OptParser): TaintedString {.rtl, extern: "npo2$1", deprecat
|
||||
type
|
||||
GetoptResult* = tuple[kind: CmdLineKind, key, val: TaintedString]
|
||||
|
||||
{.deprecated: [TGetoptResult: GetoptResult].}
|
||||
|
||||
iterator getopt*(p: var OptParser): GetoptResult =
|
||||
## This is an convenience iterator for iterating over the given OptParser object.
|
||||
## Example:
|
||||
|
||||
@@ -45,8 +45,6 @@ type
|
||||
SqlLexer* = object of BaseLexer ## the parser object.
|
||||
filename: string
|
||||
|
||||
{.deprecated: [TToken: Token, TSqlLexer: SqlLexer].}
|
||||
|
||||
const
|
||||
tokKindToStr: array[TokKind, string] = [
|
||||
"invalid", "[EOF]", "identifier", "quoted identifier", "string constant",
|
||||
|
||||
@@ -365,8 +365,6 @@ type
|
||||
ikVar, ## ``var`` part of the interpolated string
|
||||
ikExpr ## ``expr`` part of the interpolated string
|
||||
|
||||
{.deprecated: [TInterpolatedKind: InterpolatedKind].}
|
||||
|
||||
iterator interpolatedFragments*(s: string): tuple[kind: InterpolatedKind,
|
||||
value: string] =
|
||||
## Tokenizes the string `s` into substrings for interpolation purposes.
|
||||
|
||||
@@ -98,9 +98,6 @@ type
|
||||
filename: string
|
||||
options: set[XmlParseOption]
|
||||
|
||||
{.deprecated: [TXmlParser: XmlParser, TXmlParseOptions: XmlParseOption,
|
||||
TXmlError: XmlErrorKind, TXmlEventKind: XmlEventKind].}
|
||||
|
||||
const
|
||||
errorMessages: array[XmlErrorKind, string] = [
|
||||
"no error",
|
||||
|
||||
@@ -74,8 +74,8 @@ type
|
||||
line: int ## line the symbol has been declared/used in
|
||||
col: int ## column the symbol has been declared/used in
|
||||
flags: set[NonTerminalFlag] ## the nonterminal's flags
|
||||
rule: Node ## the rule that the symbol refers to
|
||||
Node {.shallow.} = object
|
||||
rule: Peg ## the rule that the symbol refers to
|
||||
Peg* {.shallow.} = object ## type that represents a PEG
|
||||
case kind: PegKind
|
||||
of pkEmpty..pkWhitespace: nil
|
||||
of pkTerminal, pkTerminalIgnoreCase, pkTerminalIgnoreStyle: term: string
|
||||
@@ -83,13 +83,9 @@ type
|
||||
of pkCharChoice, pkGreedyRepSet: charChoice: ref set[char]
|
||||
of pkNonTerminal: nt: NonTerminal
|
||||
of pkBackRef..pkBackRefIgnoreStyle: index: range[0..MaxSubpatterns]
|
||||
else: sons: seq[Node]
|
||||
else: sons: seq[Peg]
|
||||
NonTerminal* = ref NonTerminalObj
|
||||
|
||||
Peg* = Node ## type that represents a PEG
|
||||
|
||||
{.deprecated: [TPeg: Peg, TNode: Node].}
|
||||
|
||||
proc term*(t: string): Peg {.nosideEffect, rtl, extern: "npegs$1Str".} =
|
||||
## constructs a PEG from a terminal string
|
||||
if t.len != 1:
|
||||
|
||||
@@ -37,8 +37,6 @@ type
|
||||
length: int
|
||||
data: string # != nil if a leaf
|
||||
|
||||
{.deprecated: [PRope: Rope].}
|
||||
|
||||
proc isConc(r: Rope): bool {.inline.} = return isNil(r.data)
|
||||
|
||||
# Note that the left and right pointers are not needed for leafs.
|
||||
|
||||
@@ -94,9 +94,6 @@ type
|
||||
disp: Dispatcher
|
||||
AsyncScgiState* = ref AsyncScgiStateObj
|
||||
|
||||
{.deprecated: [EScgi: ScgiError, TScgiState: ScgiState,
|
||||
PAsyncScgiState: AsyncScgiState].}
|
||||
|
||||
proc recvBuffer(s: var ScgiState, L: int) =
|
||||
if L > s.bufLen:
|
||||
s.bufLen = L
|
||||
|
||||
@@ -271,7 +271,7 @@ else:
|
||||
msg.add("Internal Error\n")
|
||||
var err = newException(IOSelectorsException, msg)
|
||||
raise err
|
||||
|
||||
|
||||
proc setNonBlocking(fd: cint) {.inline.} =
|
||||
setBlocking(fd.SocketHandle, false)
|
||||
|
||||
@@ -316,18 +316,18 @@ else:
|
||||
include ioselects/ioselectors_poll
|
||||
|
||||
proc register*[T](s: Selector[T], fd: int | SocketHandle,
|
||||
events: set[Event], data: T) {.deprecated.} =
|
||||
events: set[Event], data: T) {.deprecated: "use registerHandle instead".} =
|
||||
## **Deprecated since v0.18.0:** Use ``registerHandle`` instead.
|
||||
s.registerHandle(fd, events, data)
|
||||
|
||||
proc setEvent*(ev: SelectEvent) {.deprecated.} =
|
||||
proc setEvent*(ev: SelectEvent) {.deprecated: "use trigger instead".} =
|
||||
## Trigger event ``ev``.
|
||||
##
|
||||
## **Deprecated since v0.18.0:** Use ``trigger`` instead.
|
||||
ev.trigger()
|
||||
|
||||
proc update*[T](s: Selector[T], fd: int | SocketHandle,
|
||||
events: set[Event]) {.deprecated.} =
|
||||
events: set[Event]) {.deprecated: "use updateHandle instead".} =
|
||||
## Update file/socket descriptor ``fd``, registered in selector
|
||||
## ``s`` with new events set ``event``.
|
||||
##
|
||||
|
||||
@@ -51,8 +51,6 @@ type
|
||||
Smtp* = SmtpBase[Socket]
|
||||
AsyncSmtp* = SmtpBase[AsyncSocket]
|
||||
|
||||
{.deprecated: [EInvalidReply: ReplyError, TMessage: Message, TSMTP: Smtp].}
|
||||
|
||||
proc debugSend(smtp: Smtp | AsyncSmtp, cmd: string) {.multisync.} =
|
||||
if smtp.debug:
|
||||
echo("C:" & cmd)
|
||||
|
||||
@@ -65,8 +65,6 @@ type
|
||||
y_stats*: RunningStat ## stats for second set of data
|
||||
s_xy: float ## accumulated data for combined xy
|
||||
|
||||
{.deprecated: [TFloatClass: FloatClass, TRunningStat: RunningStat].}
|
||||
|
||||
# ----------- RunningStat --------------------------
|
||||
proc clear*(s: var RunningStat) =
|
||||
## reset `s`
|
||||
|
||||
@@ -57,8 +57,6 @@ type
|
||||
tags: [WriteIOEffect], gcsafe.}
|
||||
flushImpl*: proc (s: Stream) {.nimcall, tags: [WriteIOEffect], gcsafe.}
|
||||
|
||||
{.deprecated: [PStream: Stream, TStream: StreamObj].}
|
||||
|
||||
proc flush*(s: Stream) =
|
||||
## flushes the buffers that the stream `s` might use.
|
||||
if not isNil(s.flushImpl): s.flushImpl(s)
|
||||
@@ -76,27 +74,14 @@ proc atEnd*(s: Stream): bool =
|
||||
## been read.
|
||||
result = s.atEndImpl(s)
|
||||
|
||||
proc atEnd*(s, unused: Stream): bool {.deprecated.} =
|
||||
## checks if more data can be read from `f`. Returns true if all data has
|
||||
## been read.
|
||||
result = s.atEndImpl(s)
|
||||
|
||||
proc setPosition*(s: Stream, pos: int) =
|
||||
## sets the position `pos` of the stream `s`.
|
||||
s.setPositionImpl(s, pos)
|
||||
|
||||
proc setPosition*(s, unused: Stream, pos: int) {.deprecated.} =
|
||||
## sets the position `pos` of the stream `s`.
|
||||
s.setPositionImpl(s, pos)
|
||||
|
||||
proc getPosition*(s: Stream): int =
|
||||
## retrieves the current position in the stream `s`.
|
||||
result = s.getPositionImpl(s)
|
||||
|
||||
proc getPosition*(s, unused: Stream): int {.deprecated.} =
|
||||
## retrieves the current position in the stream `s`.
|
||||
result = s.getPositionImpl(s)
|
||||
|
||||
proc readData*(s: Stream, buffer: pointer, bufLen: int): int =
|
||||
## low level proc that reads data into an untyped `buffer` of `bufLen` size.
|
||||
result = s.readDataImpl(s, buffer, bufLen)
|
||||
@@ -114,11 +99,6 @@ proc readAll*(s: Stream): string =
|
||||
inc r, bufferSize
|
||||
setLen(result, r+bufferSize)
|
||||
|
||||
proc readData*(s, unused: Stream, buffer: pointer,
|
||||
bufLen: int): int {.deprecated.} =
|
||||
## low level proc that reads data into an untyped `buffer` of `bufLen` size.
|
||||
result = s.readDataImpl(s, buffer, bufLen)
|
||||
|
||||
proc peekData*(s: Stream, buffer: pointer, bufLen: int): int =
|
||||
## low level proc that reads data into an untyped `buffer` of `bufLen` size
|
||||
## without moving stream position
|
||||
@@ -153,11 +133,6 @@ proc write*(s: Stream, x: string) =
|
||||
else:
|
||||
if x.len > 0: writeData(s, unsafeAddr x[0], x.len)
|
||||
|
||||
proc writeLn*(s: Stream, args: varargs[string, `$`]) {.deprecated.} =
|
||||
## **Deprecated since version 0.11.4:** Use **writeLine** instead.
|
||||
for str in args: write(s, str)
|
||||
write(s, "\n")
|
||||
|
||||
proc writeLine*(s: Stream, args: varargs[string, `$`]) =
|
||||
## writes one or more strings to the the stream `s` followed
|
||||
## by a new line. No length field or terminating zero is written.
|
||||
@@ -348,8 +323,6 @@ when not defined(js):
|
||||
data*: string
|
||||
pos: int
|
||||
|
||||
{.deprecated: [PStringStream: StringStream, TStringStream: StringStreamObj].}
|
||||
|
||||
proc ssAtEnd(s: Stream): bool =
|
||||
var s = StringStream(s)
|
||||
return s.pos >= s.data.len
|
||||
@@ -409,7 +382,6 @@ when not defined(js):
|
||||
FileStream* = ref FileStreamObj ## a stream that encapsulates a `File`
|
||||
FileStreamObj* = object of Stream
|
||||
f: File
|
||||
{.deprecated: [PFileStream: FileStream, TFileStream: FileStreamObj].}
|
||||
|
||||
proc fsClose(s: Stream) =
|
||||
if FileStream(s).f != nil:
|
||||
@@ -472,9 +444,6 @@ else:
|
||||
handle*: FileHandle
|
||||
pos: int
|
||||
|
||||
{.deprecated: [PFileHandleStream: FileHandleStream,
|
||||
TFileHandleStream: FileHandleStreamObj].}
|
||||
|
||||
proc newEOS(msg: string): ref OSError =
|
||||
new(result)
|
||||
result.msg = msg
|
||||
|
||||
@@ -17,9 +17,7 @@ import
|
||||
|
||||
when defined(js):
|
||||
{.pragma: rtlFunc.}
|
||||
{.pragma: deprecatedGetFunc.}
|
||||
else:
|
||||
{.pragma: deprecatedGetFunc, deprecatedGet.}
|
||||
{.pragma: rtlFunc, rtl.}
|
||||
import os
|
||||
include "system/inclrtl"
|
||||
@@ -38,9 +36,6 @@ type
|
||||
|
||||
StringTableRef* = ref StringTableObj ## use this type to declare string tables
|
||||
|
||||
{.deprecated: [TStringTableMode: StringTableMode,
|
||||
TStringTable: StringTableObj, PStringTable: StringTableRef].}
|
||||
|
||||
proc len*(t: StringTableRef): int {.rtlFunc, extern: "nst$1".} =
|
||||
## returns the number of keys in `t`.
|
||||
result = t.counter
|
||||
@@ -73,10 +68,6 @@ type
|
||||
useKey ## do not replace ``$key`` if it is not found
|
||||
## in the table (or in the environment)
|
||||
|
||||
{.deprecated: [TFormatFlag: FormatFlag].}
|
||||
|
||||
# implementation
|
||||
|
||||
const
|
||||
growthFactor = 2
|
||||
startSize = 64
|
||||
@@ -118,17 +109,12 @@ template get(t: StringTableRef, key: string) =
|
||||
raise newException(KeyError, "key not found")
|
||||
|
||||
proc `[]`*(t: StringTableRef, key: string): var string {.
|
||||
rtlFunc, extern: "nstTake", deprecatedGetFunc.} =
|
||||
rtlFunc, extern: "nstTake".} =
|
||||
## retrieves the location at ``t[key]``. If `key` is not in `t`, the
|
||||
## ``KeyError`` exception is raised. One can check with ``hasKey`` whether
|
||||
## the key exists.
|
||||
get(t, key)
|
||||
|
||||
proc mget*(t: StringTableRef, key: string): var string {.deprecated.} =
|
||||
## retrieves the location at ``t[key]``. If `key` is not in `t`, the
|
||||
## ``KeyError`` exception is raised. Use ```[]``` instead.
|
||||
get(t, key)
|
||||
|
||||
proc getOrDefault*(t: StringTableRef; key: string, default: string = ""): string =
|
||||
var index = rawGet(t, key)
|
||||
if index >= 0: result = t.data[index].val
|
||||
@@ -193,7 +179,8 @@ proc newStringTable*(mode: StringTableMode): StringTableRef {.
|
||||
result.counter = 0
|
||||
newSeq(result.data, startSize)
|
||||
|
||||
proc clear*(s: StringTableRef, mode: StringTableMode) =
|
||||
proc clear*(s: StringTableRef, mode: StringTableMode) {.
|
||||
rtlFunc, extern: "nst$1".} =
|
||||
## resets a string table to be empty again.
|
||||
s.mode = mode
|
||||
s.counter = 0
|
||||
|
||||
@@ -31,8 +31,6 @@ type
|
||||
SubexError* = object of ValueError ## exception that is raised for
|
||||
## an invalid subex
|
||||
|
||||
{.deprecated: [EInvalidSubex: SubexError].}
|
||||
|
||||
proc raiseInvalidFormat(msg: string) {.noinline.} =
|
||||
raise newException(SubexError, "invalid format string: " & msg)
|
||||
|
||||
@@ -44,7 +42,6 @@ type
|
||||
else:
|
||||
f: cstring
|
||||
num, i, lineLen: int
|
||||
{.deprecated: [TFormatParser: FormatParser].}
|
||||
|
||||
template call(x: untyped): untyped =
|
||||
p.i = i
|
||||
|
||||
@@ -18,14 +18,12 @@ type
|
||||
hostname*, port*, path*, query*, anchor*: string
|
||||
opaque*: bool
|
||||
|
||||
{.deprecated: [TUrl: Url, TUri: Uri].}
|
||||
|
||||
{.push warning[deprecated]: off.}
|
||||
proc `$`*(url: Url): string {.deprecated.} =
|
||||
proc `$`*(url: Url): string {.deprecated: "use Uri instead".} =
|
||||
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||
return string(url)
|
||||
|
||||
proc `/`*(a, b: Url): Url {.deprecated.} =
|
||||
proc `/`*(a, b: Url): Url {.deprecated: "use Uri instead".} =
|
||||
## Joins two URLs together, separating them with / if needed.
|
||||
##
|
||||
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||
@@ -40,7 +38,7 @@ proc `/`*(a, b: Url): Url {.deprecated.} =
|
||||
urlS.add(bs)
|
||||
result = Url(urlS)
|
||||
|
||||
proc add*(url: var Url, a: Url) {.deprecated.} =
|
||||
proc add*(url: var Url, a: Url) {.deprecated: "use Uri instead".} =
|
||||
## Appends url to url.
|
||||
##
|
||||
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||
|
||||
@@ -16,8 +16,6 @@ type
|
||||
## for invalid XML.
|
||||
errors*: seq[string] ## All detected parsing errors.
|
||||
|
||||
{.deprecated: [EInvalidXml: XmlError].}
|
||||
|
||||
proc raiseInvalidXml(errors: seq[string]) =
|
||||
var e: ref XmlError
|
||||
new(e)
|
||||
|
||||
@@ -33,9 +33,6 @@ type
|
||||
fAttr: XmlAttributes
|
||||
fClientData: int ## for other clients
|
||||
|
||||
{.deprecated: [PXmlNode: XmlNode, TXmlNodeKind: XmlNodeKind, PXmlAttributes:
|
||||
XmlAttributes, TXmlNode: XmlNodeObj].}
|
||||
|
||||
proc newXmlNode(kind: XmlNodeKind): XmlNode =
|
||||
## creates a new ``XmlNode``.
|
||||
new(result)
|
||||
@@ -155,11 +152,6 @@ proc `[]`* (n: var XmlNode, i: int): var XmlNode {.inline.} =
|
||||
assert n.k == xnElement
|
||||
result = n.s[i]
|
||||
|
||||
proc mget*(n: var XmlNode, i: int): var XmlNode {.inline, deprecated.} =
|
||||
## returns the `i`'th child of `n` so that it can be modified. Use ```[]```
|
||||
## instead.
|
||||
n[i]
|
||||
|
||||
iterator items*(n: XmlNode): XmlNode {.inline.} =
|
||||
## iterates over any child of `n`.
|
||||
assert n.k == xnElement
|
||||
|
||||
Reference in New Issue
Block a user