bugfixes and a temporary optimization

indirect is way too aggressive. It needs to be reworked
This commit is contained in:
2026-03-15 22:32:35 +01:00
parent dd97929a04
commit 9c1062c076
5 changed files with 66 additions and 2 deletions

View File

@@ -269,6 +269,9 @@ local function writeEntry(entry, levelStack)
if opts.Q then io.write('"') end if opts.Q then io.write('"') end
if opts.color == "always" then if opts.color == "always" then
if not entry.extension then
print("entry:", entry)
end
io.write("\27[" .. colorize(entry) .. "m") io.write("\27[" .. colorize(entry) .. "m")
end end

View File

@@ -5,6 +5,7 @@
local sysyieldobj = {} local sysyieldobj = {}
local coroutine = coroutine
local function sysyield() local function sysyield()
coroutine.yield(sysyieldobj) coroutine.yield(sysyieldobj)
@@ -26,6 +27,7 @@ end
function coroutine.wrap(f) function coroutine.wrap(f)
local co = coroutine.create(f) local co = coroutine.create(f)
return function(...) return function(...)
if coroutine.status(co) ~= "suspended" then return end
local t = {coroutine.resume(co, ...)} local t = {coroutine.resume(co, ...)}
if t[1] then if t[1] then
return table.unpack(t, 2) return table.unpack(t, 2)

View File

@@ -428,6 +428,10 @@ nn_Exit ne_screen_handler(nn_ScreenRequest *req) {
req->keyboard = NULL; req->keyboard = NULL;
return NN_OK; return NN_OK;
} }
if(req->h != 0) {
req->keyboard = NULL;
return NN_OK;
}
size_t keylen = strlen(buf->keyboard); size_t keylen = strlen(buf->keyboard);
if(keylen > req->w) keylen = req->w; if(keylen > req->w) keylen = req->w;
memcpy(req->keyboard, buf->keyboard, keylen); memcpy(req->keyboard, buf->keyboard, keylen);
@@ -1204,6 +1208,7 @@ int main(int argc, char **argv) {
tickClock = tickDelay; tickClock = tickDelay;
nn_clearstack(c); nn_clearstack(c);
if(getenv("NN_NOIDLE") != NULL) nn_resetIdleTime(c);
nn_Exit e = nn_tick(c); nn_Exit e = nn_tick(c);
if(e != NN_OK) { if(e != NN_OK) {
nn_setErrorFromExit(c, e); nn_setErrorFromExit(c, e);

View File

@@ -1127,7 +1127,11 @@ bool nn_isComputerIdle(nn_Computer *computer) {
} }
void nn_addIdleTime(nn_Computer *computer, double time) { void nn_addIdleTime(nn_Computer *computer, double time) {
computer->idleTimestamp += time; //computer->idleTimestamp += time;
}
void nn_resetIdleTime(nn_Computer *computer) {
computer->idleTimestamp = -1;
} }
nn_Exit nn_tick(nn_Computer *computer) { nn_Exit nn_tick(nn_Computer *computer) {
@@ -1430,7 +1434,7 @@ nn_Exit nn_call(nn_Computer *computer, const char *address, const char *method)
nn_Method m = c.cstate->methods[j]; nn_Method m = c.cstate->methods[j];
if(nn_strcmp(m.name, method) != 0) continue; if(nn_strcmp(m.name, method) != 0) continue;
// indirect calls consume the entire call budget // indirect calls consume the entire call budget
if((m.flags & NN_DIRECT) == NN_INDIRECT) computer->callBudget = 0; //if((m.flags & NN_DIRECT) == NN_INDIRECT) computer->callBudget = 0;
} }
nn_ComponentRequest req; nn_ComponentRequest req;
@@ -3094,6 +3098,7 @@ static nn_Exit nn_screen_handler(nn_ComponentRequest *req) {
scrreq.instance = req->compUserdata; scrreq.instance = req->compUserdata;
const char *method = req->methodCalled; const char *method = req->methodCalled;
nn_Exit e;
switch(req->action) { switch(req->action) {
case NN_COMP_FREETYPE: case NN_COMP_FREETYPE:
@@ -3110,6 +3115,54 @@ static nn_Exit nn_screen_handler(nn_ComponentRequest *req) {
req->methodEnabled = true; req->methodEnabled = true;
return NN_OK; return NN_OK;
case NN_COMP_CALL: case NN_COMP_CALL:
if(nn_strcmp(method, "isOn") == 0) {
scrreq.action = NN_SCR_ISON;
e = state->handler(&scrreq);
if(e) return e;
req->returnCount = 1;
return nn_pushbool(C, scrreq.w != 0);
}
if(nn_strcmp(method, "isPrecise") == 0) {
scrreq.action = NN_SCR_ISPRECISE;
e = state->handler(&scrreq);
if(e) return e;
req->returnCount = 1;
return nn_pushbool(C, scrreq.w != 0);
}
if(nn_strcmp(method, "isTouchModeInverted") == 0) {
scrreq.action = NN_SCR_ISTOUCHINVERTED;
e = state->handler(&scrreq);
if(e) return e;
req->returnCount = 1;
return nn_pushbool(C, scrreq.w != 0);
}
if(nn_strcmp(method, "getAspectRatio") == 0) {
scrreq.action = NN_SCR_GETASPECTRATIO;
e = state->handler(&scrreq);
if(e) return e;
req->returnCount = 2;
e = nn_pushinteger(C, scrreq.w);
if(e) return e;
return nn_pushinteger(C, scrreq.h);
}
if(nn_strcmp(method, "getKeyboards") == 0) {
char buf[NN_MAX_ADDRESS];
size_t kbCount = 0;
while(true) {
scrreq.action = NN_SCR_GETKEYBOARD;
scrreq.keyboard = buf;
scrreq.w = sizeof(buf);
scrreq.h = kbCount;
e = state->handler(&scrreq);
if(e) return e;
if(scrreq.keyboard == NULL) break;
e = nn_pushlstring(C, buf, scrreq.w);
if(e) return e;
kbCount++;
}
req->returnCount = 1;
return nn_pusharraytable(C, kbCount);
}
nn_setError(C, "method not implemented yet"); nn_setError(C, "method not implemented yet");
return NN_EBADCALL; return NN_EBADCALL;
} }

View File

@@ -467,6 +467,7 @@ nn_ComputerState nn_getComputerState(nn_Computer *computer);
bool nn_isComputerIdle(nn_Computer *computer); bool nn_isComputerIdle(nn_Computer *computer);
// Shifts over the idle timestamp. // Shifts over the idle timestamp.
void nn_addIdleTime(nn_Computer *computer, double time); void nn_addIdleTime(nn_Computer *computer, double time);
void nn_resetIdleTime(nn_Computer *computer);
// runs a tick of the computer. Make sure to check the state as well! // runs a tick of the computer. Make sure to check the state as well!
// This automatically resets the component budgets and call budget. // This automatically resets the component budgets and call budget.
// It also sets the idle timestamp to the current uptime. // It also sets the idle timestamp to the current uptime.