Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,8 @@ static __exception int js_get_length32(JSContext *ctx, uint32_t *pres,
JSValue obj);
static __exception int js_get_length64(JSContext *ctx, int64_t *pres,
JSValue obj);
static __exception int js_set_length64(JSContext *ctx, JSValue obj,
int64_t len);
static void free_arg_list(JSContext *ctx, JSValue *tab, uint32_t len);
static JSValue *build_arg_list(JSContext *ctx, uint32_t *plen,
JSValue array_arg);
Expand Down Expand Up @@ -7000,6 +7002,10 @@ int JS_GetLength(JSContext *ctx, JSValue obj, int64_t *pres) {
return js_get_length64(ctx, pres, obj);
}

int JS_SetLength(JSContext *ctx, JSValue obj, int64_t len) {
return js_set_length64(ctx, obj, len);
}

/* return TRUE, FALSE or (-1) in case of exception */
static int JS_OrdinaryIsInstanceOf(JSContext *ctx, JSValue val,
JSValue obj)
Expand Down Expand Up @@ -36857,6 +36863,15 @@ static __exception int js_get_length64(JSContext *ctx, int64_t *pres,
return JS_ToLengthFree(ctx, pres, len_val);
}

static __exception int js_set_length64(JSContext *ctx, JSValue obj, int64_t len)
{
JSValue len_val;
len_val = JS_NewInt64(ctx, len);
if (JS_IsException(len_val))
return -1;
return JS_SetProperty(ctx, obj, JS_ATOM_length, len_val);
}

static void free_arg_list(JSContext *ctx, JSValue *tab, uint32_t len)
{
uint32_t i;
Expand Down
1 change: 1 addition & 0 deletions quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ JS_EXTERN int JS_DeleteProperty(JSContext *ctx, JSValue obj, JSAtom prop, int fl
JS_EXTERN int JS_SetPrototype(JSContext *ctx, JSValue obj, JSValue proto_val);
JS_EXTERN JSValue JS_GetPrototype(JSContext *ctx, JSValue val);
JS_EXTERN int JS_GetLength(JSContext *ctx, JSValue obj, int64_t *pres);
JS_EXTERN int JS_SetLength(JSContext *ctx, JSValue obj, int64_t len);

#define JS_GPN_STRING_MASK (1 << 0)
#define JS_GPN_SYMBOL_MASK (1 << 1)
Expand Down