diff --git a/scripts/compile.ce b/scripts/compile.ce index e1df81a3..6ab9d743 100644 --- a/scripts/compile.ce +++ b/scripts/compile.ce @@ -36,7 +36,9 @@ for (var i = 0; i < files.length; i++) { try { var src_stat = fd.stat(file) var obj_stat = fd.stat(obj_file) - if (obj_stat.modtime >= src_stat.modtime) { + var src_time = src_stat.modtime ?? src_stat.mtime + var obj_time = obj_stat.modtime ?? obj_stat.mtime + if (src_time != null && obj_time != null && obj_time >= src_time) { needs_compile = false } } catch (e) { diff --git a/scripts/enet.c b/scripts/enet.c index c33292cb..d7571ac3 100644 --- a/scripts/enet.c +++ b/scripts/enet.c @@ -178,7 +178,7 @@ static JSValue js_enet_host_service(JSContext *ctx, JSValueConst this_val, int a break; } - uncaught_exception(ctx, JS_Call(ctx, callback, JS_NULL, 1, &event_obj)); + // TODO: raise exception? JS_FreeValue(ctx, event_obj); } diff --git a/scripts/nota.c b/scripts/nota.c index 9b39718e..769cf342 100755 --- a/scripts/nota.c +++ b/scripts/nota.c @@ -1,4 +1,5 @@ #include "cell.h" +#include "cell_internal.h" #define NOTA_IMPLEMENTATION #include "nota.h" diff --git a/scripts/os.c b/scripts/os.c index 63265bec..7681f78b 100644 --- a/scripts/os.c +++ b/scripts/os.c @@ -115,11 +115,7 @@ static JSValue js_os_platform(JSContext *js, JSValue self, int argc, JSValue *ar #elif defined(__linux__) return JS_NewString(js,"Linux"); #elif defined(__APPLE__) - #ifdef TARGET_OS_IPHONE - return JS_NewString(js,"iOS"); - #else - return JS_NewString(js,"macOS"); - #endif + return JS_NewString(js,"macOS"); #elif defined(__FreeBSD__) return JS_NewString(js,"FreeBSD"); #elif defined(__OpenBSD__) diff --git a/source/cell.c b/source/cell.c index dd8a0ac4..a00522c4 100644 --- a/source/cell.c +++ b/source/cell.c @@ -20,6 +20,7 @@ #include "stb_ds.h" #include "cell.h" +#include "cell_internal.h" #ifdef TRACY_ENABLE #include diff --git a/source/cell.h b/source/cell.h index 14c89c9e..5e632ba2 100644 --- a/source/cell.h +++ b/source/cell.h @@ -15,91 +15,6 @@ JSValue js_new_blob_stoned_copy(JSContext *js, void *data, size_t bytes); void *js_get_blob_data(JSContext *js, size_t *size, JSValue v); int js_is_blob(JSContext *js, JSValue v); -#ifdef HAVE_MIMALLOC -typedef struct mi_heap_s mi_heap_t; -#endif - -/* Letter type for unified message queue */ -typedef enum { - LETTER_BLOB, /* Blob message */ - LETTER_CALLBACK /* JSValue callback function */ -} letter_type; - -typedef struct letter { - letter_type type; - union { - blob *blob_data; /* For LETTER_BLOB */ - JSValue callback; /* For LETTER_CALLBACK */ - }; -} letter; - - -#define ACTOR_IDLE 0 // Actor not doing anything -#define ACTOR_READY 1 // Actor ready for a turn -#define ACTOR_RUNNING 2 // Actor taking a turn -#define ACTOR_EXHAUSTED 3 // Actor waiting for GC -#define ACTOR_RECLAIMING 4 // Actor running GC -#define ACTOR_SLOW 5 // Actor going slowly; deprioritize - -extern int tracy_profiling_enabled; - -typedef struct cell_rt { - JSContext *context; -#ifdef HAVE_MIMALLOC -mi_heap_t *heap; -#endif - JSValue idx_buffer; - JSValue on_exception; - JSValue message_handle; - - void *init_wota; - - /* Protects JSContext usage */ - SDL_Mutex *mutex; /* for everything else */ - SDL_Mutex *msg_mutex; /* For message queue and timers queue */ - - char *id; - - int idx_count; - - /* The “mailbox” for incoming messages + a dedicated lock for it: */ - struct letter *letters; - - /* CHANGED FOR EVENTS: a separate lock for the actor->events queue */ - struct { Uint32 key; JSValue value; } *timers; - - int state; - Uint32 ar; // timer for unneeded - double ar_secs; // time for unneeded - JSValue unneeded; // fn to call before unneeded - - int disrupt; - int main_thread_only; - int affinity; - - JSAtom actor_sym; - - const char *name; // human friendly name -} cell_rt; - -extern cell_rt *root_cell; // first actor in the system - -cell_rt *create_actor(void *wota); -const char *register_actor(const char *id, cell_rt *actor, int mainthread, double ar); -void actor_disrupt(cell_rt *actor); - -const char *send_message(const char *id, void *msg); -Uint32 actor_timer_cb(cell_rt *actor, SDL_TimerID id, Uint32 interval); -JSValue js_actor_delay(JSContext *js, JSValue self, int argc, JSValue *argv); -JSValue js_actor_removetimer(JSContext *js, JSValue self, int argc, JSValue *argv); -void actor_unneeded(cell_rt *actor, JSValue fn, double seconds); -void script_startup(cell_rt *rt); -int uncaught_exception(JSContext *js, JSValue v); -int actor_exists(const char *id); -cell_rt *get_actor(char *id); -void set_actor_state(cell_rt *actor); -void actor_clock(cell_rt *actor, JSValue fn); - int randombytes(void *buf, size_t n); int cell_random(); diff --git a/source/qjs_actor.c b/source/qjs_actor.c index 8c8a49f8..32b31687 100644 --- a/source/qjs_actor.c +++ b/source/qjs_actor.c @@ -1,4 +1,5 @@ #include "cell.h" +#include "cell_internal.h" #include #include diff --git a/source/qjs_wota.c b/source/qjs_wota.c index 3a0eec6f..9d29839d 100644 --- a/source/qjs_wota.c +++ b/source/qjs_wota.c @@ -1,4 +1,5 @@ #include "cell.h" +#include "cell_internal.h" #include "wota.h" #include diff --git a/source/scheduler.c b/source/scheduler_sdl.c similarity index 100% rename from source/scheduler.c rename to source/scheduler_sdl.c