From 0c145b4e5b01f2f1fffb93125fac71e580b1ffe2 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Fri, 4 Nov 2022 12:04:59 +0100 Subject: [PATCH] Renders rendering under renders --- Toy | 2 +- assets/scripts/init.toy | 2 +- assets/scripts/render.toy | 6 +++--- assets/scripts/root.toy | 8 +------- core/lib_node.c | 9 ++++++--- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Toy b/Toy index cceefa6..5d240f8 160000 --- a/Toy +++ b/Toy @@ -1 +1 @@ -Subproject commit cceefa63756b1b7ec41e482c7df1035f87b4643a +Subproject commit 5d240f85a6b37d57ada72dccc25174527a3b00ab diff --git a/assets/scripts/init.toy b/assets/scripts/init.toy index 7721b08..04239e8 100644 --- a/assets/scripts/init.toy +++ b/assets/scripts/init.toy @@ -1,5 +1,5 @@ import engine; -import input; +//import input; /* //input settings, mapping SDL2's virtual keys to event names diff --git a/assets/scripts/render.toy b/assets/scripts/render.toy index 0b59176..446bbff 100644 --- a/assets/scripts/render.toy +++ b/assets/scripts/render.toy @@ -6,12 +6,12 @@ var x: int = 50; var y: int = 50; //accessors -fn getX() { +fn getX(node: opaque) { print "Called getX"; return x; } -fn getY() { +fn getY(node: opaque) { return y; } @@ -37,7 +37,7 @@ fn onFree(node: opaque) { } fn onDraw(node: opaque) { - //print "render.toy:onDraw() called"; + print "render.toy:onDraw() called"; var px = parent.callNode("getX"); var py = parent.callNode("getY"); diff --git a/assets/scripts/root.toy b/assets/scripts/root.toy index 028a078..75b54fd 100644 --- a/assets/scripts/root.toy +++ b/assets/scripts/root.toy @@ -17,13 +17,7 @@ fn onInit(node: opaque) { // node.makeChild("assets/scripts/child.toy"); node.makeChild("assets/scripts/render.toy"); - print node; - print node.getNodeChild(0); - - var o = node.getNodeChild(0); - print o.callNode("getX"); - - print node.getNodeChild(0).callNode("getX"); + node.getNodeChild(0).makeChild("assets/scripts/render.toy"); } fn onStep(node: opaque) { diff --git a/core/lib_node.c b/core/lib_node.c index 978f6ec..02305f5 100644 --- a/core/lib_node.c +++ b/core/lib_node.c @@ -559,10 +559,13 @@ static int nativeCallNode(Interpreter* interpreter, LiteralArray* arguments) { return -1; } - //call the function - Literal result = callEngineNodeLiteral(AS_OPAQUE(nodeLiteral), interpreter, fnName); + char* strptr = AS_STRING(fnName); + Literal fnNameIdentifier = TO_IDENTIFIER_LITERAL(copyString(strptr, strlen(strptr)), strlen(strptr)); - // pushLiteralArray(&interpreter->stack, result); + //call the function + Literal result = callEngineNodeLiteral(AS_OPAQUE(nodeLiteral), interpreter, fnNameIdentifier); + + pushLiteralArray(&interpreter->stack, result); //cleanup freeLiteral(nodeLiteral);