remove undefined; only use null now

This commit is contained in:
2025-06-17 14:32:27 -05:00
parent 3459d85a82
commit c9adbed3ff
85 changed files with 1132 additions and 1232 deletions

View File

@@ -378,7 +378,7 @@ void actor_unneeded(cell_rt *actor, JSValue fn, double seconds)
JS_FreeValue(actor->context, actor->unneeded);
if (!JS_IsFunction(actor->context, fn)) {
actor->unneeded = JS_UNDEFINED;
actor->unneeded = JS_NULL;
goto END;
}
@@ -398,10 +398,10 @@ cell_rt *create_actor(void *wota)
cell_rt *actor = calloc(sizeof(*actor), 1);
actor->heap = mi_heap_new();
actor->init_wota = wota;
actor->idx_buffer = JS_UNDEFINED;
actor->message_handle = JS_UNDEFINED;
actor->unneeded = JS_UNDEFINED;
actor->on_exception = JS_UNDEFINED;
actor->idx_buffer = JS_NULL;
actor->message_handle = JS_NULL;
actor->unneeded = JS_NULL;
actor->on_exception = JS_NULL;
actor->actor_sym = JS_ATOM_NULL;
arrsetcap(actor->letters, 5);
@@ -476,9 +476,9 @@ static Uint32 actor_remove_cb(cell_rt *actor, Uint32 id, Uint32 interval)
{
actor->disrupt = 1;
if (!JS_IsUndefined(actor->unneeded)) {
if (!JS_IsNull(actor->unneeded)) {
SDL_LockMutex(actor->mutex);
JSValue ret = JS_Call(actor->context, actor->unneeded, JS_UNDEFINED, 0, NULL);
JSValue ret = JS_Call(actor->context, actor->unneeded, JS_NULL, 0, NULL);
uncaught_exception(actor->context, ret);
SDL_UnlockMutex(actor->mutex);
}
@@ -574,11 +574,11 @@ void actor_turn(cell_rt *actor)
size_t size = l.blob_data->length / 8; // Convert bits to bytes
JSValue arg = js_new_blob_stoned_copy(actor->context, l.blob_data->data, size);
blob_destroy(l.blob_data);
result = JS_Call(actor->context, actor->message_handle, JS_UNDEFINED, 1, &arg);
result = JS_Call(actor->context, actor->message_handle, JS_NULL, 1, &arg);
uncaught_exception(actor->context, result);
JS_FreeValue(actor->context, arg);
} else if (l.type == LETTER_CALLBACK) {
result = JS_Call(actor->context, l.callback, JS_UNDEFINED, 0, NULL);
result = JS_Call(actor->context, l.callback, JS_NULL, 0, NULL);
uncaught_exception(actor->context, result);
JS_FreeValue(actor->context, l.callback);
}
@@ -627,7 +627,7 @@ JSValue js_actor_delay(JSContext *js, JSValue self, int argc, JSValue *argv)
JS_ToFloat64(js, &seconds, argv[1]);
if (seconds <= 0) {
actor_clock(actor, argv[0]);
return JS_UNDEFINED;
return JS_NULL;
}
SDL_LockMutex(actor->msg_mutex);
@@ -643,11 +643,11 @@ JSValue js_actor_removetimer(JSContext *js, JSValue self, int argc, JSValue *arg
cell_rt *actor = JS_GetContextOpaque(js);
uint32_t timer_id;
JS_ToUint32(js, &timer_id, argv[0]);
if (timer_id == -1) return JS_UNDEFINED;
if (timer_id == -1) return JS_NULL;
SDL_RemoveTimer(timer_id);
JSValue cb = JS_UNDEFINED;
JSValue cb = JS_NULL;
SDL_LockMutex(actor->msg_mutex);
int id = hmgeti(actor->timers, timer_id);
@@ -659,7 +659,7 @@ JSValue js_actor_removetimer(JSContext *js, JSValue self, int argc, JSValue *arg
JS_FreeValue(js,cb);
return JS_UNDEFINED;
return JS_NULL;
}
// Wrapper struct to keep the array pointer stable
@@ -788,7 +788,7 @@ int uncaught_exception(JSContext *js, JSValue v)
}
JSValue exp = JS_GetException(js);
JSValue ret = JS_Call(js, rt->on_exception, JS_UNDEFINED, 1, &exp);
JSValue ret = JS_Call(js, rt->on_exception, JS_NULL, 1, &exp);
JS_FreeValue(js,ret);
JS_FreeValue(js, exp);
JS_FreeValue(js,v);