Update quickjs to 2019-10-27
This commit is contained in:
parent
6afaa8ff7e
commit
5578af79a9
13 changed files with 146 additions and 148 deletions
2
justfile
2
justfile
|
@ -1,6 +1,6 @@
|
|||
embed_dir := "./libquickjs-sys/embed/quickjs"
|
||||
|
||||
DOWNLOAD_URL := "https://bellard.org/quickjs/quickjs-2019-09-18.tar.xz"
|
||||
DOWNLOAD_URL := "https://bellard.org/quickjs/quickjs-2019-10-27.tar.xz"
|
||||
FEATURES := "--all-features"
|
||||
|
||||
download-new:
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
# libquickjs_sys - Changelog
|
||||
|
||||
## v0.4.0 - ??
|
||||
## v0.4.0 - 2019-11-02
|
||||
|
||||
Upgraded to version `2019-09-18`.
|
||||
Upgraded to version `2019-09-18`:
|
||||
|
||||
* Added `JS_ValueToAtom`
|
||||
* ...
|
||||
* Added `JS_SetConstructor`
|
||||
* `JS_GetTypedArrayBuffer`
|
||||
|
||||
Updated bindgen dependency to 0.51.
|
||||
|
||||
## v0.3.0 - 2019-08-13
|
||||
|
||||
|
|
|
@ -13,11 +13,6 @@ keywords = ["quickjs"]
|
|||
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = { version = "0.50.0", optional = true }
|
||||
copy_dir = { version = "0.1.2", optional = true }
|
||||
|
||||
|
||||
[features]
|
||||
bundled = ["copy_dir"]
|
||||
patched = []
|
||||
|
@ -25,3 +20,8 @@ bignum = []
|
|||
default = ["bundled"]
|
||||
|
||||
system = ["bindgen"]
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = { version = "0.51.0", optional = true }
|
||||
copy_dir = { version = "0.1.2", optional = true }
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ FFI Bindings for [quickjs](https://bellard.org/quickjs/), a Javascript engine.
|
|||
See the [quick](https://crates.io/crates/quickjs) crate for a high-level
|
||||
wrapper.
|
||||
|
||||
**Embedded VERSION: 2019-09-18**
|
||||
**Embedded VERSION: 2019-10-27**
|
||||
|
||||
## Embedded vs system
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ pub const __STDC_IEC_559_COMPLEX__: u32 = 1;
|
|||
pub const __STDC_ISO_10646__: u32 = 201706;
|
||||
pub const __GNU_LIBRARY__: u32 = 6;
|
||||
pub const __GLIBC__: u32 = 2;
|
||||
pub const __GLIBC_MINOR__: u32 = 29;
|
||||
pub const __GLIBC_MINOR__: u32 = 30;
|
||||
pub const _SYS_CDEFS_H: u32 = 1;
|
||||
pub const __glibc_c99_flexarr_available: u32 = 1;
|
||||
pub const __WORDSIZE: u32 = 64;
|
||||
|
@ -2848,6 +2848,15 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn JS_GetArrayBuffer(ctx: *mut JSContext, psize: *mut usize, obj: JSValue) -> *mut u8;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn JS_GetTypedArrayBuffer(
|
||||
ctx: *mut JSContext,
|
||||
obj: JSValue,
|
||||
pbyte_offset: *mut usize,
|
||||
pbyte_length: *mut usize,
|
||||
pbytes_per_element: *mut usize,
|
||||
) -> JSValue;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn JS_NewPromiseCapability(ctx: *mut JSContext, resolving_funcs: *mut JSValue) -> JSValue;
|
||||
}
|
||||
|
@ -3174,6 +3183,9 @@ extern "C" {
|
|||
data: *mut JSValue,
|
||||
) -> JSValue;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn JS_SetConstructor(ctx: *mut JSContext, func_obj: JSValue, proto: JSValue);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct JSCFunctionListEntry {
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2019-10-27:
|
||||
|
||||
- added example of C class in a module (examples/test_point.js)
|
||||
- added JS_GetTypedArrayBuffer()
|
||||
- misc bug fixes
|
||||
|
||||
2019-09-18:
|
||||
|
||||
- added os.exec and other system calls
|
||||
|
|
|
@ -146,7 +146,10 @@ ifeq ($(CROSS_PREFIX),)
|
|||
ifdef CONFIG_ASAN
|
||||
PROGS+=
|
||||
else
|
||||
PROGS+=examples/hello examples/hello_module examples/c_module
|
||||
PROGS+=examples/hello examples/hello_module examples/test_fib
|
||||
ifndef CONFIG_DARWIN
|
||||
PROGS+=examples/fib.so examples/point.so
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -166,7 +169,7 @@ LIBS+=-ldl
|
|||
endif
|
||||
|
||||
$(OBJDIR):
|
||||
mkdir -p $(OBJDIR)
|
||||
mkdir -p $(OBJDIR) $(OBJDIR)/examples $(OBJDIR)/tests
|
||||
|
||||
qjs$(EXE): $(QJS_OBJS)
|
||||
$(CC) $(LDFLAGS) $(LDEXPORT) -o $@ $^ $(LIBS)
|
||||
|
@ -324,8 +327,9 @@ unicode_gen: $(OBJDIR)/unicode_gen.host.o $(OBJDIR)/cutils.host.o libunicode.c u
|
|||
|
||||
clean:
|
||||
rm -f repl.c repl-bn.c qjscalc.c out.c
|
||||
rm -f *.a *.so *.o *.d *~ jscompress unicode_gen regexp_test $(PROGS)
|
||||
rm -f hello.c hello_module.c c_module.c
|
||||
rm -f *.a *.o *.d *~ jscompress unicode_gen regexp_test $(PROGS)
|
||||
rm -f hello.c hello_module.c test_fib.c
|
||||
rm -f examples/*.so tests/*.so
|
||||
rm -rf $(OBJDIR)/ *.dSYM/ qjs-debug qjsbn-debug
|
||||
rm -rf run-test262-debug run-test262-32 run-test262-bn32
|
||||
|
||||
|
@ -372,14 +376,17 @@ examples/hello_module: $(QJSC) libquickjs$(LTOEXT).a $(HELLO_MODULE_SRCS)
|
|||
|
||||
# use of an external C module (static compilation)
|
||||
|
||||
c_module.c: $(QJSC) examples/c_module.js
|
||||
$(QJSC) -e -M examples/fib.so,fib -m -o $@ examples/c_module.js
|
||||
test_fib.c: $(QJSC) examples/test_fib.js
|
||||
$(QJSC) -e -M examples/fib.so,fib -m -o $@ examples/test_fib.js
|
||||
|
||||
examples/c_module: $(OBJDIR)/c_module.o $(OBJDIR)/fib.o libquickjs$(LTOEXT).a
|
||||
examples/test_fib: $(OBJDIR)/test_fib.o $(OBJDIR)/examples/fib.o libquickjs$(LTOEXT).a
|
||||
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
$(OBJDIR)/fib.o: examples/fib.c
|
||||
$(CC) $(CFLAGS_OPT) -c -o $@ $<
|
||||
examples/fib.so: $(OBJDIR)/examples/fib.pic.o
|
||||
$(CC) $(LDFLAGS) -shared -o $@ $^
|
||||
|
||||
examples/point.so: $(OBJDIR)/examples/point.pic.o
|
||||
$(CC) $(LDFLAGS) -shared -o $@ $^
|
||||
|
||||
###############################################################################
|
||||
# documentation
|
||||
|
@ -404,7 +411,7 @@ doc/%.html: doc/%.html.pre
|
|||
# tests
|
||||
|
||||
ifndef CONFIG_DARWIN
|
||||
test: bjson.so
|
||||
test: tests/bjson.so
|
||||
endif
|
||||
|
||||
test: qjs qjsbn
|
||||
|
@ -415,6 +422,7 @@ test: qjs qjsbn
|
|||
./qjs tests/test_std.js
|
||||
ifndef CONFIG_DARWIN
|
||||
./qjs tests/test_bjson.js
|
||||
./qjs examples/test_point.js
|
||||
endif
|
||||
./qjsbn tests/test_closure.js
|
||||
./qjsbn tests/test_op.js
|
||||
|
@ -492,7 +500,7 @@ bench-v8: qjs qjs32
|
|||
make -C tests/bench-v8
|
||||
./qjs -d tests/bench-v8/combined.js
|
||||
|
||||
bjson.so: $(OBJDIR)/bjson.pic.o
|
||||
tests/bjson.so: $(OBJDIR)/tests/bjson.pic.o
|
||||
$(CC) $(LDFLAGS) -shared -o $@ $^ $(LIBS)
|
||||
|
||||
-include $(wildcard $(OBJDIR)/*.d)
|
||||
|
|
|
@ -55,7 +55,7 @@ Extensions:
|
|||
- limited support for web assembly
|
||||
- get rid of __loadScript, use more common name
|
||||
- BSD sockets
|
||||
- Process or thread control
|
||||
- Workers
|
||||
- use custom printf to avoid C library compatibility issues
|
||||
- use custom timezone support to avoid C library compatibility issues
|
||||
|
||||
|
@ -75,6 +75,6 @@ REPL:
|
|||
Test262o: 0/11262 errors, 463 excluded
|
||||
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
|
||||
|
||||
Test262: 2/67351 errors, 839 excluded, 1370 skipped
|
||||
Test262bn: 2/69452 errors, 772 excluded, 383 skipped
|
||||
test262 commit: d65b9b35be091147edf31ec527a47cb95a327217
|
||||
Test262: 2/67433 errors, 901 excluded, 1658 skipped
|
||||
Test262bn: 2/69536 errors, 834 excluded, 670 skipped
|
||||
test262 commit: 21195de94cfc36eadbde00a825ca7efb3d9c3dde
|
||||
|
|
|
@ -1 +1 @@
|
|||
2019-09-18
|
||||
2019-10-27
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* QuickJS: binary JSON module (test only)
|
||||
*
|
||||
* Copyright (c) 2017-2019 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "quickjs-libc.h"
|
||||
#include "cutils.h"
|
||||
|
||||
static JSValue js_bjson_read(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
uint8_t *buf;
|
||||
uint64_t pos, len;
|
||||
JSValue obj;
|
||||
size_t size;
|
||||
|
||||
if (JS_ToIndex(ctx, &pos, argv[1]))
|
||||
return JS_EXCEPTION;
|
||||
if (JS_ToIndex(ctx, &len, argv[2]))
|
||||
return JS_EXCEPTION;
|
||||
buf = JS_GetArrayBuffer(ctx, &size, argv[0]);
|
||||
if (!buf)
|
||||
return JS_EXCEPTION;
|
||||
if (pos + len > size)
|
||||
return JS_ThrowRangeError(ctx, "array buffer overflow");
|
||||
obj = JS_ReadObject(ctx, buf + pos, len, 0);
|
||||
return obj;
|
||||
}
|
||||
|
||||
static JSValue js_bjson_write(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
size_t len;
|
||||
uint8_t *buf;
|
||||
JSValue array;
|
||||
|
||||
buf = JS_WriteObject(ctx, &len, argv[0], 0);
|
||||
if (!buf)
|
||||
return JS_EXCEPTION;
|
||||
array = JS_NewArrayBufferCopy(ctx, buf, len);
|
||||
js_free(ctx, buf);
|
||||
return array;
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_bjson_funcs[] = {
|
||||
JS_CFUNC_DEF("read", 3, js_bjson_read ),
|
||||
JS_CFUNC_DEF("write", 1, js_bjson_write ),
|
||||
};
|
||||
|
||||
static int js_bjson_init(JSContext *ctx, JSModuleDef *m)
|
||||
{
|
||||
return JS_SetModuleExportList(ctx, m, js_bjson_funcs,
|
||||
countof(js_bjson_funcs));
|
||||
}
|
||||
|
||||
#ifdef JS_SHARED_LIBRARY
|
||||
#define JS_INIT_MODULE js_init_module
|
||||
#else
|
||||
#define JS_INIT_MODULE js_init_module_bjson
|
||||
#endif
|
||||
|
||||
JSModuleDef *JS_INIT_MODULE(JSContext *ctx, const char *module_name)
|
||||
{
|
||||
JSModuleDef *m;
|
||||
m = JS_NewCModule(ctx, module_name, js_bjson_init);
|
||||
if (!m)
|
||||
return NULL;
|
||||
JS_AddModuleExportList(ctx, m, js_bjson_funcs, countof(js_bjson_funcs));
|
||||
return m;
|
||||
}
|
|
@ -7970,7 +7970,8 @@ retry:
|
|||
}
|
||||
|
||||
if (p->is_exotic) {
|
||||
if (p->class_id == JS_CLASS_ARRAY && p->fast_array) {
|
||||
if (p->class_id == JS_CLASS_ARRAY && p->fast_array &&
|
||||
__JS_AtomIsTaggedInt(prop)) {
|
||||
uint32_t idx = __JS_AtomToUInt32(prop);
|
||||
if (idx == p->u.array.count) {
|
||||
/* fast case */
|
||||
|
@ -20437,11 +20438,7 @@ static int define_var(JSParseState *s, JSFunctionDef *fd, JSAtom name,
|
|||
}
|
||||
if (var_def_type != JS_VAR_DEF_FUNCTION_DECL &&
|
||||
var_def_type != JS_VAR_DEF_NEW_FUNCTION_DECL &&
|
||||
(fd->func_kind == JS_FUNC_ASYNC ||
|
||||
fd->func_kind == JS_FUNC_GENERATOR ||
|
||||
fd->func_kind == JS_FUNC_ASYNC_GENERATOR ||
|
||||
fd->func_type == JS_PARSE_FUNC_METHOD ||
|
||||
fd->scope_level == 1) &&
|
||||
fd->scope_level == 1 &&
|
||||
find_arg(ctx, fd, name) >= 0) {
|
||||
/* lexical variable redefines a parameter name */
|
||||
return js_parse_error(s, "invalid redefinition of parameter name");
|
||||
|
@ -24026,9 +24023,10 @@ static void emit_return(JSParseState *s, BOOL hasval)
|
|||
}
|
||||
|
||||
#define DECL_MASK_FUNC (1 << 0) /* allow normal function declaration */
|
||||
#define DECL_MASK_LABEL (1 << 1) /* allow labelled statement */
|
||||
/* ored with DECL_MASK_FUNC if function declarations are allowed with a label */
|
||||
#define DECL_MASK_FUNC_WITH_LABEL (1 << 1)
|
||||
#define DECL_MASK_OTHER (1 << 2) /* all other declarations */
|
||||
#define DECL_MASK_ALL (DECL_MASK_FUNC | DECL_MASK_LABEL | DECL_MASK_OTHER)
|
||||
#define DECL_MASK_ALL (DECL_MASK_FUNC | DECL_MASK_FUNC_WITH_LABEL | DECL_MASK_OTHER)
|
||||
|
||||
static __exception int js_parse_statement_or_decl(JSParseState *s,
|
||||
int decl_mask);
|
||||
|
@ -24463,10 +24461,6 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
|
|||
if (is_label(s)) {
|
||||
BlockEnv *be;
|
||||
|
||||
if (!(decl_mask & DECL_MASK_LABEL)) {
|
||||
js_parse_error(s, "functions can only be labelled inside blocks");
|
||||
goto fail;
|
||||
}
|
||||
label_name = JS_DupAtom(ctx, s->token.u.ident.atom);
|
||||
|
||||
for (be = s->cur_func->top_break; be; be = be->prev) {
|
||||
|
@ -24490,11 +24484,12 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
|
|||
label_break = new_label(s);
|
||||
push_break_entry(s->cur_func, &break_entry,
|
||||
label_name, label_break, -1, 0);
|
||||
if (s->cur_func->js_mode & JS_MODE_STRICT)
|
||||
if (!(s->cur_func->js_mode & JS_MODE_STRICT) &&
|
||||
(decl_mask & DECL_MASK_FUNC_WITH_LABEL)) {
|
||||
mask = DECL_MASK_FUNC | DECL_MASK_FUNC_WITH_LABEL;
|
||||
} else {
|
||||
mask = 0;
|
||||
else
|
||||
mask = DECL_MASK_FUNC;
|
||||
mask |= DECL_MASK_LABEL;
|
||||
}
|
||||
if (js_parse_statement_or_decl(s, mask))
|
||||
goto fail;
|
||||
emit_label(s, label_break);
|
||||
|
@ -26578,8 +26573,8 @@ static __exception int js_parse_export(JSParseState *s)
|
|||
emit_atom(s, local_name);
|
||||
emit_u16(s, 0);
|
||||
|
||||
if (add_export_entry(s, m, local_name, JS_ATOM_default,
|
||||
JS_EXPORT_TYPE_LOCAL) < 0)
|
||||
if (!add_export_entry(s, m, local_name, JS_ATOM_default,
|
||||
JS_EXPORT_TYPE_LOCAL))
|
||||
return -1;
|
||||
break;
|
||||
case TOK_VAR:
|
||||
|
@ -28089,12 +28084,12 @@ static int find_private_class_field_all(JSContext *ctx, JSFunctionDef *fd,
|
|||
|
||||
static void get_loc_or_ref(DynBuf *bc, BOOL is_ref, int idx)
|
||||
{
|
||||
/* Note: the private field can be uninitialized, so the _check is
|
||||
necessary */
|
||||
/* if the field is not initialized, the error is catched when
|
||||
accessing it */
|
||||
if (is_ref)
|
||||
dbuf_putc(bc, OP_get_var_ref_check);
|
||||
dbuf_putc(bc, OP_get_var_ref);
|
||||
else
|
||||
dbuf_putc(bc, OP_get_loc_check);
|
||||
dbuf_putc(bc, OP_get_loc);
|
||||
dbuf_put_u16(bc, idx);
|
||||
}
|
||||
|
||||
|
@ -33455,9 +33450,8 @@ static void JS_SetConstructor2(JSContext *ctx,
|
|||
set_cycle_flag(ctx, proto);
|
||||
}
|
||||
|
||||
static void JS_SetConstructor(JSContext *ctx,
|
||||
JSValueConst func_obj,
|
||||
JSValueConst proto)
|
||||
void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj,
|
||||
JSValueConst proto)
|
||||
{
|
||||
JS_SetConstructor2(ctx, func_obj, proto,
|
||||
0, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
|
||||
|
@ -37984,6 +37978,34 @@ static JSValue js_string_match(JSContext *ctx, JSValueConst this_val,
|
|||
matcher = JS_GetProperty(ctx, regexp, atom);
|
||||
if (JS_IsException(matcher))
|
||||
return JS_EXCEPTION;
|
||||
if (atom == JS_ATOM_Symbol_matchAll) {
|
||||
int ret;
|
||||
JSValue flags;
|
||||
|
||||
ret = js_is_regexp(ctx, regexp);
|
||||
if (ret < 0)
|
||||
goto fail1;
|
||||
if (ret) {
|
||||
flags = JS_GetProperty(ctx, regexp, JS_ATOM_flags);
|
||||
if (JS_IsException(flags))
|
||||
goto fail1;
|
||||
if (JS_IsUndefined(flags) || JS_IsNull(flags)) {
|
||||
JS_ThrowTypeError(ctx, "cannot convert to object");
|
||||
goto fail1;
|
||||
}
|
||||
flags = JS_ToStringFree(ctx, flags);
|
||||
if (JS_IsException(flags))
|
||||
goto fail1;
|
||||
ret = string_indexof_char(JS_VALUE_GET_STRING(flags), 'g', 0);
|
||||
JS_FreeValue(ctx, flags);
|
||||
if (ret < 0) {
|
||||
JS_ThrowTypeError(ctx, "regexp must have the 'g' flag");
|
||||
fail1:
|
||||
JS_FreeValue(ctx, matcher);
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!JS_IsUndefined(matcher) && !JS_IsNull(matcher)) {
|
||||
return JS_CallFree(ctx, matcher, regexp, 1, &O);
|
||||
}
|
||||
|
@ -42707,11 +42729,11 @@ static int js_proxy_get_own_property_names(JSContext *ctx,
|
|||
len2 = 0;
|
||||
if (js_get_length32(ctx, &len, prop_array))
|
||||
goto fail;
|
||||
if (len == 0)
|
||||
goto done;
|
||||
tab = js_mallocz(ctx, sizeof(tab[0]) * len);
|
||||
if (!tab)
|
||||
goto fail;
|
||||
if (len > 0) {
|
||||
tab = js_mallocz(ctx, sizeof(tab[0]) * len);
|
||||
if (!tab)
|
||||
goto fail;
|
||||
}
|
||||
for(i = 0; i < len; i++) {
|
||||
val = JS_GetPropertyUint32(ctx, prop_array, i);
|
||||
if (JS_IsException(val))
|
||||
|
@ -42783,7 +42805,6 @@ static int js_proxy_get_own_property_names(JSContext *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
done:
|
||||
js_free_prop_enum(ctx, tab2, len2);
|
||||
JS_FreeValue(ctx, prop_array);
|
||||
*ptab = tab;
|
||||
|
@ -45265,7 +45286,8 @@ static JSValue js_global_decodeURI(JSContext *ctx, JSValueConst this_val,
|
|||
}
|
||||
c = (c << 6) | (c1 & 0x3f);
|
||||
}
|
||||
if (c < c_min || c > 0x10FFFF) {
|
||||
if (c < c_min || c > 0x10FFFF ||
|
||||
(c >= 0xd800 && c < 0xe000)) {
|
||||
js_throw_URIError(ctx, "malformed UTF-8");
|
||||
goto fail;
|
||||
}
|
||||
|
@ -47817,6 +47839,32 @@ static JSValue js_typed_array_get_byteOffset(JSContext *ctx,
|
|||
return JS_NewInt32(ctx, ta->offset);
|
||||
}
|
||||
|
||||
/* Return the buffer associated to the typed array or an exception if
|
||||
it is not a typed array or if the buffer is detached. pbyte_offset,
|
||||
pbyte_length or pbytes_per_element can be NULL. */
|
||||
JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValueConst obj,
|
||||
size_t *pbyte_offset,
|
||||
size_t *pbyte_length,
|
||||
size_t *pbytes_per_element)
|
||||
{
|
||||
JSObject *p;
|
||||
JSTypedArray *ta;
|
||||
p = get_typed_array(ctx, obj, FALSE);
|
||||
if (!p)
|
||||
return JS_EXCEPTION;
|
||||
if (typed_array_is_detached(ctx, p))
|
||||
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
|
||||
ta = p->u.typed_array;
|
||||
if (pbyte_offset)
|
||||
*pbyte_offset = ta->offset;
|
||||
if (pbyte_length)
|
||||
*pbyte_length = ta->length;
|
||||
if (pbytes_per_element) {
|
||||
*pbytes_per_element = 1 << typed_array_size_log2(p->class_id);
|
||||
}
|
||||
return JS_DupValue(ctx, JS_MKPTR(JS_TAG_OBJECT, ta->buffer));
|
||||
}
|
||||
|
||||
static JSValue js_typed_array_get_toStringTag(JSContext *ctx,
|
||||
JSValueConst this_val)
|
||||
{
|
||||
|
@ -48877,7 +48925,7 @@ struct TA_sort_context {
|
|||
JSValueConst arr;
|
||||
JSValueConst cmp;
|
||||
JSValue (*getfun)(JSContext *ctx, const void *a);
|
||||
void *array_ptr; /* cannot change unless the array is detached */
|
||||
uint8_t *array_ptr; /* cannot change unless the array is detached */
|
||||
int elt_size;
|
||||
};
|
||||
|
||||
|
|
|
@ -684,6 +684,7 @@ int JS_GetOwnPropertyNames(JSContext *ctx, JSPropertyEnum **ptab,
|
|||
int JS_GetOwnProperty(JSContext *ctx, JSPropertyDescriptor *desc,
|
||||
JSValueConst obj, JSAtom prop);
|
||||
|
||||
/* 'buf' must be zero terminated i.e. buf[buf_len] = '\0'. */
|
||||
JSValue JS_ParseJSON(JSContext *ctx, const char *buf, size_t buf_len,
|
||||
const char *filename);
|
||||
JSValue JS_Call(JSContext *ctx, JSValueConst func_obj, JSValueConst this_obj,
|
||||
|
@ -696,6 +697,7 @@ JSValue JS_CallConstructor2(JSContext *ctx, JSValueConst func_obj,
|
|||
JSValueConst new_target,
|
||||
int argc, JSValueConst *argv);
|
||||
JS_BOOL JS_DetectModule(const char *input, size_t input_len);
|
||||
/* 'input' must be zero terminated i.e. input[input_len] = '\0'. */
|
||||
JSValue JS_Eval(JSContext *ctx, const char *input, size_t input_len,
|
||||
const char *filename, int eval_flags);
|
||||
JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj);
|
||||
|
@ -724,6 +726,10 @@ JSValue JS_NewArrayBuffer(JSContext *ctx, uint8_t *buf, size_t len,
|
|||
JSValue JS_NewArrayBufferCopy(JSContext *ctx, const uint8_t *buf, size_t len);
|
||||
void JS_DetachArrayBuffer(JSContext *ctx, JSValueConst obj);
|
||||
uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj);
|
||||
JSValue JS_GetTypedArrayBuffer(JSContext *ctx, JSValueConst obj,
|
||||
size_t *pbyte_offset,
|
||||
size_t *pbyte_length,
|
||||
size_t *pbytes_per_element);
|
||||
|
||||
JSValue JS_NewPromiseCapability(JSContext *ctx, JSValue *resolving_funcs);
|
||||
|
||||
|
@ -825,6 +831,8 @@ static inline JSValue JS_NewCFunctionMagic(JSContext *ctx, JSCFunctionMagic *fun
|
|||
{
|
||||
return JS_NewCFunction2(ctx, (JSCFunction *)func, name, length, cproto, magic);
|
||||
}
|
||||
void JS_SetConstructor(JSContext *ctx, JSValueConst func_obj,
|
||||
JSValueConst proto);
|
||||
|
||||
/* C property definition */
|
||||
|
||||
|
|
|
@ -296,6 +296,7 @@ void parse_unicode_data(const char *filename)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
last_code = 0;
|
||||
for(;;) {
|
||||
if (!get_line(line, sizeof(line), f))
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue