diff options
author | Araq <rumpf_a@web.de> | 2012-10-05 12:10:01 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-10-05 12:10:01 +0200 |
commit | 350e178d837a212755b729bb82225193acef5734 (patch) | |
tree | bd94d64c55eeccdf8479c967bc77bac2500336af /lib | |
parent | 01dfcf63106fb18239a1c6dabf551405c33b6e7e (diff) | |
parent | f28b7be6a37d566df64cb944c1687e014be8d083 (diff) | |
download | Nim-350e178d837a212755b729bb82225193acef5734.tar.gz |
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/core/macros.nim | 8 | ||||
-rwxr-xr-x | lib/impure/graphics.nim | 2 | ||||
-rwxr-xr-x | lib/pure/sockets.nim | 2 | ||||
-rw-r--r-- | lib/pure/unittest.nim | 11 | ||||
-rwxr-xr-x | lib/system.nim | 5 |
5 files changed, 12 insertions, 16 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 8fdaf7a6c..be6aecab5 100755 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -38,7 +38,7 @@ type nnkFastAsgn, nnkGenericParams, nnkFormalParams, nnkOfInherit, nnkModule, nnkProcDef, nnkMethodDef, nnkConverterDef, nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch, - nnkElifBranch, nnkExceptBranch, nnkElse, nnkMacroStmt, + nnkElifBranch, nnkExceptBranch, nnkElse, nnkAsmStmt, nnkPragma, nnkPragmaBlock, nnkIfStmt, nnkWhenStmt, nnkForStmt, nnkParForStmt, nnkWhileStmt, nnkCaseStmt, nnkTypeSection, nnkVarSection, nnkLetSection, nnkConstSection, @@ -234,16 +234,14 @@ proc getAst*(macroOrTemplate: expr): PNimrodNode {.magic: "ExpandToAst".} ## macro FooMacro() = ## var ast = getAst(BarTemplate()) -template emit*(s: expr): stmt = +template emit*(e: expr[string]): stmt = ## accepts a single string argument and treats it as nimrod code ## that should be inserted verbatim in the program ## Example: ## ## emit("echo " & '"' & "hello world".toUpper & '"') ## - block: - const evaluated = s - eval: result = evaluated.parseStmt + eval: result = e.parseStmt proc expectKind*(n: PNimrodNode, k: TNimrodNodeKind) {.compileTime.} = ## checks that `n` is of kind `k`. If this is not the case, diff --git a/lib/impure/graphics.nim b/lib/impure/graphics.nim index 1d538b790..b3bc578d0 100755 --- a/lib/impure/graphics.nim +++ b/lib/impure/graphics.nim @@ -22,7 +22,7 @@ type PSurface* = ref TSurface ## a surface to draw onto TSurface* {.pure, final.} = object - w*, h*: int + w*, h*: Natural s*: sdl.PSurface EGraphics* = object of EIO diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim index fb04d6754..4782ddd2e 100755 --- a/lib/pure/sockets.nim +++ b/lib/pure/sockets.nim @@ -940,7 +940,7 @@ proc readIntoBuf(socket: TSocket, flags: int32): int = socket.currPos = 0 template retRead(flags, readBytes: int) = - let res = socket.readIntoBuf(flags) + let res = socket.readIntoBuf(flags.int32) if res <= 0: if readBytes > 0: return readBytes diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 0233b8bac..fce84bea4 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -151,7 +151,7 @@ template require*(conditions: stmt): stmt {.immediate, dirty.} = const AbortOnError {.inject.} = true check conditions -macro expect*(exp: stmt): stmt {.immediate.} = +macro expect*(exceptions: varargs[expr], body: stmt): stmt {.immediate.} = let exp = callsite() template expectBody(errorTypes, lineInfoLit: expr, body: stmt): PNimrodNode {.dirty.} = @@ -162,12 +162,11 @@ macro expect*(exp: stmt): stmt {.immediate.} = except errorTypes: nil - var expectCall = exp[0] - var body = exp[1] - + var body = exp[exp.len - 1] + var errorTypes = newNimNode(nnkBracket) - for i in countup(1, expectCall.len - 1): - errorTypes.add(expectCall[i]) + for i in countup(1, exp.len - 2): + errorTypes.add(exp[i]) result = getAst(expectBody(errorTypes, exp.lineinfo, body)) diff --git a/lib/system.nim b/lib/system.nim index 99f1e621a..9d7652c94 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -2349,9 +2349,8 @@ template eval*(blk: stmt): stmt = ## executes a block of code at compile time just as if it was a macro ## optionally, the block can return an AST tree that will replace the ## eval expression - block: - macro payload(x: stmt): stmt = blk - payload() + macro payload: stmt {.gensym.} = blk + payload() proc insert*(x: var string, item: string, i = 0) {.noSideEffect.} = ## inserts `item` into `x` at position `i`. |