attempt for jswota in js

This commit is contained in:
2025-06-08 00:49:19 -05:00
parent 34dcd0a235
commit 3176e6775d
15 changed files with 839 additions and 241 deletions

View File

@@ -78,13 +78,13 @@ JSC_CCALL(os_createactor,
if (rt->disrupt)
return JS_ThrowInternalError(js, "Can't start a new actor while disrupting.");
void *startup = value2wota(js, argv[0], JS_UNDEFINED);
void *startup = value2wota(js, argv[0], JS_UNDEFINED, NULL);
create_actor(startup);
)
JSC_CCALL(os_mailbox_push,
if (argc < 2) return JS_ThrowInternalError(js, "Need an actor and a message");
if (!JS_IsObject(argv[1])) return JS_ThrowInternalError(js, "Object to push must be an object.");
if (!js_is_blob(js, argv[1])) return JS_ThrowInternalError(js, "Can only send blobs.");
const char *id = JS_ToCString(js, argv[0]);
int exist = actor_exists(id);
@@ -97,7 +97,7 @@ JSC_CCALL(os_mailbox_push,
cell_rt *target = get_actor(id);
JS_FreeCString(js,id);
JSValue sys = JS_GetPropertyStr(js, argv[1], "__SYSTEM__");
/* JSValue sys = JS_GetPropertyStr(js, argv[1], "__SYSTEM__");
if (!JS_IsUndefined(sys)) {
const char *k = JS_ToCString(js,sys);
int stop = 0;
@@ -110,10 +110,15 @@ JSC_CCALL(os_mailbox_push,
if (stop) return JS_UNDEFINED;
}
void *data = value2wota(js, argv[1], JS_UNDEFINED);
*/
// void *data = value2wota(js, argv[1], JS_UNDEFINED, NULL);
size_t size;
void *data = js_get_blob_data(js, &size, argv[1]);
const char *err = send_message(id, data);
void *copy = malloc(size);
memcpy(copy, data, size);
const char *err = send_message(id, copy);
if (err) {
free(data);
return JS_ThrowInternalError(js, "Could not send message: %s", err);