Fix varargs calls

This commit is contained in:
Ruslan Mustakov 2017-07-27 00:06:45 +07:00
commit de89df71ad
4 changed files with 7 additions and 6 deletions

View file

@ -4,7 +4,7 @@ description = "FPS Counter Sample"
license = "MIT" license = "MIT"
bin = @["simple"] 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": task make, "build":
const archPostfix = when sizeof(int) == 8: "_64" else: "_32" const archPostfix = when sizeof(int) == 8: "_64" else: "_32"

View file

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

View file

@ -416,7 +416,7 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string],
raise newException(ValueError, raise newException(ValueError,
"Non-standard type $# for varargs params of method $# of type $#" % "Non-standard type $# for varargs params of method $# of type $#" %
[arg.typ, godotMethodName, typ.godotName]) [arg.typ, godotMethodName, typ.godotName])
if not isStandardType: if not isStandardType and varargsName.isNil:
if arg.typ == "string": if arg.typ == "string":
argConversions.add(newNode(nkLetSection).addChain( argConversions.add(newNode(nkLetSection).addChain(
newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(), newIdentDefs(ident("argToPassToGodot" & $idx), newEmptyNode(),
@ -441,8 +441,9 @@ proc doGenerateMethod(tree: PNode, methodBindRegistry: var HashSet[string],
argConversions.add(argLoop) argConversions.add(argLoop)
argLoop.add(newInfix(ident("idx"), ident("<"), argLenNode) argLoop.add(newInfix(ident("idx"), ident("<"), argLenNode)
) )
argLoop.add(argAsgn) argLoop.add(newNode(nkStmtList).addChain(
argLoop.add(newCommand(ident("inc"), ident("idx"))) argAsgn,
newCommand(ident("inc"), ident("idx"))))
let retName = if isVarargs: "callRet" else: "ptrCallRet" let retName = if isVarargs: "callRet" else: "ptrCallRet"
let theCall = newCall( let theCall = newCall(

View file

@ -24,7 +24,7 @@ proc ptrCall*(methodBind: ptr GodotMethodBind;
importc: "godot_method_bind_ptrcall", header: "godot/gdnative.h".} importc: "godot_method_bind_ptrcall", header: "godot/gdnative.h".}
proc call*(methodBind: ptr GodotMethodBind; proc call*(methodBind: ptr GodotMethodBind;
instance: ptr GodotObject; 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 {. callError: var VariantCallError): Variant {.
importc: "godot_method_bind_call", header: "godot/gdnative.h".} importc: "godot_method_bind_call", header: "godot/gdnative.h".}