diff options
author | Florian Dold <florian@dold.me> | 2023-01-02 22:51:14 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-01-02 22:51:14 +0100 |
commit | a9d2a10f9dfc2cacf17e574928e6b851e084beef (patch) | |
tree | a933ed371b4647fcb1ba81d3be5d12d06b0a1d83 /qtart.c | |
parent | 6dba524755c9b5a3dccc4372cf74cf1ed6d46586 (diff) | |
download | quickjs-tart-a9d2a10f9dfc2cacf17e574928e6b851e084beef.tar.gz quickjs-tart-a9d2a10f9dfc2cacf17e574928e6b851e084beef.tar.bz2 quickjs-tart-a9d2a10f9dfc2cacf17e574928e6b851e084beef.zip |
wip
Diffstat (limited to 'qtart.c')
-rw-r--r-- | qtart.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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), "<input>", 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; |