mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 04:27:44 +00:00
resolved conflict
This commit is contained in:
@@ -299,6 +299,7 @@ proc mainCommand* =
|
||||
else:
|
||||
rawMessage(errInvalidCommandX, command)
|
||||
of "doc":
|
||||
wantMainModule()
|
||||
gCmd = cmdDoc
|
||||
loadConfigs(DocConfig)
|
||||
commandDoc()
|
||||
@@ -316,6 +317,7 @@ proc mainCommand* =
|
||||
loadConfigs(DocTexConfig)
|
||||
commandRst2TeX()
|
||||
of "jsondoc":
|
||||
wantMainModule()
|
||||
gCmd = cmdDoc
|
||||
loadConfigs(DocConfig)
|
||||
wantMainModule()
|
||||
|
||||
@@ -78,17 +78,17 @@ proc tryExec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]): bool {
|
||||
tags: [FReadDB, FWriteDb].} =
|
||||
## tries to execute the query and returns true if successful, false otherwise.
|
||||
var q = dbFormat(query, args)
|
||||
return mysql.RealQuery(db, q, q.len) == 0'i32
|
||||
return mysql.realQuery(db, q, q.len) == 0'i32
|
||||
|
||||
proc rawExec(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) =
|
||||
var q = dbFormat(query, args)
|
||||
if mysql.RealQuery(db, q, q.len) != 0'i32: dbError(db)
|
||||
if mysql.realQuery(db, q, q.len) != 0'i32: dbError(db)
|
||||
|
||||
proc exec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) {.
|
||||
tags: [FReadDB, FWriteDb].} =
|
||||
## executes the query and raises EDB if not successful.
|
||||
var q = dbFormat(query, args)
|
||||
if mysql.RealQuery(db, q, q.len) != 0'i32: dbError(db)
|
||||
if mysql.realQuery(db, q, q.len) != 0'i32: dbError(db)
|
||||
|
||||
proc newRow(L: int): TRow =
|
||||
newSeq(result, L)
|
||||
@@ -96,8 +96,8 @@ proc newRow(L: int): TRow =
|
||||
|
||||
proc properFreeResult(sqlres: mysql.PRES, row: cstringArray) =
|
||||
if row != nil:
|
||||
while mysql.FetchRow(sqlres) != nil: discard
|
||||
mysql.FreeResult(sqlres)
|
||||
while mysql.fetchRow(sqlres) != nil: discard
|
||||
mysql.freeResult(sqlres)
|
||||
|
||||
iterator fastRows*(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
|
||||
@@ -105,13 +105,13 @@ iterator fastRows*(db: TDbConn, query: TSqlQuery,
|
||||
## fast, but potenially dangerous: If the for-loop-body executes another
|
||||
## query, the results can be undefined. For MySQL this is the case!.
|
||||
rawExec(db, query, args)
|
||||
var sqlres = mysql.UseResult(db)
|
||||
var sqlres = mysql.useResult(db)
|
||||
if sqlres != nil:
|
||||
var L = int(mysql.NumFields(sqlres))
|
||||
var L = int(mysql.numFields(sqlres))
|
||||
var result = newRow(L)
|
||||
var row: cstringArray
|
||||
while true:
|
||||
row = mysql.FetchRow(sqlres)
|
||||
row = mysql.fetchRow(sqlres)
|
||||
if row == nil: break
|
||||
for i in 0..L-1:
|
||||
setLen(result[i], 0)
|
||||
@@ -124,11 +124,11 @@ proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||
## retrieves a single row. If the query doesn't return any rows, this proc
|
||||
## will return a TRow with empty strings for each column.
|
||||
rawExec(db, query, args)
|
||||
var sqlres = mysql.UseResult(db)
|
||||
var sqlres = mysql.useResult(db)
|
||||
if sqlres != nil:
|
||||
var L = int(mysql.NumFields(sqlres))
|
||||
var L = int(mysql.numFields(sqlres))
|
||||
result = newRow(L)
|
||||
var row = mysql.FetchRow(sqlres)
|
||||
var row = mysql.fetchRow(sqlres)
|
||||
if row != nil:
|
||||
for i in 0..L-1:
|
||||
setLen(result[i], 0)
|
||||
@@ -140,24 +140,24 @@ proc getAllRows*(db: TDbConn, query: TSqlQuery,
|
||||
## executes the query and returns the whole result dataset.
|
||||
result = @[]
|
||||
rawExec(db, query, args)
|
||||
var sqlres = mysql.UseResult(db)
|
||||
var sqlres = mysql.useResult(db)
|
||||
if sqlres != nil:
|
||||
var L = int(mysql.NumFields(sqlres))
|
||||
var L = int(mysql.numFields(sqlres))
|
||||
var row: cstringArray
|
||||
var j = 0
|
||||
while true:
|
||||
row = mysql.FetchRow(sqlres)
|
||||
row = mysql.fetchRow(sqlres)
|
||||
if row == nil: break
|
||||
setLen(result, j+1)
|
||||
newSeq(result[j], L)
|
||||
for i in 0..L-1: result[j][i] = $row[i]
|
||||
inc(j)
|
||||
mysql.FreeResult(sqlres)
|
||||
mysql.freeResult(sqlres)
|
||||
|
||||
iterator rows*(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
|
||||
## same as `FastRows`, but slower and safe.
|
||||
for r in items(GetAllRows(db, query, args)): yield r
|
||||
## same as `fastRows`, but slower and safe.
|
||||
for r in items(getAllRows(db, query, args)): yield r
|
||||
|
||||
proc getValue*(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string, `$`]): string {.tags: [FReadDB].} =
|
||||
@@ -165,7 +165,7 @@ proc getValue*(db: TDbConn, query: TSqlQuery,
|
||||
## result dataset. Returns "" if the dataset contains no rows or the database
|
||||
## value is NULL.
|
||||
result = ""
|
||||
for row in FastRows(db, query, args):
|
||||
for row in fastRows(db, query, args):
|
||||
result = row[0]
|
||||
break
|
||||
|
||||
@@ -174,16 +174,16 @@ proc tryInsertId*(db: TDbConn, query: TSqlQuery,
|
||||
## executes the query (typically "INSERT") and returns the
|
||||
## generated ID for the row or -1 in case of an error.
|
||||
var q = dbFormat(query, args)
|
||||
if mysql.RealQuery(db, q, q.len) != 0'i32:
|
||||
if mysql.realQuery(db, q, q.len) != 0'i32:
|
||||
result = -1'i64
|
||||
else:
|
||||
result = mysql.InsertId(db)
|
||||
result = mysql.insertId(db)
|
||||
|
||||
proc insertId*(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} =
|
||||
## executes the query (typically "INSERT") and returns the
|
||||
## generated ID for the row.
|
||||
result = TryInsertID(db, query, args)
|
||||
result = tryInsertID(db, query, args)
|
||||
if result < 0: dbError(db)
|
||||
|
||||
proc execAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||
@@ -192,7 +192,7 @@ proc execAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||
## runs the query (typically "UPDATE") and returns the
|
||||
## number of affected rows
|
||||
rawExec(db, query, args)
|
||||
result = mysql.AffectedRows(db)
|
||||
result = mysql.affectedRows(db)
|
||||
|
||||
proc close*(db: TDbConn) {.tags: [FDb].} =
|
||||
## closes the database connection.
|
||||
@@ -202,7 +202,7 @@ proc open*(connection, user, password, database: string): TDbConn {.
|
||||
tags: [FDb].} =
|
||||
## opens a database connection. Raises `EDb` if the connection could not
|
||||
## be established.
|
||||
result = mysql.Init(nil)
|
||||
result = mysql.init(nil)
|
||||
if result == nil: dbError("could not open database connection")
|
||||
let
|
||||
colonPos = connection.find(':')
|
||||
@@ -210,9 +210,9 @@ proc open*(connection, user, password, database: string): TDbConn {.
|
||||
else: substr(connection, 0, colonPos-1)
|
||||
port: int32 = if colonPos < 0: 0'i32
|
||||
else: substr(connection, colonPos+1).parseInt.int32
|
||||
if mysql.RealConnect(result, host, user, password, database,
|
||||
if mysql.realConnect(result, host, user, password, database,
|
||||
port, nil, 0) == nil:
|
||||
var errmsg = $mysql.error(result)
|
||||
db_mysql.Close(result)
|
||||
db_mysql.close(result)
|
||||
dbError(errmsg)
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ proc dbError(db: TDbConn) {.noreturn.} =
|
||||
## raises an EDb exception.
|
||||
var e: ref EDb
|
||||
new(e)
|
||||
e.msg = $PQerrorMessage(db)
|
||||
e.msg = $pqErrorMessage(db)
|
||||
raise e
|
||||
|
||||
proc dbError*(msg: string) {.noreturn.} =
|
||||
@@ -68,17 +68,17 @@ proc tryExec*(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string, `$`]): bool {.tags: [FReadDB, FWriteDb].} =
|
||||
## tries to execute the query and returns true if successful, false otherwise.
|
||||
var q = dbFormat(query, args)
|
||||
var res = PQExec(db, q)
|
||||
result = PQresultStatus(res) == PGRES_COMMAND_OK
|
||||
PQclear(res)
|
||||
var res = pqExec(db, q)
|
||||
result = pqresultStatus(res) == PGRES_COMMAND_OK
|
||||
pqclear(res)
|
||||
|
||||
proc exec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) {.
|
||||
tags: [FReadDB, FWriteDb].} =
|
||||
## executes the query and raises EDB if not successful.
|
||||
var q = dbFormat(query, args)
|
||||
var res = PQExec(db, q)
|
||||
if PQresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
|
||||
PQclear(res)
|
||||
var res = pqExec(db, q)
|
||||
if pqresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
|
||||
pqclear(res)
|
||||
|
||||
proc newRow(L: int): TRow =
|
||||
newSeq(result, L)
|
||||
@@ -87,13 +87,13 @@ proc newRow(L: int): TRow =
|
||||
proc setupQuery(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string]): PPGresult =
|
||||
var q = dbFormat(query, args)
|
||||
result = PQExec(db, q)
|
||||
if PQresultStatus(result) != PGRES_TUPLES_OK: dbError(db)
|
||||
result = pqExec(db, q)
|
||||
if pqresultStatus(result) != PGRES_TUPLES_OK: dbError(db)
|
||||
|
||||
proc setRow(res: PPGresult, r: var TRow, line, cols: int32) =
|
||||
for col in 0..cols-1:
|
||||
setLen(r[col], 0)
|
||||
var x = PQgetvalue(res, line, col)
|
||||
var x = pqgetvalue(res, line, col)
|
||||
add(r[col], x)
|
||||
|
||||
iterator fastRows*(db: TDbConn, query: TSqlQuery,
|
||||
@@ -102,41 +102,41 @@ iterator fastRows*(db: TDbConn, query: TSqlQuery,
|
||||
## fast, but potenially dangerous: If the for-loop-body executes another
|
||||
## query, the results can be undefined. For Postgres it is safe though.
|
||||
var res = setupQuery(db, query, args)
|
||||
var L = PQnfields(res)
|
||||
var L = pqnfields(res)
|
||||
var result = newRow(L)
|
||||
for i in 0..PQntuples(res)-1:
|
||||
for i in 0..pqntuples(res)-1:
|
||||
setRow(res, result, i, L)
|
||||
yield result
|
||||
PQclear(res)
|
||||
pqclear(res)
|
||||
|
||||
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
|
||||
## retrieves a single row. If the query doesn't return any rows, this proc
|
||||
## will return a TRow with empty strings for each column.
|
||||
var res = setupQuery(db, query, args)
|
||||
var L = PQnfields(res)
|
||||
var L = pqnfields(res)
|
||||
result = newRow(L)
|
||||
setRow(res, result, 0, L)
|
||||
PQclear(res)
|
||||
pqclear(res)
|
||||
|
||||
proc getAllRows*(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string, `$`]): seq[TRow] {.tags: [FReadDB].} =
|
||||
## executes the query and returns the whole result dataset.
|
||||
result = @[]
|
||||
for r in FastRows(db, query, args):
|
||||
for r in fastRows(db, query, args):
|
||||
result.add(r)
|
||||
|
||||
iterator rows*(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
|
||||
## same as `FastRows`, but slower and safe.
|
||||
for r in items(GetAllRows(db, query, args)): yield r
|
||||
## same as `fastRows`, but slower and safe.
|
||||
for r in items(getAllRows(db, query, args)): yield r
|
||||
|
||||
proc getValue*(db: TDbConn, query: TSqlQuery,
|
||||
args: varargs[string, `$`]): string {.tags: [FReadDB].} =
|
||||
## executes the query and returns the first column of the first row of the
|
||||
## result dataset. Returns "" if the dataset contains no rows or the database
|
||||
## value is NULL.
|
||||
var x = PQgetvalue(setupQuery(db, query, args), 0, 0)
|
||||
var x = pqgetvalue(setupQuery(db, query, args), 0, 0)
|
||||
result = if isNil(x): "" else: $x
|
||||
|
||||
proc tryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||
@@ -145,10 +145,10 @@ proc tryInsertID*(db: TDbConn, query: TSqlQuery,
|
||||
## generated ID for the row or -1 in case of an error. For Postgre this adds
|
||||
## ``RETURNING id`` to the query, so it only works if your primary key is
|
||||
## named ``id``.
|
||||
var x = PQgetvalue(setupQuery(db, TSqlQuery(string(query) & " RETURNING id"),
|
||||
var x = pqgetvalue(setupQuery(db, TSqlQuery(string(query) & " RETURNING id"),
|
||||
args), 0, 0)
|
||||
if not isNil(x):
|
||||
result = ParseBiggestInt($x)
|
||||
result = parseBiggestInt($x)
|
||||
else:
|
||||
result = -1
|
||||
|
||||
@@ -158,7 +158,7 @@ proc insertID*(db: TDbConn, query: TSqlQuery,
|
||||
## generated ID for the row. For Postgre this adds
|
||||
## ``RETURNING id`` to the query, so it only works if your primary key is
|
||||
## named ``id``.
|
||||
result = TryInsertID(db, query, args)
|
||||
result = tryInsertID(db, query, args)
|
||||
if result < 0: dbError(db)
|
||||
|
||||
proc execAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||
@@ -167,14 +167,14 @@ proc execAffectedRows*(db: TDbConn, query: TSqlQuery,
|
||||
## executes the query (typically "UPDATE") and returns the
|
||||
## number of affected rows.
|
||||
var q = dbFormat(query, args)
|
||||
var res = PQExec(db, q)
|
||||
if PQresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
|
||||
result = parseBiggestInt($PQcmdTuples(res))
|
||||
PQclear(res)
|
||||
var res = pqExec(db, q)
|
||||
if pqresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
|
||||
result = parseBiggestInt($pqcmdTuples(res))
|
||||
pqclear(res)
|
||||
|
||||
proc close*(db: TDbConn) {.tags: [FDb].} =
|
||||
## closes the database connection.
|
||||
if db != nil: PQfinish(db)
|
||||
if db != nil: pqfinish(db)
|
||||
|
||||
proc open*(connection, user, password, database: string): TDbConn {.
|
||||
tags: [FDb].} =
|
||||
@@ -195,7 +195,7 @@ proc open*(connection, user, password, database: string): TDbConn {.
|
||||
##
|
||||
## Note that the connection parameter is not used but exists to maintain
|
||||
## the nim db api.
|
||||
result = PQsetdbLogin(nil, nil, nil, nil, database, user, password)
|
||||
if PQStatus(result) != CONNECTION_OK: dbError(result) # result = nil
|
||||
result = pqsetdbLogin(nil, nil, nil, nil, database, user, password)
|
||||
if pqStatus(result) != CONNECTION_OK: dbError(result) # result = nil
|
||||
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module contains simple high-level procedures for dealing with the
|
||||
## web. Use cases:
|
||||
##
|
||||
## * requesting URLs
|
||||
## * sending and retrieving emails
|
||||
## * sending and retrieving files from an FTP server
|
||||
##
|
||||
## Currently only requesting URLs is implemented. The implementation depends
|
||||
## on the libcurl library!
|
||||
##
|
||||
## **Deprecated since version 0.8.8:** Use the
|
||||
## `httpclient <httpclient.html>`_ module instead.
|
||||
##
|
||||
|
||||
{.deprecated.}
|
||||
|
||||
import libcurl, streams
|
||||
|
||||
proc curlwrapperWrite(p: pointer, size, nmemb: int,
|
||||
data: pointer): int {.cdecl.} =
|
||||
var stream = cast[PStream](data)
|
||||
stream.writeData(p, size*nmemb)
|
||||
return size*nmemb
|
||||
|
||||
proc URLretrieveStream*(url: string): PStream =
|
||||
## retrieves the given `url` and returns a stream which one can read from to
|
||||
## obtain the contents. Returns nil if an error occurs.
|
||||
result = newStringStream()
|
||||
var hCurl = easy_init()
|
||||
if hCurl == nil: return nil
|
||||
if easy_setopt(hCurl, OPT_URL, url) != E_OK: return nil
|
||||
if easy_setopt(hCurl, OPT_WRITEFUNCTION,
|
||||
curlwrapperWrite) != E_OK: return nil
|
||||
if easy_setopt(hCurl, OPT_WRITEDATA, result) != E_OK: return nil
|
||||
if easy_perform(hCurl) != E_OK: return nil
|
||||
easy_cleanup(hCurl)
|
||||
|
||||
proc URLretrieveString*(url: string): TaintedString =
|
||||
## retrieves the given `url` and returns the contents. Returns nil if an
|
||||
## error occurs.
|
||||
var stream = newStringStream()
|
||||
var hCurl = easy_init()
|
||||
if hCurl == nil: return
|
||||
if easy_setopt(hCurl, OPT_URL, url) != E_OK: return
|
||||
if easy_setopt(hCurl, OPT_WRITEFUNCTION,
|
||||
curlwrapperWrite) != E_OK: return
|
||||
if easy_setopt(hCurl, OPT_WRITEDATA, stream) != E_OK: return
|
||||
if easy_perform(hCurl) != E_OK: return
|
||||
easy_cleanup(hCurl)
|
||||
result = stream.data.TaintedString
|
||||
|
||||
when isMainModule:
|
||||
echo URLretrieveString("http://nim-code.org/")
|
||||
|
||||
@@ -446,7 +446,7 @@ proc unescape*(uri: cstring): cstring {.importc, nodecl.}
|
||||
|
||||
proc decodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
|
||||
proc encodeURIComponent*(uri: cstring): cstring {.importc, nodecl.}
|
||||
proc isFinite*(x: biggestFloat): bool {.importc, nodecl.}
|
||||
proc isNaN*(x: biggestFloat): bool {.importc, nodecl.}
|
||||
proc parseFloat*(s: cstring): biggestFloat {.importc, nodecl.}
|
||||
proc isFinite*(x: BiggestFloat): bool {.importc, nodecl.}
|
||||
proc isNaN*(x: BiggestFloat): bool {.importc, nodecl.}
|
||||
proc parseFloat*(s: cstring): BiggestFloat {.importc, nodecl.}
|
||||
proc parseInt*(s: cstring): int {.importc, nodecl.}
|
||||
|
||||
@@ -18,42 +18,137 @@ export Port, SocketFlag
|
||||
#{.injectStmt: newGcInvariant().}
|
||||
|
||||
## AsyncDispatch
|
||||
## -------------
|
||||
## *************
|
||||
##
|
||||
## This module implements a brand new dispatcher based on Futures.
|
||||
## On Windows IOCP is used and on other operating systems the ``selectors``
|
||||
## module is used instead.
|
||||
## This module implements asynchronous IO. This includes a dispatcher,
|
||||
## a ``Future`` type implementation, and an ``async`` macro which allows
|
||||
## asynchronous code to be written in a synchronous style with the ``await``
|
||||
## keyword.
|
||||
##
|
||||
## **Note:** This module is still largely experimental.
|
||||
## The dispatcher acts as a kind of event loop. You must call ``poll`` on it
|
||||
## (or a function which does so for you such as ``waitFor`` or ``runForever``)
|
||||
## in order to poll for any outstanding events. The underlying implementation
|
||||
## is based on epoll on Linux, IO Completion Ports on Windows and select on
|
||||
## other operating systems.
|
||||
##
|
||||
## The ``poll`` function will not, on its own, return any events. Instead
|
||||
## an appropriate ``Future`` object will be completed. A ``Future`` is a
|
||||
## type which holds a value which is not yet available, but which *may* be
|
||||
## available in the future. You can check whether a future is finished
|
||||
## by using the ``finished`` function. When a future is finished it means that
|
||||
## either the value that it holds is now available or it holds an error instead.
|
||||
## The latter situation occurs when the operation to complete a future fails
|
||||
## with an exception. You can distinguish between the two situations with the
|
||||
## ``failed`` function.
|
||||
##
|
||||
## Future objects can also store a callback procedure which will be called
|
||||
## automatically once the future completes.
|
||||
##
|
||||
## Futures therefore can be thought of as an implementation of the proactor
|
||||
## pattern. In this
|
||||
## pattern you make a request for an action, and once that action is fulfilled
|
||||
## a future is completed with the result of that action. Requests can be
|
||||
## made by calling the appropriate functions. For example: calling the ``recv``
|
||||
## function will create a request for some data to be read from a socket. The
|
||||
## future which the ``recv`` function returns will then complete once the
|
||||
## requested amount of data is read **or** an exception occurs.
|
||||
##
|
||||
## Code to read some data from a socket may look something like this:
|
||||
##
|
||||
## .. code-block::nim
|
||||
## var future = socket.recv(100)
|
||||
## future.callback =
|
||||
## proc () =
|
||||
## echo(future.read)
|
||||
##
|
||||
## All asynchronous functions returning a ``Future`` will not block. They
|
||||
## will not however return immediately. An asynchronous function will have
|
||||
## code which will be executed before an asynchronous request is made, in most
|
||||
## cases this code sets up the request.
|
||||
##
|
||||
## In the above example, the ``recv`` function will return a brand new
|
||||
## ``Future`` instance once the request for data to be read from the socket
|
||||
## is made. This ``Future`` instance will complete once the requested amount
|
||||
## of data is read, in this case it is 100 bytes. The second line sets a
|
||||
## callback on this future which will be called once the future completes.
|
||||
## All the callback does is write the data stored in the future to ``stdout``.
|
||||
## The ``read`` function is used for this and it checks whether the future
|
||||
## completes with an error for you (if it did it will simply raise the
|
||||
## error), if there is no error however it returns the value of the future.
|
||||
##
|
||||
## Asynchronous procedures
|
||||
## -----------------------
|
||||
##
|
||||
## Asynchronous procedures remove the pain of working with callbacks. They do
|
||||
## this by allowing you to write asynchronous code the same way as you would
|
||||
## write synchronous code.
|
||||
##
|
||||
## An asynchronous procedure is marked using the ``{.async.}`` pragma.
|
||||
## When marking a procedure with the ``{.async.}`` pragma it must have a
|
||||
## ``Future[T]`` return type or no return type at all. If you do not specify
|
||||
## a return type then ``Future[void]`` is assumed.
|
||||
##
|
||||
## Inside asynchronous procedures ``await`` can be used to call any
|
||||
## procedures which return a
|
||||
## ``Future``; this includes asynchronous procedures. When a procedure is
|
||||
## "awaited", the asynchronous procedure it is awaited in will
|
||||
## suspend its execution
|
||||
## until the awaited procedure's Future completes. At which point the
|
||||
## asynchronous procedure will resume its execution. During the period
|
||||
## when an asynchronous procedure is suspended other asynchronous procedures
|
||||
## will be run by the dispatcher.
|
||||
##
|
||||
## The ``await`` call may be used in many contexts. It can be used on the right
|
||||
## hand side of a variable declaration: ``var data = await socket.recv(100)``,
|
||||
## in which case the variable will be set to the value of the future
|
||||
## automatically. It can be used to await a ``Future`` object, and it can
|
||||
## be used to await a procedure returning a ``Future[void]``:
|
||||
## ``await socket.send("foobar")``.
|
||||
##
|
||||
## Discarding futures
|
||||
## ------------------
|
||||
##
|
||||
## Futures should **never** be discarded. This is because they may contain
|
||||
## errors. If you do not care for the result of a Future then you should
|
||||
## use the ``asyncCheck`` procedure instead of the ``discard`` keyword.
|
||||
##
|
||||
## Examples
|
||||
## --------
|
||||
##
|
||||
## For examples take a look at the documentation for the modules implementing
|
||||
## asynchronous IO. A good place to start is the
|
||||
## `asyncnet module <asyncnet.html>`_.
|
||||
##
|
||||
## Limitations/Bugs
|
||||
## ----------------
|
||||
##
|
||||
## * ``except`` statement (without `try`) does not work inside async procedures.
|
||||
## * The effect system (``raises: []``) does not work with async procedures.
|
||||
## * Can't await in a ``except`` body
|
||||
|
||||
|
||||
# TODO: ``except`` statement (without `try`) does not work.
|
||||
# TODO: Multiple exception names in a ``except`` don't work.
|
||||
# TODO: The effect system (raises: []) has trouble with my try transformation.
|
||||
# TODO: Can't await in a 'except' body
|
||||
# TODO: getCurrentException(Msg) don't work
|
||||
# TODO: Check if yielded future is nil and throw a more meaningful exception
|
||||
|
||||
# -- Futures
|
||||
|
||||
type
|
||||
FutureBase* = ref object of RootObj
|
||||
FutureBase* = ref object of RootObj ## Untyped future.
|
||||
cb: proc () {.closure,gcsafe.}
|
||||
finished: bool
|
||||
error*: ref Exception
|
||||
error*: ref Exception ## Stored exception
|
||||
errorStackTrace*: string
|
||||
when not defined(release):
|
||||
stackTrace: string ## For debugging purposes only.
|
||||
id: int
|
||||
fromProc: string
|
||||
|
||||
Future*[T] = ref object of FutureBase
|
||||
value: T
|
||||
Future*[T] = ref object of FutureBase ## Typed future.
|
||||
value: T ## Stored value
|
||||
|
||||
{.deprecated: [PFutureBase: FutureBase, PFuture: Future].}
|
||||
|
||||
|
||||
var currentID* = 0
|
||||
var currentID = 0
|
||||
proc newFuture*[T](fromProc: string = "unspecified"): Future[T] =
|
||||
## Creates a new future.
|
||||
##
|
||||
@@ -161,6 +256,10 @@ proc read*[T](future: Future[T]): T =
|
||||
raise newException(ValueError, "Future still in progress.")
|
||||
|
||||
proc readError*[T](future: Future[T]): ref Exception =
|
||||
## Retrieves the exception stored in ``future``.
|
||||
##
|
||||
## An ``ValueError`` exception will be thrown if no exception exists
|
||||
## in the specified Future.
|
||||
if future.error != nil: return future.error
|
||||
else:
|
||||
raise newException(ValueError, "No error in future.")
|
||||
@@ -173,7 +272,7 @@ proc finished*[T](future: Future[T]): bool =
|
||||
|
||||
proc failed*(future: FutureBase): bool =
|
||||
## Determines whether ``future`` completed with an error.
|
||||
future.error != nil
|
||||
return future.error != nil
|
||||
|
||||
proc asyncCheck*[T](future: Future[T]) =
|
||||
## Sets a callback on ``future`` which raises an exception if the future
|
||||
@@ -950,7 +1049,7 @@ proc accept*(socket: TAsyncFD,
|
||||
|
||||
# -- Await Macro
|
||||
|
||||
template createCb*(retFutureSym, iteratorNameSym,
|
||||
template createCb(retFutureSym, iteratorNameSym,
|
||||
name: expr): stmt {.immediate.} =
|
||||
var nameIterVar = iteratorNameSym
|
||||
#{.push stackTrace: off.}
|
||||
@@ -1193,7 +1292,7 @@ macro async*(prc: stmt): stmt {.immediate.} =
|
||||
|
||||
# -> createCb(retFuture)
|
||||
var cbName = newIdentNode("cb")
|
||||
var procCb = newCall("createCb", retFutureSym, iteratorNameSym,
|
||||
var procCb = newCall(bindSym"createCb", retFutureSym, iteratorNameSym,
|
||||
newStrLitNode(prc[0].getName))
|
||||
outerProcBody.add procCb
|
||||
|
||||
@@ -1232,7 +1331,10 @@ proc recvLine*(socket: TAsyncFD): Future[string] {.async.} =
|
||||
## is read) then line will be set to ``""``.
|
||||
## The partial line **will be lost**.
|
||||
##
|
||||
## **Warning**: This assumes that lines are delimited by ``\r\l``.
|
||||
## **Warning**: This assumes that lines are delimited by ``\r\L``.
|
||||
##
|
||||
## **Note**: This procedure is mostly used for testing. You likely want to
|
||||
## use ``asyncnet.recvLine`` instead.
|
||||
|
||||
template addNLIfEmpty(): stmt =
|
||||
if result.len == 0:
|
||||
|
||||
@@ -6,6 +6,24 @@
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implement an asynchronous FTP client.
|
||||
##
|
||||
## Examples
|
||||
## --------
|
||||
##
|
||||
## .. code-block::nim
|
||||
##
|
||||
## var ftp = newAsyncFtpClient("example.com", user = "test", pass = "test")
|
||||
## proc main(ftp: AsyncFtpClient) {.async.} =
|
||||
## await ftp.connect()
|
||||
## echo await ftp.pwd()
|
||||
## echo await ftp.listDirs()
|
||||
## await ftp.store("payload.jpg", "payload.jpg")
|
||||
## await ftp.retrFile("payload.jpg", "payload2.jpg")
|
||||
## echo("Finished")
|
||||
##
|
||||
## waitFor main(ftp)
|
||||
|
||||
import asyncdispatch, asyncnet, strutils, parseutils, os, times
|
||||
|
||||
from ftpclient import FtpBaseObj, ReplyError, FtpEvent
|
||||
|
||||
@@ -9,7 +9,20 @@
|
||||
|
||||
## This module implements a high performance asynchronous HTTP server.
|
||||
##
|
||||
## **Note:** This module is still largely experimental.
|
||||
## Examples
|
||||
## --------
|
||||
##
|
||||
## This example will create an HTTP server on port 8080. The server will
|
||||
## respond to all requests with a ``200 OK`` response code and "Hello World"
|
||||
## as the response body.
|
||||
##
|
||||
## .. code-block::nim
|
||||
## var server = newAsyncHttpServer()
|
||||
## proc cb(req: TRequest) {.async.} =
|
||||
## await req.respond(Http200, "Hello World")
|
||||
##
|
||||
## asyncCheck server.serve(Port(8080), cb)
|
||||
## runForever()
|
||||
|
||||
import strtabs, asyncnet, asyncdispatch, parseutils, uri, strutils
|
||||
type
|
||||
@@ -52,6 +65,7 @@ proc `==`*(protocol: tuple[orig: string, major, minor: int],
|
||||
result = protocol.major == major and protocol.minor == minor
|
||||
|
||||
proc newAsyncHttpServer*(): PAsyncHttpServer =
|
||||
## Creates a new ``AsyncHttpServer`` instance.
|
||||
new result
|
||||
|
||||
proc addHeaders(msg: var string, headers: PStringTable) =
|
||||
|
||||
@@ -91,10 +91,10 @@ import sockets, os
|
||||
## getSocket(s).accept(client)
|
||||
|
||||
when defined(windows):
|
||||
from winlean import TimeVal, SocketHandle, TFdSet, FD_ZERO, FD_SET,
|
||||
from winlean import TimeVal, SocketHandle, fdSet, FD_ZERO, TFdSet,
|
||||
fdSet, FD_ISSET, select
|
||||
else:
|
||||
from posix import TimeVal, SocketHandle, TFdSet, FD_ZERO, FD_SET,
|
||||
from posix import TimeVal, SocketHandle, fdSet, FD_ZERO, TFdSet,
|
||||
fdSet, FD_ISSET, select
|
||||
|
||||
type
|
||||
|
||||
@@ -10,8 +10,20 @@
|
||||
## This module implements a high-level asynchronous sockets API based on the
|
||||
## asynchronous dispatcher defined in the ``asyncdispatch`` module.
|
||||
##
|
||||
## Example
|
||||
## =======
|
||||
## SSL
|
||||
## ---
|
||||
##
|
||||
## SSL can be enabled by compiling with the ``-d:ssl`` flag.
|
||||
##
|
||||
## You must create a new SSL context with the ``newContext`` function defined
|
||||
## in the ``net`` module. You may then call ``wrapSocket`` on your socket using
|
||||
## the newly created SSL context to get an SSL socket.
|
||||
##
|
||||
## Examples
|
||||
## --------
|
||||
##
|
||||
## Chat server
|
||||
## ^^^^^^^^^^^
|
||||
##
|
||||
## The following example demonstrates a simple chat server.
|
||||
##
|
||||
@@ -41,8 +53,6 @@
|
||||
## asyncCheck serve()
|
||||
## runForever()
|
||||
##
|
||||
##
|
||||
## **Note:** This module is still largely experimental.
|
||||
|
||||
import asyncdispatch
|
||||
import rawsockets
|
||||
|
||||
@@ -59,6 +59,7 @@ template encodeInternal(s: expr, lineLen: int, newLine: string): stmt {.immediat
|
||||
setLen(result, r+4)
|
||||
else:
|
||||
#assert(r == result.len)
|
||||
discard
|
||||
|
||||
proc encode*[T:SomeInteger|char](s: openarray[T], lineLen = 75, newLine="\13\10"): string =
|
||||
## encodes `s` into base64 representation. After `lineLen` characters, a
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
#
|
||||
# Nim's Runtime Library
|
||||
# (c) Copyright 2012 Dominik Picheta
|
||||
# (c) Copyright 2014 Dominik Picheta
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
@@ -48,6 +48,19 @@
|
||||
##
|
||||
## echo(postContent("http://validator.w3.org/check", headers, body))
|
||||
##
|
||||
## Asynchronous HTTP requests
|
||||
## ==========================
|
||||
##
|
||||
## You simply have to create a new instance of the ``AsyncHttpClient`` object.
|
||||
## You may then use ``await`` on the functions defined for that object.
|
||||
## Keep in mind that the following code needs to be inside an asynchronous
|
||||
## procedure.
|
||||
##
|
||||
## .. code-block::nim
|
||||
##
|
||||
## var client = newAsyncHttpClient()
|
||||
## var resp = await client.request("http://google.com")
|
||||
##
|
||||
## SSL/TLS support
|
||||
## ===============
|
||||
## This requires the OpenSSL library, fortunately it's widely used and installed
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
##
|
||||
## run(handleRequest, TPort(80))
|
||||
##
|
||||
## **Warning:** The API of this module is unstable, and therefore is subject
|
||||
## to change.
|
||||
|
||||
import parseutils, strutils, os, osproc, strtabs, streams, sockets, asyncio
|
||||
|
||||
@@ -90,14 +88,14 @@ proc serveFile*(client: TSocket, filename: string) =
|
||||
headers(client, filename)
|
||||
const bufSize = 8000 # != 8K might be good for memory manager
|
||||
var buf = alloc(bufsize)
|
||||
while True:
|
||||
while true:
|
||||
var bytesread = readBuffer(f, buf, bufsize)
|
||||
if bytesread > 0:
|
||||
var byteswritten = send(client, buf, bytesread)
|
||||
if bytesread != bytesWritten:
|
||||
dealloc(buf)
|
||||
close(f)
|
||||
OSError(OSLastError())
|
||||
raiseOSError(osLastError())
|
||||
if bytesread != bufSize: break
|
||||
dealloc(buf)
|
||||
close(f)
|
||||
@@ -228,9 +226,9 @@ proc open*(s: var TServer, port = TPort(80), reuseAddr = false) =
|
||||
## creates a new server at port `port`. If ``port == 0`` a free port is
|
||||
## acquired that can be accessed later by the ``port`` proc.
|
||||
s.socket = socket(AF_INET)
|
||||
if s.socket == InvalidSocket: OSError(OSLastError())
|
||||
if s.socket == invalidSocket: raiseOSError(osLastError())
|
||||
if reuseAddr:
|
||||
s.socket.setSockOpt(OptReuseAddr, True)
|
||||
s.socket.setSockOpt(OptReuseAddr, true)
|
||||
bindAddr(s.socket, port)
|
||||
listen(s.socket)
|
||||
|
||||
@@ -238,7 +236,7 @@ proc open*(s: var TServer, port = TPort(80), reuseAddr = false) =
|
||||
s.port = getSockName(s.socket)
|
||||
else:
|
||||
s.port = port
|
||||
s.client = InvalidSocket
|
||||
s.client = invalidSocket
|
||||
s.reqMethod = ""
|
||||
s.body = ""
|
||||
s.path = ""
|
||||
@@ -346,7 +344,7 @@ proc next*(s: var TServer) =
|
||||
# XXX we ignore "HTTP/1.1" etc. for now here
|
||||
var query = 0
|
||||
var last = i
|
||||
while last < data.len and data[last] notin whitespace:
|
||||
while last < data.len and data[last] notin Whitespace:
|
||||
if data[last] == '?' and query == 0: query = last
|
||||
inc(last)
|
||||
if query > 0:
|
||||
@@ -466,7 +464,7 @@ proc nextAsync(s: PAsyncHTTPServer) =
|
||||
# XXX we ignore "HTTP/1.1" etc. for now here
|
||||
var query = 0
|
||||
var last = i
|
||||
while last < data.len and data[last] notin whitespace:
|
||||
while last < data.len and data[last] notin Whitespace:
|
||||
if data[last] == '?' and query == 0: query = last
|
||||
inc(last)
|
||||
if query > 0:
|
||||
@@ -483,7 +481,7 @@ proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: TSo
|
||||
## Creates an Asynchronous HTTP server at ``port``.
|
||||
var capturedRet: PAsyncHTTPServer
|
||||
new(capturedRet)
|
||||
capturedRet.asyncSocket = AsyncSocket()
|
||||
capturedRet.asyncSocket = asyncSocket()
|
||||
capturedRet.asyncSocket.handleAccept =
|
||||
proc (s: PAsyncSocket) =
|
||||
nextAsync(capturedRet)
|
||||
@@ -491,7 +489,7 @@ proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: TSo
|
||||
capturedRet.query)
|
||||
if quit: capturedRet.asyncSocket.close()
|
||||
if reuseAddr:
|
||||
capturedRet.asyncSocket.setSockOpt(OptReuseAddr, True)
|
||||
capturedRet.asyncSocket.setSockOpt(OptReuseAddr, true)
|
||||
|
||||
capturedRet.asyncSocket.bindAddr(port, address)
|
||||
capturedRet.asyncSocket.listen()
|
||||
@@ -500,7 +498,7 @@ proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: TSo
|
||||
else:
|
||||
capturedRet.port = port
|
||||
|
||||
capturedRet.client = InvalidSocket
|
||||
capturedRet.client = invalidSocket
|
||||
capturedRet.reqMethod = ""
|
||||
capturedRet.body = ""
|
||||
capturedRet.path = ""
|
||||
|
||||
@@ -80,7 +80,7 @@ when defined(Nimdoc): # only for proper documentation:
|
||||
## search patch components (as in PATH), such as ':' for POSIX or ';' for
|
||||
## Windows.
|
||||
|
||||
FileSystemCaseSensitive* = True
|
||||
FileSystemCaseSensitive* = true
|
||||
## True if the file system is case sensitive, false otherwise. Used by
|
||||
## `cmpPaths` to compare filenames properly.
|
||||
|
||||
|
||||
@@ -729,7 +729,7 @@ type
|
||||
len*: int # output length pointer
|
||||
is_null*: Pmy_bool # Pointer to null indicator
|
||||
buffer*: pointer # buffer to get/put data
|
||||
error*: pmy_bool # set this if you want to track data truncations happened during fetch
|
||||
error*: PMy_bool # set this if you want to track data truncations happened during fetch
|
||||
buffer_type*: Tenum_field_types # buffer type
|
||||
buffer_length*: int # buffer length, must be set for str/binary
|
||||
# Following are for internal use. Set by mysql_stmt_bind_param
|
||||
@@ -904,7 +904,7 @@ proc shutdown*(MySQL: PMySQL, shutdown_level: Tenum_shutdown_level): cint{.stdca
|
||||
dynlib: lib, importc: "mysql_shutdown".}
|
||||
proc dump_debug_info*(MySQL: PMySQL): cint{.stdcall, dynlib: lib,
|
||||
importc: "mysql_dump_debug_info".}
|
||||
proc refresh*(MySQL: PMySQL, refresh_options: cuint): cint{.stdcall, dynlib: lib,
|
||||
proc refresh*(sql: PMySQL, refresh_options: cuint): cint{.stdcall, dynlib: lib,
|
||||
importc: "mysql_refresh".}
|
||||
proc kill*(MySQL: PMySQL, pid: int): cint{.stdcall, dynlib: lib, importc: "mysql_kill".}
|
||||
proc set_server_option*(MySQL: PMySQL, option: Tenum_mysql_set_option): cint{.stdcall,
|
||||
@@ -1040,7 +1040,7 @@ const
|
||||
NO_DATA* = 100
|
||||
DATA_TRUNCATED* = 101
|
||||
|
||||
proc reload*(MySQL: PMySQL): cint
|
||||
proc reload*(x: PMySQL): cint
|
||||
when defined(USE_OLD_FUNCTIONS):
|
||||
proc connect*(MySQL: PMySQL, host: cstring, user: cstring, passwd: cstring): PMySQL{.stdcall,
|
||||
dynlib: lib, importc: "mysql_connect".}
|
||||
@@ -1059,7 +1059,7 @@ proc IS_NOT_NULL(n: int32): bool =
|
||||
proc IS_BLOB(n: int32): bool =
|
||||
result = (n and BLOB_FLAG) != 0
|
||||
|
||||
proc IS_NUM_FIELD(f: pst_mysql_field): bool =
|
||||
proc IS_NUM_FIELD(f: Pst_mysql_field): bool =
|
||||
result = (f.flags and NUM_FLAG) != 0
|
||||
|
||||
proc IS_NUM(t: Tenum_field_types): bool =
|
||||
@@ -1071,7 +1071,7 @@ proc INTERNAL_NUM_FIELD(f: Pst_mysql_field): bool =
|
||||
((f.ftype != FIELD_TYPE_TIMESTAMP) or (f.len == 14) or (f.len == 8)) or
|
||||
(f.ftype == FIELD_TYPE_YEAR)
|
||||
|
||||
proc reload(mysql: PMySQL): cint =
|
||||
result = refresh(mysql, REFRESH_GRANT)
|
||||
proc reload(x: PMySQL): cint =
|
||||
result = refresh(x, REFRESH_GRANT)
|
||||
|
||||
{.pop.}
|
||||
|
||||
@@ -145,182 +145,182 @@ type
|
||||
p*: pointer
|
||||
|
||||
|
||||
proc PQconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
proc pqconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
importc: "PQconnectStart".}
|
||||
proc PQconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
proc pqconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
dynlib: dllName, importc: "PQconnectPoll".}
|
||||
proc PQconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
proc pqconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
|
||||
importc: "PQconnectdb".}
|
||||
proc PQsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring,
|
||||
proc pqsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring,
|
||||
pgtty: cstring, dbName: cstring, login: cstring, pwd: cstring): PPGconn{.
|
||||
cdecl, dynlib: dllName, importc: "PQsetdbLogin".}
|
||||
proc PQsetdb*(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn
|
||||
proc PQfinish*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQfinish".}
|
||||
proc PQconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName,
|
||||
proc pqsetdb*(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): Ppgconn
|
||||
proc pqfinish*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQfinish".}
|
||||
proc pqconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName,
|
||||
importc: "PQconndefaults".}
|
||||
proc PQconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName,
|
||||
proc pqconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName,
|
||||
importc: "PQconninfoFree".}
|
||||
proc PQresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQresetStart".}
|
||||
proc PQresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
proc pqresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
|
||||
dynlib: dllName, importc: "PQresetPoll".}
|
||||
proc PQreset*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQreset".}
|
||||
proc PQrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqreset*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQreset".}
|
||||
proc pqrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQrequestCancel".}
|
||||
proc PQdb*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQdb".}
|
||||
proc PQuser*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQuser".}
|
||||
proc PQpass*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQpass".}
|
||||
proc PQhost*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQhost".}
|
||||
proc PQport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport".}
|
||||
proc PQtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".}
|
||||
proc PQoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqdb*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQdb".}
|
||||
proc pquser*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQuser".}
|
||||
proc pqpass*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQpass".}
|
||||
proc pqhost*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQhost".}
|
||||
proc pqport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport".}
|
||||
proc pqtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".}
|
||||
proc pqoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQoptions".}
|
||||
proc PQstatus*(conn: PPGconn): TConnStatusType{.cdecl, dynlib: dllName,
|
||||
proc pqstatus*(conn: PPGconn): TConnStatusType{.cdecl, dynlib: dllName,
|
||||
importc: "PQstatus".}
|
||||
proc PQtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl,
|
||||
proc pqtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl,
|
||||
dynlib: dllName, importc: "PQtransactionStatus".}
|
||||
proc PQparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl,
|
||||
proc pqparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQparameterStatus".}
|
||||
proc PQprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQprotocolVersion".}
|
||||
proc PQerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQerrorMessage".}
|
||||
proc PQsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsocket".}
|
||||
proc PQbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQbackendPID".}
|
||||
proc PQclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQclientEncoding".}
|
||||
proc PQsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl,
|
||||
proc pqsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQsetClientEncoding".}
|
||||
when defined(USE_SSL):
|
||||
# Get the SSL structure associated with a connection
|
||||
proc PQgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName,
|
||||
proc pqgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName,
|
||||
importc: "PQgetssl".}
|
||||
proc PQsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
|
||||
proc pqsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
|
||||
cdecl, dynlib: dllName, importc: "PQsetErrorVerbosity".}
|
||||
proc PQtrace*(conn: PPGconn, debug_port: TFile){.cdecl, dynlib: dllName,
|
||||
proc pqtrace*(conn: PPGconn, debug_port: TFile){.cdecl, dynlib: dllName,
|
||||
importc: "PQtrace".}
|
||||
proc PQuntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
|
||||
proc PQsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, arg: pointer): PQnoticeReceiver{.
|
||||
proc pquntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
|
||||
proc pqsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, arg: pointer): PQnoticeReceiver{.
|
||||
cdecl, dynlib: dllName, importc: "PQsetNoticeReceiver".}
|
||||
proc PQsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor,
|
||||
proc pqsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor,
|
||||
arg: pointer): PQnoticeProcessor{.cdecl,
|
||||
dynlib: dllName, importc: "PQsetNoticeProcessor".}
|
||||
proc PQexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName,
|
||||
proc pqexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName,
|
||||
importc: "PQexec".}
|
||||
proc PQexecParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
proc pqexecParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
paramTypes: POid, paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQexecParams".}
|
||||
proc PQexecPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
|
||||
proc pqexecPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
|
||||
paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQexecPrepared".}
|
||||
proc PQsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName,
|
||||
proc pqsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsendQuery".}
|
||||
proc PQsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
proc pqsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32,
|
||||
paramTypes: POid, paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32,
|
||||
resultFormat: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsendQueryParams".}
|
||||
proc PQsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
|
||||
proc pqsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
|
||||
paramValues: cstringArray,
|
||||
paramLengths, paramFormats: ptr int32,
|
||||
resultFormat: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQsendQueryPrepared".}
|
||||
proc PQgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName,
|
||||
proc pqgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName,
|
||||
importc: "PQgetResult".}
|
||||
proc PQisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQisBusy".}
|
||||
proc PQconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQconsumeInput".}
|
||||
proc PQnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName,
|
||||
proc pqnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName,
|
||||
importc: "PQnotifies".}
|
||||
proc PQputCopyData*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.
|
||||
proc pqputCopyData*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQputCopyData".}
|
||||
proc PQputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl,
|
||||
proc pqputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQputCopyEnd".}
|
||||
proc PQgetCopyData*(conn: PPGconn, buffer: cstringArray, async: int32): int32{.
|
||||
proc pqgetCopyData*(conn: PPGconn, buffer: cstringArray, async: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetCopyData".}
|
||||
proc PQgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl,
|
||||
proc pqgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQgetline".}
|
||||
proc PQputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName,
|
||||
proc pqputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQputline".}
|
||||
proc PQgetlineAsync*(conn: PPGconn, buffer: cstring, bufsize: int32): int32{.
|
||||
proc pqgetlineAsync*(conn: PPGconn, buffer: cstring, bufsize: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetlineAsync".}
|
||||
proc PQputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl,
|
||||
proc pqputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQputnbytes".}
|
||||
proc PQendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQendcopy".}
|
||||
proc PQsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl,
|
||||
proc pqsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQsetnonblocking".}
|
||||
proc PQisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
proc pqisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQisnonblocking".}
|
||||
proc PQflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush".}
|
||||
proc PQfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32,
|
||||
proc pqflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush".}
|
||||
proc pqfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32,
|
||||
result_is_int: int32, args: PPQArgBlock, nargs: int32): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQfn".}
|
||||
proc PQresultStatus*(res: PPGresult): TExecStatusType{.cdecl, dynlib: dllName,
|
||||
proc pqresultStatus*(res: PPGresult): TExecStatusType{.cdecl, dynlib: dllName,
|
||||
importc: "PQresultStatus".}
|
||||
proc PQresStatus*(status: TExecStatusType): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqresStatus*(status: TExecStatusType): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQresStatus".}
|
||||
proc PQresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQresultErrorMessage".}
|
||||
proc PQresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl,
|
||||
proc pqresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQresultErrorField".}
|
||||
proc PQntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
proc pqntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQntuples".}
|
||||
proc PQnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
proc pqnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQnfields".}
|
||||
proc PQbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
proc pqbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQbinaryTuples".}
|
||||
proc PQfname*(res: PPGresult, field_num: int32): cstring{.cdecl,
|
||||
proc pqfname*(res: PPGresult, field_num: int32): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQfname".}
|
||||
proc PQfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl,
|
||||
proc pqfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQfnumber".}
|
||||
proc PQftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
proc pqftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "PQftable".}
|
||||
proc PQftablecol*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
proc pqftablecol*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQftablecol".}
|
||||
proc PQfformat*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
proc pqfformat*(res: PPGresult, field_num: int32): int32{.cdecl,
|
||||
dynlib: dllName, importc: "PQfformat".}
|
||||
proc PQftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
proc pqftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "PQftype".}
|
||||
proc PQfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc pqfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQfsize".}
|
||||
proc PQfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc pqfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQfmod".}
|
||||
proc PQcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQcmdStatus".}
|
||||
proc PQoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQoidStatus".}
|
||||
proc PQoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName,
|
||||
proc pqoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "PQoidValue".}
|
||||
proc PQcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
proc pqcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
|
||||
importc: "PQcmdTuples".}
|
||||
proc PQgetvalue*(res: PPGresult, tup_num: int32, field_num: int32): cstring{.
|
||||
proc pqgetvalue*(res: PPGresult, tup_num: int32, field_num: int32): cstring{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetvalue".}
|
||||
proc PQgetlength*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
|
||||
proc pqgetlength*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetlength".}
|
||||
proc PQgetisnull*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
|
||||
proc pqgetisnull*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
|
||||
cdecl, dynlib: dllName, importc: "PQgetisnull".}
|
||||
proc PQclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".}
|
||||
proc PQfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".}
|
||||
proc PQmakeEmptyPGresult*(conn: PPGconn, status: TExecStatusType): PPGresult{.
|
||||
proc pqclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".}
|
||||
proc pqfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".}
|
||||
proc pqmakeEmptyPGresult*(conn: PPGconn, status: TExecStatusType): PPGresult{.
|
||||
cdecl, dynlib: dllName, importc: "PQmakeEmptyPGresult".}
|
||||
proc PQescapeString*(till, `from`: cstring, len: int): int{.cdecl,
|
||||
proc pqescapeString*(till, `from`: cstring, len: int): int{.cdecl,
|
||||
dynlib: dllName, importc: "PQescapeString".}
|
||||
proc PQescapeBytea*(bintext: cstring, binlen: int, bytealen: var int): cstring{.
|
||||
proc pqescapeBytea*(bintext: cstring, binlen: int, bytealen: var int): cstring{.
|
||||
cdecl, dynlib: dllName, importc: "PQescapeBytea".}
|
||||
proc PQunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl,
|
||||
proc pqunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl,
|
||||
dynlib: dllName, importc: "PQunescapeBytea".}
|
||||
proc PQprint*(fout: TFile, res: PPGresult, ps: PPQprintOpt){.cdecl,
|
||||
proc pqprint*(fout: TFile, res: PPGresult, ps: PPQprintOpt){.cdecl,
|
||||
dynlib: dllName, importc: "PQprint".}
|
||||
proc PQdisplayTuples*(res: PPGresult, fp: TFile, fillAlign: int32,
|
||||
proc pqdisplayTuples*(res: PPGresult, fp: TFile, fillAlign: int32,
|
||||
fieldSep: cstring, printHeader: int32, quiet: int32){.
|
||||
cdecl, dynlib: dllName, importc: "PQdisplayTuples".}
|
||||
proc PQprintTuples*(res: PPGresult, fout: TFile, printAttName: int32,
|
||||
proc pqprintTuples*(res: PPGresult, fout: TFile, printAttName: int32,
|
||||
terseOutput: int32, width: int32){.cdecl, dynlib: dllName,
|
||||
importc: "PQprintTuples".}
|
||||
proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl,
|
||||
@@ -343,8 +343,8 @@ proc lo_import*(conn: PPGconn, filename: cstring): Oid{.cdecl, dynlib: dllName,
|
||||
importc: "lo_import".}
|
||||
proc lo_export*(conn: PPGconn, lobjId: Oid, filename: cstring): int32{.cdecl,
|
||||
dynlib: dllName, importc: "lo_export".}
|
||||
proc PQmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName,
|
||||
proc pqmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName,
|
||||
importc: "PQmblen".}
|
||||
proc PQenv2encoding*(): int32{.cdecl, dynlib: dllName, importc: "PQenv2encoding".}
|
||||
proc PQsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn =
|
||||
result = PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, "", "")
|
||||
proc pqenv2encoding*(): int32{.cdecl, dynlib: dllName, importc: "PQenv2encoding".}
|
||||
proc pqsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): PPgConn =
|
||||
result = pqSetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, "", "")
|
||||
|
||||
@@ -88,8 +88,8 @@ const
|
||||
SQLITE_REINDEX* = 27
|
||||
SQLITE_DENY* = 1
|
||||
SQLITE_IGNORE* = 2 # Original from sqlite3.h:
|
||||
##define SQLITE_STATIC ((void(*)(void *))0)
|
||||
##define SQLITE_TRANSIENT ((void(*)(void *))-1)
|
||||
#define SQLITE_STATIC ((void(*)(void *))0)
|
||||
#define SQLITE_TRANSIENT ((void(*)(void *))-1)
|
||||
SQLITE_DETERMINISTIC* = 0x800
|
||||
|
||||
const
|
||||
|
||||
@@ -55,8 +55,8 @@ include "website.tmpl"
|
||||
# ------------------------- configuration file -------------------------------
|
||||
|
||||
const
|
||||
Version = "0.7"
|
||||
Usage = "nimweb - Nim Website Generator Version " & version & """
|
||||
version = "0.7"
|
||||
usage = "nimweb - Nim Website Generator Version " & version & """
|
||||
|
||||
(c) 2012 Andreas Rumpf
|
||||
Usage:
|
||||
@@ -117,10 +117,10 @@ proc parseCmdLine(c: var TConfigData) =
|
||||
of cmdLongOption, cmdShortOption:
|
||||
case normalize(key)
|
||||
of "help", "h":
|
||||
stdout.write(Usage)
|
||||
stdout.write(usage)
|
||||
quit(0)
|
||||
of "version", "v":
|
||||
stdout.write(Version & "\n")
|
||||
stdout.write(version & "\n")
|
||||
quit(0)
|
||||
of "o", "output": c.outdir = val
|
||||
of "parallelbuild":
|
||||
@@ -133,9 +133,9 @@ proc parseCmdLine(c: var TConfigData) =
|
||||
var idx = val.find('=')
|
||||
if idx < 0: quit("invalid command line")
|
||||
c.vars[substr(val, 0, idx-1)] = substr(val, idx+1)
|
||||
else: quit(Usage)
|
||||
else: quit(usage)
|
||||
of cmdEnd: break
|
||||
if c.infile.len == 0: quit(Usage)
|
||||
if c.infile.len == 0: quit(usage)
|
||||
|
||||
proc walkDirRecursively(s: var seq[string], root, ext: string) =
|
||||
for k, f in walkDir(root):
|
||||
@@ -250,9 +250,9 @@ proc buildDocSamples(c: var TConfigData, destPath: string) =
|
||||
## it didn't make much sense to integrate into the existing generic
|
||||
## documentation builders.
|
||||
const src = "doc"/"docgen_sample.nim"
|
||||
exec("nimrod doc $# -o:$# $#" %
|
||||
exec("nim doc $# -o:$# $#" %
|
||||
[c.nimrodArgs, destPath / "docgen_sample.html", src])
|
||||
exec("nimrod doc2 $# -o:$# $#" %
|
||||
exec("nim doc2 $# -o:$# $#" %
|
||||
[c.nimrodArgs, destPath / "docgen_sample2.html", src])
|
||||
|
||||
proc buildDoc(c: var TConfigData, destPath: string) =
|
||||
@@ -261,30 +261,30 @@ proc buildDoc(c: var TConfigData, destPath: string) =
|
||||
commands = newSeq[string](len(c.doc) + len(c.srcdoc) + len(c.srcdoc2))
|
||||
i = 0
|
||||
for d in items(c.doc):
|
||||
commands[i] = "nimrod rst2html $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
|
||||
commands[i] = "nim rst2html $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
|
||||
[c.nimrodArgs, c.gitCommit,
|
||||
destPath / changeFileExt(splitFile(d).name, "html"), d]
|
||||
i.inc
|
||||
for d in items(c.srcdoc):
|
||||
commands[i] = "nimrod doc $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
|
||||
commands[i] = "nim doc $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
|
||||
[c.nimrodArgs, c.gitCommit,
|
||||
destPath / changeFileExt(splitFile(d).name, "html"), d]
|
||||
i.inc
|
||||
for d in items(c.srcdoc2):
|
||||
commands[i] = "nimrod doc2 $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
|
||||
commands[i] = "nim doc2 $# --docSeeSrcUrl:$# -o:$# --index:on $#" %
|
||||
[c.nimrodArgs, c.gitCommit,
|
||||
destPath / changeFileExt(splitFile(d).name, "html"), d]
|
||||
i.inc
|
||||
|
||||
mexec(commands, c.numProcessors)
|
||||
exec("nimrod buildIndex -o:$1/theindex.html $1" % [destPath])
|
||||
exec("nim buildIndex -o:$1/theindex.html $1" % [destPath])
|
||||
|
||||
proc buildPdfDoc(c: var TConfigData, destPath: string) =
|
||||
if os.execShellCmd("pdflatex -version") != 0:
|
||||
echo "pdflatex not found; no PDF documentation generated"
|
||||
else:
|
||||
for d in items(c.pdf):
|
||||
exec("nimrod rst2tex $# $#" % [c.nimrodArgs, d])
|
||||
exec("nim rst2tex $# $#" % [c.nimrodArgs, d])
|
||||
# call LaTeX twice to get cross references right:
|
||||
exec("pdflatex " & changeFileExt(d, "tex"))
|
||||
exec("pdflatex " & changeFileExt(d, "tex"))
|
||||
@@ -300,9 +300,14 @@ proc buildPdfDoc(c: var TConfigData, destPath: string) =
|
||||
|
||||
proc buildAddDoc(c: var TConfigData, destPath: string) =
|
||||
# build additional documentation (without the index):
|
||||
<<<<<<< HEAD
|
||||
var commands = newSeq[string](c.webdoc.len)
|
||||
for i, doc in pairs(c.webdoc):
|
||||
commands[i] = "nimrod doc $# --docSeeSrcUrl:$# -o:$# $#" %
|
||||
=======
|
||||
for d in items(c.webdoc):
|
||||
exec("nim doc $# --docSeeSrcUrl:$# -o:$# $#" %
|
||||
>>>>>>> 0047172274a73c681f619f5cd60aaad7109f694d
|
||||
[c.nimrodArgs, c.gitCommit,
|
||||
destPath / changeFileExt(splitFile(doc).name, "html"), doc]
|
||||
mexec(commands, c.numProcessors)
|
||||
@@ -387,12 +392,12 @@ proc buildNewsRss(c: var TConfigData, destPath: string) =
|
||||
generateRss(destFilename, parseNewsTitles(srcFilename))
|
||||
|
||||
proc buildJS(destPath: string) =
|
||||
exec("nimrod js -d:release --out:$1 web/babelpkglist.nim" %
|
||||
exec("nim js -d:release --out:$1 web/babelpkglist.nim" %
|
||||
[destPath / "babelpkglist.js"])
|
||||
|
||||
proc main(c: var TConfigData) =
|
||||
const
|
||||
cmd = "nimrod rst2html --compileonly $1 -o:web/$2.temp web/$2.txt"
|
||||
cmd = "nim rst2html --compileonly $1 -o:web/$2.temp web/$2.txt"
|
||||
if c.ticker.len > 0:
|
||||
try:
|
||||
c.ticker = readFile("web" / c.ticker)
|
||||
|
||||
@@ -42,8 +42,11 @@ News
|
||||
and is now a Nimble package.
|
||||
- Many wrappers have been moved into their own repositories and are now
|
||||
Nimble packages including ``lua``, ``opengl``, ``x11``, ``nim-zmq``,
|
||||
``gtk2``, ``mongo``, ``cairo``, ``tcl`` and ``python``. They can be
|
||||
``gtk2``, ``mongo``, ``cairo``, ``tcl``, ``python`` and
|
||||
`more <https://github.com/Araq/Nimrod/issues/623>`_. They can be
|
||||
found under the `nim-code <https://github.com/nimrod-code>`_ organisation.
|
||||
- Removed the deprecated ``web`` module, the ``httpclient`` module should
|
||||
be used instead.
|
||||
|
||||
Language Additions
|
||||
------------------
|
||||
|
||||
@@ -39,7 +39,7 @@ UNIX. We don't believe this to be a coincidence. - Jeremy S. Anderson."""
|
||||
doc: "endb;intern;apis;lib;manual;tut1;tut2;nimc;overview;filters"
|
||||
doc: "tools;niminst;nimgrep;gc;estp;idetools;docgen;koch;backends.txt"
|
||||
pdf: "manual;lib;tut1;tut2;nimc;niminst;gc"
|
||||
srcdoc2: "system.nim;impure/graphics;wrappers/sdl"
|
||||
srcdoc2: "system.nim"
|
||||
srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned"
|
||||
srcdoc2: "impure/re;pure/sockets;pure/typetraits"
|
||||
srcdoc: "system/threads.nim;system/channels.nim;js/dom"
|
||||
@@ -47,7 +47,7 @@ srcdoc2: "pure/os;pure/strutils;pure/math;pure/matchers;pure/algorithm"
|
||||
srcdoc2: "pure/complex;pure/times;pure/osproc;pure/pegs;pure/dynlib"
|
||||
srcdoc2: "pure/parseopt;pure/parseopt2;pure/hashes;pure/strtabs;pure/lexbase"
|
||||
srcdoc2: "pure/parsecfg;pure/parsexml;pure/parsecsv;pure/parsesql"
|
||||
srcdoc2: "pure/streams;pure/terminal;pure/cgi;impure/web;pure/unicode"
|
||||
srcdoc2: "pure/streams;pure/terminal;pure/cgi;pure/unicode"
|
||||
srcdoc2: "impure/zipfiles;pure/htmlgen;pure/parseutils;pure/browsers"
|
||||
srcdoc2: "impure/db_postgres;impure/db_mysql;impure/db_sqlite"
|
||||
srcdoc2: "pure/httpserver;pure/httpclient;pure/smtp;impure/ssl;pure/fsmonitor"
|
||||
@@ -67,14 +67,14 @@ srcdoc2: "pure/rawsockets;pure/asynchttpserver;pure/net;pure/selectors;pure/futu
|
||||
srcdoc2: "wrappers/expat;wrappers/readline/history"
|
||||
srcdoc2: "wrappers/libsvm.nim;wrappers/libuv"
|
||||
srcdoc2: "wrappers/zip/zlib;wrappers/zip/libzip"
|
||||
srcdoc2: "wrappers/libcurl;pure/md5;wrappers/mysql;wrappers/iup"
|
||||
srcdoc2: "pure/md5;wrappers/mysql;wrappers/iup"
|
||||
srcdoc2: "posix/posix;wrappers/odbcsql"
|
||||
srcdoc2: "wrappers/tre;wrappers/openssl;wrappers/pcre"
|
||||
srcdoc2: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc"
|
||||
srcdoc2: "wrappers/readline/readline;wrappers/readline/rltypedefs"
|
||||
srcdoc2: "wrappers/joyent_http_parser"
|
||||
|
||||
webdoc: "wrappers/libcurl;pure/md5;wrappers/mysql;wrappers/iup"
|
||||
webdoc: "pure/md5;wrappers/mysql;wrappers/iup"
|
||||
webdoc: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc"
|
||||
webdoc: "wrappers/expat;wrappers/pcre"
|
||||
webdoc: "wrappers/tre;wrappers/openssl"
|
||||
|
||||
Reference in New Issue
Block a user