diff options
author | Araq <rumpf_a@web.de> | 2014-04-08 00:34:35 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-04-08 00:34:35 +0200 |
commit | 831a8c8db4004863664019181816c7a9037a5955 (patch) | |
tree | 01e61f4a5f0b83748aeab027cf5dd19da9784d33 /lib | |
parent | 42a8ab34f1eeda9e7ab728b78a27954209ac1ed1 (diff) | |
parent | 230af70be49f0af48cd1152f1dae5074d4fcd106 (diff) | |
download | Nim-831a8c8db4004863664019181816c7a9037a5955.tar.gz |
Merge branch 'devel' of https://github.com/Araq/Nimrod into devel
Diffstat (limited to 'lib')
-rw-r--r-- | lib/packages/docutils/rstast.nim | 26 | ||||
-rw-r--r-- | lib/pure/asyncdispatch.nim | 2 | ||||
-rw-r--r-- | lib/windows/winlean.nim | 7 |
3 files changed, 32 insertions, 3 deletions
diff --git a/lib/packages/docutils/rstast.nim b/lib/packages/docutils/rstast.nim index f5ef0f53d..8f946d973 100644 --- a/lib/packages/docutils/rstast.nim +++ b/lib/packages/docutils/rstast.nim @@ -9,7 +9,7 @@ ## This module implements an AST for the `reStructuredText`:idx: parser. -import strutils +import strutils, json type TRstNodeKind* = enum ## the possible node kinds of an PRstNode @@ -286,3 +286,27 @@ proc renderRstToRst*(n: PRstNode, result: var string) = var d: TRenderContext renderRstToRst(d, n, result) +proc renderRstToJsonNode(node: PRstNode): PJsonNode = + result = + %[ + (key: "kind", val: %($node.kind)), + (key: "level", val: %BiggestInt(node.level)) + ] + if node.text != nil: + result.add("text", %node.text) + if node.sons != nil and len(node.sons) > 0: + var accm = newSeq[PJsonNode](len(node.sons)) + for i, son in node.sons: + accm[i] = renderRstToJsonNode(son) + result.add("sons", %accm) + +proc renderRstToJson*(node: PRstNode): string = + ## Writes the given RST node as JSON that is in the form + ## :: + ## { + ## "kind":string node.kind, + ## "text":optional string node.text, + ## "level":optional int node.level, + ## "sons":optional node array + ## } + renderRstToJsonNode(node).pretty diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index ef2bab875..880458ee5 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -922,7 +922,7 @@ macro async*(prc: stmt): stmt {.immediate.} = result[6] = outerProcBody - echo(toStrLit(result)) + #echo(toStrLit(result)) proc recvLine*(socket: TAsyncFD): PFuture[string] {.async.} = ## Reads a line of data from ``socket``. Returned future will complete once diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim index 4d87cf4b2..69a3c5c81 100644 --- a/lib/windows/winlean.nim +++ b/lib/windows/winlean.nim @@ -657,7 +657,12 @@ type D4*: array [0..7, int8] const - ERROR_IO_PENDING* = 997 + ERROR_IO_PENDING* = 997 # a.k.a WSA_IO_PENDING + WSAECONNABORTED* = 10053 + WSAECONNRESET* = 10054 + WSAEDISCON* = 10101 + WSAENETRESET* = 10052 + WSAETIMEDOUT* = 10060 proc CreateIoCompletionPort*(FileHandle: THANDLE, ExistingCompletionPort: THANDLE, CompletionKey: DWORD, |