Fix crash when passing nil seq to godot
Up version to 0.5.10
This commit is contained in:
parent
178192651f
commit
cf75723fa1
2 changed files with 11 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
version = "0.5.9"
|
version = "0.5.10"
|
||||||
author = "Xored Software, Inc."
|
author = "Xored Software, Inc."
|
||||||
description = "Godot Engine bindings"
|
description = "Godot Engine bindings"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
||||||
|
|
@ -689,12 +689,20 @@ proc godotTypeInfo*(T: typedesc[seq]): GodotTypeInfo =
|
||||||
proc godotTypeInfo*(T: typedesc[array]): GodotTypeInfo =
|
proc godotTypeInfo*(T: typedesc[array]): GodotTypeInfo =
|
||||||
arrTypeInfo(T)
|
arrTypeInfo(T)
|
||||||
|
|
||||||
proc toVariant*[T](s: openarray[T]): Variant =
|
template arrayToVariant(s: untyped): Variant =
|
||||||
var arr = newArray()
|
var arr = newArray()
|
||||||
mixin toVariant
|
mixin toVariant
|
||||||
for item in s:
|
for item in s:
|
||||||
arr.add(toVariant(item))
|
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 =
|
proc fromVariant*[T](s: var seq[T], val: Variant): ConversionResult =
|
||||||
if val.getType() == VariantType.Nil:
|
if val.getType() == VariantType.Nil:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue