From de89df71ade1a980741695003c8c57a808c53f18 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Thu, 27 Jul 2017 00:06:45 +0700 Subject: [PATCH] Fix varargs calls --- examples/simple/src/simple.nimble | 2 +- godot.nimble | 2 +- godot/apigen/apigen.nim | 7 ++++--- godot/core/godotcore.nim | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/simple/src/simple.nimble b/examples/simple/src/simple.nimble index 43a4780..f33fa69 100644 --- a/examples/simple/src/simple.nimble +++ b/examples/simple/src/simple.nimble @@ -4,7 +4,7 @@ description = "FPS Counter Sample" license = "MIT" bin = @["simple"] -requires "https://github.com/pragmagic/godot-nim.git >= 0.2.2 & < 0.3.0" +requires "https://github.com/pragmagic/godot-nim.git >= 0.2.3 & < 0.3.0" task make, "build": const archPostfix = when sizeof(int) == 8: "_64" else: "_32" diff --git a/godot.nimble b/godot.nimble index 712aadf..eecbb2f 100644 --- a/godot.nimble +++ b/godot.nimble @@ -1,4 +1,4 @@ -version = "0.2.2" +version = "0.2.3" author = "Xored Software, Inc." description = "Godot Engine bindings" license = "MIT" diff --git a/godot/apigen/apigen.nim b/godot/apigen/apigen.nim index 8238029..85f00a1 100644 --- a/godot/apigen/apigen.nim +++ b/godot/apigen/apigen.nim @@ -416,7 +416,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], raise newException(ValueError, "Non-standard type $# for varargs params of method $# of type $#" % [arg.typ, godotMethodName, typ.godotName]) - if not isStandardType: + if not isStandardType and varargsName.isNil: if arg.typ == "string": argConversions.add(newNode(nkLetSection).addChain( newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), @@ -441,8 +441,9 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string], argConversions.add(argLoop) argLoop.add(newInfix(ident("idx"), ident("<"), argLenNode) ) - argLoop.add(argAsgn) - argLoop.add(newCommand(ident("inc"), ident("idx"))) + argLoop.add(newNode(nkStmtList).addChain( + argAsgn, + newCommand(ident("inc"), ident("idx")))) let retName = if isVarargs: "callRet" else: "ptrCallRet" let theCall = newCall( diff --git a/godot/core/godotcore.nim b/godot/core/godotcore.nim index f0a0884..f0b51ff 100644 --- a/godot/core/godotcore.nim +++ b/godot/core/godotcore.nim @@ -24,7 +24,7 @@ proc ptrCall*(methodBind: ptr GodotMethodBind; importc: "godot_method_bind_ptrcall", header: "godot/gdnative.h".} proc call*(methodBind: ptr GodotMethodBind; instance: ptr GodotObject; - args: ptr array[MAX_ARG_COUNT, Variant]; argCount: cint; + args: var ptr array[MAX_ARG_COUNT, Variant]; argCount: cint; callError: var VariantCallError): Variant {. importc: "godot_method_bind_call", header: "godot/gdnative.h".}