From e95712ca1830ecec1fff3315b049ed587905c17e Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 4 Mar 2015 02:46:00 +0100 Subject: [PATCH] bugfixes and cleanups --- src/squeaknim.nim | 4 +++- tests/Test1.nim | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/squeaknim.nim b/src/squeaknim.nim index d8fa6f6..f96b9b5 100644 --- a/src/squeaknim.nim +++ b/src/squeaknim.nim @@ -38,6 +38,7 @@ template writeSmallTalkCode*(filename: string) = writeFile(filename, stCode) proc mapTypeToC(symbolicType: NimNode): string {.compileTime.} = + if symbolicType.kind == nnkEmpty: return "void" let t = symbolicType.getType if symbolicType.kind == nnkSym and t.typeKind == ntyObject: return gPrefix & $symbolicType @@ -46,6 +47,7 @@ proc mapTypeToC(symbolicType: NimNode): string {.compileTime.} = expectKind t, nnkBracketExpr result = mapTypeToC(t[1]) & "*" of ntyCString: result = "char*" + of ntyPointer: result = "void*" of ntyInt: result = intType of ntyInt8: result = "sbyte" of ntyInt16: result = "short" @@ -61,7 +63,7 @@ proc mapTypeToC(symbolicType: NimNode): string {.compileTime.} = of ntyBool, ntyChar, ntyEnum: result = "char" else: quit "Error: cannot wrap to Squeak " & treeRepr(t) -macro exportSt*(className: string; body: stmt): stmt = +macro exportSt*(body: stmt): stmt = # generates something like: # system: aString diff --git a/tests/Test1.nim b/tests/Test1.nim index aa04380..71e7a71 100644 --- a/tests/Test1.nim +++ b/tests/Test1.nim @@ -3,7 +3,7 @@ import squeaknim # Just compile with "nim c Test1.nim", copy resulting lib and Test1.st # to a Squeak directory, file in Test1.st and then it should be fine -# to call foo, see class side of Test1 +# to call foo, see class side of Test1 type MyFloat = float32 @@ -18,13 +18,13 @@ setModulename "Test1", "UR" # Generate the Smalltalk class URVector3 representing Vector3 wrapObject(Vector3) -# Generate declarations for Smalltalk code +# Generate declarations for Smalltalk code writeExternalLibrary() # Here follows Nim procedures that will be callable via FFI # Note that exportSt pragma to export. -proc foo*(a, b: Vector3, c: int): cstring {.exportSt: "bar".} = +proc foo*(a, b: Vector3, c: int): cstring {.exportSt.} = # Just a silly test proc result = "x plus y plus c " & $(a.x + b.y + c.float) -- libgit2 0.22.2