Temporary solution for multilevel calls
This commit is contained in:
parent
692fbe892b
commit
a91fe1f713
1 changed files with 15 additions and 4 deletions
|
|
@ -191,7 +191,7 @@ proc parseType(definition, callSite: NimNode): ObjectDecl =
|
||||||
macro invokeVarArgs(procIdent, objIdent;
|
macro invokeVarArgs(procIdent, objIdent;
|
||||||
minArgs, maxArgs: static[int], numArgsIdent,
|
minArgs, maxArgs: static[int], numArgsIdent,
|
||||||
argSeqIdent; argTypes: seq[NimNode],
|
argSeqIdent; argTypes: seq[NimNode],
|
||||||
hasReturnValue: static[bool]): typed =
|
hasReturnValue, isStaticCall: static[bool]): typed =
|
||||||
## Produces statement in form:
|
## Produces statement in form:
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
|
|
@ -233,7 +233,7 @@ macro invokeVarArgs(procIdent, objIdent;
|
||||||
for i in minArgs..maxArgs:
|
for i in minArgs..maxArgs:
|
||||||
let branch = newNimNode(nnkOfBranch).add(newIntLitNode(i))
|
let branch = newNimNode(nnkOfBranch).add(newIntLitNode(i))
|
||||||
let branchBody = newStmtList()
|
let branchBody = newStmtList()
|
||||||
let invocation = newNimNode(nnkCall)
|
var invocation = newNimNode(nnkCall)
|
||||||
invocation.add(procIdent)
|
invocation.add(procIdent)
|
||||||
invocation.add(objIdent) # self
|
invocation.add(objIdent) # self
|
||||||
for idx in 0..<i:
|
for idx in 0..<i:
|
||||||
|
|
@ -243,6 +243,10 @@ macro invokeVarArgs(procIdent, objIdent;
|
||||||
branchBody.add(getAst(conv($procIdent, argT,
|
branchBody.add(getAst(conv($procIdent, argT,
|
||||||
argSeqIdent, idx, argIdent, errIdent)))
|
argSeqIdent, idx, argIdent, errIdent)))
|
||||||
invocation.add(argIdent)
|
invocation.add(argIdent)
|
||||||
|
|
||||||
|
if isStaticCall:
|
||||||
|
invocation = newNimNode(nnkCall).add(ident("procCall"), invocation)
|
||||||
|
|
||||||
if hasReturnValue:
|
if hasReturnValue:
|
||||||
let theCall = newNimNode(nnkBracketExpr).add(newNimNode(nnkDotExpr).add(
|
let theCall = newNimNode(nnkBracketExpr).add(newNimNode(nnkDotExpr).add(
|
||||||
newCall("toGodot", invocation), ident("godotVariant")))
|
newCall("toGodot", invocation), ident("godotVariant")))
|
||||||
|
|
@ -462,13 +466,20 @@ proc genType(obj: ObjectDecl): NimNode {.compileTime.} =
|
||||||
args: var array[MAX_ARG_COUNT, ptr GodotVariant]):
|
args: var array[MAX_ARG_COUNT, ptr GodotVariant]):
|
||||||
GodotVariant {.noconv.} =
|
GodotVariant {.noconv.} =
|
||||||
let self = cast[classNameIdent](userData)
|
let self = cast[classNameIdent](userData)
|
||||||
|
const isStaticCall = methodNameLit == cstring"_ready" or
|
||||||
|
methodNameLit == cstring"_init" or
|
||||||
|
methodNameLit == cstring"_enter_tree" or
|
||||||
|
methodNameLit == cstring"_exit_tree" or
|
||||||
|
methodNameLit == cstring"_enter_world" or
|
||||||
|
methodNameLit == cstring"_exit_world" or
|
||||||
|
methodNameLit == cstring"_draw"
|
||||||
when defined(release):
|
when defined(release):
|
||||||
invokeVarArgs(methodNameIdent, self, minArgs, maxArgs, numArgs,
|
invokeVarArgs(methodNameIdent, self, minArgs, maxArgs, numArgs,
|
||||||
args, argTypes, hasReturnValue)
|
args, argTypes, hasReturnValue, isStaticCall)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
invokeVarArgs(methodNameIdent, self, minArgs, maxArgs, numArgs,
|
invokeVarArgs(methodNameIdent, self, minArgs, maxArgs, numArgs,
|
||||||
args, argTypes, hasReturnValue)
|
args, argTypes, hasReturnValue, isStaticCall)
|
||||||
except:
|
except:
|
||||||
let ex = getCurrentException()
|
let ex = getCurrentException()
|
||||||
printError("Unhandled Nim exception (" & $ex.name & "): " &
|
printError("Unhandled Nim exception (" & $ex.name & "): " &
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue