Commit e95712ca1830ecec1fff3315b049ed587905c17e
1 parent
01dbfa89
bugfixes and cleanups
Showing
2 changed files
with
6 additions
and
4 deletions
src/squeaknim.nim
... | ... | @@ -38,6 +38,7 @@ template writeSmallTalkCode*(filename: string) = |
38 | 38 | writeFile(filename, stCode) |
39 | 39 | |
40 | 40 | proc mapTypeToC(symbolicType: NimNode): string {.compileTime.} = |
41 | + if symbolicType.kind == nnkEmpty: return "void" | |
41 | 42 | let t = symbolicType.getType |
42 | 43 | if symbolicType.kind == nnkSym and t.typeKind == ntyObject: |
43 | 44 | return gPrefix & $symbolicType |
... | ... | @@ -46,6 +47,7 @@ proc mapTypeToC(symbolicType: NimNode): string {.compileTime.} = |
46 | 47 | expectKind t, nnkBracketExpr |
47 | 48 | result = mapTypeToC(t[1]) & "*" |
48 | 49 | of ntyCString: result = "char*" |
50 | + of ntyPointer: result = "void*" | |
49 | 51 | of ntyInt: result = intType |
50 | 52 | of ntyInt8: result = "sbyte" |
51 | 53 | of ntyInt16: result = "short" |
... | ... | @@ -61,7 +63,7 @@ proc mapTypeToC(symbolicType: NimNode): string {.compileTime.} = |
61 | 63 | of ntyBool, ntyChar, ntyEnum: result = "char" |
62 | 64 | else: quit "Error: cannot wrap to Squeak " & treeRepr(t) |
63 | 65 | |
64 | -macro exportSt*(className: string; body: stmt): stmt = | |
66 | +macro exportSt*(body: stmt): stmt = | |
65 | 67 | # generates something like: |
66 | 68 | |
67 | 69 | # system: aString | ... | ... |
tests/Test1.nim
... | ... | @@ -3,7 +3,7 @@ import squeaknim |
3 | 3 | |
4 | 4 | # Just compile with "nim c Test1.nim", copy resulting lib and Test1.st |
5 | 5 | # to a Squeak directory, file in Test1.st and then it should be fine |
6 | -# to call foo, see class side of Test1 | |
6 | +# to call foo, see class side of Test1 | |
7 | 7 | |
8 | 8 | type |
9 | 9 | MyFloat = float32 |
... | ... | @@ -18,13 +18,13 @@ setModulename "Test1", "UR" |
18 | 18 | # Generate the Smalltalk class URVector3 representing Vector3 |
19 | 19 | wrapObject(Vector3) |
20 | 20 | |
21 | -# Generate declarations for Smalltalk code | |
21 | +# Generate declarations for Smalltalk code | |
22 | 22 | writeExternalLibrary() |
23 | 23 | |
24 | 24 | # Here follows Nim procedures that will be callable via FFI |
25 | 25 | # Note that exportSt pragma to export. |
26 | 26 | |
27 | -proc foo*(a, b: Vector3, c: int): cstring {.exportSt: "bar".} = | |
27 | +proc foo*(a, b: Vector3, c: int): cstring {.exportSt.} = | |
28 | 28 | # Just a silly test proc |
29 | 29 | result = "x plus y plus c " & $(a.x + b.y + c.float) |
30 | 30 | ... | ... |