diff --git a/meson.build b/meson.build index b43b4270..8a09b1f1 100644 --- a/meson.build +++ b/meson.build @@ -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', diff --git a/source/qjs_crypto.c b/scripts/crypto.c similarity index 100% rename from source/qjs_crypto.c rename to scripts/crypto.c diff --git a/source/qjs_debug.c b/scripts/debug.c similarity index 100% rename from source/qjs_debug.c rename to scripts/debug.c diff --git a/source/qjs_enet.c b/scripts/enet.c similarity index 100% rename from source/qjs_enet.c rename to scripts/enet.c diff --git a/source/qjs_fd.c b/scripts/fd.c similarity index 100% rename from source/qjs_fd.c rename to scripts/fd.c diff --git a/source/qjs_fit.c b/scripts/fit.c similarity index 100% rename from source/qjs_fit.c rename to scripts/fit.c diff --git a/source/qjs_http.c b/scripts/http.c similarity index 100% rename from source/qjs_http.c rename to scripts/http.c diff --git a/source/qjs_js.c b/scripts/js.c similarity index 100% rename from source/qjs_js.c rename to scripts/js.c diff --git a/source/qjs_kim.c b/scripts/kim.c similarity index 100% rename from source/qjs_kim.c rename to scripts/kim.c diff --git a/source/qjs_miniz.c b/scripts/miniz.c similarity index 100% rename from source/qjs_miniz.c rename to scripts/miniz.c diff --git a/source/qjs_nota.c b/scripts/nota.c similarity index 99% rename from source/qjs_nota.c rename to scripts/nota.c index 5252f50e..9b39718e 100755 --- a/source/qjs_nota.c +++ b/scripts/nota.c @@ -1,4 +1,3 @@ -#include "qjs_nota.h" #include "cell.h" #define NOTA_IMPLEMENTATION diff --git a/source/qjs_num.c b/scripts/num.c similarity index 99% rename from source/qjs_num.c rename to scripts/num.c index 55d0d8e3..b6ba08ec 100644 --- a/source/qjs_num.c +++ b/scripts/num.c @@ -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), diff --git a/source/qjs_os.c b/scripts/os.c similarity index 100% rename from source/qjs_os.c rename to scripts/os.c diff --git a/source/qjs_qop.c b/scripts/qop.c similarity index 100% rename from source/qjs_qop.c rename to scripts/qop.c diff --git a/source/qjs_socket.c b/scripts/socket.c similarity index 100% rename from source/qjs_socket.c rename to scripts/socket.c diff --git a/source/qjs_text.c b/scripts/text.c similarity index 100% rename from source/qjs_text.c rename to scripts/text.c diff --git a/source/qjs_time.c b/scripts/time.c similarity index 100% rename from source/qjs_time.c rename to scripts/time.c diff --git a/source/qjs_utf8.c b/scripts/utf8.c similarity index 100% rename from source/qjs_utf8.c rename to scripts/utf8.c diff --git a/source/qjs_wildstar.c b/scripts/wildstar.c similarity index 100% rename from source/qjs_wildstar.c rename to scripts/wildstar.c diff --git a/source/cell.h b/source/cell.h index b5099aab..77b02f2c 100644 --- a/source/cell.h +++ b/source/cell.h @@ -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 diff --git a/source/qjs_actor.c b/source/qjs_actor.c index f44f176a..47f9c009 100644 --- a/source/qjs_actor.c +++ b/source/qjs_actor.c @@ -7,71 +7,6 @@ #include #include -// 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) diff --git a/source/qjs_actor.h b/source/qjs_actor.h deleted file mode 100644 index 1aaa3d9f..00000000 --- a/source/qjs_actor.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/source/qjs_nota.h b/source/qjs_nota.h deleted file mode 100644 index 570495bd..00000000 --- a/source/qjs_nota.h +++ /dev/null @@ -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