@zappdev/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/zapp-cli.js +9471 -0
- package/native/src/app/app.zc +490 -0
- package/native/src/event/event.zc +24 -0
- package/native/src/event/events.zc +70 -0
- package/native/src/platform/darwin/backend.zc +923 -0
- package/native/src/platform/darwin/backend_bootstrap.zc +9 -0
- package/native/src/platform/darwin/bootstrap.zc +9 -0
- package/native/src/platform/darwin/engine_jsc.zc +86 -0
- package/native/src/platform/darwin/engine_qjs.zc +92 -0
- package/native/src/platform/darwin/platform.zc +156 -0
- package/native/src/platform/darwin/webview.zc +550 -0
- package/native/src/platform/darwin/webview_bootstrap.zc +9 -0
- package/native/src/platform/darwin/window.zc +1223 -0
- package/native/src/platform/darwin/worker/common.zc +223 -0
- package/native/src/platform/darwin/worker/core/base64_core.zc +29 -0
- package/native/src/platform/darwin/worker/core/crypto_core.zc +19 -0
- package/native/src/platform/darwin/worker/core/encoding_core.zc +32 -0
- package/native/src/platform/darwin/worker/core/fetch_core.zc +145 -0
- package/native/src/platform/darwin/worker/core/url_core.zc +69 -0
- package/native/src/platform/darwin/worker/core/websocket_core.zc +179 -0
- package/native/src/platform/darwin/worker/dispatch.zc +55 -0
- package/native/src/platform/darwin/worker/jsc/base64_jsc.zc +39 -0
- package/native/src/platform/darwin/worker/jsc/crypto_jsc.zc +49 -0
- package/native/src/platform/darwin/worker/jsc/encoding_jsc.zc +86 -0
- package/native/src/platform/darwin/worker/jsc/fetch_jsc.zc +149 -0
- package/native/src/platform/darwin/worker/jsc/url_jsc.zc +54 -0
- package/native/src/platform/darwin/worker/jsc/websocket_jsc.zc +127 -0
- package/native/src/platform/darwin/worker/jsc.zc +670 -0
- package/native/src/platform/darwin/worker/mod.zc +30 -0
- package/native/src/platform/darwin/worker/qjs/fetch_qjs.zc +233 -0
- package/native/src/platform/darwin/worker/qjs/qjs_macros.zc +23 -0
- package/native/src/platform/darwin/worker/qjs/websocket_qjs.zc +223 -0
- package/native/src/platform/darwin/worker/qjs.zc +1053 -0
- package/native/src/platform/darwin/worker/timers.zc +149 -0
- package/native/src/platform/darwin/worker/timers_qjs.zc +209 -0
- package/native/src/platform/platform.zc +64 -0
- package/native/src/platform/shared/log.zc +156 -0
- package/native/src/platform/shared/worker/qjs/base64_qjs.zc +38 -0
- package/native/src/platform/shared/worker/qjs/crypto_qjs.zc +44 -0
- package/native/src/platform/shared/worker/qjs/encoding_qjs.zc +95 -0
- package/native/src/platform/shared/worker/qjs/url_qjs.zc +65 -0
- package/native/src/platform/shared/worker_registry.zc +206 -0
- package/native/src/platform/window.zc +446 -0
- package/native/src/platform/windows/backend.zc +452 -0
- package/native/src/platform/windows/backend_bootstrap.zc +9 -0
- package/native/src/platform/windows/bootstrap.zc +9 -0
- package/native/src/platform/windows/engine_qjs.zc +60 -0
- package/native/src/platform/windows/platform.zc +387 -0
- package/native/src/platform/windows/webview.zc +1175 -0
- package/native/src/platform/windows/webview_bootstrap.zc +9 -0
- package/native/src/platform/windows/window.zc +1271 -0
- package/native/src/platform/windows/worker/common.zc +409 -0
- package/native/src/platform/windows/worker/core/base64_core.zc +52 -0
- package/native/src/platform/windows/worker/core/crypto_core.zc +34 -0
- package/native/src/platform/windows/worker/core/encoding_core.zc +60 -0
- package/native/src/platform/windows/worker/core/fetch_core.zc +274 -0
- package/native/src/platform/windows/worker/core/url_core.zc +216 -0
- package/native/src/platform/windows/worker/core/websocket_core.zc +343 -0
- package/native/src/platform/windows/worker/dispatch.zc +34 -0
- package/native/src/platform/windows/worker/mod.zc +46 -0
- package/native/src/platform/windows/worker/qjs/fetch_qjs.zc +255 -0
- package/native/src/platform/windows/worker/qjs/websocket_qjs.zc +263 -0
- package/native/src/platform/windows/worker/qjs.zc +1049 -0
- package/native/src/platform/windows/worker/timers_qjs.zc +288 -0
- package/native/src/platform/worker.zc +8 -0
- package/native/src/service/service.zc +228 -0
- package/native/vendor/quickjs-ng/.gitattributes +4 -0
- package/native/vendor/quickjs-ng/.github/dependabot.yml +7 -0
- package/native/vendor/quickjs-ng/.github/workflows/ci.yml +812 -0
- package/native/vendor/quickjs-ng/.github/workflows/docs.yml +49 -0
- package/native/vendor/quickjs-ng/.github/workflows/release.yml +162 -0
- package/native/vendor/quickjs-ng/.github/workflows/test-docs.yml +23 -0
- package/native/vendor/quickjs-ng/.github/workflows/tsan.yml +32 -0
- package/native/vendor/quickjs-ng/.github/workflows/valgrind.yml +33 -0
- package/native/vendor/quickjs-ng/.gitmodules +5 -0
- package/native/vendor/quickjs-ng/CMakeLists.txt +553 -0
- package/native/vendor/quickjs-ng/LICENSE +24 -0
- package/native/vendor/quickjs-ng/Makefile +149 -0
- package/native/vendor/quickjs-ng/amalgam.js +53 -0
- package/native/vendor/quickjs-ng/api-test.c +927 -0
- package/native/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
- package/native/vendor/quickjs-ng/builtin-array-fromasync.js +36 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip-keyed.js +194 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
- package/native/vendor/quickjs-ng/builtin-iterator-zip.js +210 -0
- package/native/vendor/quickjs-ng/ctest.c +17 -0
- package/native/vendor/quickjs-ng/cutils.h +2013 -0
- package/native/vendor/quickjs-ng/cxxtest.cc +2 -0
- package/native/vendor/quickjs-ng/dtoa.c +1619 -0
- package/native/vendor/quickjs-ng/dtoa.h +87 -0
- package/native/vendor/quickjs-ng/examples/fib.c +67 -0
- package/native/vendor/quickjs-ng/examples/fib_module.js +10 -0
- package/native/vendor/quickjs-ng/examples/hello.js +1 -0
- package/native/vendor/quickjs-ng/examples/hello_module.js +6 -0
- package/native/vendor/quickjs-ng/examples/meson.build +17 -0
- package/native/vendor/quickjs-ng/examples/pi_bigint.js +118 -0
- package/native/vendor/quickjs-ng/examples/point.c +154 -0
- package/native/vendor/quickjs-ng/examples/test_fib.js +8 -0
- package/native/vendor/quickjs-ng/examples/test_point.js +43 -0
- package/native/vendor/quickjs-ng/fuzz.c +51 -0
- package/native/vendor/quickjs-ng/gen/function_source.c +81 -0
- package/native/vendor/quickjs-ng/gen/hello.c +53 -0
- package/native/vendor/quickjs-ng/gen/hello_module.c +106 -0
- package/native/vendor/quickjs-ng/gen/repl.c +3053 -0
- package/native/vendor/quickjs-ng/gen/standalone.c +324 -0
- package/native/vendor/quickjs-ng/gen/test_fib.c +81 -0
- package/native/vendor/quickjs-ng/libregexp-opcode.h +58 -0
- package/native/vendor/quickjs-ng/libregexp.c +2687 -0
- package/native/vendor/quickjs-ng/libregexp.h +98 -0
- package/native/vendor/quickjs-ng/libunicode-table.h +4707 -0
- package/native/vendor/quickjs-ng/libunicode.c +1746 -0
- package/native/vendor/quickjs-ng/libunicode.h +126 -0
- package/native/vendor/quickjs-ng/list.h +107 -0
- package/native/vendor/quickjs-ng/lre-test.c +73 -0
- package/native/vendor/quickjs-ng/meson.build +684 -0
- package/native/vendor/quickjs-ng/meson_options.txt +6 -0
- package/native/vendor/quickjs-ng/qjs-wasi-reactor.c +208 -0
- package/native/vendor/quickjs-ng/qjs.c +748 -0
- package/native/vendor/quickjs-ng/qjsc.c +673 -0
- package/native/vendor/quickjs-ng/quickjs-atom.h +267 -0
- package/native/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
- package/native/vendor/quickjs-ng/quickjs-libc.c +4986 -0
- package/native/vendor/quickjs-ng/quickjs-libc.h +79 -0
- package/native/vendor/quickjs-ng/quickjs-opcode.h +369 -0
- package/native/vendor/quickjs-ng/quickjs.c +60259 -0
- package/native/vendor/quickjs-ng/quickjs.h +1419 -0
- package/native/vendor/quickjs-ng/repl.js +1927 -0
- package/native/vendor/quickjs-ng/run-test262.c +2417 -0
- package/native/vendor/quickjs-ng/standalone.js +129 -0
- package/native/vendor/quickjs-ng/tests/assert.js +49 -0
- package/native/vendor/quickjs-ng/tests/bug1221.js +16 -0
- package/native/vendor/quickjs-ng/tests/bug1296.js +12 -0
- package/native/vendor/quickjs-ng/tests/bug1297.js +22 -0
- package/native/vendor/quickjs-ng/tests/bug1301.js +21 -0
- package/native/vendor/quickjs-ng/tests/bug1302.js +24 -0
- package/native/vendor/quickjs-ng/tests/bug1305.js +26 -0
- package/native/vendor/quickjs-ng/tests/bug1318.js +54 -0
- package/native/vendor/quickjs-ng/tests/bug1352.js +8 -0
- package/native/vendor/quickjs-ng/tests/bug1354.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug1355.js +58 -0
- package/native/vendor/quickjs-ng/tests/bug1368.js +9 -0
- package/native/vendor/quickjs-ng/tests/bug39/1.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug39/2.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug39/3.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug488-upstream.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug633/0.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug633/1.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug633/2.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug633/3.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug645/0.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug645/1.js +9 -0
- package/native/vendor/quickjs-ng/tests/bug645/2.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug648.js +13 -0
- package/native/vendor/quickjs-ng/tests/bug652.js +4 -0
- package/native/vendor/quickjs-ng/tests/bug741.js +19 -0
- package/native/vendor/quickjs-ng/tests/bug775.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug776.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug832.js +2 -0
- package/native/vendor/quickjs-ng/tests/bug858.js +26 -0
- package/native/vendor/quickjs-ng/tests/bug904.js +6 -0
- package/native/vendor/quickjs-ng/tests/bug988.js +7 -0
- package/native/vendor/quickjs-ng/tests/bug999.js +3 -0
- package/native/vendor/quickjs-ng/tests/destructured-export.js +8 -0
- package/native/vendor/quickjs-ng/tests/detect_module/0.js +1 -0
- package/native/vendor/quickjs-ng/tests/detect_module/1.js +2 -0
- package/native/vendor/quickjs-ng/tests/detect_module/2.js +1 -0
- package/native/vendor/quickjs-ng/tests/detect_module/3.js +8 -0
- package/native/vendor/quickjs-ng/tests/detect_module/4.js +3 -0
- package/native/vendor/quickjs-ng/tests/empty.js +0 -0
- package/native/vendor/quickjs-ng/tests/fixture_cyclic_import.js +2 -0
- package/native/vendor/quickjs-ng/tests/fixture_string_exports.js +12 -0
- package/native/vendor/quickjs-ng/tests/function_source.js +14 -0
- package/native/vendor/quickjs-ng/tests/microbench.js +1267 -0
- package/native/vendor/quickjs-ng/tests/null_or_undefined.js +38 -0
- package/native/vendor/quickjs-ng/tests/str-pad-leak.js +5 -0
- package/native/vendor/quickjs-ng/tests/test_bigint.js +107 -0
- package/native/vendor/quickjs-ng/tests/test_bjson.js +366 -0
- package/native/vendor/quickjs-ng/tests/test_builtin.js +1314 -0
- package/native/vendor/quickjs-ng/tests/test_closure.js +220 -0
- package/native/vendor/quickjs-ng/tests/test_cyclic_import.js +12 -0
- package/native/vendor/quickjs-ng/tests/test_domexception.js +35 -0
- package/native/vendor/quickjs-ng/tests/test_language.js +755 -0
- package/native/vendor/quickjs-ng/tests/test_loop.js +367 -0
- package/native/vendor/quickjs-ng/tests/test_queue_microtask.js +39 -0
- package/native/vendor/quickjs-ng/tests/test_std.js +340 -0
- package/native/vendor/quickjs-ng/tests/test_string_exports.js +25 -0
- package/native/vendor/quickjs-ng/tests/test_worker.js +43 -0
- package/native/vendor/quickjs-ng/tests/test_worker_module.js +30 -0
- package/native/vendor/quickjs-ng/tests.conf +14 -0
- package/native/vendor/quickjs-ng/unicode_download.sh +19 -0
- package/native/vendor/quickjs-ng/unicode_gen.c +3108 -0
- package/native/vendor/quickjs-ng/unicode_gen_def.h +310 -0
- package/native/vendor/quickjs-ng/update-version.sh +32 -0
- package/native/vendor/webview2/include/WebView2.h +60636 -0
- package/native/vendor/webview2/include/WebView2EnvironmentOptions.h +406 -0
- package/package.json +33 -0
- package/src/backend.ts +139 -0
- package/src/build-config.ts +87 -0
- package/src/build.ts +276 -0
- package/src/common.ts +195 -0
- package/src/config.ts +89 -0
- package/src/dev.ts +164 -0
- package/src/generate.ts +200 -0
- package/src/icons.ts +116 -0
- package/src/init.ts +190 -0
- package/src/package.ts +150 -0
- package/src/zapp-cli.ts +263 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* QuickJS WASI Reactor Mode
|
|
3
|
+
*
|
|
4
|
+
* In reactor mode, QuickJS exports functions that can be called repeatedly
|
|
5
|
+
* by the host instead of running main() once and blocking in the event loop.
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2017-2021 Fabrice Bellard
|
|
8
|
+
* Copyright (c) 2017-2021 Charlie Gordon
|
|
9
|
+
*
|
|
10
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
* in the Software without restriction, including without limitation the rights
|
|
13
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
* furnished to do so, subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in
|
|
18
|
+
* all copies or substantial portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
23
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
* THE SOFTWARE.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/* Include qjs.c to get access to static functions like eval_buf, eval_file,
|
|
30
|
+
* parse_limit, and JS_NewCustomContext */
|
|
31
|
+
#include "qjs.c"
|
|
32
|
+
|
|
33
|
+
static JSRuntime *reactor_rt = NULL;
|
|
34
|
+
static JSContext *reactor_ctx = NULL;
|
|
35
|
+
|
|
36
|
+
int qjs_init_argv(int argc, char **argv);
|
|
37
|
+
|
|
38
|
+
__attribute__((export_name("qjs_init")))
|
|
39
|
+
int qjs_init(void)
|
|
40
|
+
{
|
|
41
|
+
static char *empty_argv[] = { "qjs", NULL };
|
|
42
|
+
return qjs_init_argv(1, empty_argv);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
__attribute__((export_name("qjs_init_argv")))
|
|
46
|
+
int qjs_init_argv(int argc, char **argv)
|
|
47
|
+
{
|
|
48
|
+
int optind = 1;
|
|
49
|
+
char *expr = NULL;
|
|
50
|
+
int module = -1;
|
|
51
|
+
int load_std = 0;
|
|
52
|
+
char *include_list[32];
|
|
53
|
+
int i, include_count = 0;
|
|
54
|
+
int64_t memory_limit = -1;
|
|
55
|
+
int64_t stack_size = -1;
|
|
56
|
+
|
|
57
|
+
if (reactor_rt)
|
|
58
|
+
return -1; /* already initialized */
|
|
59
|
+
|
|
60
|
+
/* Parse options (subset of main()) */
|
|
61
|
+
while (optind < argc && *argv[optind] == '-') {
|
|
62
|
+
char *arg = argv[optind] + 1;
|
|
63
|
+
const char *longopt = "";
|
|
64
|
+
char *optarg = NULL;
|
|
65
|
+
if (!*arg)
|
|
66
|
+
break;
|
|
67
|
+
optind++;
|
|
68
|
+
if (*arg == '-') {
|
|
69
|
+
longopt = arg + 1;
|
|
70
|
+
optarg = strchr(longopt, '=');
|
|
71
|
+
if (optarg)
|
|
72
|
+
*optarg++ = '\0';
|
|
73
|
+
arg += strlen(arg);
|
|
74
|
+
if (!*longopt)
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
for (; *arg || *longopt; longopt = "") {
|
|
78
|
+
char opt = *arg;
|
|
79
|
+
if (opt) {
|
|
80
|
+
arg++;
|
|
81
|
+
if (!optarg && *arg)
|
|
82
|
+
optarg = arg;
|
|
83
|
+
}
|
|
84
|
+
if (opt == 'e' || !strcmp(longopt, "eval")) {
|
|
85
|
+
if (!optarg) {
|
|
86
|
+
if (optind >= argc)
|
|
87
|
+
return -1;
|
|
88
|
+
optarg = argv[optind++];
|
|
89
|
+
}
|
|
90
|
+
expr = optarg;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (opt == 'I' || !strcmp(longopt, "include")) {
|
|
94
|
+
if (optind >= argc || include_count >= countof(include_list))
|
|
95
|
+
return -1;
|
|
96
|
+
include_list[include_count++] = argv[optind++];
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (opt == 'm' || !strcmp(longopt, "module")) {
|
|
100
|
+
module = 1;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (!strcmp(longopt, "std")) {
|
|
104
|
+
load_std = 1;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (!strcmp(longopt, "memory-limit")) {
|
|
108
|
+
if (!optarg) {
|
|
109
|
+
if (optind >= argc)
|
|
110
|
+
return -1;
|
|
111
|
+
optarg = argv[optind++];
|
|
112
|
+
}
|
|
113
|
+
memory_limit = parse_limit(optarg);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
if (!strcmp(longopt, "stack-size")) {
|
|
117
|
+
if (!optarg) {
|
|
118
|
+
if (optind >= argc)
|
|
119
|
+
return -1;
|
|
120
|
+
optarg = argv[optind++];
|
|
121
|
+
}
|
|
122
|
+
stack_size = parse_limit(optarg);
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
break; /* ignore unknown options */
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
reactor_rt = JS_NewRuntime();
|
|
130
|
+
if (!reactor_rt)
|
|
131
|
+
return -1;
|
|
132
|
+
if (memory_limit >= 0)
|
|
133
|
+
JS_SetMemoryLimit(reactor_rt, (size_t)memory_limit);
|
|
134
|
+
if (stack_size >= 0)
|
|
135
|
+
JS_SetMaxStackSize(reactor_rt, (size_t)stack_size);
|
|
136
|
+
|
|
137
|
+
js_std_set_worker_new_context_func(JS_NewCustomContext);
|
|
138
|
+
js_std_init_handlers(reactor_rt);
|
|
139
|
+
|
|
140
|
+
reactor_ctx = JS_NewCustomContext(reactor_rt);
|
|
141
|
+
if (!reactor_ctx) {
|
|
142
|
+
js_std_free_handlers(reactor_rt);
|
|
143
|
+
JS_FreeRuntime(reactor_rt);
|
|
144
|
+
reactor_rt = NULL;
|
|
145
|
+
return -1;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
JS_SetModuleLoaderFunc2(reactor_rt, NULL, js_module_loader,
|
|
149
|
+
js_module_check_attributes, NULL);
|
|
150
|
+
JS_SetHostPromiseRejectionTracker(reactor_rt, js_std_promise_rejection_tracker, NULL);
|
|
151
|
+
js_std_add_helpers(reactor_ctx, argc - optind, argv + optind);
|
|
152
|
+
|
|
153
|
+
if (load_std) {
|
|
154
|
+
const char *str =
|
|
155
|
+
"import * as bjson from 'qjs:bjson';\n"
|
|
156
|
+
"import * as std from 'qjs:std';\n"
|
|
157
|
+
"import * as os from 'qjs:os';\n"
|
|
158
|
+
"globalThis.bjson = bjson;\n"
|
|
159
|
+
"globalThis.std = std;\n"
|
|
160
|
+
"globalThis.os = os;\n";
|
|
161
|
+
if (eval_buf(reactor_ctx, str, strlen(str), "<input>", JS_EVAL_TYPE_MODULE))
|
|
162
|
+
goto fail;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
for (i = 0; i < include_count; i++) {
|
|
166
|
+
if (eval_file(reactor_ctx, include_list[i], 0))
|
|
167
|
+
goto fail;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (expr) {
|
|
171
|
+
if (eval_buf(reactor_ctx, expr, strlen(expr), "<cmdline>",
|
|
172
|
+
module == 1 ? JS_EVAL_TYPE_MODULE : 0))
|
|
173
|
+
goto fail;
|
|
174
|
+
} else if (optind < argc) {
|
|
175
|
+
if (eval_file(reactor_ctx, argv[optind], module))
|
|
176
|
+
goto fail;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return 0;
|
|
180
|
+
|
|
181
|
+
fail:
|
|
182
|
+
js_std_free_handlers(reactor_rt);
|
|
183
|
+
JS_FreeContext(reactor_ctx);
|
|
184
|
+
JS_FreeRuntime(reactor_rt);
|
|
185
|
+
reactor_rt = NULL;
|
|
186
|
+
reactor_ctx = NULL;
|
|
187
|
+
return -1;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
__attribute__((export_name("qjs_get_context")))
|
|
191
|
+
JSContext *qjs_get_context(void)
|
|
192
|
+
{
|
|
193
|
+
return reactor_ctx;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
__attribute__((export_name("qjs_destroy")))
|
|
197
|
+
void qjs_destroy(void)
|
|
198
|
+
{
|
|
199
|
+
if (reactor_ctx) {
|
|
200
|
+
js_std_free_handlers(reactor_rt);
|
|
201
|
+
JS_FreeContext(reactor_ctx);
|
|
202
|
+
reactor_ctx = NULL;
|
|
203
|
+
}
|
|
204
|
+
if (reactor_rt) {
|
|
205
|
+
JS_FreeRuntime(reactor_rt);
|
|
206
|
+
reactor_rt = NULL;
|
|
207
|
+
}
|
|
208
|
+
}
|