This fixes #872 on Github.
run: |
git clone https://github.com/quickjs-ng/quickjs quickjs-ng
cd quickjs-ng
- git checkout v0.8.0
+ git checkout v0.9.0
CFLAGS="$CC_OPT -fPIC" LDFLAGS=$LD_OPT cmake -B build
cmake --build build --target qjs -j $(nproc)
. auto/feature
+ njs_feature="QuickJS JS_IsArray()"
+ njs_feature_name=NJS_HAVE_QUICKJS_IS_ARRAY_SINGLE_ARG
+ njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored \"-Wcast-function-type\"
+ #endif
+
+ #include <quickjs.h>
+
+ int main() {
+ JSRuntime *rt;
+ JSContext *ctx;
+
+ rt = JS_NewRuntime();
+ ctx = JS_NewContext(rt);
+ (void) JS_IsArray(JS_UNDEFINED);
+ JS_FreeContext(ctx);
+ JS_FreeRuntime(rt);
+ return 0;
+ }"
+
+ . auto/feature
+
njs_feature="QuickJS JS_AddIntrinsicBigInt()"
njs_feature_name=NJS_HAVE_QUICKJS_ADD_INTRINSIC_BIG_INT
njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
goto exception;
}
- } else if (JS_IsArray(cx, prev)) {
+ } else if (qjs_is_array(cx, prev)) {
length = JS_GetPropertyStr(cx, prev, "length");
if (JS_ToUint32(cx, &len, length) < 0) {
goto fail;
}
- if (JS_IsArray(cx, val)) {
+ if (qjs_is_array(cx, val)) {
key = JS_AtomToString(cx, ptab[n].atom);
if (JS_IsException(key)) {
JS_FreeValue(cx, val);
njs_str_t s;
qjs_webcrypto_entry_t *e;
- if (!JS_IsArray(cx, value)) {
+ if (!qjs_is_array(cx, value)) {
JS_ThrowTypeError(cx, "\"keyUsages\" argument must be an Array");
return JS_EXCEPTION;
}
return -1;
}
- if (!JS_IsArray(cx, setval)) {
+ if (!qjs_is_array(cx, setval)) {
JS_ThrowTypeError(cx, "setval is not an array");
return -1;
}
goto exception;
}
- } else if (JS_IsArray(cx, prev)) {
+ } else if (qjs_is_array(cx, prev)) {
length = JS_GetPropertyStr(cx, prev, "length");
if (JS_ToUint32(cx, &len, length)) {
return 1;
}
- if (JS_IsArray(cx, *value)) {
+ if (qjs_is_array(cx, *value)) {
v = JS_GetPropertyStr(cx, *value, "length");
if (JS_IsException(v)) {
return -1;
ph = &header;
for (i = 0; i < (uint32_t) length; i++) {
- if (JS_IsArray(cx, *value)) {
+ if (qjs_is_array(cx, *value)) {
v = JS_GetPropertyUint32(cx, *value, i);
if (JS_IsException(v)) {
return -1;
rc = ngx_qjs_string(cx, v, &s);
- if (JS_IsArray(cx, *value)) {
+ if (qjs_is_array(cx, *value)) {
JS_FreeValue(cx, v);
}
}
if (value != NULL) {
- if (JS_IsArray(cx, *value)) {
+ if (qjs_is_array(cx, *value)) {
len = JS_GetPropertyStr(cx, *value, "length");
if (JS_IsException(len)) {
return -1;
rc = ngx_qjs_string(cx, setval, &s);
- if (value != NULL && JS_IsArray(cx, *value)) {
+ if (value != NULL && qjs_is_array(cx, *value)) {
JS_FreeValue(cx, setval);
}
return 1;
}
- if (JS_IsArray(cx, *value)) {
+ if (qjs_is_array(cx, *value)) {
len = JS_GetPropertyStr(cx, *value, "length");
if (JS_IsException(len)) {
return -1;
rc = ngx_qjs_string(cx, setval, &s);
- if (JS_IsArray(cx, *value)) {
+ if (qjs_is_array(cx, *value)) {
JS_FreeValue(cx, setval);
}
#include <quickjs.h>
+#ifndef JS_BOOL
+#define JS_BOOL bool
+#endif
+
#if defined(__GNUC__) && (__GNUC__ >= 8)
#pragma GCC diagnostic pop
#endif
|| JS_VALUE_GET_TAG(v) == JS_TAG_UNDEFINED;
}
-
#ifdef NJS_HAVE_QUICKJS_IS_SAME_VALUE
#define qjs_is_same_value(cx, a, b) JS_IsSameValue(cx, a, b)
#else
#define qjs_is_same_value(cx, a, b) JS_SameValue(cx, a, b)
#endif
+#ifdef NJS_HAVE_QUICKJS_IS_ARRAY_SINGLE_ARG
+#define qjs_is_array(cx, a) JS_IsArray(a)
+#else
+#define qjs_is_array(cx, a) JS_IsArray(cx, a)
+#endif
extern qjs_module_t *qjs_modules[];
list = argv[0];
- if (!JS_IsArray(ctx, list)) {
+ if (!qjs_is_array(ctx, list)) {
return JS_ThrowTypeError(ctx,
"\"list\" argument must be an instance of Array");
}