From c2b36a0343ed8af0f817743a7b662900cc7c1d92 Mon Sep 17 00:00:00 2001 From: Dustin Lacewell Date: Wed, 3 Dec 2014 13:26:37 -0800 Subject: [PATCH 1/4] Adds some flexibility to the lib name of SDL_ttf to allow for newer distributions --- lib/wrappers/sdl/sdl_ttf.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wrappers/sdl/sdl_ttf.nim b/lib/wrappers/sdl/sdl_ttf.nim index e0410c798f..cbea7c078c 100644 --- a/lib/wrappers/sdl/sdl_ttf.nim +++ b/lib/wrappers/sdl/sdl_ttf.nim @@ -163,7 +163,7 @@ elif defined(macosx): ttfLibName = "libSDL_ttf-2.0.0.dylib" else: const - ttfLibName = "libSDL_ttf.so(|.1|.0)" + ttfLibName = "libSDL_ttf(-2.0|).so(|.1|.0)" const MAJOR_VERSION* = 2 MINOR_VERSION* = 0 From 51d2096cd340ec9ef0cb1e598d5c389a95b9c456 Mon Sep 17 00:00:00 2001 From: Dustin Lacewell Date: Wed, 3 Dec 2014 15:15:58 -0800 Subject: [PATCH 2/4] Update the pattern to prefer the old version --- lib/pure/sockets.nim | 3 ++- lib/wrappers/sdl/sdl_ttf.nim | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim index 99cdc002c6..e3c32e806e 100644 --- a/lib/pure/sockets.nim +++ b/lib/pure/sockets.nim @@ -45,7 +45,8 @@ else: # Note: The enumerations are mapped to Window's constants. -when defined(ssl): +when defined(ssl): + type SSLError* = object of Exception diff --git a/lib/wrappers/sdl/sdl_ttf.nim b/lib/wrappers/sdl/sdl_ttf.nim index cbea7c078c..9ebe70b9d2 100644 --- a/lib/wrappers/sdl/sdl_ttf.nim +++ b/lib/wrappers/sdl/sdl_ttf.nim @@ -163,7 +163,7 @@ elif defined(macosx): ttfLibName = "libSDL_ttf-2.0.0.dylib" else: const - ttfLibName = "libSDL_ttf(-2.0|).so(|.1|.0)" + ttfLibName = "libSDL_ttf(|-2.0).so(|.1|.0)" const MAJOR_VERSION* = 2 MINOR_VERSION* = 0 From 898501d9d1973a0ac1571a9e34c33f47e36d6c8a Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Thu, 4 Dec 2014 18:47:01 +0000 Subject: [PATCH 3/4] Moved smiliey format to config hash table. --- lib/packages/docutils/rstgen.nim | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim index 5142920396..fc60b36721 100644 --- a/lib/packages/docutils/rstgen.nim +++ b/lib/packages/docutils/rstgen.nim @@ -60,7 +60,6 @@ type seenIndexTerms: Table[string, int] ## \ ## Keeps count of same text index terms to generate different identifiers ## for hyperlinks. See renderIndexTerm proc for details. - smileyFrmt: string ## How to massage the smiley filename. PDoc = var TRstGenerator ## Alias to type less. @@ -81,8 +80,7 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget, config: StringTableRef, filename: string, options: TRstParseOptions, findFile: TFindFileHandler=nil, - msgHandler: TMsgHandler=nil, - smileyFrmt = "/images/smilies/$1.gif") = + msgHandler: TMsgHandler=nil) = ## Initializes a ``TRstGenerator``. ## ## You need to call this before using a ``TRstGenerator`` with any other @@ -142,7 +140,6 @@ proc initRstGenerator*(g: var TRstGenerator, target: TOutputTarget, let s = config["split.item.toc"] if s != "": g.splitAfter = parseInt(s) for i in low(g.meta)..high(g.meta): g.meta[i] = "" - g.smileyFrmt = smileyFrmt proc writeIndexFile*(g: var TRstGenerator, outfile: string) = ## Writes the current index buffer to the specified output file. @@ -778,7 +775,7 @@ proc renderSmiley(d: PDoc, n: PRstNode, result: var string) = dispA(d.target, result, """""", - "\\includegraphics{$1}", [d.smileyFrmt % n.text]) + "\\includegraphics{$1}", [d.config["doc.smiley_format"] % n.text]) proc parseCodeBlockField(d: PDoc, n: PRstNode, params: var CodeBlockParams) = ## Parses useful fields which can appear before a code block. @@ -1204,6 +1201,7 @@ $content """) setConfigVar("doc.body_no_toc", "$moduledesc $content") setConfigVar("doc.file", "$content") + setConfigVar("doc.smiley_format", "/images/smilies/$1.gif") # ---------- forum --------------------------------------------------------- From cd0f17202ee167c0ec0db2bb497d1c4554655abd Mon Sep 17 00:00:00 2001 From: juxiliary Date: Sat, 6 Dec 2014 21:57:20 +1000 Subject: [PATCH 4/4] Fixing extraneous semicolon in jsgen output jsgen was producing javascript objects like this ``` {, name:"foo"} ``` causing syntax errors in javascript interpretors. --- compiler/jsgen.nim | 2 +- tests/js/testobjs.nim | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/js/testobjs.nim diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 108c0fe107..2ae85d5cff 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -1431,7 +1431,7 @@ proc genObjConstr(p: PProc, n: PNode, r: var TCompRes) = r.res = toRope("{") r.kind = resExpr for i in countup(1, sonsLen(n) - 1): - if i > 0: app(r.res, ", ") + if i > 1: app(r.res, ", ") var it = n.sons[i] internalAssert it.kind == nkExprColonExpr gen(p, it.sons[1], a) diff --git a/tests/js/testobjs.nim b/tests/js/testobjs.nim new file mode 100644 index 0000000000..4fb9a83dc4 --- /dev/null +++ b/tests/js/testobjs.nim @@ -0,0 +1,34 @@ +## Tests javascript object generation + +type + Kg = distinct float + Price = int + Item = object of RootObj + weight: Kg + price: Price + desc: cstring + Person = object of RootObj + name: cstring + age: int + item: Item + Test = object + name: cstring + Recurse[T] = object + data: T + next: ref Recurse[T] + +var + test = Test(name: "Jorden") + sword = Item(desc: "pointy", weight: Kg(10.0), + price: Price(50)) + knight = Person(name: "robert", age: 19, item: sword) + recurse4 = (ref Recurse[int])(data: 4, next: nil) + recurse3 = (ref Recurse[int])(data: 3, next: recurse4) + recurse2 = (ref Recurse[int])(data: 2, next: recurse3) + recurse1 = Recurse[int](data: 1, next: recurse2) + + +assert(test.name == "Jorden") +assert(knight.age == 19) +assert(knight.item.price == 50) +assert(recurse1.next.next.data == 3)