made large parts of the stdlib gcsafe
This commit is contained in:
parent
be6474af63
commit
e6d17e6273
21 changed files with 138 additions and 113 deletions
|
|
@ -7,6 +7,8 @@
|
|||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
include "system/inclrtl"
|
||||
|
||||
import os, oids, tables, strutils, macros
|
||||
|
||||
import rawsockets
|
||||
|
|
@ -31,7 +33,7 @@ export TPort
|
|||
|
||||
type
|
||||
PFutureBase* = ref object of PObject
|
||||
cb: proc () {.closure.}
|
||||
cb: proc () {.closure,gcsafe.}
|
||||
finished: bool
|
||||
|
||||
PFuture*[T] = ref object of PFutureBase
|
||||
|
|
@ -68,7 +70,7 @@ proc fail*[T](future: PFuture[T], error: ref EBase) =
|
|||
if future.cb != nil:
|
||||
future.cb()
|
||||
|
||||
proc `callback=`*(future: PFutureBase, cb: proc () {.closure.}) =
|
||||
proc `callback=`*(future: PFutureBase, cb: proc () {.closure,gcsafe.}) =
|
||||
## Sets the callback proc to be called when the future completes.
|
||||
##
|
||||
## If future has already completed then ``cb`` will be called immediately.
|
||||
|
|
@ -80,7 +82,7 @@ proc `callback=`*(future: PFutureBase, cb: proc () {.closure.}) =
|
|||
future.cb()
|
||||
|
||||
proc `callback=`*[T](future: PFuture[T],
|
||||
cb: proc (future: PFuture[T]) {.closure.}) =
|
||||
cb: proc (future: PFuture[T]) {.closure,gcsafe.}) =
|
||||
## Sets the callback proc to be called when the future completes.
|
||||
##
|
||||
## If future has already completed then ``cb`` will be called immediately.
|
||||
|
|
@ -122,7 +124,7 @@ when defined(windows) or defined(nimdoc):
|
|||
TCompletionData* = object
|
||||
sock: TAsyncFD
|
||||
cb: proc (sock: TAsyncFD, bytesTransferred: DWORD,
|
||||
errcode: TOSErrorCode) {.closure.}
|
||||
errcode: TOSErrorCode) {.closure,gcsafe.}
|
||||
|
||||
PDispatcher* = ref object
|
||||
ioPort: THandle
|
||||
|
|
@ -237,7 +239,7 @@ when defined(windows) or defined(nimdoc):
|
|||
let func =
|
||||
cast[proc (s: TSocketHandle, name: ptr TSockAddr, namelen: cint,
|
||||
lpSendBuffer: pointer, dwSendDataLength: dword,
|
||||
lpdwBytesSent: PDWORD, lpOverlapped: POverlapped): bool {.stdcall.}](connectExPtr)
|
||||
lpdwBytesSent: PDWORD, lpOverlapped: POverlapped): bool {.stdcall,gcsafe.}](connectExPtr)
|
||||
|
||||
result = func(s, name, namelen, lpSendBuffer, dwSendDataLength, lpdwBytesSent,
|
||||
lpOverlapped)
|
||||
|
|
@ -251,7 +253,7 @@ when defined(windows) or defined(nimdoc):
|
|||
cast[proc (listenSock, acceptSock: TSocketHandle, lpOutputBuffer: pointer,
|
||||
dwReceiveDataLength, dwLocalAddressLength,
|
||||
dwRemoteAddressLength: DWORD, lpdwBytesReceived: PDWORD,
|
||||
lpOverlapped: POverlapped): bool {.stdcall.}](acceptExPtr)
|
||||
lpOverlapped: POverlapped): bool {.stdcall,gcsafe.}](acceptExPtr)
|
||||
result = func(listenSock, acceptSock, lpOutputBuffer, dwReceiveDataLength,
|
||||
dwLocalAddressLength, dwRemoteAddressLength, lpdwBytesReceived,
|
||||
lpOverlapped)
|
||||
|
|
@ -268,7 +270,7 @@ when defined(windows) or defined(nimdoc):
|
|||
dwReceiveDataLength, dwLocalAddressLength,
|
||||
dwRemoteAddressLength: DWORD, LocalSockaddr: ptr ptr TSockAddr,
|
||||
LocalSockaddrLength: lpint, RemoteSockaddr: ptr ptr TSockAddr,
|
||||
RemoteSockaddrLength: lpint) {.stdcall.}](getAcceptExSockAddrsPtr)
|
||||
RemoteSockaddrLength: lpint) {.stdcall,gcsafe.}](getAcceptExSockAddrsPtr)
|
||||
|
||||
func(lpOutputBuffer, dwReceiveDataLength, dwLocalAddressLength,
|
||||
dwRemoteAddressLength, LocalSockaddr, LocalSockaddrLength,
|
||||
|
|
@ -537,7 +539,7 @@ else:
|
|||
from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK
|
||||
type
|
||||
TAsyncFD* = distinct cint
|
||||
TCallback = proc (sock: TAsyncFD): bool {.closure.}
|
||||
TCallback = proc (sock: TAsyncFD): bool {.closure,gcsafe.}
|
||||
|
||||
PData* = ref object of PObject
|
||||
sock: TAsyncFD
|
||||
|
|
@ -757,7 +759,7 @@ proc accept*(socket: TAsyncFD): PFuture[TAsyncFD] =
|
|||
|
||||
template createCb*(retFutureSym, iteratorNameSym: expr): stmt {.immediate.} =
|
||||
var nameIterVar = iteratorNameSym
|
||||
proc cb {.closure.} =
|
||||
proc cb {.closure,gcsafe.} =
|
||||
if not nameIterVar.finished:
|
||||
var next = nameIterVar()
|
||||
if next == nil:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
include "system/inclrtl"
|
||||
|
||||
import sockets, os
|
||||
|
||||
## This module implements an asynchronous event loop together with asynchronous sockets
|
||||
|
|
@ -98,13 +100,13 @@ type
|
|||
fd*: TSocketHandle
|
||||
deleVal*: PObject
|
||||
|
||||
handleRead*: proc (h: PObject) {.nimcall.}
|
||||
handleWrite*: proc (h: PObject) {.nimcall.}
|
||||
handleError*: proc (h: PObject) {.nimcall.}
|
||||
hasDataBuffered*: proc (h: PObject): bool {.nimcall.}
|
||||
handleRead*: proc (h: PObject) {.nimcall, gcsafe.}
|
||||
handleWrite*: proc (h: PObject) {.nimcall, gcsafe.}
|
||||
handleError*: proc (h: PObject) {.nimcall, gcsafe.}
|
||||
hasDataBuffered*: proc (h: PObject): bool {.nimcall, gcsafe.}
|
||||
|
||||
open*: bool
|
||||
task*: proc (h: PObject) {.nimcall.}
|
||||
task*: proc (h: PObject) {.nimcall, gcsafe.}
|
||||
mode*: TFileMode
|
||||
|
||||
PDelegate* = ref TDelegate
|
||||
|
|
@ -118,13 +120,13 @@ type
|
|||
socket: TSocket
|
||||
info: TInfo
|
||||
|
||||
handleRead*: proc (s: PAsyncSocket) {.closure.}
|
||||
handleWrite: proc (s: PAsyncSocket) {.closure.}
|
||||
handleConnect*: proc (s: PAsyncSocket) {.closure.}
|
||||
handleRead*: proc (s: PAsyncSocket) {.closure, gcsafe.}
|
||||
handleWrite: proc (s: PAsyncSocket) {.closure, gcsafe.}
|
||||
handleConnect*: proc (s: PAsyncSocket) {.closure, gcsafe.}
|
||||
|
||||
handleAccept*: proc (s: PAsyncSocket) {.closure.}
|
||||
handleAccept*: proc (s: PAsyncSocket) {.closure, gcsafe.}
|
||||
|
||||
handleTask*: proc (s: PAsyncSocket) {.closure.}
|
||||
handleTask*: proc (s: PAsyncSocket) {.closure, gcsafe.}
|
||||
|
||||
lineBuffer: TaintedString ## Temporary storage for ``readLine``
|
||||
sendBuffer: string ## Temporary storage for ``send``
|
||||
|
|
@ -213,7 +215,7 @@ proc asyncSockHandleRead(h: PObject) =
|
|||
else:
|
||||
PAsyncSocket(h).handleAccept(PAsyncSocket(h))
|
||||
|
||||
proc close*(sock: PAsyncSocket)
|
||||
proc close*(sock: PAsyncSocket) {.gcsafe.}
|
||||
proc asyncSockHandleWrite(h: PObject) =
|
||||
when defined(ssl):
|
||||
if PAsyncSocket(h).socket.isSSL and not
|
||||
|
|
@ -254,7 +256,7 @@ proc asyncSockHandleWrite(h: PObject) =
|
|||
PAsyncSocket(h).deleg.mode = fmRead
|
||||
|
||||
when defined(ssl):
|
||||
proc asyncSockDoHandshake(h: PObject) =
|
||||
proc asyncSockDoHandshake(h: PObject) {.gcsafe.} =
|
||||
if PAsyncSocket(h).socket.isSSL and not
|
||||
PAsyncSocket(h).socket.gotHandshake:
|
||||
if PAsyncSocket(h).sslNeedAccept:
|
||||
|
|
@ -437,7 +439,7 @@ proc isSendDataBuffered*(s: PAsyncSocket): bool =
|
|||
return s.sendBuffer.len != 0
|
||||
|
||||
proc setHandleWrite*(s: PAsyncSocket,
|
||||
handleWrite: proc (s: PAsyncSocket) {.closure.}) =
|
||||
handleWrite: proc (s: PAsyncSocket) {.closure, gcsafe.}) =
|
||||
## Setter for the ``handleWrite`` event.
|
||||
##
|
||||
## To remove this event you should use the ``delHandleWrite`` function.
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ proc setCookie*(name, value: string) =
|
|||
write(stdout, "Set-Cookie: ", name, "=", value, "\n")
|
||||
|
||||
var
|
||||
gcookies: PStringTable = nil
|
||||
gcookies {.threadvar.}: PStringTable
|
||||
|
||||
proc getCookie*(name: string): TaintedString =
|
||||
## Gets a cookie. If no cookie of `name` exists, "" is returned.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
include "system/inclrtl"
|
||||
|
||||
import sockets, strutils, parseutils, times, os, asyncio
|
||||
|
||||
## This module **partially** implements an FTP client as specified
|
||||
|
|
@ -41,7 +43,7 @@ type
|
|||
dummyA, dummyB: pointer # workaround a Nimrod API issue
|
||||
asyncCSock: PAsyncSocket
|
||||
asyncDSock: PAsyncSocket
|
||||
handleEvent*: proc (ftp: PAsyncFTPClient, ev: TFTPEvent) {.closure.}
|
||||
handleEvent*: proc (ftp: PAsyncFTPClient, ev: TFTPEvent){.closure,gcsafe.}
|
||||
disp: PDispatcher
|
||||
asyncDSockID: PDelegate
|
||||
user, pass: string
|
||||
|
|
@ -59,7 +61,7 @@ type
|
|||
JRetrText, JRetr, JStore
|
||||
|
||||
TFTPJob = object
|
||||
prc: proc (ftp: PFTPClient, async: bool): bool {.nimcall.}
|
||||
prc: proc (ftp: PFTPClient, async: bool): bool {.nimcall, gcsafe.}
|
||||
case typ*: FTPJobType
|
||||
of JRetrText:
|
||||
lines: string
|
||||
|
|
@ -148,7 +150,8 @@ proc assertReply(received: TaintedString, expected: varargs[string]) =
|
|||
[expected.join("' or '"), received.string])
|
||||
|
||||
proc createJob(ftp: PFTPClient,
|
||||
prc: proc (ftp: PFTPClient, async: bool): bool {.nimcall.},
|
||||
prc: proc (ftp: PFTPClient, async: bool): bool {.
|
||||
nimcall,gcsafe.},
|
||||
cmd: FTPJobType) =
|
||||
if ftp.jobInProgress:
|
||||
raise newException(EFTP, "Unable to do two jobs at once.")
|
||||
|
|
@ -558,7 +561,7 @@ proc csockHandleRead(s: PAsyncSocket, ftp: PAsyncFTPClient) =
|
|||
|
||||
proc asyncFTPClient*(address: string, port = TPort(21),
|
||||
user, pass = "",
|
||||
handleEvent: proc (ftp: PAsyncFTPClient, ev: TFTPEvent) {.closure.} =
|
||||
handleEvent: proc (ftp: PAsyncFTPClient, ev: TFTPEvent) {.closure,gcsafe.} =
|
||||
(proc (ftp: PAsyncFTPClient, ev: TFTPEvent) = discard)): PAsyncFTPClient =
|
||||
## Create a ``PAsyncFTPClient`` object.
|
||||
##
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ proc nextAsync(s: PAsyncHTTPServer) =
|
|||
s.path = data.substr(i, last-1)
|
||||
|
||||
proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: TSocket,
|
||||
path, query: string): bool {.closure.},
|
||||
path, query: string): bool {.closure, gcsafe.},
|
||||
port = TPort(80), address = "",
|
||||
reuseAddr = false): PAsyncHTTPServer =
|
||||
## Creates an Asynchronous HTTP server at ``port``.
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
## **Warning:** The API of this module is unstable, and therefore is subject
|
||||
## to change.
|
||||
|
||||
include "system/inclrtl"
|
||||
|
||||
import sockets, strutils, parseutils, times, asyncio, os
|
||||
|
||||
type
|
||||
|
|
@ -41,7 +43,7 @@ type
|
|||
nick, user, realname, serverPass: string
|
||||
case isAsync: bool
|
||||
of true:
|
||||
handleEvent: proc (irc: PAsyncIRC, ev: TIRCEvent) {.closure.}
|
||||
handleEvent: proc (irc: PAsyncIRC, ev: TIRCEvent) {.closure, gcsafe.}
|
||||
asyncSock: PAsyncSocket
|
||||
myDispatcher: PDispatcher
|
||||
of false:
|
||||
|
|
@ -445,7 +447,7 @@ proc asyncIRC*(address: string, port: TPort = 6667.TPort,
|
|||
realname = "NimrodBot", serverPass = "",
|
||||
joinChans: seq[string] = @[],
|
||||
msgLimit: bool = true,
|
||||
ircEvent: proc (irc: PAsyncIRC, ev: TIRCEvent) {.closure.}
|
||||
ircEvent: proc (irc: PAsyncIRC, ev: TIRCEvent) {.closure,gcsafe.}
|
||||
): PAsyncIRC =
|
||||
## Use this function if you want to use asyncio's dispatcher.
|
||||
##
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
## Basic math routines for Nimrod.
|
||||
## This module is available for the JavaScript target.
|
||||
|
||||
include "system/inclrtl"
|
||||
|
||||
{.push debugger:off .} # the user does not want to trace a part
|
||||
# of the standard library!
|
||||
|
||||
|
|
@ -127,25 +129,25 @@ proc variance*(x: openArray[float]): float {.noSideEffect.} =
|
|||
result = result + diff*diff
|
||||
result = result / toFloat(len(x))
|
||||
|
||||
proc random*(max: int): int
|
||||
proc random*(max: int): int {.gcsafe.}
|
||||
## returns a random number in the range 0..max-1. The sequence of
|
||||
## random number is always the same, unless `randomize` is called
|
||||
## which initializes the random number generator with a "random"
|
||||
## number, i.e. a tickcount.
|
||||
|
||||
when not defined(windows):
|
||||
proc random*(max: float): float
|
||||
proc random*(max: float): float {.gcsafe.}
|
||||
## returns a random number in the range 0..<max. The sequence of
|
||||
## random number is always the same, unless `randomize` is called
|
||||
## which initializes the random number generator with a "random"
|
||||
## number, i.e. a tickcount. This is currently not supported for windows.
|
||||
|
||||
proc randomize*()
|
||||
proc randomize*() {.gcsafe.}
|
||||
## initializes the random number generator with a "random"
|
||||
## number, i.e. a tickcount. Note: Does nothing for the JavaScript target,
|
||||
## as JavaScript does not support this.
|
||||
|
||||
proc randomize*(seed: int)
|
||||
proc randomize*(seed: int) {.gcsafe.}
|
||||
## initializes the random number generator with a specific seed.
|
||||
## Note: Does nothing for the JavaScript target,
|
||||
## as JavaScript does not support this.
|
||||
|
|
@ -227,8 +229,8 @@ else:
|
|||
result = int(floor(mathrandom() * float(max)))
|
||||
proc random(max: float): float =
|
||||
result = float(mathrandom() * float(max))
|
||||
proc randomize() = nil
|
||||
proc randomize(seed: int) = nil
|
||||
proc randomize() = discard
|
||||
proc randomize(seed: int) = discard
|
||||
|
||||
proc sqrt*(x: float): float {.importc: "Math.sqrt", nodecl.}
|
||||
proc ln*(x: float): float {.importc: "Math.log", nodecl.}
|
||||
|
|
|
|||
|
|
@ -1564,7 +1564,7 @@ when defined(windows):
|
|||
# ourselves. This has the additional benefit that the program's behaviour
|
||||
# is always the same -- independent of the used C compiler.
|
||||
var
|
||||
ownArgv: seq[string]
|
||||
ownArgv {.threadvar.}: seq[string]
|
||||
|
||||
proc paramCount*(): int {.rtl, extern: "nos$1", tags: [FReadIO].} =
|
||||
## Returns the number of `command line arguments`:idx: given to the
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ const
|
|||
SymChars: TCharSet = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\x80'..'\xFF', '.',
|
||||
'/', '\\'}
|
||||
|
||||
proc rawGetTok(c: var TCfgParser, tok: var TToken)
|
||||
proc rawGetTok(c: var TCfgParser, tok: var TToken) {.gcsafe.}
|
||||
|
||||
proc open*(c: var TCfgParser, input: PStream, filename: string,
|
||||
lineOffset = 0) {.
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
## **Warning:** The API of this module is unstable, and therefore is subject
|
||||
## to change.
|
||||
|
||||
include "system/inclrtl"
|
||||
|
||||
import sockets, strutils, os, strtabs, asyncio
|
||||
|
||||
type
|
||||
|
|
@ -82,7 +84,7 @@ type
|
|||
|
||||
TAsyncScgiState = object
|
||||
handleRequest: proc (client: PAsyncSocket,
|
||||
input: string, headers: PStringTable) {.closure.}
|
||||
input: string, headers: PStringTable) {.closure,gcsafe.}
|
||||
asyncServer: PAsyncSocket
|
||||
disp: PDispatcher
|
||||
PAsyncScgiState* = ref TAsyncScgiState
|
||||
|
|
@ -150,7 +152,7 @@ proc writeStatusOkTextContent*(c: TSocket, contentType = "text/html") =
|
|||
"Content-Type: $1\r\L\r\L" % contentType)
|
||||
|
||||
proc run*(handleRequest: proc (client: TSocket, input: string,
|
||||
headers: PStringTable): bool {.nimcall.},
|
||||
headers: PStringTable): bool {.nimcall,gcsafe.},
|
||||
port = TPort(4000)) =
|
||||
## encapsulates the SCGI object and main loop.
|
||||
var s: TScgiState
|
||||
|
|
@ -246,7 +248,8 @@ proc handleAccept(sock: PAsyncSocket, s: PAsyncScgiState) =
|
|||
s.disp.register(client)
|
||||
|
||||
proc open*(handleRequest: proc (client: PAsyncSocket,
|
||||
input: string, headers: PStringTable) {.closure.},
|
||||
input: string, headers: PStringTable) {.
|
||||
closure, gcsafe.},
|
||||
port = TPort(4000), address = "127.0.0.1",
|
||||
reuseAddr = false): PAsyncScgiState =
|
||||
## Creates an ``PAsyncScgiState`` object which serves as a SCGI server.
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
## Asynchronous sockets are supported, however a better alternative is to use
|
||||
## the `asyncio <asyncio.html>`_ module.
|
||||
|
||||
include "system/inclrtl"
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
|
||||
when hostOS == "solaris":
|
||||
|
|
@ -544,7 +546,7 @@ proc acceptAddr*(server: TSocket, client: var TSocket, address: var string) {.
|
|||
else:
|
||||
SSLError("Unknown error")
|
||||
|
||||
proc setBlocking*(s: TSocket, blocking: bool) {.tags: [].}
|
||||
proc setBlocking*(s: TSocket, blocking: bool) {.tags: [], gcsafe.}
|
||||
## Sets blocking mode on socket
|
||||
|
||||
when defined(ssl):
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
## interface for Nimrod file objects (`TFile`) and strings. Other modules
|
||||
## may provide other implementations for this standard stream interface.
|
||||
|
||||
include "system/inclrtl"
|
||||
|
||||
proc newEIO(msg: string): ref EIO =
|
||||
new(result)
|
||||
result.msg = msg
|
||||
|
|
@ -23,15 +25,15 @@ type
|
|||
## here shouldn't be used directly. They are
|
||||
## accessible so that a stream implementation
|
||||
## can override them.
|
||||
closeImpl*: proc (s: PStream) {.nimcall, tags: [].}
|
||||
atEndImpl*: proc (s: PStream): bool {.nimcall, tags: [].}
|
||||
setPositionImpl*: proc (s: PStream, pos: int) {.nimcall, tags: [].}
|
||||
getPositionImpl*: proc (s: PStream): int {.nimcall, tags: [].}
|
||||
closeImpl*: proc (s: PStream) {.nimcall, tags: [], gcsafe.}
|
||||
atEndImpl*: proc (s: PStream): bool {.nimcall, tags: [], gcsafe.}
|
||||
setPositionImpl*: proc (s: PStream, pos: int) {.nimcall, tags: [], gcsafe.}
|
||||
getPositionImpl*: proc (s: PStream): int {.nimcall, tags: [], gcsafe.}
|
||||
readDataImpl*: proc (s: PStream, buffer: pointer,
|
||||
bufLen: int): int {.nimcall, tags: [FReadIO].}
|
||||
bufLen: int): int {.nimcall, tags: [FReadIO], gcsafe.}
|
||||
writeDataImpl*: proc (s: PStream, buffer: pointer, bufLen: int) {.nimcall,
|
||||
tags: [FWriteIO].}
|
||||
flushImpl*: proc (s: PStream) {.nimcall, tags: [FWriteIO].}
|
||||
tags: [FWriteIO], gcsafe.}
|
||||
flushImpl*: proc (s: PStream) {.nimcall, tags: [FWriteIO], gcsafe.}
|
||||
|
||||
proc flush*(s: PStream) =
|
||||
## flushes the buffers that the stream `s` might use.
|
||||
|
|
|
|||
|
|
@ -135,38 +135,38 @@ type
|
|||
months*: int ## The number of months
|
||||
years*: int ## The number of years
|
||||
|
||||
proc getTime*(): TTime {.tags: [FTime].}
|
||||
proc getTime*(): TTime {.tags: [FTime], gcsafe.}
|
||||
## gets the current calendar time as a UNIX epoch value (number of seconds
|
||||
## elapsed since 1970) with integer precission. Use epochTime for higher
|
||||
## resolution.
|
||||
proc getLocalTime*(t: TTime): TTimeInfo {.tags: [FTime], raises: [].}
|
||||
proc getLocalTime*(t: TTime): TTimeInfo {.tags: [FTime], raises: [], gcsafe.}
|
||||
## converts the calendar time `t` to broken-time representation,
|
||||
## expressed relative to the user's specified time zone.
|
||||
proc getGMTime*(t: TTime): TTimeInfo {.tags: [FTime], raises: [].}
|
||||
proc getGMTime*(t: TTime): TTimeInfo {.tags: [FTime], raises: [], gcsafe.}
|
||||
## converts the calendar time `t` to broken-down time representation,
|
||||
## expressed in Coordinated Universal Time (UTC).
|
||||
|
||||
proc timeInfoToTime*(timeInfo: TTimeInfo): TTime {.tags: [].}
|
||||
proc timeInfoToTime*(timeInfo: TTimeInfo): TTime {.tags: [], gcsafe.}
|
||||
## converts a broken-down time structure to
|
||||
## calendar time representation. The function ignores the specified
|
||||
## contents of the structure members `weekday` and `yearday` and recomputes
|
||||
## them from the other information in the broken-down time structure.
|
||||
|
||||
proc fromSeconds*(since1970: float): TTime {.tags: [], raises: [].}
|
||||
proc fromSeconds*(since1970: float): TTime {.tags: [], raises: [], gcsafe.}
|
||||
## Takes a float which contains the number of seconds since the unix epoch and
|
||||
## returns a time object.
|
||||
|
||||
proc fromSeconds*(since1970: int64): TTime {.tags: [], raises: [].} =
|
||||
proc fromSeconds*(since1970: int64): TTime {.tags: [], raises: [], gcsafe.} =
|
||||
## Takes an int which contains the number of seconds since the unix epoch and
|
||||
## returns a time object.
|
||||
fromSeconds(float(since1970))
|
||||
|
||||
proc toSeconds*(time: TTime): float {.tags: [], raises: [].}
|
||||
proc toSeconds*(time: TTime): float {.tags: [], raises: [], gcsafe.}
|
||||
## Returns the time in seconds since the unix epoch.
|
||||
|
||||
proc `$` *(timeInfo: TTimeInfo): string {.tags: [], raises: [].}
|
||||
proc `$` *(timeInfo: TTimeInfo): string {.tags: [], raises: [], gcsafe.}
|
||||
## converts a `TTimeInfo` object to a string representation.
|
||||
proc `$` *(time: TTime): string {.tags: [], raises: [].}
|
||||
proc `$` *(time: TTime): string {.tags: [], raises: [], gcsafe.}
|
||||
## converts a calendar time to a string representation.
|
||||
|
||||
proc `-`*(a, b: TTime): int64 {.
|
||||
|
|
@ -189,14 +189,15 @@ proc `==`*(a, b: TTime): bool {.
|
|||
result = a - b == 0
|
||||
|
||||
when not defined(JS):
|
||||
proc getTzname*(): tuple[nonDST, DST: string] {.tags: [FTime], raises: [].}
|
||||
proc getTzname*(): tuple[nonDST, DST: string] {.tags: [FTime], raises: [],
|
||||
gcsafe.}
|
||||
## returns the local timezone; ``nonDST`` is the name of the local non-DST
|
||||
## timezone, ``DST`` is the name of the local DST timezone.
|
||||
|
||||
proc getTimezone*(): int {.tags: [FTime], raises: [].}
|
||||
proc getTimezone*(): int {.tags: [FTime], raises: [], gcsafe.}
|
||||
## returns the offset of the local (non-DST) timezone in seconds west of UTC.
|
||||
|
||||
proc getStartMilsecs*(): int {.deprecated, tags: [FTime].}
|
||||
proc getStartMilsecs*(): int {.deprecated, tags: [FTime], gcsafe.}
|
||||
## get the miliseconds from the start of the program. **Deprecated since
|
||||
## version 0.8.10.** Use ``epochTime`` or ``cpuTime`` instead.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue