Replace JSValueConst with JSValue (#195)
JSValueConst was only used for the now removed CONFIG_CHECK_JSVALUE build mode. It is kept around as an alias for JSValue in quickjs.h to avoid breaking everyone's source builds but remove it everywhere else.
This commit is contained in:
parent
4d57997ee7
commit
f1b7b6da71
9 changed files with 1503 additions and 1503 deletions
|
@ -35,8 +35,8 @@ static int fib(int n)
|
||||||
return fib(n - 1) + fib(n - 2);
|
return fib(n - 1) + fib(n - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_fib(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_fib(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int n, res;
|
int n, res;
|
||||||
if (JS_ToInt32(ctx, &n, argv[0]))
|
if (JS_ToInt32(ctx, &n, argv[0]))
|
||||||
|
|
|
@ -43,8 +43,8 @@ static void js_point_finalizer(JSRuntime *rt, JSValue val)
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_point_ctor(JSContext *ctx,
|
static JSValue js_point_ctor(JSContext *ctx,
|
||||||
JSValueConst new_target,
|
JSValue new_target,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSPointData *s;
|
JSPointData *s;
|
||||||
JSValue obj = JS_UNDEFINED;
|
JSValue obj = JS_UNDEFINED;
|
||||||
|
@ -74,7 +74,7 @@ static JSValue js_point_ctor(JSContext *ctx,
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_point_get_xy(JSContext *ctx, JSValueConst this_val, int magic)
|
static JSValue js_point_get_xy(JSContext *ctx, JSValue this_val, int magic)
|
||||||
{
|
{
|
||||||
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
|
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
|
||||||
if (!s)
|
if (!s)
|
||||||
|
@ -85,7 +85,7 @@ static JSValue js_point_get_xy(JSContext *ctx, JSValueConst this_val, int magic)
|
||||||
return JS_NewInt32(ctx, s->y);
|
return JS_NewInt32(ctx, s->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_point_set_xy(JSContext *ctx, JSValueConst this_val, JSValue val, int magic)
|
static JSValue js_point_set_xy(JSContext *ctx, JSValue this_val, JSValue val, int magic)
|
||||||
{
|
{
|
||||||
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
|
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
|
||||||
int v;
|
int v;
|
||||||
|
@ -100,8 +100,8 @@ static JSValue js_point_set_xy(JSContext *ctx, JSValueConst this_val, JSValue va
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_point_norm(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_point_norm(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
|
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
|
||||||
if (!s)
|
if (!s)
|
||||||
|
|
2
qjsc.c
2
qjsc.c
|
@ -150,7 +150,7 @@ static void dump_hex(FILE *f, const uint8_t *buf, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_object_code(JSContext *ctx,
|
static void output_object_code(JSContext *ctx,
|
||||||
FILE *fo, JSValueConst obj, const char *c_name,
|
FILE *fo, JSValue obj, const char *c_name,
|
||||||
BOOL load_only)
|
BOOL load_only)
|
||||||
{
|
{
|
||||||
uint8_t *out_buf;
|
uint8_t *out_buf;
|
||||||
|
|
318
quickjs-libc.c
318
quickjs-libc.c
|
@ -162,7 +162,7 @@ static BOOL my_isdigit(int c)
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_printf_internal(JSContext *ctx,
|
static JSValue js_printf_internal(JSContext *ctx,
|
||||||
int argc, JSValueConst *argv, FILE *fp)
|
int argc, JSValue *argv, FILE *fp)
|
||||||
{
|
{
|
||||||
char fmtbuf[32];
|
char fmtbuf[32];
|
||||||
uint8_t cbuf[UTF8_CHAR_LEN_MAX+1];
|
uint8_t cbuf[UTF8_CHAR_LEN_MAX+1];
|
||||||
|
@ -423,8 +423,8 @@ uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load and evaluate a file */
|
/* load and evaluate a file */
|
||||||
static JSValue js_loadScript(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_loadScript(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
@ -448,8 +448,8 @@ static JSValue js_loadScript(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load a file as a UTF-8 encoded string */
|
/* load a file as a UTF-8 encoded string */
|
||||||
static JSValue js_std_loadFile(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_loadFile(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
@ -530,7 +530,7 @@ static JSModuleDef *js_module_loader_so(JSContext *ctx,
|
||||||
}
|
}
|
||||||
#endif /* !_WIN32 */
|
#endif /* !_WIN32 */
|
||||||
|
|
||||||
int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
|
int js_module_set_import_meta(JSContext *ctx, JSValue func_val,
|
||||||
JS_BOOL use_realpath, JS_BOOL is_main)
|
JS_BOOL use_realpath, JS_BOOL is_main)
|
||||||
{
|
{
|
||||||
JSModuleDef *m;
|
JSModuleDef *m;
|
||||||
|
@ -617,8 +617,8 @@ JSModuleDef *js_module_loader(JSContext *ctx,
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_exit(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_exit(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
if (JS_ToInt32(ctx, &status, argv[0]))
|
if (JS_ToInt32(ctx, &status, argv[0]))
|
||||||
|
@ -627,8 +627,8 @@ static JSValue js_std_exit(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_getenv(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_getenv(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *name, *str;
|
const char *name, *str;
|
||||||
name = JS_ToCString(ctx, argv[0]);
|
name = JS_ToCString(ctx, argv[0]);
|
||||||
|
@ -664,8 +664,8 @@ static void unsetenv(const char *name)
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
static JSValue js_std_setenv(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_setenv(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *name, *value;
|
const char *name, *value;
|
||||||
name = JS_ToCString(ctx, argv[0]);
|
name = JS_ToCString(ctx, argv[0]);
|
||||||
|
@ -682,8 +682,8 @@ static JSValue js_std_setenv(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_unsetenv(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_unsetenv(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
name = JS_ToCString(ctx, argv[0]);
|
name = JS_ToCString(ctx, argv[0]);
|
||||||
|
@ -696,8 +696,8 @@ static JSValue js_std_unsetenv(JSContext *ctx, JSValueConst this_val,
|
||||||
|
|
||||||
/* return an object containing the list of the available environment
|
/* return an object containing the list of the available environment
|
||||||
variables. */
|
variables. */
|
||||||
static JSValue js_std_getenviron(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_getenviron(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
char **envp;
|
char **envp;
|
||||||
const char *name, *p, *value;
|
const char *name, *p, *value;
|
||||||
|
@ -733,8 +733,8 @@ static JSValue js_std_getenviron(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_gc(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_gc(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JS_RunGC(JS_GetRuntime(ctx));
|
JS_RunGC(JS_GetRuntime(ctx));
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
|
@ -746,7 +746,7 @@ static int interrupt_handler(JSRuntime *rt, void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_bool_option(JSContext *ctx, BOOL *pbool,
|
static int get_bool_option(JSContext *ctx, BOOL *pbool,
|
||||||
JSValueConst obj,
|
JSValue obj,
|
||||||
const char *option)
|
const char *option)
|
||||||
{
|
{
|
||||||
JSValue val;
|
JSValue val;
|
||||||
|
@ -760,15 +760,15 @@ static int get_bool_option(JSContext *ctx, BOOL *pbool,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_evalScript(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_evalScript(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSRuntime *rt = JS_GetRuntime(ctx);
|
JSRuntime *rt = JS_GetRuntime(ctx);
|
||||||
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
||||||
const char *str;
|
const char *str;
|
||||||
size_t len;
|
size_t len;
|
||||||
JSValue ret;
|
JSValue ret;
|
||||||
JSValueConst options_obj;
|
JSValue options_obj;
|
||||||
BOOL backtrace_barrier = FALSE;
|
BOOL backtrace_barrier = FALSE;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
|
@ -832,8 +832,8 @@ static ssize_t js_get_errno(ssize_t ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_strerror(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_strerror(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
if (JS_ToInt32(ctx, &err, argv[0]))
|
if (JS_ToInt32(ctx, &err, argv[0]))
|
||||||
|
@ -869,8 +869,8 @@ static void js_set_error_object(JSContext *ctx, JSValue obj, int err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_open(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_open(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *filename, *mode = NULL;
|
const char *filename, *mode = NULL;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -905,8 +905,8 @@ static JSValue js_std_open(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_popen(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_popen(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *filename, *mode = NULL;
|
const char *filename, *mode = NULL;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -941,8 +941,8 @@ static JSValue js_std_popen(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_fdopen(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_fdopen(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *mode;
|
const char *mode;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -974,8 +974,8 @@ static JSValue js_std_fdopen(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_tmpfile(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_tmpfile(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
f = tmpfile();
|
f = tmpfile();
|
||||||
|
@ -986,19 +986,19 @@ static JSValue js_std_tmpfile(JSContext *ctx, JSValueConst this_val,
|
||||||
return js_new_std_file(ctx, f, TRUE, FALSE);
|
return js_new_std_file(ctx, f, TRUE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_sprintf(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_sprintf(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
return js_printf_internal(ctx, argc, argv, NULL);
|
return js_printf_internal(ctx, argc, argv, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_printf(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_printf(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
return js_printf_internal(ctx, argc, argv, stdout);
|
return js_printf_internal(ctx, argc, argv, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FILE *js_std_file_get(JSContext *ctx, JSValueConst obj)
|
static FILE *js_std_file_get(JSContext *ctx, JSValue obj)
|
||||||
{
|
{
|
||||||
JSSTDFile *s = JS_GetOpaque2(ctx, obj, js_std_file_class_id);
|
JSSTDFile *s = JS_GetOpaque2(ctx, obj, js_std_file_class_id);
|
||||||
if (!s)
|
if (!s)
|
||||||
|
@ -1010,8 +1010,8 @@ static FILE *js_std_file_get(JSContext *ctx, JSValueConst obj)
|
||||||
return s->f;
|
return s->f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_puts(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_puts(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv, int magic)
|
int argc, JSValue *argv, int magic)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1036,8 +1036,8 @@ static JSValue js_std_file_puts(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_close(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_close(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSSTDFile *s = JS_GetOpaque2(ctx, this_val, js_std_file_class_id);
|
JSSTDFile *s = JS_GetOpaque2(ctx, this_val, js_std_file_class_id);
|
||||||
int err;
|
int err;
|
||||||
|
@ -1053,8 +1053,8 @@ static JSValue js_std_file_close(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt32(ctx, err);
|
return JS_NewInt32(ctx, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_printf(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_printf(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -1062,8 +1062,8 @@ static JSValue js_std_file_printf(JSContext *ctx, JSValueConst this_val,
|
||||||
return js_printf_internal(ctx, argc, argv, f);
|
return js_printf_internal(ctx, argc, argv, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_flush(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_flush(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -1072,8 +1072,8 @@ static JSValue js_std_file_flush(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_tell(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_tell(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv, int is_bigint)
|
int argc, JSValue *argv, int is_bigint)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
|
@ -1090,8 +1090,8 @@ static JSValue js_std_file_tell(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt64(ctx, pos);
|
return JS_NewInt64(ctx, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_seek(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_seek(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
|
@ -1112,8 +1112,8 @@ static JSValue js_std_file_seek(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt32(ctx, ret);
|
return JS_NewInt32(ctx, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_eof(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_eof(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -1121,8 +1121,8 @@ static JSValue js_std_file_eof(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewBool(ctx, feof(f));
|
return JS_NewBool(ctx, feof(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_error(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_error(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -1130,8 +1130,8 @@ static JSValue js_std_file_error(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewBool(ctx, ferror(f));
|
return JS_NewBool(ctx, ferror(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_clearerr(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_clearerr(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -1140,8 +1140,8 @@ static JSValue js_std_file_clearerr(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_fileno(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_fileno(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -1149,8 +1149,8 @@ static JSValue js_std_file_fileno(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt32(ctx, fileno(f));
|
return JS_NewInt32(ctx, fileno(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_read_write(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_read_write(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv, int magic)
|
int argc, JSValue *argv, int magic)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
uint64_t pos, len;
|
uint64_t pos, len;
|
||||||
|
@ -1176,8 +1176,8 @@ static JSValue js_std_file_read_write(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: could use less memory and go faster */
|
/* XXX: could use less memory and go faster */
|
||||||
static JSValue js_std_file_getline(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_getline(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
int c;
|
int c;
|
||||||
|
@ -1212,8 +1212,8 @@ static JSValue js_std_file_getline(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: could use less memory and go faster */
|
/* XXX: could use less memory and go faster */
|
||||||
static JSValue js_std_file_readAsString(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_readAsString(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
int c;
|
int c;
|
||||||
|
@ -1221,7 +1221,7 @@ static JSValue js_std_file_readAsString(JSContext *ctx, JSValueConst this_val,
|
||||||
JSValue obj;
|
JSValue obj;
|
||||||
uint64_t max_size64;
|
uint64_t max_size64;
|
||||||
size_t max_size;
|
size_t max_size;
|
||||||
JSValueConst max_size_val;
|
JSValue max_size_val;
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
|
@ -1254,8 +1254,8 @@ static JSValue js_std_file_readAsString(JSContext *ctx, JSValueConst this_val,
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_getByte(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_getByte(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -1263,8 +1263,8 @@ static JSValue js_std_file_getByte(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt32(ctx, fgetc(f));
|
return JS_NewInt32(ctx, fgetc(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_file_putByte(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_file_putByte(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
FILE *f = js_std_file_get(ctx, this_val);
|
FILE *f = js_std_file_get(ctx, this_val);
|
||||||
int c;
|
int c;
|
||||||
|
@ -1315,8 +1315,8 @@ static int http_get_status(const char *buf)
|
||||||
return atoi(p);
|
return atoi(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_std_urlGet(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_std_urlGet(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *url;
|
const char *url;
|
||||||
DynBuf cmd_buf;
|
DynBuf cmd_buf;
|
||||||
|
@ -1326,7 +1326,7 @@ static JSValue js_std_urlGet(JSContext *ctx, JSValueConst this_val,
|
||||||
size_t i, len;
|
size_t i, len;
|
||||||
int c, status;
|
int c, status;
|
||||||
JSValue response = JS_UNDEFINED, ret_obj;
|
JSValue response = JS_UNDEFINED, ret_obj;
|
||||||
JSValueConst options_obj;
|
JSValue options_obj;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
BOOL binary_flag, full_flag;
|
BOOL binary_flag, full_flag;
|
||||||
|
|
||||||
|
@ -1571,8 +1571,8 @@ JSModuleDef *js_init_module_std(JSContext *ctx, const char *module_name)
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
/* 'os' object */
|
/* 'os' object */
|
||||||
|
|
||||||
static JSValue js_os_open(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_open(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *filename;
|
const char *filename;
|
||||||
int flags, mode, ret;
|
int flags, mode, ret;
|
||||||
|
@ -1601,8 +1601,8 @@ static JSValue js_os_open(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt32(ctx, ret);
|
return JS_NewInt32(ctx, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_close(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_close(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
if (JS_ToInt32(ctx, &fd, argv[0]))
|
if (JS_ToInt32(ctx, &fd, argv[0]))
|
||||||
|
@ -1611,8 +1611,8 @@ static JSValue js_os_close(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt32(ctx, ret);
|
return JS_NewInt32(ctx, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_seek(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_seek(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int fd, whence;
|
int fd, whence;
|
||||||
int64_t pos, ret;
|
int64_t pos, ret;
|
||||||
|
@ -1634,8 +1634,8 @@ static JSValue js_os_seek(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt64(ctx, ret);
|
return JS_NewInt64(ctx, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_read_write(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_read_write(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv, int magic)
|
int argc, JSValue *argv, int magic)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
uint64_t pos, len;
|
uint64_t pos, len;
|
||||||
|
@ -1661,8 +1661,8 @@ static JSValue js_os_read_write(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt64(ctx, ret);
|
return JS_NewInt64(ctx, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_isatty(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_isatty(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
if (JS_ToInt32(ctx, &fd, argv[0]))
|
if (JS_ToInt32(ctx, &fd, argv[0]))
|
||||||
|
@ -1671,8 +1671,8 @@ static JSValue js_os_isatty(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
static JSValue js_os_ttyGetWinSize(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_ttyGetWinSize(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
|
@ -1697,8 +1697,8 @@ static JSValue js_os_ttyGetWinSize(JSContext *ctx, JSValueConst this_val,
|
||||||
#define __ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
#define __ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
||||||
#define __ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200
|
#define __ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200
|
||||||
|
|
||||||
static JSValue js_os_ttySetRaw(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_ttySetRaw(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
|
@ -1715,8 +1715,8 @@ static JSValue js_os_ttySetRaw(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static JSValue js_os_ttyGetWinSize(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_ttyGetWinSize(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
|
@ -1745,8 +1745,8 @@ static void term_exit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: should add a way to go back to normal mode */
|
/* XXX: should add a way to go back to normal mode */
|
||||||
static JSValue js_os_ttySetRaw(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_ttySetRaw(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
struct termios tty;
|
struct termios tty;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -1775,8 +1775,8 @@ static JSValue js_os_ttySetRaw(JSContext *ctx, JSValueConst this_val,
|
||||||
|
|
||||||
#endif /* !_WIN32 */
|
#endif /* !_WIN32 */
|
||||||
|
|
||||||
static JSValue js_os_remove(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_remove(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *filename;
|
const char *filename;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -1801,8 +1801,8 @@ static JSValue js_os_remove(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt32(ctx, ret);
|
return JS_NewInt32(ctx, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_rename(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_rename(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *oldpath, *newpath;
|
const char *oldpath, *newpath;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -1850,14 +1850,14 @@ static void free_rw_handler(JSRuntime *rt, JSOSRWHandler *rh)
|
||||||
js_free_rt(rt, rh);
|
js_free_rt(rt, rh);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_setReadHandler(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_setReadHandler(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv, int magic)
|
int argc, JSValue *argv, int magic)
|
||||||
{
|
{
|
||||||
JSRuntime *rt = JS_GetRuntime(ctx);
|
JSRuntime *rt = JS_GetRuntime(ctx);
|
||||||
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
||||||
JSOSRWHandler *rh;
|
JSOSRWHandler *rh;
|
||||||
int fd;
|
int fd;
|
||||||
JSValueConst func;
|
JSValue func;
|
||||||
|
|
||||||
if (JS_ToInt32(ctx, &fd, argv[0]))
|
if (JS_ToInt32(ctx, &fd, argv[0]))
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
|
@ -1920,14 +1920,14 @@ static void os_signal_handler(int sig_num)
|
||||||
typedef void (*sighandler_t)(int sig_num);
|
typedef void (*sighandler_t)(int sig_num);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static JSValue js_os_signal(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_signal(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSRuntime *rt = JS_GetRuntime(ctx);
|
JSRuntime *rt = JS_GetRuntime(ctx);
|
||||||
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
||||||
JSOSSignalHandler *sh;
|
JSOSSignalHandler *sh;
|
||||||
uint32_t sig_num;
|
uint32_t sig_num;
|
||||||
JSValueConst func;
|
JSValue func;
|
||||||
sighandler_t handler;
|
sighandler_t handler;
|
||||||
|
|
||||||
if (!is_main_thread(rt))
|
if (!is_main_thread(rt))
|
||||||
|
@ -1968,8 +1968,8 @@ static JSValue js_os_signal(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static JSValue js_os_cputime(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_cputime(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
struct rusage ru;
|
struct rusage ru;
|
||||||
int64_t cputime;
|
int64_t cputime;
|
||||||
|
@ -1982,8 +1982,8 @@ static JSValue js_os_cputime(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static JSValue js_os_now(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_now(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
return JS_NewInt64(ctx, js__hrtime_ns() / 1000);
|
return JS_NewInt64(ctx, js__hrtime_ns() / 1000);
|
||||||
}
|
}
|
||||||
|
@ -2014,7 +2014,7 @@ static void js_os_timer_finalizer(JSRuntime *rt, JSValue val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void js_os_timer_mark(JSRuntime *rt, JSValueConst val,
|
static void js_os_timer_mark(JSRuntime *rt, JSValue val,
|
||||||
JS_MarkFunc *mark_func)
|
JS_MarkFunc *mark_func)
|
||||||
{
|
{
|
||||||
JSOSTimer *th = JS_GetOpaque(val, js_os_timer_class_id);
|
JSOSTimer *th = JS_GetOpaque(val, js_os_timer_class_id);
|
||||||
|
@ -2023,13 +2023,13 @@ static void js_os_timer_mark(JSRuntime *rt, JSValueConst val,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_setTimeout(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_setTimeout(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSRuntime *rt = JS_GetRuntime(ctx);
|
JSRuntime *rt = JS_GetRuntime(ctx);
|
||||||
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
||||||
int64_t delay;
|
int64_t delay;
|
||||||
JSValueConst func;
|
JSValue func;
|
||||||
JSOSTimer *th;
|
JSOSTimer *th;
|
||||||
JSValue obj;
|
JSValue obj;
|
||||||
|
|
||||||
|
@ -2054,8 +2054,8 @@ static JSValue js_os_setTimeout(JSContext *ctx, JSValueConst this_val,
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_clearTimeout(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_clearTimeout(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSOSTimer *th = JS_GetOpaque2(ctx, argv[0], js_os_timer_class_id);
|
JSOSTimer *th = JS_GetOpaque2(ctx, argv[0], js_os_timer_class_id);
|
||||||
if (!th)
|
if (!th)
|
||||||
|
@ -2070,7 +2070,7 @@ static JSClassDef js_os_timer_class = {
|
||||||
.gc_mark = js_os_timer_mark,
|
.gc_mark = js_os_timer_mark,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void call_handler(JSContext *ctx, JSValueConst func)
|
static void call_handler(JSContext *ctx, JSValue func)
|
||||||
{
|
{
|
||||||
JSValue ret, func1;
|
JSValue ret, func1;
|
||||||
/* 'func' might be destroyed when calling itself (if it frees the
|
/* 'func' might be destroyed when calling itself (if it frees the
|
||||||
|
@ -2213,7 +2213,7 @@ static int handle_posted_message(JSRuntime *rt, JSContext *ctx,
|
||||||
/* 'func' might be destroyed when calling itself (if it frees the
|
/* 'func' might be destroyed when calling itself (if it frees the
|
||||||
handler), so must take extra care */
|
handler), so must take extra care */
|
||||||
func = JS_DupValue(ctx, port->on_message_func);
|
func = JS_DupValue(ctx, port->on_message_func);
|
||||||
retval = JS_Call(ctx, func, JS_UNDEFINED, 1, (JSValueConst *)&obj);
|
retval = JS_Call(ctx, func, JS_UNDEFINED, 1, (JSValue *)&obj);
|
||||||
JS_FreeValue(ctx, obj);
|
JS_FreeValue(ctx, obj);
|
||||||
JS_FreeValue(ctx, func);
|
JS_FreeValue(ctx, func);
|
||||||
if (JS_IsException(retval)) {
|
if (JS_IsException(retval)) {
|
||||||
|
@ -2377,8 +2377,8 @@ static JSValue make_string_error(JSContext *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return [cwd, errorcode] */
|
/* return [cwd, errorcode] */
|
||||||
static JSValue js_os_getcwd(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_getcwd(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
int err;
|
int err;
|
||||||
|
@ -2392,8 +2392,8 @@ static JSValue js_os_getcwd(JSContext *ctx, JSValueConst this_val,
|
||||||
return make_string_error(ctx, buf, err);
|
return make_string_error(ctx, buf, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_chdir(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_chdir(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *target;
|
const char *target;
|
||||||
int err;
|
int err;
|
||||||
|
@ -2406,8 +2406,8 @@ static JSValue js_os_chdir(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_NewInt32(ctx, err);
|
return JS_NewInt32(ctx, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_os_mkdir(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_mkdir(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int mode, ret;
|
int mode, ret;
|
||||||
const char *path;
|
const char *path;
|
||||||
|
@ -2432,8 +2432,8 @@ static JSValue js_os_mkdir(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return [array, errorcode] */
|
/* return [array, errorcode] */
|
||||||
static JSValue js_os_readdir(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_readdir(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
DIR *f;
|
DIR *f;
|
||||||
|
@ -2483,8 +2483,8 @@ static int64_t timespec_to_ms(const struct timespec *tv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* return [obj, errcode] */
|
/* return [obj, errcode] */
|
||||||
static JSValue js_os_stat(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_stat(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv, int is_lstat)
|
int argc, JSValue *argv, int is_lstat)
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
int err, res;
|
int err, res;
|
||||||
|
@ -2583,8 +2583,8 @@ static void ms_to_timeval(struct timeval *tv, uint64_t v)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static JSValue js_os_utimes(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_utimes(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
int64_t atime, mtime;
|
int64_t atime, mtime;
|
||||||
|
@ -2617,8 +2617,8 @@ static JSValue js_os_utimes(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sleep(delay_ms) */
|
/* sleep(delay_ms) */
|
||||||
static JSValue js_os_sleep(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_sleep(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int64_t delay;
|
int64_t delay;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -2659,8 +2659,8 @@ static char *realpath(const char *path, char *buf)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* return [path, errorcode] */
|
/* return [path, errorcode] */
|
||||||
static JSValue js_os_realpath(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_realpath(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
char buf[PATH_MAX], *res;
|
char buf[PATH_MAX], *res;
|
||||||
|
@ -2681,8 +2681,8 @@ static JSValue js_os_realpath(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
static JSValue js_os_symlink(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_symlink(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *target, *linkpath;
|
const char *target, *linkpath;
|
||||||
int err;
|
int err;
|
||||||
|
@ -2702,8 +2702,8 @@ static JSValue js_os_symlink(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return [path, errorcode] */
|
/* return [path, errorcode] */
|
||||||
static JSValue js_os_readlink(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_readlink(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
@ -2725,7 +2725,7 @@ static JSValue js_os_readlink(JSContext *ctx, JSValueConst this_val,
|
||||||
return make_string_error(ctx, buf, err);
|
return make_string_error(ctx, buf, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char **build_envp(JSContext *ctx, JSValueConst obj)
|
static char **build_envp(JSContext *ctx, JSValue obj)
|
||||||
{
|
{
|
||||||
uint32_t len, i;
|
uint32_t len, i;
|
||||||
JSPropertyEnum *tab;
|
JSPropertyEnum *tab;
|
||||||
|
@ -2841,10 +2841,10 @@ static int my_execvpe(const char *filename, char **argv, char **envp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exec(args[, options]) -> exitcode */
|
/* exec(args[, options]) -> exitcode */
|
||||||
static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_exec(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSValueConst options, args = argv[0];
|
JSValue options, args = argv[0];
|
||||||
JSValue val, ret_val;
|
JSValue val, ret_val;
|
||||||
const char **exec_argv, *file = NULL, *str, *cwd = NULL;
|
const char **exec_argv, *file = NULL, *str, *cwd = NULL;
|
||||||
char **envp = environ;
|
char **envp = environ;
|
||||||
|
@ -3039,8 +3039,8 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* waitpid(pid, block) -> [pid, status] */
|
/* waitpid(pid, block) -> [pid, status] */
|
||||||
static JSValue js_os_waitpid(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_waitpid(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int pid, status, options, ret;
|
int pid, status, options, ret;
|
||||||
JSValue obj;
|
JSValue obj;
|
||||||
|
@ -3067,8 +3067,8 @@ static JSValue js_os_waitpid(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pipe() -> [read_fd, write_fd] or null if error */
|
/* pipe() -> [read_fd, write_fd] or null if error */
|
||||||
static JSValue js_os_pipe(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_pipe(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int pipe_fds[2], ret;
|
int pipe_fds[2], ret;
|
||||||
JSValue obj;
|
JSValue obj;
|
||||||
|
@ -3087,8 +3087,8 @@ static JSValue js_os_pipe(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* kill(pid, sig) */
|
/* kill(pid, sig) */
|
||||||
static JSValue js_os_kill(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_kill(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int pid, sig, ret;
|
int pid, sig, ret;
|
||||||
|
|
||||||
|
@ -3101,8 +3101,8 @@ static JSValue js_os_kill(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dup(fd) */
|
/* dup(fd) */
|
||||||
static JSValue js_os_dup(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_dup(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
|
|
||||||
|
@ -3113,8 +3113,8 @@ static JSValue js_os_dup(JSContext *ctx, JSValueConst this_val,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dup2(fd) */
|
/* dup2(fd) */
|
||||||
static JSValue js_os_dup2(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_os_dup2(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int fd, fd2, ret;
|
int fd, fd2, ret;
|
||||||
|
|
||||||
|
@ -3322,7 +3322,7 @@ static void *worker_func(void *opaque)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_worker_ctor_internal(JSContext *ctx, JSValueConst new_target,
|
static JSValue js_worker_ctor_internal(JSContext *ctx, JSValue new_target,
|
||||||
JSWorkerMessagePipe *recv_pipe,
|
JSWorkerMessagePipe *recv_pipe,
|
||||||
JSWorkerMessagePipe *send_pipe)
|
JSWorkerMessagePipe *send_pipe)
|
||||||
{
|
{
|
||||||
|
@ -3354,8 +3354,8 @@ static JSValue js_worker_ctor_internal(JSContext *ctx, JSValueConst new_target,
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_worker_ctor(JSContext *ctx, JSValueConst new_target,
|
static JSValue js_worker_ctor(JSContext *ctx, JSValue new_target,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSRuntime *rt = JS_GetRuntime(ctx);
|
JSRuntime *rt = JS_GetRuntime(ctx);
|
||||||
WorkerFuncArgs *args = NULL;
|
WorkerFuncArgs *args = NULL;
|
||||||
|
@ -3438,8 +3438,8 @@ static JSValue js_worker_ctor(JSContext *ctx, JSValueConst new_target,
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_worker_postMessage(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_worker_postMessage(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSWorkerData *worker = JS_GetOpaque2(ctx, this_val, js_worker_class_id);
|
JSWorkerData *worker = JS_GetOpaque2(ctx, this_val, js_worker_class_id);
|
||||||
JSWorkerMessagePipe *ps;
|
JSWorkerMessagePipe *ps;
|
||||||
|
@ -3514,8 +3514,8 @@ static JSValue js_worker_postMessage(JSContext *ctx, JSValueConst this_val,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_worker_set_onmessage(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_worker_set_onmessage(JSContext *ctx, JSValue this_val,
|
||||||
JSValueConst func)
|
JSValue func)
|
||||||
{
|
{
|
||||||
JSRuntime *rt = JS_GetRuntime(ctx);
|
JSRuntime *rt = JS_GetRuntime(ctx);
|
||||||
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
|
||||||
|
@ -3549,7 +3549,7 @@ static JSValue js_worker_set_onmessage(JSContext *ctx, JSValueConst this_val,
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_worker_get_onmessage(JSContext *ctx, JSValueConst this_val)
|
static JSValue js_worker_get_onmessage(JSContext *ctx, JSValue this_val)
|
||||||
{
|
{
|
||||||
JSWorkerData *worker = JS_GetOpaque2(ctx, this_val, js_worker_class_id);
|
JSWorkerData *worker = JS_GetOpaque2(ctx, this_val, js_worker_class_id);
|
||||||
JSWorkerMessageHandler *port;
|
JSWorkerMessageHandler *port;
|
||||||
|
@ -3738,8 +3738,8 @@ JSModuleDef *js_init_module_os(JSContext *ctx, const char *module_name)
|
||||||
|
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
|
|
||||||
static JSValue js_print(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_print(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
@ -3850,7 +3850,7 @@ void js_std_free_handlers(JSRuntime *rt)
|
||||||
JS_SetRuntimeOpaque(rt, NULL); /* fail safe */
|
JS_SetRuntimeOpaque(rt, NULL); /* fail safe */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void js_dump_obj(JSContext *ctx, FILE *f, JSValueConst val)
|
static void js_dump_obj(JSContext *ctx, FILE *f, JSValue val)
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
|
@ -3863,7 +3863,7 @@ static void js_dump_obj(JSContext *ctx, FILE *f, JSValueConst val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void js_std_dump_error1(JSContext *ctx, JSValueConst exception_val)
|
static void js_std_dump_error1(JSContext *ctx, JSValue exception_val)
|
||||||
{
|
{
|
||||||
JSValue val;
|
JSValue val;
|
||||||
BOOL is_error;
|
BOOL is_error;
|
||||||
|
@ -3888,8 +3888,8 @@ void js_std_dump_error(JSContext *ctx)
|
||||||
JS_FreeValue(ctx, exception_val);
|
JS_FreeValue(ctx, exception_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void js_std_promise_rejection_tracker(JSContext *ctx, JSValueConst promise,
|
void js_std_promise_rejection_tracker(JSContext *ctx, JSValue promise,
|
||||||
JSValueConst reason,
|
JSValue reason,
|
||||||
BOOL is_handled, void *opaque)
|
BOOL is_handled, void *opaque)
|
||||||
{
|
{
|
||||||
if (!is_handled) {
|
if (!is_handled) {
|
||||||
|
|
|
@ -41,14 +41,14 @@ void js_std_init_handlers(JSRuntime *rt);
|
||||||
void js_std_free_handlers(JSRuntime *rt);
|
void js_std_free_handlers(JSRuntime *rt);
|
||||||
void js_std_dump_error(JSContext *ctx);
|
void js_std_dump_error(JSContext *ctx);
|
||||||
uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename);
|
uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename);
|
||||||
int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
|
int js_module_set_import_meta(JSContext *ctx, JSValue func_val,
|
||||||
JS_BOOL use_realpath, JS_BOOL is_main);
|
JS_BOOL use_realpath, JS_BOOL is_main);
|
||||||
JSModuleDef *js_module_loader(JSContext *ctx,
|
JSModuleDef *js_module_loader(JSContext *ctx,
|
||||||
const char *module_name, void *opaque);
|
const char *module_name, void *opaque);
|
||||||
void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len,
|
void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len,
|
||||||
int flags);
|
int flags);
|
||||||
void js_std_promise_rejection_tracker(JSContext *ctx, JSValueConst promise,
|
void js_std_promise_rejection_tracker(JSContext *ctx, JSValue promise,
|
||||||
JSValueConst reason,
|
JSValue reason,
|
||||||
JS_BOOL is_handled, void *opaque);
|
JS_BOOL is_handled, void *opaque);
|
||||||
void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt));
|
void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt));
|
||||||
|
|
||||||
|
|
238
quickjs.h
238
quickjs.h
|
@ -265,9 +265,9 @@ static inline JS_BOOL JS_VALUE_IS_NAN(JSValue v)
|
||||||
/* don't include the stack frames before this eval in the Error() backtraces */
|
/* don't include the stack frames before this eval in the Error() backtraces */
|
||||||
#define JS_EVAL_FLAG_BACKTRACE_BARRIER (1 << 6)
|
#define JS_EVAL_FLAG_BACKTRACE_BARRIER (1 << 6)
|
||||||
|
|
||||||
typedef JSValue JSCFunction(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv);
|
typedef JSValue JSCFunction(JSContext *ctx, JSValue this_val, int argc, JSValue *argv);
|
||||||
typedef JSValue JSCFunctionMagic(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic);
|
typedef JSValue JSCFunctionMagic(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, int magic);
|
||||||
typedef JSValue JSCFunctionData(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic, JSValue *func_data);
|
typedef JSValue JSCFunctionData(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, int magic, JSValue *func_data);
|
||||||
|
|
||||||
typedef struct JSMallocState {
|
typedef struct JSMallocState {
|
||||||
size_t malloc_count;
|
size_t malloc_count;
|
||||||
|
@ -300,9 +300,9 @@ JS_EXTERN void JS_FreeRuntime(JSRuntime *rt);
|
||||||
JS_EXTERN void *JS_GetRuntimeOpaque(JSRuntime *rt);
|
JS_EXTERN void *JS_GetRuntimeOpaque(JSRuntime *rt);
|
||||||
JS_EXTERN void JS_SetRuntimeOpaque(JSRuntime *rt, void *opaque);
|
JS_EXTERN void JS_SetRuntimeOpaque(JSRuntime *rt, void *opaque);
|
||||||
typedef void JS_MarkFunc(JSRuntime *rt, JSGCObjectHeader *gp);
|
typedef void JS_MarkFunc(JSRuntime *rt, JSGCObjectHeader *gp);
|
||||||
JS_EXTERN void JS_MarkValue(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func);
|
JS_EXTERN void JS_MarkValue(JSRuntime *rt, JSValue val, JS_MarkFunc *mark_func);
|
||||||
JS_EXTERN void JS_RunGC(JSRuntime *rt);
|
JS_EXTERN void JS_RunGC(JSRuntime *rt);
|
||||||
JS_EXTERN JS_BOOL JS_IsLiveObject(JSRuntime *rt, JSValueConst obj);
|
JS_EXTERN JS_BOOL JS_IsLiveObject(JSRuntime *rt, JSValue obj);
|
||||||
|
|
||||||
JS_EXTERN JSContext *JS_NewContext(JSRuntime *rt);
|
JS_EXTERN JSContext *JS_NewContext(JSRuntime *rt);
|
||||||
JS_EXTERN void JS_FreeContext(JSContext *s);
|
JS_EXTERN void JS_FreeContext(JSContext *s);
|
||||||
|
@ -331,8 +331,8 @@ JS_EXTERN void JS_AddIntrinsicWeakRef(JSContext *ctx);
|
||||||
JS_EXTERN void JS_AddPerformance(JSContext *ctx);
|
JS_EXTERN void JS_AddPerformance(JSContext *ctx);
|
||||||
|
|
||||||
/* Only used for running 262 tests. TODO(saghul) add build time flag. */
|
/* Only used for running 262 tests. TODO(saghul) add build time flag. */
|
||||||
JS_EXTERN JSValue js_string_codePointRange(JSContext *ctx, JSValueConst this_val,
|
JS_EXTERN JSValue js_string_codePointRange(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv);
|
int argc, JSValue *argv);
|
||||||
|
|
||||||
JS_EXTERN void *js_malloc_rt(JSRuntime *rt, size_t size);
|
JS_EXTERN void *js_malloc_rt(JSRuntime *rt, size_t size);
|
||||||
JS_EXTERN void js_free_rt(JSRuntime *rt, void *ptr);
|
JS_EXTERN void js_free_rt(JSRuntime *rt, void *ptr);
|
||||||
|
@ -380,7 +380,7 @@ JS_EXTERN void JS_FreeAtomRT(JSRuntime *rt, JSAtom v);
|
||||||
JS_EXTERN JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom);
|
JS_EXTERN JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom);
|
||||||
JS_EXTERN JSValue JS_AtomToString(JSContext *ctx, JSAtom atom);
|
JS_EXTERN JSValue JS_AtomToString(JSContext *ctx, JSAtom atom);
|
||||||
JS_EXTERN const char *JS_AtomToCString(JSContext *ctx, JSAtom atom);
|
JS_EXTERN const char *JS_AtomToCString(JSContext *ctx, JSAtom atom);
|
||||||
JS_EXTERN JSAtom JS_ValueToAtom(JSContext *ctx, JSValueConst val);
|
JS_EXTERN JSAtom JS_ValueToAtom(JSContext *ctx, JSValue val);
|
||||||
|
|
||||||
/* object class support */
|
/* object class support */
|
||||||
|
|
||||||
|
@ -401,37 +401,37 @@ typedef struct JSClassExoticMethods {
|
||||||
FALSE if the property does not exists, TRUE if it exists. If 1 is
|
FALSE if the property does not exists, TRUE if it exists. If 1 is
|
||||||
returned, the property descriptor 'desc' is filled if != NULL. */
|
returned, the property descriptor 'desc' is filled if != NULL. */
|
||||||
int (*get_own_property)(JSContext *ctx, JSPropertyDescriptor *desc,
|
int (*get_own_property)(JSContext *ctx, JSPropertyDescriptor *desc,
|
||||||
JSValueConst obj, JSAtom prop);
|
JSValue obj, JSAtom prop);
|
||||||
/* '*ptab' should hold the '*plen' property keys. Return 0 if OK,
|
/* '*ptab' should hold the '*plen' property keys. Return 0 if OK,
|
||||||
-1 if exception. The 'is_enumerable' field is ignored.
|
-1 if exception. The 'is_enumerable' field is ignored.
|
||||||
*/
|
*/
|
||||||
int (*get_own_property_names)(JSContext *ctx, JSPropertyEnum **ptab,
|
int (*get_own_property_names)(JSContext *ctx, JSPropertyEnum **ptab,
|
||||||
uint32_t *plen,
|
uint32_t *plen,
|
||||||
JSValueConst obj);
|
JSValue obj);
|
||||||
/* return < 0 if exception, or TRUE/FALSE */
|
/* return < 0 if exception, or TRUE/FALSE */
|
||||||
int (*delete_property)(JSContext *ctx, JSValueConst obj, JSAtom prop);
|
int (*delete_property)(JSContext *ctx, JSValue obj, JSAtom prop);
|
||||||
/* return < 0 if exception or TRUE/FALSE */
|
/* return < 0 if exception or TRUE/FALSE */
|
||||||
int (*define_own_property)(JSContext *ctx, JSValueConst this_obj,
|
int (*define_own_property)(JSContext *ctx, JSValue this_obj,
|
||||||
JSAtom prop, JSValueConst val,
|
JSAtom prop, JSValue val,
|
||||||
JSValueConst getter, JSValueConst setter,
|
JSValue getter, JSValue setter,
|
||||||
int flags);
|
int flags);
|
||||||
/* The following methods can be emulated with the previous ones,
|
/* The following methods can be emulated with the previous ones,
|
||||||
so they are usually not needed */
|
so they are usually not needed */
|
||||||
/* return < 0 if exception or TRUE/FALSE */
|
/* return < 0 if exception or TRUE/FALSE */
|
||||||
int (*has_property)(JSContext *ctx, JSValueConst obj, JSAtom atom);
|
int (*has_property)(JSContext *ctx, JSValue obj, JSAtom atom);
|
||||||
JSValue (*get_property)(JSContext *ctx, JSValueConst obj, JSAtom atom,
|
JSValue (*get_property)(JSContext *ctx, JSValue obj, JSAtom atom,
|
||||||
JSValueConst receiver);
|
JSValue receiver);
|
||||||
/* return < 0 if exception or TRUE/FALSE */
|
/* return < 0 if exception or TRUE/FALSE */
|
||||||
int (*set_property)(JSContext *ctx, JSValueConst obj, JSAtom atom,
|
int (*set_property)(JSContext *ctx, JSValue obj, JSAtom atom,
|
||||||
JSValueConst value, JSValueConst receiver, int flags);
|
JSValue value, JSValue receiver, int flags);
|
||||||
} JSClassExoticMethods;
|
} JSClassExoticMethods;
|
||||||
|
|
||||||
typedef void JSClassFinalizer(JSRuntime *rt, JSValue val);
|
typedef void JSClassFinalizer(JSRuntime *rt, JSValue val);
|
||||||
typedef void JSClassGCMark(JSRuntime *rt, JSValueConst val,
|
typedef void JSClassGCMark(JSRuntime *rt, JSValue val,
|
||||||
JS_MarkFunc *mark_func);
|
JS_MarkFunc *mark_func);
|
||||||
#define JS_CALL_FLAG_CONSTRUCTOR (1 << 0)
|
#define JS_CALL_FLAG_CONSTRUCTOR (1 << 0)
|
||||||
typedef JSValue JSClassCall(JSContext *ctx, JSValueConst func_obj,
|
typedef JSValue JSClassCall(JSContext *ctx, JSValue func_obj,
|
||||||
JSValueConst this_val, int argc, JSValueConst *argv,
|
JSValue this_val, int argc, JSValue *argv,
|
||||||
int flags);
|
int flags);
|
||||||
|
|
||||||
typedef struct JSClassDef {
|
typedef struct JSClassDef {
|
||||||
|
@ -496,61 +496,61 @@ JS_EXTERN JSValue JS_NewFloat64(JSContext *ctx, double d);
|
||||||
JS_EXTERN JSValue JS_NewBigInt64(JSContext *ctx, int64_t v);
|
JS_EXTERN JSValue JS_NewBigInt64(JSContext *ctx, int64_t v);
|
||||||
JS_EXTERN JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v);
|
JS_EXTERN JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v);
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsNumber(JSValueConst v)
|
static inline JS_BOOL JS_IsNumber(JSValue v)
|
||||||
{
|
{
|
||||||
int tag = JS_VALUE_GET_TAG(v);
|
int tag = JS_VALUE_GET_TAG(v);
|
||||||
return tag == JS_TAG_INT || JS_TAG_IS_FLOAT64(tag);
|
return tag == JS_TAG_INT || JS_TAG_IS_FLOAT64(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsBigInt(JSContext *ctx, JSValueConst v)
|
static inline JS_BOOL JS_IsBigInt(JSContext *ctx, JSValue v)
|
||||||
{
|
{
|
||||||
int tag = JS_VALUE_GET_TAG(v);
|
int tag = JS_VALUE_GET_TAG(v);
|
||||||
return tag == JS_TAG_BIG_INT;
|
return tag == JS_TAG_BIG_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsBool(JSValueConst v)
|
static inline JS_BOOL JS_IsBool(JSValue v)
|
||||||
{
|
{
|
||||||
return JS_VALUE_GET_TAG(v) == JS_TAG_BOOL;
|
return JS_VALUE_GET_TAG(v) == JS_TAG_BOOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsNull(JSValueConst v)
|
static inline JS_BOOL JS_IsNull(JSValue v)
|
||||||
{
|
{
|
||||||
return JS_VALUE_GET_TAG(v) == JS_TAG_NULL;
|
return JS_VALUE_GET_TAG(v) == JS_TAG_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsUndefined(JSValueConst v)
|
static inline JS_BOOL JS_IsUndefined(JSValue v)
|
||||||
{
|
{
|
||||||
return JS_VALUE_GET_TAG(v) == JS_TAG_UNDEFINED;
|
return JS_VALUE_GET_TAG(v) == JS_TAG_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsException(JSValueConst v)
|
static inline JS_BOOL JS_IsException(JSValue v)
|
||||||
{
|
{
|
||||||
return js_unlikely(JS_VALUE_GET_TAG(v) == JS_TAG_EXCEPTION);
|
return js_unlikely(JS_VALUE_GET_TAG(v) == JS_TAG_EXCEPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsUninitialized(JSValueConst v)
|
static inline JS_BOOL JS_IsUninitialized(JSValue v)
|
||||||
{
|
{
|
||||||
return js_unlikely(JS_VALUE_GET_TAG(v) == JS_TAG_UNINITIALIZED);
|
return js_unlikely(JS_VALUE_GET_TAG(v) == JS_TAG_UNINITIALIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsString(JSValueConst v)
|
static inline JS_BOOL JS_IsString(JSValue v)
|
||||||
{
|
{
|
||||||
return JS_VALUE_GET_TAG(v) == JS_TAG_STRING;
|
return JS_VALUE_GET_TAG(v) == JS_TAG_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsSymbol(JSValueConst v)
|
static inline JS_BOOL JS_IsSymbol(JSValue v)
|
||||||
{
|
{
|
||||||
return JS_VALUE_GET_TAG(v) == JS_TAG_SYMBOL;
|
return JS_VALUE_GET_TAG(v) == JS_TAG_SYMBOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JS_BOOL JS_IsObject(JSValueConst v)
|
static inline JS_BOOL JS_IsObject(JSValue v)
|
||||||
{
|
{
|
||||||
return JS_VALUE_GET_TAG(v) == JS_TAG_OBJECT;
|
return JS_VALUE_GET_TAG(v) == JS_TAG_OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_EXTERN JSValue JS_Throw(JSContext *ctx, JSValue obj);
|
JS_EXTERN JSValue JS_Throw(JSContext *ctx, JSValue obj);
|
||||||
JS_EXTERN JSValue JS_GetException(JSContext *ctx);
|
JS_EXTERN JSValue JS_GetException(JSContext *ctx);
|
||||||
JS_EXTERN JS_BOOL JS_IsError(JSContext *ctx, JSValueConst val);
|
JS_EXTERN JS_BOOL JS_IsError(JSContext *ctx, JSValue val);
|
||||||
JS_EXTERN void JS_ResetUncatchableError(JSContext *ctx);
|
JS_EXTERN void JS_ResetUncatchableError(JSContext *ctx);
|
||||||
JS_EXTERN JSValue JS_NewError(JSContext *ctx);
|
JS_EXTERN JSValue JS_NewError(JSContext *ctx);
|
||||||
JS_EXTERN JSValue __js_printf_like(2, 3) JS_ThrowSyntaxError(JSContext *ctx, const char *fmt, ...);
|
JS_EXTERN JSValue __js_printf_like(2, 3) JS_ThrowSyntaxError(JSContext *ctx, const char *fmt, ...);
|
||||||
|
@ -581,7 +581,7 @@ static inline void JS_FreeValueRT(JSRuntime *rt, JSValue v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JSValue JS_DupValue(JSContext *ctx, JSValueConst v)
|
static inline JSValue JS_DupValue(JSContext *ctx, JSValue v)
|
||||||
{
|
{
|
||||||
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
||||||
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
|
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
|
||||||
|
@ -590,7 +590,7 @@ static inline JSValue JS_DupValue(JSContext *ctx, JSValueConst v)
|
||||||
return (JSValue)v;
|
return (JSValue)v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValueConst v)
|
static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValue v)
|
||||||
{
|
{
|
||||||
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
||||||
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
|
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
|
||||||
|
@ -599,83 +599,83 @@ static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValueConst v)
|
||||||
return (JSValue)v;
|
return (JSValue)v;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_EXTERN int JS_ToBool(JSContext *ctx, JSValueConst val); /* return -1 for JS_EXCEPTION */
|
JS_EXTERN int JS_ToBool(JSContext *ctx, JSValue val); /* return -1 for JS_EXCEPTION */
|
||||||
JS_EXTERN int JS_ToInt32(JSContext *ctx, int32_t *pres, JSValueConst val);
|
JS_EXTERN int JS_ToInt32(JSContext *ctx, int32_t *pres, JSValue val);
|
||||||
static inline int JS_ToUint32(JSContext *ctx, uint32_t *pres, JSValueConst val)
|
static inline int JS_ToUint32(JSContext *ctx, uint32_t *pres, JSValue val)
|
||||||
{
|
{
|
||||||
return JS_ToInt32(ctx, (int32_t*)pres, val);
|
return JS_ToInt32(ctx, (int32_t*)pres, val);
|
||||||
}
|
}
|
||||||
JS_EXTERN int JS_ToInt64(JSContext *ctx, int64_t *pres, JSValueConst val);
|
JS_EXTERN int JS_ToInt64(JSContext *ctx, int64_t *pres, JSValue val);
|
||||||
JS_EXTERN int JS_ToIndex(JSContext *ctx, uint64_t *plen, JSValueConst val);
|
JS_EXTERN int JS_ToIndex(JSContext *ctx, uint64_t *plen, JSValue val);
|
||||||
JS_EXTERN int JS_ToFloat64(JSContext *ctx, double *pres, JSValueConst val);
|
JS_EXTERN int JS_ToFloat64(JSContext *ctx, double *pres, JSValue val);
|
||||||
/* return an exception if 'val' is a Number */
|
/* return an exception if 'val' is a Number */
|
||||||
JS_EXTERN int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValueConst val);
|
JS_EXTERN int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValue val);
|
||||||
/* same as JS_ToInt64() but allow BigInt */
|
/* same as JS_ToInt64() but allow BigInt */
|
||||||
JS_EXTERN int JS_ToInt64Ext(JSContext *ctx, int64_t *pres, JSValueConst val);
|
JS_EXTERN int JS_ToInt64Ext(JSContext *ctx, int64_t *pres, JSValue val);
|
||||||
|
|
||||||
JS_EXTERN JSValue JS_NewStringLen(JSContext *ctx, const char *str1, size_t len1);
|
JS_EXTERN JSValue JS_NewStringLen(JSContext *ctx, const char *str1, size_t len1);
|
||||||
JS_EXTERN JSValue JS_NewString(JSContext *ctx, const char *str);
|
JS_EXTERN JSValue JS_NewString(JSContext *ctx, const char *str);
|
||||||
JS_EXTERN JSValue JS_NewAtomString(JSContext *ctx, const char *str);
|
JS_EXTERN JSValue JS_NewAtomString(JSContext *ctx, const char *str);
|
||||||
JS_EXTERN JSValue JS_ToString(JSContext *ctx, JSValueConst val);
|
JS_EXTERN JSValue JS_ToString(JSContext *ctx, JSValue val);
|
||||||
JS_EXTERN JSValue JS_ToPropertyKey(JSContext *ctx, JSValueConst val);
|
JS_EXTERN JSValue JS_ToPropertyKey(JSContext *ctx, JSValue val);
|
||||||
JS_EXTERN const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValueConst val1, JS_BOOL cesu8);
|
JS_EXTERN const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValue val1, JS_BOOL cesu8);
|
||||||
static inline const char *JS_ToCStringLen(JSContext *ctx, size_t *plen, JSValueConst val1)
|
static inline const char *JS_ToCStringLen(JSContext *ctx, size_t *plen, JSValue val1)
|
||||||
{
|
{
|
||||||
return JS_ToCStringLen2(ctx, plen, val1, 0);
|
return JS_ToCStringLen2(ctx, plen, val1, 0);
|
||||||
}
|
}
|
||||||
static inline const char *JS_ToCString(JSContext *ctx, JSValueConst val1)
|
static inline const char *JS_ToCString(JSContext *ctx, JSValue val1)
|
||||||
{
|
{
|
||||||
return JS_ToCStringLen2(ctx, NULL, val1, 0);
|
return JS_ToCStringLen2(ctx, NULL, val1, 0);
|
||||||
}
|
}
|
||||||
JS_EXTERN void JS_FreeCString(JSContext *ctx, const char *ptr);
|
JS_EXTERN void JS_FreeCString(JSContext *ctx, const char *ptr);
|
||||||
|
|
||||||
JS_EXTERN JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValueConst proto, JSClassID class_id);
|
JS_EXTERN JSValue JS_NewObjectProtoClass(JSContext *ctx, JSValue proto, JSClassID class_id);
|
||||||
JS_EXTERN JSValue JS_NewObjectClass(JSContext *ctx, int class_id);
|
JS_EXTERN JSValue JS_NewObjectClass(JSContext *ctx, int class_id);
|
||||||
JS_EXTERN JSValue JS_NewObjectProto(JSContext *ctx, JSValueConst proto);
|
JS_EXTERN JSValue JS_NewObjectProto(JSContext *ctx, JSValue proto);
|
||||||
JS_EXTERN JSValue JS_NewObject(JSContext *ctx);
|
JS_EXTERN JSValue JS_NewObject(JSContext *ctx);
|
||||||
|
|
||||||
JS_EXTERN JS_BOOL JS_IsFunction(JSContext* ctx, JSValueConst val);
|
JS_EXTERN JS_BOOL JS_IsFunction(JSContext* ctx, JSValue val);
|
||||||
JS_EXTERN JS_BOOL JS_IsConstructor(JSContext* ctx, JSValueConst val);
|
JS_EXTERN JS_BOOL JS_IsConstructor(JSContext* ctx, JSValue val);
|
||||||
JS_EXTERN JS_BOOL JS_SetConstructorBit(JSContext *ctx, JSValueConst func_obj, JS_BOOL val);
|
JS_EXTERN JS_BOOL JS_SetConstructorBit(JSContext *ctx, JSValue func_obj, JS_BOOL val);
|
||||||
|
|
||||||
JS_EXTERN JSValue JS_NewArray(JSContext *ctx);
|
JS_EXTERN JSValue JS_NewArray(JSContext *ctx);
|
||||||
JS_EXTERN int JS_IsArray(JSContext *ctx, JSValueConst val);
|
JS_EXTERN int JS_IsArray(JSContext *ctx, JSValue val);
|
||||||
|
|
||||||
JS_EXTERN JSValue JS_NewDate(JSContext *ctx, double epoch_ms);
|
JS_EXTERN JSValue JS_NewDate(JSContext *ctx, double epoch_ms);
|
||||||
|
|
||||||
JS_EXTERN JSValue JS_GetPropertyInternal(JSContext *ctx, JSValueConst obj,
|
JS_EXTERN JSValue JS_GetPropertyInternal(JSContext *ctx, JSValue obj,
|
||||||
JSAtom prop, JSValueConst receiver,
|
JSAtom prop, JSValue receiver,
|
||||||
JS_BOOL throw_ref_error);
|
JS_BOOL throw_ref_error);
|
||||||
static js_force_inline JSValue JS_GetProperty(JSContext *ctx, JSValueConst this_obj,
|
static js_force_inline JSValue JS_GetProperty(JSContext *ctx, JSValue this_obj,
|
||||||
JSAtom prop)
|
JSAtom prop)
|
||||||
{
|
{
|
||||||
return JS_GetPropertyInternal(ctx, this_obj, prop, this_obj, 0);
|
return JS_GetPropertyInternal(ctx, this_obj, prop, this_obj, 0);
|
||||||
}
|
}
|
||||||
JS_EXTERN JSValue JS_GetPropertyStr(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN JSValue JS_GetPropertyStr(JSContext *ctx, JSValue this_obj,
|
||||||
const char *prop);
|
const char *prop);
|
||||||
JS_EXTERN JSValue JS_GetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN JSValue JS_GetPropertyUint32(JSContext *ctx, JSValue this_obj,
|
||||||
uint32_t idx);
|
uint32_t idx);
|
||||||
|
|
||||||
int JS_SetPropertyInternal(JSContext *ctx, JSValueConst this_obj,
|
int JS_SetPropertyInternal(JSContext *ctx, JSValue this_obj,
|
||||||
JSAtom prop, JSValue val,
|
JSAtom prop, JSValue val,
|
||||||
int flags);
|
int flags);
|
||||||
static inline int JS_SetProperty(JSContext *ctx, JSValueConst this_obj,
|
static inline int JS_SetProperty(JSContext *ctx, JSValue this_obj,
|
||||||
JSAtom prop, JSValue val)
|
JSAtom prop, JSValue val)
|
||||||
{
|
{
|
||||||
return JS_SetPropertyInternal(ctx, this_obj, prop, val, JS_PROP_THROW);
|
return JS_SetPropertyInternal(ctx, this_obj, prop, val, JS_PROP_THROW);
|
||||||
}
|
}
|
||||||
JS_EXTERN int JS_SetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN int JS_SetPropertyUint32(JSContext *ctx, JSValue this_obj,
|
||||||
uint32_t idx, JSValue val);
|
uint32_t idx, JSValue val);
|
||||||
JS_EXTERN int JS_SetPropertyInt64(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN int JS_SetPropertyInt64(JSContext *ctx, JSValue this_obj,
|
||||||
int64_t idx, JSValue val);
|
int64_t idx, JSValue val);
|
||||||
JS_EXTERN int JS_SetPropertyStr(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN int JS_SetPropertyStr(JSContext *ctx, JSValue this_obj,
|
||||||
const char *prop, JSValue val);
|
const char *prop, JSValue val);
|
||||||
JS_EXTERN int JS_HasProperty(JSContext *ctx, JSValueConst this_obj, JSAtom prop);
|
JS_EXTERN int JS_HasProperty(JSContext *ctx, JSValue this_obj, JSAtom prop);
|
||||||
JS_EXTERN int JS_IsExtensible(JSContext *ctx, JSValueConst obj);
|
JS_EXTERN int JS_IsExtensible(JSContext *ctx, JSValue obj);
|
||||||
JS_EXTERN int JS_PreventExtensions(JSContext *ctx, JSValueConst obj);
|
JS_EXTERN int JS_PreventExtensions(JSContext *ctx, JSValue obj);
|
||||||
JS_EXTERN int JS_DeleteProperty(JSContext *ctx, JSValueConst obj, JSAtom prop, int flags);
|
JS_EXTERN int JS_DeleteProperty(JSContext *ctx, JSValue obj, JSAtom prop, int flags);
|
||||||
JS_EXTERN int JS_SetPrototype(JSContext *ctx, JSValueConst obj, JSValueConst proto_val);
|
JS_EXTERN int JS_SetPrototype(JSContext *ctx, JSValue obj, JSValue proto_val);
|
||||||
JS_EXTERN JSValue JS_GetPrototype(JSContext *ctx, JSValueConst val);
|
JS_EXTERN JSValue JS_GetPrototype(JSContext *ctx, JSValue val);
|
||||||
|
|
||||||
#define JS_GPN_STRING_MASK (1 << 0)
|
#define JS_GPN_STRING_MASK (1 << 0)
|
||||||
#define JS_GPN_SYMBOL_MASK (1 << 1)
|
#define JS_GPN_SYMBOL_MASK (1 << 1)
|
||||||
|
@ -686,61 +686,61 @@ JS_EXTERN JSValue JS_GetPrototype(JSContext *ctx, JSValueConst val);
|
||||||
#define JS_GPN_SET_ENUM (1 << 5)
|
#define JS_GPN_SET_ENUM (1 << 5)
|
||||||
|
|
||||||
JS_EXTERN int JS_GetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab,
|
JS_EXTERN int JS_GetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab,
|
||||||
uint32_t *plen, JSValueConst obj, int flags);
|
uint32_t *plen, JSValue obj, int flags);
|
||||||
JS_EXTERN int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc,
|
JS_EXTERN int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc,
|
||||||
JSValueConst obj, JSAtom prop);
|
JSValue obj, JSAtom prop);
|
||||||
|
|
||||||
JS_EXTERN JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj,
|
JS_EXTERN JSValue JS_Call(JSContext *ctx, JSValue func_obj, JSValue this_obj,
|
||||||
int argc, JSValueConst *argv);
|
int argc, JSValue *argv);
|
||||||
JS_EXTERN JSValue JS_Invoke(JSContext *ctx, JSValueConst this_val, JSAtom atom,
|
JS_EXTERN JSValue JS_Invoke(JSContext *ctx, JSValue this_val, JSAtom atom,
|
||||||
int argc, JSValueConst *argv);
|
int argc, JSValue *argv);
|
||||||
JS_EXTERN JSValue JS_CallConstructor(JSContext *ctx, JSValueConst func_obj,
|
JS_EXTERN JSValue JS_CallConstructor(JSContext *ctx, JSValue func_obj,
|
||||||
int argc, JSValueConst *argv);
|
int argc, JSValue *argv);
|
||||||
JS_EXTERN JSValue JS_CallConstructor2(JSContext *ctx, JSValueConst func_obj,
|
JS_EXTERN JSValue JS_CallConstructor2(JSContext *ctx, JSValue func_obj,
|
||||||
JSValueConst new_target,
|
JSValue new_target,
|
||||||
int argc, JSValueConst *argv);
|
int argc, JSValue *argv);
|
||||||
JS_EXTERN JS_BOOL JS_DetectModule(const char *input, size_t input_len);
|
JS_EXTERN JS_BOOL JS_DetectModule(const char *input, size_t input_len);
|
||||||
/* 'input' must be zero terminated i.e. input[input_len] = '\0'. */
|
/* 'input' must be zero terminated i.e. input[input_len] = '\0'. */
|
||||||
JS_EXTERN JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len,
|
JS_EXTERN JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len,
|
||||||
const char *filename, int eval_flags);
|
const char *filename, int eval_flags);
|
||||||
/* same as JS_Eval() but with an explicit 'this_obj' parameter */
|
/* same as JS_Eval() but with an explicit 'this_obj' parameter */
|
||||||
JS_EXTERN JSValue JS_EvalThis(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN JSValue JS_EvalThis(JSContext *ctx, JSValue this_obj,
|
||||||
const char *input, size_t input_len,
|
const char *input, size_t input_len,
|
||||||
const char *filename, int eval_flags);
|
const char *filename, int eval_flags);
|
||||||
JS_EXTERN JSValue JS_GetGlobalObject(JSContext *ctx);
|
JS_EXTERN JSValue JS_GetGlobalObject(JSContext *ctx);
|
||||||
JS_EXTERN int JS_IsInstanceOf(JSContext *ctx, JSValueConst val, JSValueConst obj);
|
JS_EXTERN int JS_IsInstanceOf(JSContext *ctx, JSValue val, JSValue obj);
|
||||||
JS_EXTERN int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN int JS_DefineProperty(JSContext *ctx, JSValue this_obj,
|
||||||
JSAtom prop, JSValueConst val,
|
JSAtom prop, JSValue val,
|
||||||
JSValueConst getter, JSValueConst setter, int flags);
|
JSValue getter, JSValue setter, int flags);
|
||||||
JS_EXTERN int JS_DefinePropertyValue(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN int JS_DefinePropertyValue(JSContext *ctx, JSValue this_obj,
|
||||||
JSAtom prop, JSValue val, int flags);
|
JSAtom prop, JSValue val, int flags);
|
||||||
JS_EXTERN int JS_DefinePropertyValueUint32(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN int JS_DefinePropertyValueUint32(JSContext *ctx, JSValue this_obj,
|
||||||
uint32_t idx, JSValue val, int flags);
|
uint32_t idx, JSValue val, int flags);
|
||||||
JS_EXTERN int JS_DefinePropertyValueStr(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN int JS_DefinePropertyValueStr(JSContext *ctx, JSValue this_obj,
|
||||||
const char *prop, JSValue val, int flags);
|
const char *prop, JSValue val, int flags);
|
||||||
JS_EXTERN int JS_DefinePropertyGetSet(JSContext *ctx, JSValueConst this_obj,
|
JS_EXTERN int JS_DefinePropertyGetSet(JSContext *ctx, JSValue this_obj,
|
||||||
JSAtom prop, JSValue getter, JSValue setter,
|
JSAtom prop, JSValue getter, JSValue setter,
|
||||||
int flags);
|
int flags);
|
||||||
JS_EXTERN void JS_SetOpaque(JSValue obj, void *opaque);
|
JS_EXTERN void JS_SetOpaque(JSValue obj, void *opaque);
|
||||||
JS_EXTERN void *JS_GetOpaque(JSValueConst obj, JSClassID class_id);
|
JS_EXTERN void *JS_GetOpaque(JSValue obj, JSClassID class_id);
|
||||||
JS_EXTERN void *JS_GetOpaque2(JSContext *ctx, JSValueConst obj, JSClassID class_id);
|
JS_EXTERN void *JS_GetOpaque2(JSContext *ctx, JSValue obj, JSClassID class_id);
|
||||||
JS_EXTERN void *JS_GetAnyOpaque(JSValueConst obj, JSClassID *class_id);
|
JS_EXTERN void *JS_GetAnyOpaque(JSValue obj, JSClassID *class_id);
|
||||||
|
|
||||||
/* 'buf' must be zero terminated i.e. buf[buf_len] = '\0'. */
|
/* 'buf' must be zero terminated i.e. buf[buf_len] = '\0'. */
|
||||||
JS_EXTERN JSValue JS_ParseJSON(JSContext *ctx, const char *buf, size_t buf_len,
|
JS_EXTERN JSValue JS_ParseJSON(JSContext *ctx, const char *buf, size_t buf_len,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
JS_EXTERN JSValue JS_JSONStringify(JSContext *ctx, JSValueConst obj,
|
JS_EXTERN JSValue JS_JSONStringify(JSContext *ctx, JSValue obj,
|
||||||
JSValueConst replacer, JSValueConst space0);
|
JSValue replacer, JSValue space0);
|
||||||
|
|
||||||
typedef void JSFreeArrayBufferDataFunc(JSRuntime *rt, void *opaque, void *ptr);
|
typedef void JSFreeArrayBufferDataFunc(JSRuntime *rt, void *opaque, void *ptr);
|
||||||
JS_EXTERN JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len,
|
JS_EXTERN JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len,
|
||||||
JSFreeArrayBufferDataFunc *free_func, void *opaque,
|
JSFreeArrayBufferDataFunc *free_func, void *opaque,
|
||||||
JS_BOOL is_shared);
|
JS_BOOL is_shared);
|
||||||
JS_EXTERN JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len);
|
JS_EXTERN JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len);
|
||||||
JS_EXTERN void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj);
|
JS_EXTERN void JS_DetachArrayBuffer(JSContext *ctx, JSValue obj);
|
||||||
JS_EXTERN uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj);
|
JS_EXTERN uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValue obj);
|
||||||
JS_EXTERN uint8_t *JS_GetUint8Array(JSContext *ctx, size_t *psize, JSValueConst obj);
|
JS_EXTERN uint8_t *JS_GetUint8Array(JSContext *ctx, size_t *psize, JSValue obj);
|
||||||
JS_EXTERN JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValueConst obj,
|
JS_EXTERN JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValue obj,
|
||||||
size_t *pbyte_offset,
|
size_t *pbyte_offset,
|
||||||
size_t *pbyte_length,
|
size_t *pbyte_length,
|
||||||
size_t *pbytes_per_element);
|
size_t *pbytes_per_element);
|
||||||
|
@ -759,8 +759,8 @@ JS_EXTERN void JS_SetSharedArrayBufferFunctions(JSRuntime *rt, const JSSharedArr
|
||||||
JS_EXTERN JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs);
|
JS_EXTERN JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs);
|
||||||
|
|
||||||
/* is_handled = TRUE means that the rejection is handled */
|
/* is_handled = TRUE means that the rejection is handled */
|
||||||
typedef void JSHostPromiseRejectionTracker(JSContext *ctx, JSValueConst promise,
|
typedef void JSHostPromiseRejectionTracker(JSContext *ctx, JSValue promise,
|
||||||
JSValueConst reason,
|
JSValue reason,
|
||||||
JS_BOOL is_handled, void *opaque);
|
JS_BOOL is_handled, void *opaque);
|
||||||
JS_EXTERN void JS_SetHostPromiseRejectionTracker(JSRuntime *rt, JSHostPromiseRejectionTracker *cb, void *opaque);
|
JS_EXTERN void JS_SetHostPromiseRejectionTracker(JSRuntime *rt, JSHostPromiseRejectionTracker *cb, void *opaque);
|
||||||
|
|
||||||
|
@ -770,7 +770,7 @@ JS_EXTERN void JS_SetInterruptHandler(JSRuntime *rt, JSInterruptHandler *cb, voi
|
||||||
/* if can_block is TRUE, Atomics.wait() can be used */
|
/* if can_block is TRUE, Atomics.wait() can be used */
|
||||||
JS_EXTERN void JS_SetCanBlock(JSRuntime *rt, JS_BOOL can_block);
|
JS_EXTERN void JS_SetCanBlock(JSRuntime *rt, JS_BOOL can_block);
|
||||||
/* set the [IsHTMLDDA] internal slot */
|
/* set the [IsHTMLDDA] internal slot */
|
||||||
JS_EXTERN void JS_SetIsHTMLDDA(JSContext *ctx, JSValueConst obj);
|
JS_EXTERN void JS_SetIsHTMLDDA(JSContext *ctx, JSValue obj);
|
||||||
|
|
||||||
typedef struct JSModuleDef JSModuleDef;
|
typedef struct JSModuleDef JSModuleDef;
|
||||||
|
|
||||||
|
@ -793,8 +793,8 @@ JS_EXTERN JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m);
|
||||||
|
|
||||||
/* JS Job support */
|
/* JS Job support */
|
||||||
|
|
||||||
typedef JSValue JSJobFunc(JSContext *ctx, int argc, JSValueConst *argv);
|
typedef JSValue JSJobFunc(JSContext *ctx, int argc, JSValue *argv);
|
||||||
JS_EXTERN int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func, int argc, JSValueConst *argv);
|
JS_EXTERN int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func, int argc, JSValue *argv);
|
||||||
|
|
||||||
JS_EXTERN JS_BOOL JS_IsJobPending(JSRuntime *rt);
|
JS_EXTERN JS_BOOL JS_IsJobPending(JSRuntime *rt);
|
||||||
JS_EXTERN int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx);
|
JS_EXTERN int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx);
|
||||||
|
@ -806,8 +806,8 @@ JS_EXTERN int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx);
|
||||||
#define JS_WRITE_OBJ_REFERENCE (1 << 3) /* allow object references to
|
#define JS_WRITE_OBJ_REFERENCE (1 << 3) /* allow object references to
|
||||||
encode arbitrary object
|
encode arbitrary object
|
||||||
graph */
|
graph */
|
||||||
JS_EXTERN uint8_t *JS_WriteObject(JSContext *ctx, size_t *psize, JSValueConst obj, int flags);
|
JS_EXTERN uint8_t *JS_WriteObject(JSContext *ctx, size_t *psize, JSValue obj, int flags);
|
||||||
JS_EXTERN uint8_t *JS_WriteObject2(JSContext *ctx, size_t *psize, JSValueConst obj,
|
JS_EXTERN uint8_t *JS_WriteObject2(JSContext *ctx, size_t *psize, JSValue obj,
|
||||||
int flags, uint8_t ***psab_tab, size_t *psab_tab_len);
|
int flags, uint8_t ***psab_tab, size_t *psab_tab_len);
|
||||||
|
|
||||||
#define JS_READ_OBJ_BYTECODE (1 << 0) /* allow function/module */
|
#define JS_READ_OBJ_BYTECODE (1 << 0) /* allow function/module */
|
||||||
|
@ -820,7 +820,7 @@ JS_EXTERN JSValue JS_ReadObject(JSContext *ctx, const uint8_t *buf, size_t buf_l
|
||||||
JS_EXTERN JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj);
|
JS_EXTERN JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj);
|
||||||
/* load the dependencies of the module 'obj'. Useful when JS_ReadObject()
|
/* load the dependencies of the module 'obj'. Useful when JS_ReadObject()
|
||||||
returns a module. */
|
returns a module. */
|
||||||
JS_EXTERN int JS_ResolveModule(JSContext *ctx, JSValueConst obj);
|
JS_EXTERN int JS_ResolveModule(JSContext *ctx, JSValue obj);
|
||||||
|
|
||||||
/* only exported for os.Worker() */
|
/* only exported for os.Worker() */
|
||||||
JS_EXTERN JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels);
|
JS_EXTERN JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels);
|
||||||
|
@ -847,18 +847,18 @@ typedef enum JSCFunctionEnum { /* XXX: should rename for namespace isolation */
|
||||||
|
|
||||||
typedef union JSCFunctionType {
|
typedef union JSCFunctionType {
|
||||||
JSCFunction *generic;
|
JSCFunction *generic;
|
||||||
JSValue (*generic_magic)(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic);
|
JSValue (*generic_magic)(JSContext *ctx, JSValue this_val, int argc, JSValue *argv, int magic);
|
||||||
JSCFunction *constructor;
|
JSCFunction *constructor;
|
||||||
JSValue (*constructor_magic)(JSContext *ctx, JSValueConst new_target, int argc, JSValueConst *argv, int magic);
|
JSValue (*constructor_magic)(JSContext *ctx, JSValue new_target, int argc, JSValue *argv, int magic);
|
||||||
JSCFunction *constructor_or_func;
|
JSCFunction *constructor_or_func;
|
||||||
double (*f_f)(double);
|
double (*f_f)(double);
|
||||||
double (*f_f_f)(double, double);
|
double (*f_f_f)(double, double);
|
||||||
JSValue (*getter)(JSContext *ctx, JSValueConst this_val);
|
JSValue (*getter)(JSContext *ctx, JSValue this_val);
|
||||||
JSValue (*setter)(JSContext *ctx, JSValueConst this_val, JSValueConst val);
|
JSValue (*setter)(JSContext *ctx, JSValue this_val, JSValue val);
|
||||||
JSValue (*getter_magic)(JSContext *ctx, JSValueConst this_val, int magic);
|
JSValue (*getter_magic)(JSContext *ctx, JSValue this_val, int magic);
|
||||||
JSValue (*setter_magic)(JSContext *ctx, JSValueConst this_val, JSValueConst val, int magic);
|
JSValue (*setter_magic)(JSContext *ctx, JSValue this_val, JSValue val, int magic);
|
||||||
JSValue (*iterator_next)(JSContext *ctx, JSValueConst this_val,
|
JSValue (*iterator_next)(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv, int *pdone, int magic);
|
int argc, JSValue *argv, int *pdone, int magic);
|
||||||
} JSCFunctionType;
|
} JSCFunctionType;
|
||||||
|
|
||||||
JS_EXTERN JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func,
|
JS_EXTERN JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func,
|
||||||
|
@ -866,7 +866,7 @@ JS_EXTERN JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func,
|
||||||
int length, JSCFunctionEnum cproto, int magic);
|
int length, JSCFunctionEnum cproto, int magic);
|
||||||
JS_EXTERN JSValue JS_NewCFunctionData(JSContext *ctx, JSCFunctionData *func,
|
JS_EXTERN JSValue JS_NewCFunctionData(JSContext *ctx, JSCFunctionData *func,
|
||||||
int length, int magic, int data_len,
|
int length, int magic, int data_len,
|
||||||
JSValueConst *data);
|
JSValue *data);
|
||||||
|
|
||||||
static inline JSValue JS_NewCFunction(JSContext *ctx, JSCFunction *func, const char *name,
|
static inline JSValue JS_NewCFunction(JSContext *ctx, JSCFunction *func, const char *name,
|
||||||
int length)
|
int length)
|
||||||
|
@ -882,8 +882,8 @@ static inline JSValue JS_NewCFunctionMagic(JSContext *ctx, JSCFunctionMagic *fun
|
||||||
JSCFunctionType ft = { .generic_magic = func };
|
JSCFunctionType ft = { .generic_magic = func };
|
||||||
return JS_NewCFunction2(ctx, ft.generic, name, length, cproto, magic);
|
return JS_NewCFunction2(ctx, ft.generic, name, length, cproto, magic);
|
||||||
}
|
}
|
||||||
JS_EXTERN void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj,
|
JS_EXTERN void JS_SetConstructor(JSContext *ctx, JSValue func_obj,
|
||||||
JSValueConst proto);
|
JSValue proto);
|
||||||
|
|
||||||
/* C property definition */
|
/* C property definition */
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ typedef struct JSCFunctionListEntry {
|
||||||
#define JS_ALIAS_DEF(name, from) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, .u = { .alias = { from, -1 } } }
|
#define JS_ALIAS_DEF(name, from) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, .u = { .alias = { from, -1 } } }
|
||||||
#define JS_ALIAS_BASE_DEF(name, from, base) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, .u = { .alias = { from, base } } }
|
#define JS_ALIAS_BASE_DEF(name, from, base) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, .u = { .alias = { from, base } } }
|
||||||
|
|
||||||
JS_EXTERN void JS_SetPropertyFunctionList(JSContext *ctx, JSValueConst obj,
|
JS_EXTERN void JS_SetPropertyFunctionList(JSContext *ctx, JSValue obj,
|
||||||
const JSCFunctionListEntry *tab,
|
const JSCFunctionListEntry *tab,
|
||||||
int len);
|
int len);
|
||||||
|
|
||||||
|
|
|
@ -371,8 +371,8 @@ static void enumerate_tests(const char *path)
|
||||||
namelist_cmp_indirect);
|
namelist_cmp_indirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_print(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_print(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
@ -508,7 +508,7 @@ static void *agent_start(void *arg)
|
||||||
NULL, NULL, TRUE);
|
NULL, NULL, TRUE);
|
||||||
args[1] = JS_NewInt32(ctx, agent->broadcast_val);
|
args[1] = JS_NewInt32(ctx, agent->broadcast_val);
|
||||||
ret_val = JS_Call(ctx, agent->broadcast_func, JS_UNDEFINED,
|
ret_val = JS_Call(ctx, agent->broadcast_func, JS_UNDEFINED,
|
||||||
2, (JSValueConst *)args);
|
2, (JSValue *)args);
|
||||||
JS_FreeValue(ctx, args[0]);
|
JS_FreeValue(ctx, args[0]);
|
||||||
JS_FreeValue(ctx, args[1]);
|
JS_FreeValue(ctx, args[1]);
|
||||||
if (JS_IsException(ret_val))
|
if (JS_IsException(ret_val))
|
||||||
|
@ -594,7 +594,7 @@ static BOOL is_broadcast_pending(void)
|
||||||
static JSValue js_agent_broadcast(JSContext *ctx, JSValue this_val,
|
static JSValue js_agent_broadcast(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValue *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
JSValueConst sab = argv[0];
|
JSValue sab = argv[0];
|
||||||
struct list_head *el;
|
struct list_head *el;
|
||||||
Test262Agent *agent;
|
Test262Agent *agent;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#include "../quickjs-libc.h"
|
#include "../quickjs-libc.h"
|
||||||
#include "../cutils.h"
|
#include "../cutils.h"
|
||||||
|
|
||||||
static JSValue js_bjson_read(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_bjson_read(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
uint64_t pos, len;
|
uint64_t pos, len;
|
||||||
|
@ -49,8 +49,8 @@ static JSValue js_bjson_read(JSContext *ctx, JSValueConst this_val,
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_bjson_write(JSContext *ctx, JSValueConst this_val,
|
static JSValue js_bjson_write(JSContext *ctx, JSValue this_val,
|
||||||
int argc, JSValueConst *argv)
|
int argc, JSValue *argv)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
Loading…
Reference in a new issue