script folder

This commit is contained in:
2025-11-26 20:25:00 -06:00
parent e28e241485
commit b577e889a1
23 changed files with 29 additions and 120 deletions

View File

@@ -7,71 +7,6 @@
#include <stdlib.h>
#include <string.h>
// External function declarations
JSValue js_actor_delay(JSContext *js, JSValue self, int argc, JSValue *argv);
JSValue js_actor_removetimer(JSContext *js, JSValue self, int argc, JSValue *argv);
cell_rt *js2actor(JSContext *js, JSValue v)
{
if (!JS_IsObject(v))
return NULL;
cell_rt *crt = JS_GetContextOpaque(js);
JSValue actor_data = JS_GetProperty(js, v, crt->actor_sym);
if (JS_IsNull(actor_data)) {
JS_FreeValue(js, actor_data);
return NULL;
}
JSValue id_val = JS_GetPropertyStr(js, actor_data, "id");
JS_FreeValue(js, actor_data);
if (JS_IsNull(id_val)) {
JS_FreeValue(js, id_val);
return NULL;
}
const char *id = JS_ToCString(js, id_val);
JS_FreeValue(js, id_val);
if (!id)
return NULL;
cell_rt *actor = get_actor((char*)id);
JS_FreeCString(js, id);
return actor;
}
JSValue actor2js(JSContext *js, cell_rt *actor)
{
if (!actor)
return JS_NULL;
JSValue actor_obj = JS_NewObject(js);
if (JS_IsException(actor_obj))
return actor_obj;
JSValue actor_data = JS_NewObject(js);
if (JS_IsException(actor_data)) {
JS_FreeValue(js, actor_obj);
return actor_data;
}
JS_SetPropertyStr(js, actor_data, "id", JS_NewString(js, actor->id));
/* TODO: If the actor has network info, we could add address and port here */
/* JS_SetPropertyStr(js, actor_data, "address", JS_NewString(js, actor->address)); */
/* JS_SetPropertyStr(js, actor_data, "port", JS_NewInt32(js, actor->port)); */
cell_rt *crt = JS_GetContextOpaque(js);
JS_SetProperty(js, actor_obj, crt->actor_sym, actor_data);
return actor_obj;
}
JSC_CCALL(os_createactor,
cell_rt *rt = JS_GetContextOpaque(js);
if (rt->disrupt)