From a9d2a10f9dfc2cacf17e574928e6b851e084beef Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 2 Jan 2023 22:51:14 +0100 Subject: wip --- qtart.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'qtart.c') diff --git a/qtart.c b/qtart.c index 3645758..8b701d6 100644 --- a/qtart.c +++ b/qtart.c @@ -46,6 +46,12 @@ extern const uint8_t qjsc_repl[]; extern const uint32_t qjsc_repl_size; +extern const uint8_t qjsc_prelude[]; +extern const uint32_t qjsc_prelude_size; + +extern const uint8_t qjsc_wallet_core[]; +extern const uint32_t qjsc_wallet_core_size; + static int eval_buf(JSContext *ctx, const void *buf, int buf_len, const char *filename, int eval_flags) { @@ -294,6 +300,12 @@ void help(void) exit(1); } +void +handle_host_message(void *cls, const char *msg) +{ + printf("message from JS to host: %s\n", msg); +} + int main(int argc, char **argv) { JSRuntime *rt; @@ -436,6 +448,7 @@ int main(int argc, char **argv) js_std_set_worker_new_context_func(JS_NewCustomContext); js_std_init_handlers(rt); ctx = JS_NewCustomContext(rt); + js_os_set_host_message_handler(ctx, handle_host_message, NULL); if (!ctx) { fprintf(stderr, "qjs: cannot allocate JS context\n"); exit(2); @@ -461,6 +474,9 @@ int main(int argc, char **argv) eval_buf(ctx, str, strlen(str), "", JS_EVAL_TYPE_MODULE); } + js_std_eval_binary(ctx, qjsc_prelude, qjsc_prelude_size, 0); + js_std_eval_binary(ctx, qjsc_wallet_core, qjsc_wallet_core_size, 0); + for(i = 0; i < include_count; i++) { if (eval_file(ctx, include_list[i], module)) goto fail; -- cgit v1.2.3