Convert nil strings to empty GodotString
This commit is contained in:
parent
3e2d0708e2
commit
4a5e0fe95f
1 changed files with 8 additions and 2 deletions
|
|
@ -55,8 +55,14 @@ proc `$`*(self: GodotString): string =
|
||||||
|
|
||||||
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:
|
||||||
|
initGodotString(result)
|
||||||
|
else:
|
||||||
initGodotString(result, unsafeAddr s[0], cint(s.len + 1))
|
initGodotString(result, unsafeAddr s[0], 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``
|
||||||
|
if s.isNil:
|
||||||
|
initGodotString(result)
|
||||||
|
else:
|
||||||
initGodotString(result, s, cint(s.len + 1))
|
initGodotString(result, s, cint(s.len + 1))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue