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

@@ -178,7 +178,6 @@ if host_machine.system() != 'emscripten'
else
deps += enet_dep
endif
src += 'qjs_enet.c'
mimalloc_enabled = get_option('mimalloc')
if mimalloc_enabled
@@ -221,44 +220,48 @@ link_args = link
sources = []
src += [ # core
'qjs_blob.c',
'qjs_nota.c',
'monocypher.c',
'qjs_crypto.c',
'qjs_time.c',
'qjs_js.c',
'qjs_miniz.c',
'timer.c',
'qjs_kim.c',
'qjs_utf8.c',
'qjs_fit.c',
'qjs_text.c',
'jsffi.c',
'cell.c',
'wildmatch.c',
'qjs_wildstar.c',
'qjs_qop.c',
'qjs_actor.c',
'qjs_wota.c',
]
src += [ # optional core
'qjs_debug.c',
]
src += [ # os specific
'qjs_os.c',
'qjs_fd.c',
'qjs_socket.c',
]
src += 'qjs_http.c'
src += [ # engine
'qjs_soloud.c',
]
src += ['quickjs.c', 'libregexp.c', 'libunicode.c', 'cutils.c', 'dtoa.c']
scripts = [
'nota.c',
'js.c',
'qop.c',
'wildstar.c',
'fit.c',
'crypto.c',
'text.c',
'utf8.c',
'kim.c',
'time.c',
'miniz.c',
'nota.c',
'debug.c',
'os.c',
'fd.c',
'socket.c',
'http.c',
'enet.c',
'wildstar.c',
]
foreach file: scripts
full_path = join_paths('scripts', file)
sources += files(full_path)
endforeach
srceng = 'source'
includes = [srceng]
@@ -324,10 +327,8 @@ cell = custom_target('cell',
# Install headers for building dynamic libraries using Cell
install_headers('source/cell.h', 'source/jsffi.h')
install_headers('source/blob.h')
install_headers('source/quickjs.h')
install_headers('source/qjs_macros.h')
install_headers('source/qjs_actor.h')
tests = [
'spawn_actor',

View File

@@ -1,4 +1,3 @@
#include "qjs_nota.h"
#include "cell.h"
#define NOTA_IMPLEMENTATION

View File

@@ -646,8 +646,6 @@ static JSValue js_array_addf(JSContext *ctx, JSValueConst this_val, int argc, JS
return JS_DupValue(ctx, this_val);
}
static const JSCFunctionListEntry js_matrix_proto_funcs[] = {
JS_CFUNC_DEF("inverse", 0, js_matrix_inverse),
JS_CFUNC_DEF("multiply", 1, js_matrix_multiply),

View File

@@ -9,13 +9,11 @@
#ifdef __cplusplus
extern "C" {
#endif
// blob fns
JSValue js_blob_use(JSContext *js);
// makes a new stone blob from data, copying the data over
JSValue js_new_blob_stoned_copy(JSContext *js, void *data, size_t bytes);
// returns undefined if the blob is not stone
void *js_get_blob_data(JSContext *js, size_t *size, JSValue v);
int js_is_blob(JSContext *js, JSValue v);
#ifdef HAVE_MIMALLOC

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)

View File

@@ -1,11 +0,0 @@
#ifndef QJS_ACTOR_H
#define QJS_ACTOR_H
#include "cell.h"
JSValue js_actor_use(JSContext *js);
cell_rt *js2actor(JSContext *js, JSValue v);
JSValue actor2js(JSContext *js, cell_rt *actor);
JSValue js_actor_set_symbol(JSContext *js, JSValue self, int argc, JSValue *argv);
#endif

View File

@@ -1,11 +0,0 @@
#ifndef QJS_NOTA_H
#define QJS_NOTA_H
#include "cell.h"
JSValue js_nota_use(JSContext*);
void *value2nota(JSContext*, JSValue);
JSValue nota2value(JSContext*, void*);
#endif