Fix for latest Nim

Closes #23.
This commit is contained in:
Ruslan Mustakov 2018-06-04 11:47:17 +07:00
commit 66c939b9e6
2 changed files with 3 additions and 4 deletions

View file

@ -29,14 +29,13 @@ proc `$`*(self: GodotString): string =
result = newString(length) result = newString(length)
copyMem(addr result[0], getGDNativeAPI().charStringGetData(charStr), length) copyMem(addr result[0], getGDNativeAPI().charStringGetData(charStr), length)
getGDNativeAPI().charStringDestroy(charStr) getGDNativeAPI().charStringDestroy(charStr)
assert(result[length] == '\0')
proc toGodotString*(s: string): GodotString {.inline.} = proc toGodotString*(s: string): GodotString {.inline.} =
## Converts the Nim string into ``GodotString`` ## Converts the Nim string into ``GodotString``
if s.isNil: if s.isNil:
initGodotString(result) initGodotString(result)
else: else:
initGodotString(result, unsafeAddr s[0], cint(s.len + 1)) initGodotString(result, cstring(s), cint(s.len + 1))
proc toGodotString*(s: cstring): GodotString {.inline.} = proc toGodotString*(s: cstring): GodotString {.inline.} =
## Converts the cstring into ``GodotString`` ## Converts the cstring into ``GodotString``

View file

@ -297,8 +297,8 @@ macro toGodotName(T: typedesc): string =
godotName = "float" godotName = "float"
elif T is SomeUnsignedInt or T is SomeSignedInt: elif T is SomeUnsignedInt or T is SomeSignedInt:
godotName = "int" godotName = "int"
if godotName.isNil: if godotName.isNil or godotName.len == 0:
let nameStr: string = (($T.getType()[1][1].symbol).split(':')[0]) let nameStr = (($T.getType()[1][1].symbol).split(':')[0])
godotName = case nameStr: godotName = case nameStr:
of "File", "Directory", "Thread", "Mutex", "Semaphore": of "File", "Directory", "Thread", "Mutex", "Semaphore":
"_" & nameStr "_" & nameStr