Skip to content

Commit 88272af

Browse files
committed
QuickJS: fixed compatibility issue with QuickJS-NG 0.11.0.
1 parent f37c6bb commit 88272af

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

.github/workflows/check-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
run: |
5656
git clone https://github.com/quickjs-ng/quickjs quickjs-ng
5757
cd quickjs-ng
58-
git checkout v0.9.0
58+
git checkout v0.11.0
5959
CFLAGS="$CC_OPT -fPIC" LDFLAGS=$LD_OPT cmake -B build
6060
cmake --build build --target qjs -j $(nproc)
6161

auto/quickjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,24 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
136136

137137
. auto/feature
138138

139+
njs_feature="QuickJS JS_IsError()"
140+
njs_feature_name=NJS_HAVE_QUICKJS_IS_ERROR_SINGLE_ARG
141+
njs_feature_test="#include <quickjs_compat.h>
142+
143+
int main() {
144+
JSRuntime *rt;
145+
JSContext *ctx;
146+
147+
rt = JS_NewRuntime();
148+
ctx = JS_NewContext(rt);
149+
(void) JS_IsError(JS_UNDEFINED);
150+
JS_FreeContext(ctx);
151+
JS_FreeRuntime(rt);
152+
return 0;
153+
}"
154+
155+
. auto/feature
156+
139157
njs_feature="QuickJS JS_AddIntrinsicBigInt()"
140158
njs_feature_name=NJS_HAVE_QUICKJS_ADD_INTRINSIC_BIG_INT
141159
njs_feature_test="#include <quickjs_compat.h>

external/njs_shell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@ njs_qjs_dump_error2(JSContext *ctx, JSValueConst exception)
19601960
_Bool is_error;
19611961
JSValue val;
19621962

1963-
is_error = JS_IsError(ctx, exception);
1963+
is_error = qjs_is_error(ctx, exception);
19641964

19651965
njs_qjs_dump_obj(ctx, stderr, exception, "Thrown:\n", "");
19661966

external/qjs_fs_module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,23 +2696,23 @@ qjs_fs_result(JSContext *cx, JSValue result, int calltype, JSValue callback)
26962696

26972697
switch (calltype) {
26982698
case QJS_FS_DIRECT:
2699-
if (JS_IsError(cx, result)) {
2699+
if (qjs_is_error(cx, result)) {
27002700
JS_Throw(cx, result);
27012701
return JS_EXCEPTION;
27022702
}
27032703

27042704
return result;
27052705

27062706
case QJS_FS_PROMISE:
2707-
if (JS_IsError(cx, result)) {
2707+
if (qjs_is_error(cx, result)) {
27082708
JS_Throw(cx, result);
27092709
return qjs_promise_result(cx, JS_EXCEPTION);
27102710
}
27112711

27122712
return qjs_promise_result(cx, result);
27132713

27142714
case QJS_FS_CALLBACK:
2715-
if (JS_IsError(cx, result)) {
2715+
if (qjs_is_error(cx, result)) {
27162716
arguments[0] = result;
27172717
arguments[1] = JS_UNDEFINED;
27182718

src/qjs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ static inline JS_BOOL JS_IsNullOrUndefined(JSValueConst v)
150150
#define qjs_is_array(cx, a) JS_IsArray(cx, a)
151151
#endif
152152

153+
#ifdef NJS_HAVE_QUICKJS_IS_ERROR_SINGLE_ARG
154+
#define qjs_is_error(cx, a) JS_IsError(a)
155+
#else
156+
#define qjs_is_error(cx, a) JS_IsError(cx, a)
157+
#endif
158+
153159
extern qjs_module_t *qjs_modules[];
154160

155161
#endif /* _QJS_H_INCLUDED_ */

0 commit comments

Comments
 (0)