Browse Source

Add internal duk_set_length() call

pull/20/head
Sami Vaarala 11 years ago
parent
commit
746e3bc022
  1. 14
      src/duk_api.c
  2. 3
      src/duk_api_internal.h

14
src/duk_api.c

@ -1301,6 +1301,20 @@ size_t duk_get_length(duk_context *ctx, int index) {
DUK_UNREACHABLE();
}
void duk_set_length(duk_context *ctx, duk_idx_t index, duk_size_t length) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hobject *h;
DUK_ASSERT(ctx != NULL);
h = duk_get_hobject(ctx, index);
if (!h) {
return;
}
duk_hobject_set_length(thr, h, (duk_uint32_t) length); /* XXX: typing */
}
/*
* Conversions and coercions
*

3
src/duk_api_internal.h

@ -117,5 +117,8 @@ void duk_def_prop_stridx_thrower(duk_context *ctx, int obj_index, unsigned int s
#define duk_def_prop_stridx_wec(ctx,obj_index,stridx) \
duk_def_prop_stridx((ctx), (obj_index), (stridx), DUK_PROPDESC_FLAGS_WEC)
/* Set object 'length'. */
void duk_set_length(duk_context *ctx, duk_idx_t index, duk_size_t length);
#endif /* DUK_API_INTERNAL_H_INCLUDED */

Loading…
Cancel
Save