Keyboard event-based input is working for keydown and keyup

This commit is contained in:
2022-11-05 17:54:45 +01:00
parent 0c145b4e5b
commit 2439c3d7b9
9 changed files with 266 additions and 54 deletions

View File

@@ -101,7 +101,7 @@ void freeEngineNode(EngineNode* node) {
node->freeMemory(node);
}
Literal callEngineNodeLiteral(EngineNode* node, Interpreter* interpreter, Literal key) {
Literal callEngineNodeLiteral(EngineNode* node, Interpreter* interpreter, Literal key, LiteralArray* args) {
Literal ret = TO_NULL_LITERAL;
//if this fn exists
@@ -116,6 +116,12 @@ Literal callEngineNodeLiteral(EngineNode* node, Interpreter* interpreter, Litera
pushLiteralArray(&arguments, n);
if (args) {
for (int i = 0; i < args->count; i++) {
pushLiteralArray(&arguments, args->literals[i]);
}
}
callLiteralFn(interpreter, fn, &arguments, &returns);
ret = popLiteralArray(&returns);
@@ -130,18 +136,18 @@ Literal callEngineNodeLiteral(EngineNode* node, Interpreter* interpreter, Litera
return ret;
}
Literal callEngineNode(EngineNode* node, Interpreter* interpreter, char* fnName) {
Literal callEngineNode(EngineNode* node, Interpreter* interpreter, char* fnName, LiteralArray* args) {
//call "fnName" on this node, and all children, if it exists
Literal key = TO_IDENTIFIER_LITERAL(copyString(fnName, strlen(fnName)), strlen(fnName));
Literal ret = callEngineNodeLiteral(node, interpreter, key);
Literal ret = callEngineNodeLiteral(node, interpreter, key, args);
freeLiteral(key);
return ret;
}
void callRecursiveEngineNodeLiteral(EngineNode* node, Interpreter* interpreter, Literal key) {
void callRecursiveEngineNodeLiteral(EngineNode* node, Interpreter* interpreter, Literal key, LiteralArray* args) {
//if this fn exists
if (existsLiteralDictionary(node->functions, key)) {
Literal fn = getLiteralDictionary(node->functions, key);
@@ -152,6 +158,13 @@ void callRecursiveEngineNodeLiteral(EngineNode* node, Interpreter* interpreter,
initLiteralArray(&arguments);
initLiteralArray(&returns);
//feed the arguments in backwards!
if (args) {
for (int i = args->count -1; i >= 0; i--) {
pushLiteralArray(&arguments, args->literals[i]);
}
}
pushLiteralArray(&arguments, n);
callLiteralFn(interpreter, fn, &arguments, &returns);
@@ -166,16 +179,16 @@ void callRecursiveEngineNodeLiteral(EngineNode* node, Interpreter* interpreter,
//recurse to the (non-tombstone) children
for (int i = 0; i < node->count; i++) {
if (node->children[i] != NULL) {
callRecursiveEngineNodeLiteral(node->children[i], interpreter, key);
callRecursiveEngineNodeLiteral(node->children[i], interpreter, key, args);
}
}
}
void callRecursiveEngineNode(EngineNode* node, Interpreter* interpreter, char* fnName) {
void callRecursiveEngineNode(EngineNode* node, Interpreter* interpreter, char* fnName, LiteralArray* args) {
//call "fnName" on this node, and all children, if it exists
Literal key = TO_IDENTIFIER_LITERAL(copyString(fnName, strlen(fnName)), strlen(fnName));
callRecursiveEngineNodeLiteral(node, interpreter, key);
callRecursiveEngineNodeLiteral(node, interpreter, key, args);
freeLiteral(key);
}