Finalize support for Nim 0.20

Closes #32, closes #41.
This commit is contained in:
Ruslan Mustakov 2019-09-15 15:39:10 +07:00
commit 19b0c23d62
8 changed files with 91 additions and 131 deletions

View file

@ -0,0 +1,19 @@
# Copyright 2019 Xored Software, Inc.
when (NimMajor, NimMinor, NimPatch) < (0, 19, 0):
import macros, sets
proc strVal(n: NimNode): string {.used.} =
case n.kind
of nnkIdent:
$n.ident
of nnkSym:
$n.symbol
else:
macros.strVal(n)
proc toHashSet[A](keys: openArray[A]): HashSet[A] {.inline, used.} =
toSet(keys)
proc initHashSet[A](): HashSet[A] {.inline, used.} =
initSet[A]()

View file

@ -38,7 +38,13 @@ proc `$`*(self: GodotString): string =
proc toGodotString*(s: string): GodotString {.inline.} =
## Converts the Nim string into ``GodotString``
initGodotString(result, cstring(s), cint(s.len + 1))
when (NimMajor, NimMinor, NimPatch) < (0, 19, 0):
if s.isNil:
initGodotString(result)
else:
initGodotString(result, cstring(s), cint(s.len + 1))
else:
initGodotString(result, cstring(s), cint(s.len + 1))
proc toGodotString*(s: cstring): GodotString {.inline.} =
## Converts the cstring into ``GodotString``