mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-19 15:31:28 +00:00
Remove long deprecated stuff (#10332)
This commit is contained in:
@@ -561,31 +561,6 @@ proc escapeRe*(s: string): string =
|
||||
result.add("\\x")
|
||||
result.add(toHex(ord(c), 2))
|
||||
|
||||
const ## common regular expressions
|
||||
reIdentifier* {.deprecated.} = r"\b[a-zA-Z_]+[a-zA-Z_0-9]*\b"
|
||||
## describes an identifier
|
||||
reNatural* {.deprecated.} = r"\b\d+\b"
|
||||
## describes a natural number
|
||||
reInteger* {.deprecated.} = r"\b[-+]?\d+\b"
|
||||
## describes an integer
|
||||
reHex* {.deprecated.} = r"\b0[xX][0-9a-fA-F]+\b"
|
||||
## describes a hexadecimal number
|
||||
reBinary* {.deprecated.} = r"\b0[bB][01]+\b"
|
||||
## describes a binary number (example: 0b11101)
|
||||
reOctal* {.deprecated.} = r"\b0[oO][0-7]+\b"
|
||||
## describes an octal number (example: 0o777)
|
||||
reFloat* {.deprecated.} = r"\b[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\b"
|
||||
## describes a floating point number
|
||||
reEmail* {.deprecated.} = r"\b[a-zA-Z0-9!#$%&'*+/=?^_`{|}~\-]+(?:\. &" &
|
||||
r"[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@" &
|
||||
r"(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+" &
|
||||
r"(?:[a-zA-Z]{2}|com|org|net|gov|mil|biz|" &
|
||||
r"info|mobi|name|aero|jobs|museum)\b"
|
||||
## describes a common email address
|
||||
reURL* {.deprecated.} = r"\b(http(s)?|ftp|gopher|telnet|file|notes|ms-help)" &
|
||||
r":((//)|(\\\\))+[\w\d:#@%/;$()~_?\+\-\=\\\.\&]*\b"
|
||||
## describes an URL
|
||||
|
||||
when isMainModule:
|
||||
doAssert match("(a b c)", rex"\( .* \)")
|
||||
doAssert match("WHiLe", re("while", {reIgnoreCase}))
|
||||
@@ -595,7 +570,7 @@ when isMainModule:
|
||||
doAssert "ABC".match(rex"\d+ | \w+")
|
||||
|
||||
{.push warnings:off.}
|
||||
doAssert matchLen("key", re(reIdentifier)) == 3
|
||||
doAssert matchLen("key", re"\b[a-zA-Z_]+[a-zA-Z_0-9]*\b") == 3
|
||||
{.pop.}
|
||||
|
||||
var pattern = re"[a-z0-9]+\s*=\s*[a-z0-9]+"
|
||||
|
||||
@@ -416,12 +416,12 @@ type
|
||||
BoundingRect* {.importc.} = ref object
|
||||
top*, bottom*, left*, right*, x*, y*, width*, height*: float
|
||||
|
||||
PerformanceMemory* {.importc.} = ref object
|
||||
PerformanceMemory* {.importc.} = ref object
|
||||
jsHeapSizeLimit*: float
|
||||
totalJSHeapSize*: float
|
||||
usedJSHeapSize*: float
|
||||
|
||||
PerformanceTiming* {.importc.} = ref object
|
||||
PerformanceTiming* {.importc.} = ref object
|
||||
connectStart*: float
|
||||
domComplete*: float
|
||||
domContentLoadedEventEnd*: float
|
||||
@@ -459,7 +459,6 @@ proc dispatchEvent*(et: EventTarget, ev: Event)
|
||||
proc alert*(w: Window, msg: cstring)
|
||||
proc back*(w: Window)
|
||||
proc blur*(w: Window)
|
||||
proc captureEvents*(w: Window, eventMask: int) {.deprecated.}
|
||||
proc clearInterval*(w: Window, interval: ref TInterval)
|
||||
proc clearTimeout*(w: Window, timeout: ref TTimeOut)
|
||||
proc close*(w: Window)
|
||||
@@ -478,7 +477,6 @@ proc open*(w: Window, uri, windowname: cstring,
|
||||
properties: cstring = nil): Window
|
||||
proc print*(w: Window)
|
||||
proc prompt*(w: Window, text, default: cstring): cstring
|
||||
proc releaseEvents*(w: Window, eventMask: int) {.deprecated.}
|
||||
proc resizeBy*(w: Window, x, y: int)
|
||||
proc resizeTo*(w: Window, x, y: int)
|
||||
proc routeEvent*(w: Window, event: Event)
|
||||
@@ -513,7 +511,6 @@ proc setAttribute*(n: Node, name, value: cstring)
|
||||
proc setAttributeNode*(n: Node, attr: Node)
|
||||
|
||||
# Document "methods"
|
||||
proc captureEvents*(d: Document, eventMask: int) {.deprecated.}
|
||||
proc createAttribute*(d: Document, identifier: cstring): Node
|
||||
proc createElement*(d: Document, identifier: cstring): Element
|
||||
proc createTextNode*(d: Document, identifier: cstring): Node
|
||||
@@ -524,7 +521,6 @@ proc getElementsByClassName*(d: Document, name: cstring): seq[Element]
|
||||
proc getSelection*(d: Document): cstring
|
||||
proc handleEvent*(d: Document, event: Event)
|
||||
proc open*(d: Document)
|
||||
proc releaseEvents*(d: Document, eventMask: int) {.deprecated.}
|
||||
proc routeEvent*(d: Document, event: Event)
|
||||
proc write*(d: Document, text: cstring)
|
||||
proc writeln*(d: Document, text: cstring)
|
||||
@@ -605,25 +601,3 @@ proc parseInt*(s: cstring): int {.importc, nodecl.}
|
||||
proc parseInt*(s: cstring, radix: int):int {.importc, nodecl.}
|
||||
|
||||
proc newEvent*(name: cstring): Event {.importcpp: "new Event(@)", constructor.}
|
||||
|
||||
type
|
||||
TEventHandlers* {.deprecated.} = EventTargetObj
|
||||
TWindow* {.deprecated.} = WindowObj
|
||||
TFrame* {.deprecated.} = FrameObj
|
||||
TNode* {.deprecated.} = NodeObj
|
||||
TDocument* {.deprecated.} = DocumentObj
|
||||
TElement* {.deprecated.} = ElementObj
|
||||
TLink* {.deprecated.} = LinkObj
|
||||
TEmbed* {.deprecated.} = EmbedObj
|
||||
TAnchor* {.deprecated.} = AnchorObj
|
||||
TOption* {.deprecated.} = OptionObj
|
||||
TForm* {.deprecated.} = FormObj
|
||||
TImage* {.deprecated.} = ImageObj
|
||||
TNodeType* {.deprecated.} = NodeType
|
||||
TEvent* {.deprecated.} = EventObj
|
||||
TLocation* {.deprecated.} = LocationObj
|
||||
THistory* {.deprecated.} = HistoryObj
|
||||
TNavigator* {.deprecated.} = NavigatorObj
|
||||
TStyle* {.deprecated.} = StyleObj
|
||||
TScreen* {.deprecated.} = ScreenObj
|
||||
TApplet* {.importc, deprecated.} = object of RootObj
|
||||
|
||||
@@ -337,11 +337,6 @@ proc setStackTraceStdout*() =
|
||||
## Makes Nim output stacktraces to stdout, instead of server log.
|
||||
errorMessageWriter = writeErrorMessage
|
||||
|
||||
proc setStackTraceNewLine*() {.deprecated.} =
|
||||
## Makes Nim output stacktraces to stdout, instead of server log.
|
||||
## Depracated alias for setStackTraceStdout.
|
||||
setStackTraceStdout()
|
||||
|
||||
proc setCookie*(name, value: string) =
|
||||
## Sets a cookie.
|
||||
write(stdout, "Set-Cookie: ", name, "=", value, "\n")
|
||||
|
||||
@@ -202,12 +202,6 @@ proc `[]`*[T](c: var CritBitTree[T], key: string): var T {.inline,
|
||||
## If `key` is not in `t`, the ``KeyError`` exception is raised.
|
||||
get(c, key)
|
||||
|
||||
proc mget*[T](c: var CritBitTree[T], key: string): var T {.inline, deprecated.} =
|
||||
## retrieves the value at ``c[key]``. The value can be modified.
|
||||
## If `key` is not in `t`, the ``KeyError`` exception is raised.
|
||||
## Use ``[]`` instead.
|
||||
get(c, key)
|
||||
|
||||
iterator leaves[T](n: Node[T]): Node[T] =
|
||||
if n != nil:
|
||||
# XXX actually we could compute the necessary stack size in advance:
|
||||
|
||||
@@ -357,12 +357,6 @@ proc `$`*(s: IntSet): string =
|
||||
## The `$` operator for int sets.
|
||||
dollarImpl()
|
||||
|
||||
proc empty*(s: IntSet): bool {.inline, deprecated.} =
|
||||
## Returns true if `s` is empty. This is safe to call even before
|
||||
## the set has been initialized with `initIntSet`. Note this never
|
||||
## worked reliably and so is deprecated.
|
||||
result = s.counter == 0
|
||||
|
||||
when isMainModule:
|
||||
import sequtils, algorithm
|
||||
|
||||
|
||||
@@ -191,13 +191,6 @@ proc `[]`*[A](s: var HashSet[A], key: A): var A =
|
||||
else:
|
||||
raise newException(KeyError, "key not found")
|
||||
|
||||
proc mget*[A](s: var HashSet[A], key: A): var A {.deprecated.} =
|
||||
## returns the element that is actually stored in 's' which has the same
|
||||
## value as 'key' or raises the ``KeyError`` exception. This is useful
|
||||
## when one overloaded 'hash' and '==' but still needs reference semantics
|
||||
## for sharing. Use ``[]`` instead.
|
||||
s[key]
|
||||
|
||||
proc contains*[A](s: HashSet[A], key: A): bool =
|
||||
## Returns true iff `key` is in `s`.
|
||||
##
|
||||
|
||||
@@ -189,12 +189,6 @@ proc body*(response: Response): string =
|
||||
response.body = response.bodyStream.readAll()
|
||||
return response.body
|
||||
|
||||
proc `body=`*(response: Response, value: string) {.deprecated.} =
|
||||
## Setter for backward compatibility.
|
||||
##
|
||||
## **This is deprecated and should not be used**.
|
||||
response.body = value
|
||||
|
||||
proc body*(response: AsyncResponse): Future[string] {.async.} =
|
||||
## Reads the response's body and caches it. The read is performed only
|
||||
## once.
|
||||
@@ -477,119 +471,6 @@ proc format(p: MultipartData): tuple[contentType, body: string] =
|
||||
result.body.add("--" & bound & "\c\L" & s)
|
||||
result.body.add("--" & bound & "--\c\L")
|
||||
|
||||
proc request*(url: string, httpMethod: string, extraHeaders = "",
|
||||
body = "", sslContext = getDefaultSSL(), timeout = -1,
|
||||
userAgent = defUserAgent, proxy: Proxy = nil): Response
|
||||
{.deprecated: "use HttpClient.request instead".} =
|
||||
## | Requests ``url`` with the custom method string specified by the
|
||||
## | ``httpMethod`` parameter.
|
||||
## | Extra headers can be specified and must be separated by ``\c\L``
|
||||
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||
## server takes longer than specified an ETimeout exception will be raised.
|
||||
##
|
||||
## **Deprecated since version 0.15.0**: use ``HttpClient.request`` instead.
|
||||
var r = if proxy == nil: parseUri(url) else: proxy.url
|
||||
var hostUrl = if proxy == nil: r else: parseUri(url)
|
||||
var headers = httpMethod.toUpperAscii()
|
||||
# TODO: Use generateHeaders further down once it supports proxies.
|
||||
|
||||
var s = newSocket()
|
||||
defer: s.close()
|
||||
if s == nil: raiseOSError(osLastError())
|
||||
var port = net.Port(80)
|
||||
if r.scheme == "https":
|
||||
when defined(ssl):
|
||||
sslContext.wrapSocket(s)
|
||||
port = net.Port(443)
|
||||
else:
|
||||
raise newException(HttpRequestError,
|
||||
"SSL support is not available. Cannot connect over SSL. Compile with -d:ssl to enable.")
|
||||
if r.port != "":
|
||||
port = net.Port(r.port.parseInt)
|
||||
|
||||
|
||||
# get the socket ready. If we are connecting through a proxy to SSL,
|
||||
# send the appropriate CONNECT header. If not, simply connect to the proper
|
||||
# host (which may still be the proxy, for normal HTTP)
|
||||
if proxy != nil and hostUrl.scheme == "https":
|
||||
when defined(ssl):
|
||||
var connectHeaders = "CONNECT "
|
||||
let targetPort = if hostUrl.port == "": 443 else: hostUrl.port.parseInt
|
||||
connectHeaders.add(hostUrl.hostname)
|
||||
connectHeaders.add(":" & $targetPort)
|
||||
connectHeaders.add(" HTTP/1.1\c\L")
|
||||
connectHeaders.add("Host: " & hostUrl.hostname & ":" & $targetPort & "\c\L")
|
||||
if proxy.auth != "":
|
||||
let auth = base64.encode(proxy.auth, newline = "")
|
||||
connectHeaders.add("Proxy-Authorization: basic " & auth & "\c\L")
|
||||
connectHeaders.add("\c\L")
|
||||
if timeout == -1:
|
||||
s.connect(r.hostname, port)
|
||||
else:
|
||||
s.connect(r.hostname, port, timeout)
|
||||
|
||||
s.send(connectHeaders)
|
||||
let connectResult = parseResponse(s, false, timeout)
|
||||
if not connectResult.status.startsWith("200"):
|
||||
raise newException(HttpRequestError,
|
||||
"The proxy server rejected a CONNECT request, " &
|
||||
"so a secure connection could not be established.")
|
||||
sslContext.wrapConnectedSocket(s, handshakeAsClient, hostUrl.hostname)
|
||||
else:
|
||||
raise newException(HttpRequestError, "SSL support not available. Cannot " &
|
||||
"connect via proxy over SSL. Compile with -d:ssl to enable.")
|
||||
else:
|
||||
if timeout == -1:
|
||||
s.connect(r.hostname, port)
|
||||
else:
|
||||
s.connect(r.hostname, port, timeout)
|
||||
|
||||
|
||||
# now that the socket is ready, prepare the headers
|
||||
if proxy == nil:
|
||||
headers.add ' '
|
||||
if r.path[0] != '/': headers.add '/'
|
||||
headers.add(r.path)
|
||||
if r.query.len > 0:
|
||||
headers.add("?" & r.query)
|
||||
else:
|
||||
headers.add(" " & url)
|
||||
|
||||
headers.add(" HTTP/1.1\c\L")
|
||||
|
||||
if hostUrl.port == "":
|
||||
add(headers, "Host: " & hostUrl.hostname & "\c\L")
|
||||
else:
|
||||
add(headers, "Host: " & hostUrl.hostname & ":" & hostUrl.port & "\c\L")
|
||||
|
||||
if userAgent != "":
|
||||
add(headers, "User-Agent: " & userAgent & "\c\L")
|
||||
if proxy != nil and proxy.auth != "":
|
||||
let auth = base64.encode(proxy.auth, newline = "")
|
||||
add(headers, "Proxy-Authorization: basic " & auth & "\c\L")
|
||||
add(headers, extraHeaders)
|
||||
add(headers, "\c\L")
|
||||
|
||||
# headers are ready. send them, await the result, and close the socket.
|
||||
s.send(headers)
|
||||
if body != "":
|
||||
s.send(body)
|
||||
|
||||
result = parseResponse(s, httpMethod != "HEAD", timeout)
|
||||
|
||||
proc request*(url: string, httpMethod = HttpGET, extraHeaders = "",
|
||||
body = "", sslContext = getDefaultSSL(), timeout = -1,
|
||||
userAgent = defUserAgent, proxy: Proxy = nil): Response
|
||||
{.deprecated.} =
|
||||
## | Requests ``url`` with the specified ``httpMethod``.
|
||||
## | Extra headers can be specified and must be separated by ``\c\L``
|
||||
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||
## server takes longer than specified an ETimeout exception will be raised.
|
||||
##
|
||||
## **Deprecated since version 0.15.0**: use ``HttpClient.request`` instead.
|
||||
result = request(url, $httpMethod, extraHeaders, body, sslContext, timeout,
|
||||
userAgent, proxy)
|
||||
|
||||
proc redirection(status: string): bool =
|
||||
const redirectionNRs = ["301", "302", "303", "307"]
|
||||
for i in items(redirectionNRs):
|
||||
@@ -608,130 +489,6 @@ proc getNewLocation(lastURL: string, headers: HttpHeaders): string =
|
||||
parsed.anchor = r.anchor
|
||||
result = $parsed
|
||||
|
||||
proc get*(url: string, extraHeaders = "", maxRedirects = 5,
|
||||
sslContext: SSLContext = getDefaultSSL(),
|
||||
timeout = -1, userAgent = defUserAgent,
|
||||
proxy: Proxy = nil): Response {.deprecated.} =
|
||||
## | GETs the ``url`` and returns a ``Response`` object
|
||||
## | This proc also handles redirection
|
||||
## | Extra headers can be specified and must be separated by ``\c\L``.
|
||||
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||
## 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,
|
||||
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,
|
||||
timeout, userAgent, proxy)
|
||||
lastURL = redirectTo
|
||||
|
||||
proc getContent*(url: string, extraHeaders = "", maxRedirects = 5,
|
||||
sslContext: SSLContext = getDefaultSSL(),
|
||||
timeout = -1, userAgent = defUserAgent,
|
||||
proxy: Proxy = nil): string {.deprecated.} =
|
||||
## | GETs the body and returns it as a string.
|
||||
## | Raises exceptions for the status codes ``4xx`` and ``5xx``
|
||||
## | Extra headers can be specified and must be separated by ``\c\L``.
|
||||
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||
## server takes longer than specified an ETimeout exception will be raised.
|
||||
##
|
||||
## **Deprecated since version 0.15.0**: use ``HttpClient.getContent`` instead.
|
||||
var r = get(url, extraHeaders, maxRedirects, sslContext, timeout, userAgent,
|
||||
proxy)
|
||||
if r.status[0] in {'4','5'}:
|
||||
raise newException(HttpRequestError, r.status)
|
||||
else:
|
||||
return r.body
|
||||
|
||||
proc post*(url: string, extraHeaders = "", body = "",
|
||||
maxRedirects = 5,
|
||||
sslContext: SSLContext = getDefaultSSL(),
|
||||
timeout = -1, userAgent = defUserAgent,
|
||||
proxy: Proxy = nil,
|
||||
multipart: MultipartData = nil): Response {.deprecated.} =
|
||||
## | POSTs ``body`` to the ``url`` and returns a ``Response`` object.
|
||||
## | This proc adds the necessary Content-Length header.
|
||||
## | This proc also handles redirection.
|
||||
## | Extra headers can be specified and must be separated by ``\c\L``.
|
||||
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||
## server takes longer than specified an ETimeout exception will be raised.
|
||||
## | The optional ``multipart`` parameter can be used to create
|
||||
## ``multipart/form-data`` POSTs comfortably.
|
||||
##
|
||||
## **Deprecated since version 0.15.0**: use ``HttpClient.post`` instead.
|
||||
let (mpContentType, mpBody) = format(multipart)
|
||||
|
||||
template withNewLine(x): untyped =
|
||||
if x.len > 0 and not x.endsWith("\c\L"):
|
||||
x & "\c\L"
|
||||
else:
|
||||
x
|
||||
|
||||
var xb = mpBody.withNewLine() & body
|
||||
|
||||
var xh = extraHeaders.withNewLine() &
|
||||
withNewLine("Content-Length: " & $len(xb))
|
||||
|
||||
if not multipart.isNil:
|
||||
xh.add(withNewLine("Content-Type: " & mpContentType))
|
||||
|
||||
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
|
||||
result = request(redirectTo, meth, xh, xb, sslContext, timeout,
|
||||
userAgent, proxy)
|
||||
lastURL = redirectTo
|
||||
|
||||
proc postContent*(url: string, extraHeaders = "", body = "",
|
||||
maxRedirects = 5,
|
||||
sslContext: SSLContext = getDefaultSSL(),
|
||||
timeout = -1, userAgent = defUserAgent,
|
||||
proxy: Proxy = nil,
|
||||
multipart: MultipartData = nil): string
|
||||
{.deprecated.} =
|
||||
## | POSTs ``body`` to ``url`` and returns the response's body as a string
|
||||
## | Raises exceptions for the status codes ``4xx`` and ``5xx``
|
||||
## | Extra headers can be specified and must be separated by ``\c\L``.
|
||||
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||
## server takes longer than specified an ETimeout exception will be raised.
|
||||
## | The optional ``multipart`` parameter can be used to create
|
||||
## ``multipart/form-data`` POSTs comfortably.
|
||||
##
|
||||
## **Deprecated since version 0.15.0**: use ``HttpClient.postContent``
|
||||
## instead.
|
||||
var r = post(url, extraHeaders, body, maxRedirects, sslContext, timeout,
|
||||
userAgent, proxy, multipart)
|
||||
if r.status[0] in {'4','5'}:
|
||||
raise newException(HttpRequestError, r.status)
|
||||
else:
|
||||
return r.body
|
||||
|
||||
proc downloadFile*(url: string, outputFilename: string,
|
||||
sslContext: SSLContext = getDefaultSSL(),
|
||||
timeout = -1, userAgent = defUserAgent,
|
||||
proxy: Proxy = nil) {.deprecated.} =
|
||||
## | Downloads ``url`` and saves it to ``outputFilename``
|
||||
## | An optional timeout can be specified in milliseconds, if reading from the
|
||||
## server takes longer than specified an ETimeout exception will be raised.
|
||||
##
|
||||
## **Deprecated since version 0.16.2**: use ``HttpClient.downloadFile``
|
||||
## instead.
|
||||
var f: File
|
||||
if open(f, outputFilename, fmWrite):
|
||||
f.write(getContent(url, sslContext = sslContext, timeout = timeout,
|
||||
userAgent = userAgent, proxy = proxy))
|
||||
f.close()
|
||||
else:
|
||||
fileError("Unable to open file")
|
||||
|
||||
proc generateHeaders(requestUrl: Uri, httpMethod: string,
|
||||
headers: HttpHeaders, body: string, proxy: Proxy): string =
|
||||
# GET
|
||||
|
||||
@@ -265,10 +265,6 @@ proc getAddrInfo*(address: string, port: Port, domain: Domain = AF_INET,
|
||||
else:
|
||||
raiseOSError(osLastError(), $gai_strerror(gaiResult))
|
||||
|
||||
proc dealloc*(ai: ptr AddrInfo) {.deprecated.} =
|
||||
## Deprecated since 0.16.2. Use ``freeAddrInfo`` instead.
|
||||
freeaddrinfo(ai)
|
||||
|
||||
proc ntohl*(x: uint32): uint32 =
|
||||
## Converts 32-bit unsigned integers from network to host byte order.
|
||||
## On machines where the host byte order is the same as network byte order,
|
||||
@@ -279,15 +275,6 @@ proc ntohl*(x: uint32): uint32 =
|
||||
(x shl 8'u32 and 0xff0000'u32) or
|
||||
(x shl 24'u32)
|
||||
|
||||
template ntohl*(x: int32): untyped {.deprecated.} =
|
||||
## Converts 32-bit integers from network to host byte order.
|
||||
## On machines where the host byte order is the same as network byte order,
|
||||
## this is a no-op; otherwise, it performs a 4-byte swap operation.
|
||||
## **Warning**: This template is deprecated since 0.14.0, IPv4
|
||||
## addresses are now treated as unsigned integers. Please use the unsigned
|
||||
## version of this template.
|
||||
cast[int32](nativesockets.ntohl(cast[uint32](x)))
|
||||
|
||||
proc ntohs*(x: uint16): uint16 =
|
||||
## Converts 16-bit unsigned integers from network to host byte order. On
|
||||
## machines where the host byte order is the same as network byte order,
|
||||
@@ -295,39 +282,12 @@ proc ntohs*(x: uint16): uint16 =
|
||||
when cpuEndian == bigEndian: result = x
|
||||
else: result = (x shr 8'u16) or (x shl 8'u16)
|
||||
|
||||
template ntohs*(x: int16): untyped {.deprecated.} =
|
||||
## Converts 16-bit integers from network to host byte order. On
|
||||
## machines where the host byte order is the same as network byte order,
|
||||
## this is a no-op; otherwise, it performs a 2-byte swap operation.
|
||||
## **Warning**: This template is deprecated since 0.14.0, where port
|
||||
## numbers became unsigned integers. Please use the unsigned version of
|
||||
## this template.
|
||||
cast[int16](nativesockets.ntohs(cast[uint16](x)))
|
||||
|
||||
template htonl*(x: int32): untyped {.deprecated.} =
|
||||
## Converts 32-bit integers from host to network byte order. On machines
|
||||
## where the host byte order is the same as network byte order, this is
|
||||
## a no-op; otherwise, it performs a 4-byte swap operation.
|
||||
## **Warning**: This template is deprecated since 0.14.0, IPv4
|
||||
## addresses are now treated as unsigned integers. Please use the unsigned
|
||||
## version of this template.
|
||||
nativesockets.ntohl(x)
|
||||
|
||||
template htonl*(x: uint32): untyped =
|
||||
## Converts 32-bit unsigned integers from host to network byte order. On
|
||||
## machines where the host byte order is the same as network byte order,
|
||||
## this is a no-op; otherwise, it performs a 4-byte swap operation.
|
||||
nativesockets.ntohl(x)
|
||||
|
||||
template htons*(x: int16): untyped {.deprecated.} =
|
||||
## Converts 16-bit integers from host to network byte order.
|
||||
## On machines where the host byte order is the same as network byte
|
||||
## order, this is a no-op; otherwise, it performs a 2-byte swap operation.
|
||||
## **Warning**: This template is deprecated since 0.14.0, where port
|
||||
## numbers became unsigned integers. Please use the unsigned version of
|
||||
## this template.
|
||||
nativesockets.ntohs(x)
|
||||
|
||||
template htons*(x: uint16): untyped =
|
||||
## Converts 16-bit unsigned integers from host to network byte order.
|
||||
## On machines where the host byte order is the same as network byte
|
||||
@@ -649,29 +609,6 @@ proc pruneSocketSet(s: var seq[SocketHandle], fd: var TFdSet) =
|
||||
inc(i)
|
||||
setLen(s, L)
|
||||
|
||||
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
|
||||
## from ``readfds``.
|
||||
##
|
||||
## ``timeout`` is specified in milliseconds and ``-1`` can be specified for
|
||||
## an unlimited time.
|
||||
## **Warning:** This is deprecated since version 0.16.2.
|
||||
## Use the ``selectRead`` procedure instead.
|
||||
var tv {.noInit.}: Timeval = timeValFromMilliseconds(timeout)
|
||||
|
||||
var rd: TFdSet
|
||||
var m = 0
|
||||
createFdSet((rd), readfds, m)
|
||||
|
||||
if timeout != -1:
|
||||
result = int(select(cint(m+1), addr(rd), nil, nil, addr(tv)))
|
||||
else:
|
||||
result = int(select(cint(m+1), addr(rd), nil, nil, nil))
|
||||
|
||||
pruneSocketSet(readfds, (rd))
|
||||
|
||||
proc selectRead*(readfds: var seq[SocketHandle], timeout = 500): int =
|
||||
## 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
|
||||
|
||||
@@ -967,39 +967,6 @@ when defined(posix) or defined(nimdoc):
|
||||
raiseOSError(osLastError())
|
||||
|
||||
when defined(ssl):
|
||||
proc handshake*(socket: Socket): bool
|
||||
{.tags: [ReadIOEffect, WriteIOEffect], deprecated.} =
|
||||
## This proc needs to be called on a socket after it connects. This is
|
||||
## only applicable when using ``connectAsync``.
|
||||
## This proc performs the SSL handshake.
|
||||
##
|
||||
## Returns ``False`` whenever the socket is not yet ready for a handshake,
|
||||
## ``True`` whenever handshake completed successfully.
|
||||
##
|
||||
## A SslError error is raised on any other errors.
|
||||
##
|
||||
## **Note:** This procedure is deprecated since version 0.14.0.
|
||||
result = true
|
||||
if socket.isSSL:
|
||||
var ret = SSLConnect(socket.sslHandle)
|
||||
if ret <= 0:
|
||||
var errret = SSLGetError(socket.sslHandle, ret)
|
||||
case errret
|
||||
of SSL_ERROR_ZERO_RETURN:
|
||||
raiseSSLError("TLS/SSL connection failed to initiate, socket closed prematurely.")
|
||||
of SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT,
|
||||
SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE:
|
||||
return false
|
||||
of SSL_ERROR_WANT_X509_LOOKUP:
|
||||
raiseSSLError("Function for x509 lookup has been called.")
|
||||
of SSL_ERROR_SYSCALL, SSL_ERROR_SSL:
|
||||
raiseSSLError()
|
||||
else:
|
||||
raiseSSLError("Unknown Error")
|
||||
socket.sslNoHandshake = false
|
||||
else:
|
||||
raiseSSLError("Socket is not an SSL socket.")
|
||||
|
||||
proc gotHandshake*(socket: Socket): bool =
|
||||
## Determines whether a handshake has occurred between a client (``socket``)
|
||||
## and the server that ``socket`` is connected to.
|
||||
@@ -1026,7 +993,7 @@ proc select(readfd: Socket, timeout = 500): int =
|
||||
return 1
|
||||
|
||||
var fds = @[readfd.fd]
|
||||
result = select(fds, timeout)
|
||||
result = selectRead(fds, timeout)
|
||||
|
||||
proc isClosed(socket: Socket): bool =
|
||||
socket.fd == osInvalidSocket
|
||||
@@ -1694,7 +1661,5 @@ proc connect*(socket: Socket, address: string, port = Port(0),
|
||||
when defineSsl and not defined(nimdoc):
|
||||
if socket.isSSL:
|
||||
socket.fd.setBlocking(true)
|
||||
{.warning[Deprecated]: off.}
|
||||
doAssert socket.handshake()
|
||||
{.warning[Deprecated]: on.}
|
||||
doAssert socket.gotHandshake()
|
||||
socket.fd.setBlocking(true)
|
||||
|
||||
@@ -60,9 +60,6 @@ type
|
||||
Process* = ref ProcessObj ## represents an operating system process
|
||||
|
||||
|
||||
const poUseShell* {.deprecated.} = poUsePath
|
||||
## Deprecated alias for poUsePath.
|
||||
|
||||
proc execProcess*(command: string,
|
||||
workingDir: string = "",
|
||||
args: openArray[string] = [],
|
||||
@@ -335,19 +332,6 @@ proc execProcesses*(cmds: openArray[string],
|
||||
if afterRunEvent != nil: afterRunEvent(i, p)
|
||||
close(p)
|
||||
|
||||
proc select*(readfds: var seq[Process], timeout = 500): int
|
||||
{.benign, deprecated.}
|
||||
## `select` with a sensible Nim interface. `timeout` is in milliseconds.
|
||||
## Specify -1 for no timeout. Returns the number of processes that are
|
||||
## ready to read from. The processes that are ready to be read from are
|
||||
## removed from `readfds`.
|
||||
##
|
||||
## **Warning**: This function may give unexpected or completely wrong
|
||||
## results on Windows.
|
||||
##
|
||||
## **Deprecated since version 0.17.0**: This procedure isn't cross-platform
|
||||
## and so should not be used in newly written code.
|
||||
|
||||
when not defined(useNimRtl):
|
||||
proc execProcess(command: string,
|
||||
workingDir: string = "",
|
||||
|
||||
@@ -55,15 +55,6 @@ proc initOptParser*(cmdline: seq[string]): OptParser {.rtl.} =
|
||||
|
||||
result.cmd = @cmdline
|
||||
|
||||
proc initOptParser*(cmdline: string): OptParser {.rtl, deprecated.} =
|
||||
## Initalizes option parses with cmdline. Splits cmdline in on spaces
|
||||
## and calls initOptParser(openarray[string])
|
||||
## Do not use.
|
||||
if cmdline == "": # backward compatibility
|
||||
return initOptParser(@[])
|
||||
else:
|
||||
return initOptParser(cmdline.split)
|
||||
|
||||
when not defined(createNimRtl):
|
||||
proc initOptParser*(): OptParser =
|
||||
## Initializes option parser from current command line arguments.
|
||||
|
||||
@@ -138,18 +138,6 @@ proc parseIdent*(s: string, start = 0): string =
|
||||
while i < s.len and s[i] in IdentChars: inc(i)
|
||||
result = substr(s, start, i-1)
|
||||
|
||||
proc parseToken*(s: string, token: var string, validChars: set[char],
|
||||
start = 0): int {.inline, deprecated.} =
|
||||
## parses a token and stores it in ``token``. Returns
|
||||
## the number of the parsed characters or 0 in case of an error. A token
|
||||
## consists of the characters in `validChars`.
|
||||
##
|
||||
## **Deprecated since version 0.8.12**: Use ``parseWhile`` instead.
|
||||
var i = start
|
||||
while i < s.len and s[i] in validChars: inc(i)
|
||||
result = i-start
|
||||
token = substr(s, start, i-1)
|
||||
|
||||
proc skipWhitespace*(s: string, start = 0): int {.inline.} =
|
||||
## skips the whitespace starting at ``s[start]``. Returns the number of
|
||||
## skipped characters.
|
||||
|
||||
@@ -18,33 +18,6 @@ type
|
||||
hostname*, port*, path*, query*, anchor*: string
|
||||
opaque*: bool
|
||||
|
||||
{.push warning[deprecated]: off.}
|
||||
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: "use Uri instead".} =
|
||||
## Joins two URLs together, separating them with / if needed.
|
||||
##
|
||||
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||
var urlS = $a
|
||||
var bS = $b
|
||||
if urlS == "": return b
|
||||
if urlS[urlS.len-1] != '/':
|
||||
urlS.add('/')
|
||||
if bS[0] == '/':
|
||||
urlS.add(bS.substr(1))
|
||||
else:
|
||||
urlS.add(bs)
|
||||
result = Url(urlS)
|
||||
|
||||
proc add*(url: var Url, a: Url) {.deprecated: "use Uri instead".} =
|
||||
## Appends url to url.
|
||||
##
|
||||
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||
url = url / a
|
||||
{.pop.}
|
||||
|
||||
proc encodeUrl*(s: string, usePlus=true): string =
|
||||
## Encodes a URL according to RFC3986.
|
||||
##
|
||||
|
||||
@@ -46,7 +46,7 @@ when defined(windows):
|
||||
success = false
|
||||
it = it.ai_next
|
||||
|
||||
dealloc(aiList)
|
||||
freeAddrInfo(aiList)
|
||||
if not success:
|
||||
retFuture.fail(newException(OSError, osErrorMsg(lastError)))
|
||||
return retFuture
|
||||
|
||||
@@ -83,6 +83,7 @@ task "download", "download game assets":
|
||||
var
|
||||
skipAssets = false
|
||||
path = expandFilename("data")
|
||||
client = newHttpClient()
|
||||
path.add DirSep
|
||||
path.add(extractFilename(GameAssets))
|
||||
if existsFile(path):
|
||||
@@ -101,7 +102,7 @@ task "download", "download game assets":
|
||||
echo "Downloading from ", GameAssets
|
||||
if not skipAssets:
|
||||
echo "Downloading to ", path
|
||||
downloadFile GameAssets, path
|
||||
client.downloadFile(GameAssets, path)
|
||||
echo "Download finished"
|
||||
|
||||
let targetDir = parentDir(parentDir(path))
|
||||
@@ -126,7 +127,7 @@ task "download", "download game assets":
|
||||
else:
|
||||
return
|
||||
path = extractFilename(BinLibs)
|
||||
downloadFile BinLibs, path
|
||||
client.downloadFile(BinLibs, path)
|
||||
echo "Downloaded dem libs ", path
|
||||
when true: echo "Unpack it yourself, sorry."
|
||||
else: ## this crashes, dunno why
|
||||
|
||||
Reference in New Issue
Block a user