Added scene reloading & switching

This commit is contained in:
2023-03-03 16:05:48 +11:00
parent 4965cd492d
commit f9d0a27408
7 changed files with 92 additions and 59 deletions

View File

@@ -71,13 +71,15 @@ static int nativeLoadNode(Toy_Interpreter* interpreter, Toy_LiteralArray* argume
Box_initEngineNode(node, &inner, tb, size);
//immediately call onLoad() after running the script - for loading other nodes
Box_callEngineNode(node, &engine.interpreter, "onLoad", NULL);
Box_callEngineNode(node, &inner, "onLoad", NULL);
// return the node
Toy_Literal nodeLiteral = TOY_TO_OPAQUE_LITERAL(node, node->tag);
Toy_pushLiteralArray(&interpreter->stack, nodeLiteral);
//cleanup (NOT the scope - that needs to hang around)
node->scope = inner.scope;
Toy_freeLiteralArray(&inner.stack);
Toy_freeLiteralArray(&inner.literalCache);
Toy_freeLiteral(filePathLiteral);
@@ -246,6 +248,8 @@ static int nativeFreeChildNode(Toy_Interpreter* interpreter, Toy_LiteralArray* a
return -1;
}
//TODO: differentiate between onFree() and freeing memory
Box_callRecursiveEngineNode(node, interpreter, "onFree", NULL);
Box_freeChildEngineNode(node, idx);
//cleanup