Fix crash when passing nil seq to godot

Up version to 0.5.10
This commit is contained in:
Evgeny Zuev 2017-09-19 17:47:28 +07:00 • committed by Ruslan Mustakov
commit cf75723fa1
2 changed files with 11 additions and 3 deletions

View file

@ -1,4 +1,4 @@
version = "0.5.9"
version = "0.5.10"
author = "Xored Software, Inc."
description = "Godot Engine bindings"
license = "MIT"

View file

@ -689,12 +689,20 @@ proc godotTypeInfo*(T: typedesc[seq]): GodotTypeInfo =
proc godotTypeInfo*(T: typedesc[array]): GodotTypeInfo =
arrTypeInfo(T)
proc toVariant*[T](s: openarray[T]): Variant =
template arrayToVariant(s: untyped): Variant =
var arr = newArray()
mixin toVariant
for item in s:
arr.add(toVariant(item))
result = newVariant(arr)
newVariant(arr)
proc toVariant*[T](s: seq[T]): Variant =
if s.isNil:
return newVariant()
result = arrayToVariant(s)
proc toVariant*[I, T](s: array[I, T]): Variant =
result = arrayToVariant(s)
proc fromVariant*[T](s: var seq[T], val: Variant): ConversionResult =
if val.getType() == VariantType.Nil: