Browse Source

Avoid 'index' as variable/argument name

pull/810/head
Sami Vaarala 9 years ago
parent
commit
3b8b9ac36b
  1. 12
      src/duk_api_buffer.c
  2. 38
      src/duk_api_call.c
  3. 60
      src/duk_api_codec.c
  4. 92
      src/duk_api_internal.h
  5. 162
      src/duk_api_object.c
  6. 362
      src/duk_api_public.h.in
  7. 692
      src/duk_api_stack.c
  8. 32
      src/duk_api_string.c
  9. 4
      src/duk_api_time.c
  10. 20
      src/duk_bi_array.c
  11. 6
      src/duk_bi_buffer.c
  12. 10
      src/duk_bi_string.c
  13. 8
      src/duk_debug_heap.c
  14. 22
      src/duk_error.h
  15. 12
      src/duk_error_macros.c
  16. 2
      src/duk_lexer.c

12
src/duk_api_buffer.c

@ -4,13 +4,13 @@
#include "duk_internal.h"
DUK_EXTERNAL void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size) {
DUK_EXTERNAL void *duk_resize_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t new_size) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hbuffer_dynamic *h;
DUK_ASSERT_CTX_VALID(ctx);
h = (duk_hbuffer_dynamic *) duk_require_hbuffer(ctx, index);
h = (duk_hbuffer_dynamic *) duk_require_hbuffer(ctx, idx);
DUK_ASSERT(h != NULL);
if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) {
@ -23,7 +23,7 @@ DUK_EXTERNAL void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size
return DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h);
}
DUK_EXTERNAL void *duk_steal_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size) {
DUK_EXTERNAL void *duk_steal_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hbuffer_dynamic *h;
void *ptr;
@ -31,7 +31,7 @@ DUK_EXTERNAL void *duk_steal_buffer(duk_context *ctx, duk_idx_t index, duk_size_
DUK_ASSERT(ctx != NULL);
h = (duk_hbuffer_dynamic *) duk_require_hbuffer(ctx, index);
h = (duk_hbuffer_dynamic *) duk_require_hbuffer(ctx, idx);
DUK_ASSERT(h != NULL);
if (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) {
@ -54,13 +54,13 @@ DUK_EXTERNAL void *duk_steal_buffer(duk_context *ctx, duk_idx_t index, duk_size_
return ptr;
}
DUK_EXTERNAL void duk_config_buffer(duk_context *ctx, duk_idx_t index, void *ptr, duk_size_t len) {
DUK_EXTERNAL void duk_config_buffer(duk_context *ctx, duk_idx_t idx, void *ptr, duk_size_t len) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hbuffer_external *h;
DUK_ASSERT(ctx != NULL);
h = (duk_hbuffer_external *) duk_require_hbuffer(ctx, index);
h = (duk_hbuffer_external *) duk_require_hbuffer(ctx, idx);
DUK_ASSERT(h != NULL);
if (!DUK_HBUFFER_HAS_EXTERNAL(h)) {

38
src/duk_api_call.c

@ -9,17 +9,17 @@
/* Prepare value stack for a method call through an object property.
* May currently throw an error e.g. when getting the property.
*/
DUK_LOCAL void duk__call_prop_prep_stack(duk_context *ctx, duk_idx_t normalized_obj_index, duk_idx_t nargs) {
DUK_LOCAL void duk__call_prop_prep_stack(duk_context *ctx, duk_idx_t normalized_obj_idx, duk_idx_t nargs) {
DUK_ASSERT_CTX_VALID(ctx);
DUK_DDD(DUK_DDDPRINT("duk__call_prop_prep_stack, normalized_obj_index=%ld, nargs=%ld, stacktop=%ld",
(long) normalized_obj_index, (long) nargs, (long) duk_get_top(ctx)));
DUK_DDD(DUK_DDDPRINT("duk__call_prop_prep_stack, normalized_obj_idx=%ld, nargs=%ld, stacktop=%ld",
(long) normalized_obj_idx, (long) nargs, (long) duk_get_top(ctx)));
/* [... key arg1 ... argN] */
/* duplicate key */
duk_dup(ctx, -nargs - 1); /* Note: -nargs alone would fail for nargs == 0, this is OK */
duk_get_prop(ctx, normalized_obj_index);
duk_get_prop(ctx, normalized_obj_idx);
DUK_DDD(DUK_DDDPRINT("func: %!T", (duk_tval *) duk_get_tval(ctx, -1)));
@ -29,7 +29,7 @@ DUK_LOCAL void duk__call_prop_prep_stack(duk_context *ctx, duk_idx_t normalized_
/* [... func arg1 ... argN] */
duk_dup(ctx, normalized_obj_index);
duk_dup(ctx, normalized_obj_idx);
duk_insert(ctx, -nargs - 1);
/* [... func this arg1 ... argN] */
@ -83,7 +83,7 @@ DUK_EXTERNAL void duk_call_method(duk_context *ctx, duk_idx_t nargs) {
call_flags); /* call_flags */
}
DUK_EXTERNAL void duk_call_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs) {
DUK_EXTERNAL void duk_call_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs) {
/*
* XXX: if duk_handle_call() took values through indices, this could be
* made much more sensible. However, duk_handle_call() needs to fudge
@ -93,9 +93,9 @@ DUK_EXTERNAL void duk_call_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t
DUK_ASSERT_CTX_VALID(ctx);
obj_index = duk_require_normalize_index(ctx, obj_index); /* make absolute */
obj_idx = duk_require_normalize_index(ctx, obj_idx); /* make absolute */
duk__call_prop_prep_stack(ctx, obj_index, nargs);
duk__call_prop_prep_stack(ctx, obj_idx, nargs);
duk_call_method(ctx, nargs);
}
@ -164,13 +164,13 @@ DUK_EXTERNAL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs) {
}
struct duk__pcall_prop_args {
duk_idx_t obj_index;
duk_idx_t obj_idx;
duk_idx_t nargs;
};
typedef struct duk__pcall_prop_args duk__pcall_prop_args;
DUK_LOCAL duk_ret_t duk__pcall_prop_raw(duk_context *ctx, void *udata) {
duk_idx_t obj_index;
duk_idx_t obj_idx;
duk_idx_t nargs;
duk__pcall_prop_args *args;
@ -178,16 +178,16 @@ DUK_LOCAL duk_ret_t duk__pcall_prop_raw(duk_context *ctx, void *udata) {
DUK_ASSERT(udata != NULL);
args = (duk__pcall_prop_args *) udata;
obj_index = args->obj_index;
obj_idx = args->obj_idx;
nargs = args->nargs;
obj_index = duk_require_normalize_index(ctx, obj_index); /* make absolute */
duk__call_prop_prep_stack(ctx, obj_index, nargs);
obj_idx = duk_require_normalize_index(ctx, obj_idx); /* make absolute */
duk__call_prop_prep_stack(ctx, obj_idx, nargs);
duk_call_method(ctx, nargs);
return 1;
}
DUK_EXTERNAL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs) {
DUK_EXTERNAL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs) {
duk__pcall_prop_args args;
/*
@ -197,7 +197,7 @@ DUK_EXTERNAL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_index, duk
DUK_ASSERT_CTX_VALID(ctx);
args.obj_index = obj_index;
args.obj_idx = obj_idx;
args.nargs = nargs;
/* Inputs: explicit arguments (nargs), +1 for key. If the value stack
@ -512,14 +512,14 @@ DUK_EXTERNAL duk_int_t duk_get_current_magic(duk_context *ctx) {
return 0;
}
DUK_EXTERNAL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t idx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_tval *tv;
duk_hobject *h;
DUK_ASSERT_CTX_VALID(ctx);
tv = duk_require_tval(ctx, index);
tv = duk_require_tval(ctx, idx);
if (DUK_TVAL_IS_OBJECT(tv)) {
h = DUK_TVAL_GET_OBJECT(tv);
DUK_ASSERT(h != NULL);
@ -538,12 +538,12 @@ DUK_EXTERNAL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t index) {
return 0;
}
DUK_EXTERNAL void duk_set_magic(duk_context *ctx, duk_idx_t index, duk_int_t magic) {
DUK_EXTERNAL void duk_set_magic(duk_context *ctx, duk_idx_t idx, duk_int_t magic) {
duk_hnatfunc *nf;
DUK_ASSERT_CTX_VALID(ctx);
nf = duk_require_hnatfunc(ctx, index);
nf = duk_require_hnatfunc(ctx, idx);
DUK_ASSERT(nf != NULL);
nf->magic = (duk_int16_t) magic;
}

60
src/duk_api_codec.c

@ -12,12 +12,12 @@
* buffer and string values because they're the most common. In particular,
* avoid creating a temporary string or buffer when possible.
*/
DUK_LOCAL const duk_uint8_t *duk__prep_codec_arg(duk_context *ctx, duk_idx_t index, duk_size_t *out_len) {
DUK_ASSERT(duk_is_valid_index(ctx, index)); /* checked by caller */
if (duk_is_buffer(ctx, index)) {
return (const duk_uint8_t *) duk_get_buffer(ctx, index, out_len);
DUK_LOCAL const duk_uint8_t *duk__prep_codec_arg(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len) {
DUK_ASSERT(duk_is_valid_index(ctx, idx)); /* checked by caller */
if (duk_is_buffer(ctx, idx)) {
return (const duk_uint8_t *) duk_get_buffer(ctx, idx, out_len);
} else {
return (const duk_uint8_t *) duk_to_lstring(ctx, index, out_len);
return (const duk_uint8_t *) duk_to_lstring(ctx, idx, out_len);
}
}
@ -367,7 +367,7 @@ DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_
}
#endif /* DUK_USE_BASE64_FASTPATH */
DUK_EXTERNAL const char *duk_base64_encode(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL const char *duk_base64_encode(duk_context *ctx, duk_idx_t idx) {
duk_hthread *thr = (duk_hthread *) ctx;
const duk_uint8_t *src;
duk_size_t srclen;
@ -381,8 +381,8 @@ DUK_EXTERNAL const char *duk_base64_encode(duk_context *ctx, duk_idx_t index) {
* which makes a copy of the input.
*/
index = duk_require_normalize_index(ctx, index);
src = duk__prep_codec_arg(ctx, index, &srclen);
idx = duk_require_normalize_index(ctx, idx);
src = duk__prep_codec_arg(ctx, idx, &srclen);
/* Note: for srclen=0, src may be NULL */
/* Computation must not wrap; this limit works for 32-bit size_t:
@ -399,7 +399,7 @@ DUK_EXTERNAL const char *duk_base64_encode(duk_context *ctx, duk_idx_t index) {
duk__base64_encode_helper((const duk_uint8_t *) src, srclen, dst);
ret = duk_to_string(ctx, -1);
duk_replace(ctx, index);
duk_replace(ctx, idx);
return ret;
type_error:
@ -407,7 +407,7 @@ DUK_EXTERNAL const char *duk_base64_encode(duk_context *ctx, duk_idx_t index) {
return NULL; /* never here */
}
DUK_EXTERNAL void duk_base64_decode(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL void duk_base64_decode(duk_context *ctx, duk_idx_t idx) {
duk_hthread *thr = (duk_hthread *) ctx;
const duk_uint8_t *src;
duk_size_t srclen;
@ -422,8 +422,8 @@ DUK_EXTERNAL void duk_base64_decode(duk_context *ctx, duk_idx_t index) {
* which causes an unnecessary interning.
*/
index = duk_require_normalize_index(ctx, index);
src = duk__prep_codec_arg(ctx, index, &srclen);
idx = duk_require_normalize_index(ctx, idx);
src = duk__prep_codec_arg(ctx, idx, &srclen);
/* Computation must not wrap, only srclen + 3 is at risk of
* wrapping because after that the number gets smaller.
@ -444,14 +444,14 @@ DUK_EXTERNAL void duk_base64_decode(duk_context *ctx, duk_idx_t index) {
/* XXX: convert to fixed buffer? */
(void) duk_resize_buffer(ctx, -1, (duk_size_t) (dst_final - dst));
duk_replace(ctx, index);
duk_replace(ctx, idx);
return;
type_error:
DUK_ERROR_TYPE(thr, DUK_STR_DECODE_FAILED);
}
DUK_EXTERNAL const char *duk_hex_encode(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL const char *duk_hex_encode(duk_context *ctx, duk_idx_t idx) {
const duk_uint8_t *inp;
duk_size_t len;
duk_size_t i;
@ -464,8 +464,8 @@ DUK_EXTERNAL const char *duk_hex_encode(duk_context *ctx, duk_idx_t index) {
DUK_ASSERT_CTX_VALID(ctx);
index = duk_require_normalize_index(ctx, index);
inp = duk__prep_codec_arg(ctx, index, &len);
idx = duk_require_normalize_index(ctx, idx);
inp = duk__prep_codec_arg(ctx, idx, &len);
DUK_ASSERT(inp != NULL || len == 0);
/* Fixed buffer, no zeroing because we'll fill all the data. */
@ -503,11 +503,11 @@ DUK_EXTERNAL const char *duk_hex_encode(duk_context *ctx, duk_idx_t index) {
*/
ret = duk_to_string(ctx, -1);
duk_replace(ctx, index);
duk_replace(ctx, idx);
return ret;
}
DUK_EXTERNAL void duk_hex_decode(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL void duk_hex_decode(duk_context *ctx, duk_idx_t idx) {
duk_hthread *thr = (duk_hthread *) ctx;
const duk_uint8_t *inp;
duk_size_t len;
@ -522,8 +522,8 @@ DUK_EXTERNAL void duk_hex_decode(duk_context *ctx, duk_idx_t index) {
DUK_ASSERT_CTX_VALID(ctx);
index = duk_require_normalize_index(ctx, index);
inp = duk__prep_codec_arg(ctx, index, &len);
idx = duk_require_normalize_index(ctx, idx);
inp = duk__prep_codec_arg(ctx, idx, &len);
DUK_ASSERT(inp != NULL || len == 0);
if (len & 0x01) {
@ -584,14 +584,14 @@ DUK_EXTERNAL void duk_hex_decode(duk_context *ctx, duk_idx_t index) {
}
#endif /* DUK_USE_HEX_FASTPATH */
duk_replace(ctx, index);
duk_replace(ctx, idx);
return;
type_error:
DUK_ERROR_TYPE(thr, DUK_STR_DECODE_FAILED);
}
DUK_EXTERNAL const char *duk_json_encode(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx) {
#ifdef DUK_USE_ASSERTIONS
duk_idx_t top_at_entry;
#endif
@ -602,22 +602,22 @@ DUK_EXTERNAL const char *duk_json_encode(duk_context *ctx, duk_idx_t index) {
top_at_entry = duk_get_top(ctx);
#endif
index = duk_require_normalize_index(ctx, index);
idx = duk_require_normalize_index(ctx, idx);
duk_bi_json_stringify_helper(ctx,
index /*idx_value*/,
idx /*idx_value*/,
DUK_INVALID_INDEX /*idx_replacer*/,
DUK_INVALID_INDEX /*idx_space*/,
0 /*flags*/);
DUK_ASSERT(duk_is_string(ctx, -1));
duk_replace(ctx, index);
ret = duk_get_string(ctx, index);
duk_replace(ctx, idx);
ret = duk_get_string(ctx, idx);
DUK_ASSERT(duk_get_top(ctx) == top_at_entry);
return ret;
}
DUK_EXTERNAL void duk_json_decode(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL void duk_json_decode(duk_context *ctx, duk_idx_t idx) {
#ifdef DUK_USE_ASSERTIONS
duk_idx_t top_at_entry;
#endif
@ -627,12 +627,12 @@ DUK_EXTERNAL void duk_json_decode(duk_context *ctx, duk_idx_t index) {
top_at_entry = duk_get_top(ctx);
#endif
index = duk_require_normalize_index(ctx, index);
idx = duk_require_normalize_index(ctx, idx);
duk_bi_json_parse_helper(ctx,
index /*idx_value*/,
idx /*idx_value*/,
DUK_INVALID_INDEX /*idx_reviver*/,
0 /*flags*/);
duk_replace(ctx, index);
duk_replace(ctx, idx);
DUK_ASSERT(duk_get_top(ctx) == top_at_entry);
}

92
src/duk_api_internal.h

@ -29,11 +29,11 @@ duk_bool_t duk_valstack_resize_raw(duk_context *ctx,
duk_small_uint_t flags);
#if defined(DUK_USE_VERBOSE_ERRORS) && defined(DUK_USE_PARANOID_ERRORS)
DUK_INTERNAL_DECL const char *duk_get_type_name(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL const char *duk_get_type_name(duk_context *ctx, duk_idx_t idx);
#endif
DUK_INTERNAL_DECL duk_tval *duk_get_tval(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_tval *duk_require_tval(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_tval *duk_get_tval(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_tval *duk_require_tval(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL void duk_push_tval(duk_context *ctx, duk_tval *tv);
/* Push the current 'this' binding; throw TypeError if binding is not object
@ -73,51 +73,51 @@ DUK_INTERNAL_DECL duk_tval *duk_get_borrowed_this_tval(duk_context *ctx);
#define duk_push_size_t(ctx,val) \
duk_push_uint((ctx), (duk_uint_t) (val)) /* XXX: assumed to fit for now */
DUK_INTERNAL_DECL duk_hstring *duk_get_hstring(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hobject *duk_get_hobject(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hbuffer *duk_get_hbuffer(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hthread *duk_get_hthread(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hcompfunc *duk_get_hcompfunc(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hnatfunc *duk_get_hnatfunc(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hstring *duk_get_hstring(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hobject *duk_get_hobject(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hbuffer *duk_get_hbuffer(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hthread *duk_get_hthread(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hcompfunc *duk_get_hcompfunc(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hnatfunc *duk_get_hnatfunc(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hobject *duk_get_hobject_with_class(duk_context *ctx, duk_idx_t index, duk_small_uint_t classnum);
DUK_INTERNAL_DECL duk_hobject *duk_get_hobject_with_class(duk_context *ctx, duk_idx_t idx, duk_small_uint_t classnum);
#if 0 /* This would be pointless: unexpected type and lightfunc would both return NULL */
DUK_INTERNAL_DECL duk_hobject *duk_get_hobject_or_lfunc(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hobject *duk_get_hobject_or_lfunc(duk_context *ctx, duk_idx_t idx);
#endif
DUK_INTERNAL_DECL duk_hobject *duk_get_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hobject *duk_get_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t idx);
#if 0 /*unused*/
DUK_INTERNAL_DECL void *duk_get_voidptr(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL void *duk_get_voidptr(duk_context *ctx, duk_idx_t idx);
#endif
DUK_INTERNAL_DECL duk_hstring *duk_to_hstring(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hstring *duk_to_hstring(duk_context *ctx, duk_idx_t idx);
#if defined(DUK_USE_DEBUGGER_SUPPORT) /* only needed by debugger for now */
DUK_INTERNAL_DECL duk_hstring *duk_safe_to_hstring(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hstring *duk_safe_to_hstring(duk_context *ctx, duk_idx_t idx);
#endif
DUK_INTERNAL_DECL void duk_to_object_class_string_top(duk_context *ctx);
#if !defined(DUK_USE_PARANOID_ERRORS)
DUK_INTERNAL_DECL void duk_push_hobject_class_string(duk_context *ctx, duk_hobject *h);
#endif
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped); /* out_clamped=NULL, RangeError if outside range */
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval);
DUK_INTERNAL_DECL duk_int_t duk_to_int_check_range(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval);
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_context *ctx, duk_idx_t idx, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped); /* out_clamped=NULL, RangeError if outside range */
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_context *ctx, duk_idx_t idx, duk_int_t minval, duk_int_t maxval);
DUK_INTERNAL_DECL duk_int_t duk_to_int_check_range(duk_context *ctx, duk_idx_t idx, duk_int_t minval, duk_int_t maxval);
#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
DUK_INTERNAL_DECL duk_uint8_t duk_to_uint8clamped(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_uint8_t duk_to_uint8clamped(duk_context *ctx, duk_idx_t idx);
#endif
DUK_INTERNAL_DECL duk_hstring *duk_require_hstring(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hobject *duk_require_hobject(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hbuffer *duk_require_hbuffer(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hthread *duk_require_hthread(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hcompfunc *duk_require_hcompfunc(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hnatfunc *duk_require_hnatfunc(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hstring *duk_require_hstring(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hobject *duk_require_hobject(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hbuffer *duk_require_hbuffer(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hthread *duk_require_hthread(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hcompfunc *duk_require_hcompfunc(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hnatfunc *duk_require_hnatfunc(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_with_class(duk_context *ctx, duk_idx_t index, duk_small_uint_t classnum);
DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_with_class(duk_context *ctx, duk_idx_t idx, duk_small_uint_t classnum);
DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_or_lfunc(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_or_lfunc(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL void duk_push_hstring(duk_context *ctx, duk_hstring *h);
DUK_INTERNAL_DECL void duk_push_hstring_stridx(duk_context *ctx, duk_small_int_t stridx);
@ -143,35 +143,35 @@ DUK_INTERNAL_DECL void duk_push_lightfunc_tostring(duk_context *ctx, duk_tval *t
DUK_INTERNAL_DECL duk_hbufobj *duk_push_bufobj_raw(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx);
#if !defined(DUK_USE_PARANOID_ERRORS)
DUK_INTERNAL_DECL const char *duk_push_string_readable(duk_context *ctx, duk_idx_t index);
DUK_INTERNAL_DECL const char *duk_push_string_readable(duk_context *ctx, duk_idx_t idx);
DUK_INTERNAL_DECL const char *duk_push_string_tval_readable(duk_context *ctx, duk_tval *tv);
#endif
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx); /* [] -> [val] */
DUK_INTERNAL_DECL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx); /* [val] -> [] */
DUK_INTERNAL_DECL duk_bool_t duk_del_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx); /* [] -> [] */
DUK_INTERNAL_DECL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx); /* [] -> [] */
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx); /* [] -> [val] */
DUK_INTERNAL_DECL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx); /* [val] -> [] */
DUK_INTERNAL_DECL duk_bool_t duk_del_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx); /* [] -> [] */
DUK_INTERNAL_DECL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx); /* [] -> [] */
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_bool_t *out_has_prop); /* [] -> [] */
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx, duk_bool_t *out_has_prop); /* [] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_index, duk_small_uint_t desc_flags); /* [key val] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index, duk_small_uint_t desc_flags); /* [val] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags); /* [val] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags); /* [] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags); /* [] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t desc_flags); /* [key val] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx, duk_small_uint_t desc_flags); /* [val] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx, duk_small_uint_t desc_flags); /* [val] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags); /* [] -> [] */
DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx, duk_small_uint_t desc_flags); /* [] -> [] */
/* These are macros for now, but could be separate functions to reduce code
* footprint (check call site count before refactoring).
*/
#define duk_xdef_prop_wec(ctx,obj_index) \
duk_xdef_prop((ctx), (obj_index), DUK_PROPDESC_FLAGS_WEC)
#define duk_xdef_prop_index_wec(ctx,obj_index,arr_index) \
duk_xdef_prop_index((ctx), (obj_index), (arr_index), DUK_PROPDESC_FLAGS_WEC)
#define duk_xdef_prop_stridx_wec(ctx,obj_index,stridx) \
duk_xdef_prop_stridx((ctx), (obj_index), (stridx), DUK_PROPDESC_FLAGS_WEC)
#define duk_xdef_prop_wec(ctx,obj_idx) \
duk_xdef_prop((ctx), (obj_idx), DUK_PROPDESC_FLAGS_WEC)
#define duk_xdef_prop_index_wec(ctx,obj_idx,arr_idx) \
duk_xdef_prop_index((ctx), (obj_idx), (arr_idx), DUK_PROPDESC_FLAGS_WEC)
#define duk_xdef_prop_stridx_wec(ctx,obj_idx,stridx) \
duk_xdef_prop_stridx((ctx), (obj_idx), (stridx), DUK_PROPDESC_FLAGS_WEC)
/* Set object 'length'. */
DUK_INTERNAL_DECL void duk_set_length(duk_context *ctx, duk_idx_t index, duk_size_t length);
DUK_INTERNAL_DECL void duk_set_length(duk_context *ctx, duk_idx_t idx, duk_size_t length);
/* Raw internal valstack access macros: access is unsafe so call site
* must have a guarantee that the index is valid. When that is the case,

162
src/duk_api_object.c

@ -12,7 +12,7 @@
* defineProperty, getOwnPropertyDescriptor).
*/
DUK_EXTERNAL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index) {
DUK_EXTERNAL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_tval *tv_obj;
duk_tval *tv_key;
@ -24,7 +24,7 @@ DUK_EXTERNAL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index) {
* resize is not necessary for a property get right now.
*/
tv_obj = duk_require_tval(ctx, obj_index);
tv_obj = duk_require_tval(ctx, obj_idx);
tv_key = duk_require_tval(ctx, -1);
rc = duk_hobject_getprop(thr, tv_obj, tv_key);
@ -35,24 +35,24 @@ DUK_EXTERNAL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index) {
return rc; /* 1 if property found, 0 otherwise */
}
DUK_EXTERNAL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key) {
DUK_EXTERNAL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) {
DUK_ASSERT_CTX_VALID(ctx);
DUK_ASSERT(key != NULL);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_string(ctx, key);
return duk_get_prop(ctx, obj_index);
return duk_get_prop(ctx, obj_idx);
}
DUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index) {
DUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) {
DUK_ASSERT_CTX_VALID(ctx);
obj_index = duk_require_normalize_index(ctx, obj_index);
duk_push_uarridx(ctx, arr_index);
return duk_get_prop(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_uarridx(ctx, arr_idx);
return duk_get_prop(ctx, obj_idx);
}
DUK_INTERNAL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx) {
DUK_INTERNAL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx) {
duk_hthread *thr = (duk_hthread *) ctx;
DUK_ASSERT_CTX_VALID(ctx);
@ -60,19 +60,19 @@ DUK_INTERNAL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_inde
DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS);
DUK_UNREF(thr);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
return duk_get_prop(ctx, obj_index);
return duk_get_prop(ctx, obj_idx);
}
DUK_INTERNAL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_bool_t *out_has_prop) {
DUK_INTERNAL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx, duk_bool_t *out_has_prop) {
duk_bool_t rc;
DUK_ASSERT_CTX_VALID(ctx);
DUK_ASSERT_DISABLE(stridx >= 0);
DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS);
rc = duk_get_prop_stridx(ctx, obj_index, stridx);
rc = duk_get_prop_stridx(ctx, obj_idx, stridx);
if (out_has_prop) {
*out_has_prop = rc;
}
@ -82,7 +82,7 @@ DUK_INTERNAL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t
return rc;
}
DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index) {
DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_tval *tv_obj;
duk_tval *tv_key;
@ -97,7 +97,7 @@ DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index) {
* against it internally).
*/
tv_obj = duk_require_tval(ctx, obj_index);
tv_obj = duk_require_tval(ctx, obj_idx);
tv_key = duk_require_tval(ctx, -2);
tv_val = duk_require_tval(ctx, -1);
throw_flag = duk_is_strict_call(ctx);
@ -109,26 +109,26 @@ DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index) {
return rc; /* 1 if property found, 0 otherwise */
}
DUK_EXTERNAL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key) {
DUK_EXTERNAL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) {
DUK_ASSERT_CTX_VALID(ctx);
DUK_ASSERT(key != NULL);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_string(ctx, key);
duk_swap_top(ctx, -2); /* [val key] -> [key val] */
return duk_put_prop(ctx, obj_index);
return duk_put_prop(ctx, obj_idx);
}
DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index) {
DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) {
DUK_ASSERT_CTX_VALID(ctx);
obj_index = duk_require_normalize_index(ctx, obj_index);
duk_push_uarridx(ctx, arr_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_uarridx(ctx, arr_idx);
duk_swap_top(ctx, -2); /* [val key] -> [key val] */
return duk_put_prop(ctx, obj_index);
return duk_put_prop(ctx, obj_idx);
}
DUK_INTERNAL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx) {
DUK_INTERNAL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx) {
duk_hthread *thr = (duk_hthread *) ctx;
DUK_ASSERT_CTX_VALID(ctx);
@ -136,13 +136,13 @@ DUK_INTERNAL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_inde
DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS);
DUK_UNREF(thr);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
duk_swap_top(ctx, -2); /* [val key] -> [key val] */
return duk_put_prop(ctx, obj_index);
return duk_put_prop(ctx, obj_idx);
}
DUK_EXTERNAL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index) {
DUK_EXTERNAL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_tval *tv_obj;
duk_tval *tv_key;
@ -155,7 +155,7 @@ DUK_EXTERNAL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index) {
* resize is not necessary for a property delete right now.
*/
tv_obj = duk_require_tval(ctx, obj_index);
tv_obj = duk_require_tval(ctx, obj_idx);
tv_key = duk_require_tval(ctx, -1);
throw_flag = duk_is_strict_call(ctx);
@ -166,24 +166,24 @@ DUK_EXTERNAL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index) {
return rc;
}
DUK_EXTERNAL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key) {
DUK_EXTERNAL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) {
DUK_ASSERT_CTX_VALID(ctx);
DUK_ASSERT(key != NULL);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_string(ctx, key);
return duk_del_prop(ctx, obj_index);
return duk_del_prop(ctx, obj_idx);
}
DUK_EXTERNAL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index) {
DUK_EXTERNAL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) {
DUK_ASSERT_CTX_VALID(ctx);
obj_index = duk_require_normalize_index(ctx, obj_index);
duk_push_uarridx(ctx, arr_index);
return duk_del_prop(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_uarridx(ctx, arr_idx);
return duk_del_prop(ctx, obj_idx);
}
DUK_INTERNAL duk_bool_t duk_del_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx) {
DUK_INTERNAL duk_bool_t duk_del_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx) {
duk_hthread *thr = (duk_hthread *) ctx;
DUK_ASSERT_CTX_VALID(ctx);
@ -191,12 +191,12 @@ DUK_INTERNAL duk_bool_t duk_del_prop_stridx(duk_context *ctx, duk_idx_t obj_inde
DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS);
DUK_UNREF(thr);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
return duk_del_prop(ctx, obj_index);
return duk_del_prop(ctx, obj_idx);
}
DUK_EXTERNAL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index) {
DUK_EXTERNAL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_tval *tv_obj;
duk_tval *tv_key;
@ -208,7 +208,7 @@ DUK_EXTERNAL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index) {
* resize is not necessary for a property existence check right now.
*/
tv_obj = duk_require_tval(ctx, obj_index);
tv_obj = duk_require_tval(ctx, obj_idx);
tv_key = duk_require_tval(ctx, -1);
rc = duk_hobject_hasprop(thr, tv_obj, tv_key);
@ -218,24 +218,24 @@ DUK_EXTERNAL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index) {
return rc; /* 1 if property found, 0 otherwise */
}
DUK_EXTERNAL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key) {
DUK_EXTERNAL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) {
DUK_ASSERT_CTX_VALID(ctx);
DUK_ASSERT(key != NULL);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_string(ctx, key);
return duk_has_prop(ctx, obj_index);
return duk_has_prop(ctx, obj_idx);
}
DUK_EXTERNAL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index) {
DUK_EXTERNAL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) {
DUK_ASSERT_CTX_VALID(ctx);
obj_index = duk_require_normalize_index(ctx, obj_index);
duk_push_uarridx(ctx, arr_index);
return duk_has_prop(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_uarridx(ctx, arr_idx);
return duk_has_prop(ctx, obj_idx);
}
DUK_INTERNAL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx) {
DUK_INTERNAL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx) {
duk_hthread *thr = (duk_hthread *) ctx;
DUK_ASSERT_CTX_VALID(ctx);
@ -243,9 +243,9 @@ DUK_INTERNAL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_inde
DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS);
DUK_UNREF(thr);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
return duk_has_prop(ctx, obj_index);
return duk_has_prop(ctx, obj_idx);
}
/* Define own property without inheritance looks and such. This differs from
@ -253,14 +253,14 @@ DUK_INTERNAL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_inde
* not invoked by this method. The caller must be careful to invoke any such
* behaviors if necessary.
*/
DUK_INTERNAL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_index, duk_small_uint_t desc_flags) {
DUK_INTERNAL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t desc_flags) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hobject *obj;
duk_hstring *key;
DUK_ASSERT_CTX_VALID(ctx);
obj = duk_require_hobject(ctx, obj_index);
obj = duk_require_hobject(ctx, obj_idx);
DUK_ASSERT(obj != NULL);
key = duk_to_hstring(ctx, -2);
DUK_ASSERT(key != NULL);
@ -271,20 +271,20 @@ DUK_INTERNAL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_index, duk_small
duk_pop(ctx); /* pop key */
}
DUK_INTERNAL void duk_xdef_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index, duk_small_uint_t desc_flags) {
DUK_INTERNAL void duk_xdef_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx, duk_small_uint_t desc_flags) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hobject *obj;
DUK_ASSERT_CTX_VALID(ctx);
obj = duk_require_hobject(ctx, obj_index);
obj = duk_require_hobject(ctx, obj_idx);
DUK_ASSERT(obj != NULL);
duk_hobject_define_property_internal_arridx(thr, obj, arr_index, desc_flags);
duk_hobject_define_property_internal_arridx(thr, obj, arr_idx, desc_flags);
/* value popped by call */
}
DUK_INTERNAL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags) {
DUK_INTERNAL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx, duk_small_uint_t desc_flags) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hobject *obj;
duk_hstring *key;
@ -293,7 +293,7 @@ DUK_INTERNAL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_index, du
DUK_ASSERT_DISABLE(stridx >= 0);
DUK_ASSERT(stridx < DUK_HEAP_NUM_STRINGS);
obj = duk_require_hobject(ctx, obj_index);
obj = duk_require_hobject(ctx, obj_idx);
DUK_ASSERT(obj != NULL);
key = DUK_HTHREAD_GET_STRING(thr, stridx);
DUK_ASSERT(key != NULL);
@ -303,7 +303,7 @@ DUK_INTERNAL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_index, du
/* value popped by call */
}
DUK_INTERNAL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags) {
DUK_INTERNAL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hobject *obj;
duk_hstring *key;
@ -314,7 +314,7 @@ DUK_INTERNAL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_i
DUK_ASSERT_DISABLE(builtin_idx >= 0);
DUK_ASSERT(builtin_idx < DUK_NUM_BUILTINS);
obj = duk_require_hobject(ctx, obj_index);
obj = duk_require_hobject(ctx, obj_idx);
DUK_ASSERT(obj != NULL);
key = DUK_HTHREAD_GET_STRING(thr, stridx);
DUK_ASSERT(key != NULL);
@ -329,15 +329,15 @@ DUK_INTERNAL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_i
* object creation code, function instance creation code, and Function.prototype.bind().
*/
DUK_INTERNAL void duk_xdef_prop_stridx_thrower(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags) {
DUK_INTERNAL void duk_xdef_prop_stridx_thrower(duk_context *ctx, duk_idx_t obj_idx, duk_small_int_t stridx, duk_small_uint_t desc_flags) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hobject *obj = duk_require_hobject(ctx, obj_index);
duk_hobject *obj = duk_require_hobject(ctx, obj_idx);
duk_hobject *thrower = thr->builtins[DUK_BIDX_TYPE_ERROR_THROWER];
duk_hobject_define_accessor_internal(thr, obj, DUK_HTHREAD_GET_STRING(thr, stridx), thrower, thrower, desc_flags);
}
/* Object.defineProperty() equivalent C binding. */
DUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags) {
DUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_idx_t idx_base;
duk_hobject *obj;
@ -350,7 +350,7 @@ DUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t
DUK_ASSERT_CTX_VALID(ctx);
obj = duk_require_hobject(ctx, obj_index);
obj = duk_require_hobject(ctx, obj_idx);
is_data_desc = flags & (DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE);
is_acc_desc = flags & (DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER);
@ -429,13 +429,13 @@ DUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t
* and are not exposed through the API.
*/
DUK_EXTERNAL void duk_compact(duk_context *ctx, duk_idx_t obj_index) {
DUK_EXTERNAL void duk_compact(duk_context *ctx, duk_idx_t obj_idx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hobject *obj;
DUK_ASSERT_CTX_VALID(ctx);
obj = duk_get_hobject(ctx, obj_index);
obj = duk_get_hobject(ctx, obj_idx);
if (obj) {
/* Note: this may fail, caller should protect the call if necessary */
duk_hobject_compact_props(thr, obj);
@ -444,10 +444,10 @@ DUK_EXTERNAL void duk_compact(duk_context *ctx, duk_idx_t obj_index) {
/* XXX: the duk_hobject_enum.c stack APIs should be reworked */
DUK_EXTERNAL void duk_enum(duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags) {
DUK_EXTERNAL void duk_enum(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t enum_flags) {
DUK_ASSERT_CTX_VALID(ctx);
duk_dup(ctx, obj_index);
duk_dup(ctx, obj_idx);
duk_require_hobject_or_lfunc_coerce(ctx, -1);
duk_hobject_enumerator_create(ctx, enum_flags); /* [target] -> [enum] */
}
@ -464,31 +464,31 @@ DUK_EXTERNAL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_boo
* Helpers for writing multiple properties
*/
DUK_EXTERNAL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_index, const duk_function_list_entry *funcs) {
DUK_EXTERNAL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_idx, const duk_function_list_entry *funcs) {
const duk_function_list_entry *ent = funcs;
DUK_ASSERT_CTX_VALID(ctx);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
if (ent != NULL) {
while (ent->key != NULL) {
duk_push_c_function(ctx, ent->value, ent->nargs);
duk_put_prop_string(ctx, obj_index, ent->key);
duk_put_prop_string(ctx, obj_idx, ent->key);
ent++;
}
}
}
DUK_EXTERNAL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_index, const duk_number_list_entry *numbers) {
DUK_EXTERNAL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_idx, const duk_number_list_entry *numbers) {
const duk_number_list_entry *ent = numbers;
DUK_ASSERT_CTX_VALID(ctx);
obj_index = duk_require_normalize_index(ctx, obj_index);
obj_idx = duk_require_normalize_index(ctx, obj_idx);
if (ent != NULL) {
while (ent->key != NULL) {
duk_push_number(ctx, ent->value);
duk_put_prop_string(ctx, obj_index, ent->key);
duk_put_prop_string(ctx, obj_idx, ent->key);
ent++;
}
}
@ -533,7 +533,7 @@ DUK_EXTERNAL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key)
* Object prototype
*/
DUK_EXTERNAL void duk_get_prototype(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL void duk_get_prototype(duk_context *ctx, duk_idx_t idx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hobject *obj;
duk_hobject *proto;
@ -541,7 +541,7 @@ DUK_EXTERNAL void duk_get_prototype(duk_context *ctx, duk_idx_t index) {
DUK_ASSERT_CTX_VALID(ctx);
DUK_UNREF(thr);
obj = duk_require_hobject(ctx, index);
obj = duk_require_hobject(ctx, idx);
DUK_ASSERT(obj != NULL);
/* XXX: shared helper for duk_push_hobject_or_undefined()? */
@ -553,14 +553,14 @@ DUK_EXTERNAL void duk_get_prototype(duk_context *ctx, duk_idx_t index) {
}
}
DUK_EXTERNAL void duk_set_prototype(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL void duk_set_prototype(duk_context *ctx, duk_idx_t idx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hobject *obj;
duk_hobject *proto;
DUK_ASSERT_CTX_VALID(ctx);
obj = duk_require_hobject(ctx, index);
obj = duk_require_hobject(ctx, idx);
DUK_ASSERT(obj != NULL);
duk_require_type_mask(ctx, -1, DUK_TYPE_MASK_UNDEFINED |
DUK_TYPE_MASK_OBJECT);
@ -588,14 +588,14 @@ DUK_EXTERNAL void duk_set_prototype(duk_context *ctx, duk_idx_t index) {
* XXX: same issue as with Duktape.fin: there's no way to delete the property
* now (just set it to undefined).
*/
DUK_EXTERNAL void duk_get_finalizer(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL void duk_get_finalizer(duk_context *ctx, duk_idx_t idx) {
DUK_ASSERT_CTX_VALID(ctx);
duk_get_prop_stridx(ctx, index, DUK_STRIDX_INT_FINALIZER);
duk_get_prop_stridx(ctx, idx, DUK_STRIDX_INT_FINALIZER);
}
DUK_EXTERNAL void duk_set_finalizer(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL void duk_set_finalizer(duk_context *ctx, duk_idx_t idx) {
DUK_ASSERT_CTX_VALID(ctx);
duk_put_prop_stridx(ctx, index, DUK_STRIDX_INT_FINALIZER);
duk_put_prop_stridx(ctx, idx, DUK_STRIDX_INT_FINALIZER);
}

362
src/duk_api_public.h.in

@ -328,13 +328,13 @@ DUK_EXTERNAL_DECL duk_bool_t duk_is_constructor_call(duk_context *ctx);
* Stack management
*/
DUK_EXTERNAL_DECL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_require_valid_index(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_require_valid_index(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_idx_t duk_get_top(duk_context *ctx);
DUK_EXTERNAL_DECL void duk_set_top(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_set_top(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_idx_t duk_get_top_index(duk_context *ctx);
DUK_EXTERNAL_DECL duk_idx_t duk_require_top_index(duk_context *ctx);
@ -354,14 +354,14 @@ DUK_EXTERNAL_DECL void duk_require_stack_top(duk_context *ctx, duk_idx_t top);
* Stack manipulation (other than push/pop)
*/
DUK_EXTERNAL_DECL void duk_swap(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
DUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_index);
DUK_EXTERNAL_DECL void duk_swap(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
DUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_idx);
DUK_EXTERNAL_DECL void duk_dup_top(duk_context *ctx);
DUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_index);
DUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_index);
DUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_index, duk_idx_t to_index);
DUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_idx);
DUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_idx);
DUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_idx, duk_idx_t to_idx);
DUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_xcopymove_raw(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy);
#define duk_xmove_top(to_ctx,from_ctx,count) \
@ -481,70 +481,70 @@ DUK_EXTERNAL_DECL void duk_pop_3(duk_context *ctx);
* is not needed; duk_is_valid_index() gives the same information.
*/
DUK_EXTERNAL_DECL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t index, duk_int_t type);
DUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t index, duk_uint_t mask);
DUK_EXTERNAL_DECL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_null_or_undefined(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t index);
#define duk_is_callable(ctx,index) \
duk_is_function((ctx), (index))
DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t index);
#define duk_is_primitive(ctx,index) \
duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_UNDEFINED | \
DUK_TYPE_MASK_NULL | \
DUK_TYPE_MASK_BOOLEAN | \
DUK_TYPE_MASK_NUMBER | \
DUK_TYPE_MASK_STRING | \
DUK_TYPE_MASK_BUFFER | \
DUK_TYPE_MASK_POINTER | \
DUK_TYPE_MASK_LIGHTFUNC)
#define duk_is_object_coercible(ctx,index) \
duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
DUK_TYPE_MASK_NUMBER | \
DUK_TYPE_MASK_STRING | \
DUK_TYPE_MASK_OBJECT | \
DUK_TYPE_MASK_BUFFER | \
DUK_TYPE_MASK_POINTER | \
DUK_TYPE_MASK_LIGHTFUNC)
DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t index);
#define duk_is_error(ctx,index) \
(duk_get_error_code((ctx), (index)) != 0)
#define duk_is_eval_error(ctx,index) \
(duk_get_error_code((ctx), (index)) == DUK_ERR_EVAL_ERROR)
#define duk_is_range_error(ctx,index) \
(duk_get_error_code((ctx), (index)) == DUK_ERR_RANGE_ERROR)
#define duk_is_reference_error(ctx,index) \
(duk_get_error_code((ctx), (index)) == DUK_ERR_REFERENCE_ERROR)
#define duk_is_syntax_error(ctx,index) \
(duk_get_error_code((ctx), (index)) == DUK_ERR_SYNTAX_ERROR)
#define duk_is_type_error(ctx,index) \
(duk_get_error_code((ctx), (index)) == DUK_ERR_TYPE_ERROR)
#define duk_is_uri_error(ctx,index) \
(duk_get_error_code((ctx), (index)) == DUK_ERR_URI_ERROR)
DUK_EXTERNAL_DECL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t idx, duk_int_t type);
DUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t mask);
DUK_EXTERNAL_DECL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_null_or_undefined(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t idx);
#define duk_is_callable(ctx,idx) \
duk_is_function((ctx), (idx))
DUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t idx);
#define duk_is_primitive(ctx,idx) \
duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_UNDEFINED | \
DUK_TYPE_MASK_NULL | \
DUK_TYPE_MASK_BOOLEAN | \
DUK_TYPE_MASK_NUMBER | \
DUK_TYPE_MASK_STRING | \
DUK_TYPE_MASK_BUFFER | \
DUK_TYPE_MASK_POINTER | \
DUK_TYPE_MASK_LIGHTFUNC)
#define duk_is_object_coercible(ctx,idx) \
duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \
DUK_TYPE_MASK_NUMBER | \
DUK_TYPE_MASK_STRING | \
DUK_TYPE_MASK_OBJECT | \
DUK_TYPE_MASK_BUFFER | \
DUK_TYPE_MASK_POINTER | \
DUK_TYPE_MASK_LIGHTFUNC)
DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t idx);
#define duk_is_error(ctx,idx) \
(duk_get_error_code((ctx), (idx)) != 0)
#define duk_is_eval_error(ctx,idx) \
(duk_get_error_code((ctx), (idx)) == DUK_ERR_EVAL_ERROR)
#define duk_is_range_error(ctx,idx) \
(duk_get_error_code((ctx), (idx)) == DUK_ERR_RANGE_ERROR)
#define duk_is_reference_error(ctx,idx) \
(duk_get_error_code((ctx), (idx)) == DUK_ERR_REFERENCE_ERROR)
#define duk_is_syntax_error(ctx,idx) \
(duk_get_error_code((ctx), (idx)) == DUK_ERR_SYNTAX_ERROR)
#define duk_is_type_error(ctx,idx) \
(duk_get_error_code((ctx), (idx)) == DUK_ERR_TYPE_ERROR)
#define duk_is_uri_error(ctx,idx) \
(duk_get_error_code((ctx), (idx)) == DUK_ERR_URI_ERROR)
/*
* Get operations: no coercion, returns default value for invalid
@ -554,48 +554,48 @@ DUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t i
* are not included.
*/
DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL const char *duk_get_string(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL const char *duk_get_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
DUK_EXTERNAL_DECL void *duk_get_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
DUK_EXTERNAL_DECL void *duk_get_buffer_data(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
DUK_EXTERNAL_DECL void *duk_get_pointer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_context *duk_get_context(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void *duk_get_heapptr(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_get_string(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_get_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);
DUK_EXTERNAL_DECL void *duk_get_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
DUK_EXTERNAL_DECL void *duk_get_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
DUK_EXTERNAL_DECL void *duk_get_pointer(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_context *duk_get_context(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void *duk_get_heapptr(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t idx);
/*
* Require operations: no coercion, throw error if index or type
* is incorrect. No defaulting.
*/
#define duk_require_type_mask(ctx,index,mask) \
((void) duk_check_type_mask((ctx), (index), (mask) | DUK_TYPE_MASK_THROW))
DUK_EXTERNAL_DECL void duk_require_undefined(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_require_null(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL const char *duk_require_string(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL const char *duk_require_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
DUK_EXTERNAL_DECL void *duk_require_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
DUK_EXTERNAL_DECL void *duk_require_buffer_data(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
DUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_require_function(duk_context *ctx, duk_idx_t index);
#define duk_require_callable(ctx,index) \
duk_require_function((ctx), (index))
DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t index);
#define duk_require_object_coercible(ctx,index) \
((void) duk_check_type_mask((ctx), (index), DUK_TYPE_MASK_BOOLEAN | \
#define duk_require_type_mask(ctx,idx,mask) \
((void) duk_check_type_mask((ctx), (idx), (mask) | DUK_TYPE_MASK_THROW))
DUK_EXTERNAL_DECL void duk_require_undefined(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_require_null(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_require_string(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_require_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);
DUK_EXTERNAL_DECL void *duk_require_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
DUK_EXTERNAL_DECL void *duk_require_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
DUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_require_function(duk_context *ctx, duk_idx_t idx);
#define duk_require_callable(ctx,idx) \
duk_require_function((ctx), (idx))
DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t idx);
#define duk_require_object_coercible(ctx,idx) \
((void) duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \
DUK_TYPE_MASK_NUMBER | \
DUK_TYPE_MASK_STRING | \
DUK_TYPE_MASK_OBJECT | \
@ -611,57 +611,57 @@ DUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t index);
* or an internal error (e.g. from out of memory).
*/
DUK_EXTERNAL_DECL void duk_to_undefined(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_to_null(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL const char *duk_to_string(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL const char *duk_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
DUK_EXTERNAL_DECL void *duk_to_buffer_raw(duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_uint_t flags);
DUK_EXTERNAL_DECL void *duk_to_pointer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_to_object(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_to_defaultvalue(duk_context *ctx, duk_idx_t index, duk_int_t hint);
DUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t index, duk_int_t hint);
DUK_EXTERNAL_DECL void duk_to_undefined(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_to_null(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_to_string(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);
DUK_EXTERNAL_DECL void *duk_to_buffer_raw(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, duk_uint_t flags);
DUK_EXTERNAL_DECL void *duk_to_pointer(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_to_object(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_to_defaultvalue(duk_context *ctx, duk_idx_t idx, duk_int_t hint);
DUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t idx, duk_int_t hint);
#define DUK_BUF_MODE_FIXED 0 /* internal: request fixed buffer result */
#define DUK_BUF_MODE_DYNAMIC 1 /* internal: request dynamic buffer result */
#define DUK_BUF_MODE_DONTCARE 2 /* internal: don't care about fixed/dynamic nature */
#define duk_to_buffer(ctx,index,out_size) \
duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DONTCARE)
#define duk_to_fixed_buffer(ctx,index,out_size) \
duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_FIXED)
#define duk_to_dynamic_buffer(ctx,index,out_size) \
duk_to_buffer_raw((ctx), (index), (out_size), DUK_BUF_MODE_DYNAMIC)
#define duk_to_buffer(ctx,idx,out_size) \
duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DONTCARE)
#define duk_to_fixed_buffer(ctx,idx,out_size) \
duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_FIXED)
#define duk_to_dynamic_buffer(ctx,idx,out_size) \
duk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DYNAMIC)
/* safe variants of a few coercion operations */
DUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len);
#define duk_safe_to_string(ctx,index) \
duk_safe_to_lstring((ctx), (index), NULL)
DUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);
#define duk_safe_to_string(ctx,idx) \
duk_safe_to_lstring((ctx), (idx), NULL)
/*
* Misc conversion
*/
DUK_EXTERNAL_DECL const char *duk_base64_encode(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_base64_decode(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL const char *duk_base64_encode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_base64_decode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t idx);
/*
* Buffer
*/
DUK_EXTERNAL_DECL void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size);
DUK_EXTERNAL_DECL void *duk_steal_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size);
DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t index, void *ptr, duk_size_t len);
DUK_EXTERNAL_DECL void *duk_resize_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t new_size);
DUK_EXTERNAL_DECL void *duk_steal_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);
DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t idx, void *ptr, duk_size_t len);
/*
* Property access
@ -671,19 +671,19 @@ DUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t index, void
* index as a property name (e.g. 123 is equivalent to the key "123").
*/
DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index);
DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_index);
DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index);
DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index);
DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key);
DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index);
DUK_EXTERNAL_DECL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags);
DUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx);
DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);
DUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);
DUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx);
DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);
DUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);
DUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx);
DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);
DUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);
DUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx);
DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);
DUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);
DUK_EXTERNAL_DECL void duk_def_prop(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags);
DUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key);
DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key);
@ -692,15 +692,15 @@ DUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char
* Object prototype
*/
DUK_EXTERNAL_DECL void duk_get_prototype(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_set_prototype(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_get_prototype(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_set_prototype(duk_context *ctx, duk_idx_t idx);
/*
* Object finalizer
*/
DUK_EXTERNAL_DECL void duk_get_finalizer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_set_finalizer(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_get_finalizer(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_set_finalizer(duk_context *ctx, duk_idx_t idx);
/*
* Global object
@ -712,24 +712,24 @@ DUK_EXTERNAL_DECL void duk_set_global_object(duk_context *ctx);
* Duktape/C function magic value
*/
DUK_EXTERNAL_DECL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL void duk_set_magic(duk_context *ctx, duk_idx_t index, duk_int_t magic);
DUK_EXTERNAL_DECL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL void duk_set_magic(duk_context *ctx, duk_idx_t idx, duk_int_t magic);
DUK_EXTERNAL_DECL duk_int_t duk_get_current_magic(duk_context *ctx);
/*
* Module helpers: put multiple function or constant properties
*/
DUK_EXTERNAL_DECL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_index, const duk_function_list_entry *funcs);
DUK_EXTERNAL_DECL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_index, const duk_number_list_entry *numbers);
DUK_EXTERNAL_DECL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_idx, const duk_function_list_entry *funcs);
DUK_EXTERNAL_DECL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_idx, const duk_number_list_entry *numbers);
/*
* Object operations
*/
DUK_EXTERNAL_DECL void duk_compact(duk_context *ctx, duk_idx_t obj_index);
DUK_EXTERNAL_DECL void duk_enum(duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags);
DUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value);
DUK_EXTERNAL_DECL void duk_compact(duk_context *ctx, duk_idx_t obj_idx);
DUK_EXTERNAL_DECL void duk_enum(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t enum_flags);
DUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_idx, duk_bool_t get_value);
/*
* String manipulation
@ -737,19 +737,19 @@ DUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, du
DUK_EXTERNAL_DECL void duk_concat(duk_context *ctx, duk_idx_t count);
DUK_EXTERNAL_DECL void duk_join(duk_context *ctx, duk_idx_t count);
DUK_EXTERNAL_DECL void duk_decode_string(duk_context *ctx, duk_idx_t index, duk_decode_char_function callback, void *udata);
DUK_EXTERNAL_DECL void duk_map_string(duk_context *ctx, duk_idx_t index, duk_map_char_function callback, void *udata);
DUK_EXTERNAL_DECL void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t start_char_offset, duk_size_t end_char_offset);
DUK_EXTERNAL_DECL void duk_trim(duk_context *ctx, duk_idx_t index);
DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t index, duk_size_t char_offset);
DUK_EXTERNAL_DECL void duk_decode_string(duk_context *ctx, duk_idx_t idx, duk_decode_char_function callback, void *udata);
DUK_EXTERNAL_DECL void duk_map_string(duk_context *ctx, duk_idx_t idx, duk_map_char_function callback, void *udata);
DUK_EXTERNAL_DECL void duk_substring(duk_context *ctx, duk_idx_t idx, duk_size_t start_char_offset, duk_size_t end_char_offset);
DUK_EXTERNAL_DECL void duk_trim(duk_context *ctx, duk_idx_t idx);
DUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset);
/*
* Ecmascript operators
*/
DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t index1, duk_idx_t index2);
DUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
DUK_EXTERNAL_DECL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);
/*
* Function (method) calls
@ -757,10 +757,10 @@ DUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t index1,
DUK_EXTERNAL_DECL void duk_call(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL void duk_call_method(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL void duk_call_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs);
DUK_EXTERNAL_DECL void duk_call_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);
DUK_EXTERNAL_DECL void duk_new(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, void *udata, duk_idx_t nargs, duk_idx_t nrets);
@ -885,7 +885,7 @@ DUK_EXTERNAL_DECL void duk_debugger_pause(duk_context *ctx);
*/
DUK_EXTERNAL_DECL duk_double_t duk_get_now(duk_context *ctx);
DUK_EXTERNAL_DECL void duk_time_to_components(duk_context *ctx, duk_double_t time, duk_time_components *comp);
DUK_EXTERNAL_DECL void duk_time_to_components(duk_context *ctx, duk_double_t timeval, duk_time_components *comp);
DUK_EXTERNAL_DECL duk_double_t duk_components_to_time(duk_context *ctx, duk_time_components *comp);
/*

692
src/duk_api_stack.c

File diff suppressed because it is too large

32
src/duk_api_string.c

@ -122,7 +122,7 @@ DUK_EXTERNAL void duk_join(duk_context *ctx, duk_idx_t count) {
* Case conversion needs also the character surroundings though.
*/
DUK_EXTERNAL void duk_decode_string(duk_context *ctx, duk_idx_t index, duk_decode_char_function callback, void *udata) {
DUK_EXTERNAL void duk_decode_string(duk_context *ctx, duk_idx_t idx, duk_decode_char_function callback, void *udata) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hstring *h_input;
const duk_uint8_t *p, *p_start, *p_end;
@ -130,7 +130,7 @@ DUK_EXTERNAL void duk_decode_string(duk_context *ctx, duk_idx_t index, duk_decod
DUK_ASSERT_CTX_VALID(ctx);
h_input = duk_require_hstring(ctx, index);
h_input = duk_require_hstring(ctx, idx);
DUK_ASSERT(h_input != NULL);
p_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);
@ -146,7 +146,7 @@ DUK_EXTERNAL void duk_decode_string(duk_context *ctx, duk_idx_t index, duk_decod
}
}
DUK_EXTERNAL void duk_map_string(duk_context *ctx, duk_idx_t index, duk_map_char_function callback, void *udata) {
DUK_EXTERNAL void duk_map_string(duk_context *ctx, duk_idx_t idx, duk_map_char_function callback, void *udata) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hstring *h_input;
duk_bufwriter_ctx bw_alloc;
@ -156,9 +156,9 @@ DUK_EXTERNAL void duk_map_string(duk_context *ctx, duk_idx_t index, duk_map_char
DUK_ASSERT_CTX_VALID(ctx);
index = duk_normalize_index(ctx, index);
idx = duk_normalize_index(ctx, idx);
h_input = duk_require_hstring(ctx, index);
h_input = duk_require_hstring(ctx, idx);
DUK_ASSERT(h_input != NULL);
bw = &bw_alloc;
@ -184,10 +184,10 @@ DUK_EXTERNAL void duk_map_string(duk_context *ctx, duk_idx_t index, duk_map_char
DUK_BW_COMPACT(thr, bw);
duk_to_string(ctx, -1);
duk_replace(ctx, index);
duk_replace(ctx, idx);
}
DUK_EXTERNAL void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t start_offset, duk_size_t end_offset) {
DUK_EXTERNAL void duk_substring(duk_context *ctx, duk_idx_t idx, duk_size_t start_offset, duk_size_t end_offset) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hstring *h;
duk_hstring *res;
@ -196,8 +196,8 @@ DUK_EXTERNAL void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t st
DUK_ASSERT_CTX_VALID(ctx);
index = duk_require_normalize_index(ctx, index);
h = duk_require_hstring(ctx, index);
idx = duk_require_normalize_index(ctx, idx);
h = duk_require_hstring(ctx, idx);
DUK_ASSERT(h != NULL);
if (end_offset >= DUK_HSTRING_GET_CHARLEN(h)) {
@ -228,13 +228,13 @@ DUK_EXTERNAL void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t st
(duk_uint32_t) (end_byte_offset - start_byte_offset));
duk_push_hstring(ctx, res);
duk_replace(ctx, index);
duk_replace(ctx, idx);
}
/* XXX: this is quite clunky. Add Unicode helpers to scan backwards and
* forwards with a callback to process codepoints?
*/
DUK_EXTERNAL void duk_trim(duk_context *ctx, duk_idx_t index) {
DUK_EXTERNAL void duk_trim(duk_context *ctx, duk_idx_t idx) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hstring *h;
const duk_uint8_t *p, *p_start, *p_end, *p_tmp1, *p_tmp2; /* pointers for scanning */
@ -243,8 +243,8 @@ DUK_EXTERNAL void duk_trim(duk_context *ctx, duk_idx_t index) {
DUK_ASSERT_CTX_VALID(ctx);
index = duk_require_normalize_index(ctx, index);
h = duk_require_hstring(ctx, index);
idx = duk_require_normalize_index(ctx, idx);
h = duk_require_hstring(ctx, idx);
DUK_ASSERT(h != NULL);
p_start = DUK_HSTRING_GET_DATA(h);
@ -307,17 +307,17 @@ DUK_EXTERNAL void duk_trim(duk_context *ctx, duk_idx_t index) {
}
duk_push_lstring(ctx, (const char *) q_start, (duk_size_t) (q_end - q_start));
duk_replace(ctx, index);
duk_replace(ctx, idx);
}
DUK_EXTERNAL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t index, duk_size_t char_offset) {
DUK_EXTERNAL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset) {
duk_hthread *thr = (duk_hthread *) ctx;
duk_hstring *h;
duk_ucodepoint_t cp;
DUK_ASSERT_CTX_VALID(ctx);
h = duk_require_hstring(ctx, index);
h = duk_require_hstring(ctx, idx);
DUK_ASSERT(h != NULL);
DUK_ASSERT_DISABLE(char_offset >= 0); /* always true, arg is unsigned */

4
src/duk_api_time.c

@ -8,7 +8,7 @@ DUK_EXTERNAL duk_double_t duk_get_now(duk_context *ctx) {
return ((duk_double_t) DUK_USE_DATE_GET_NOW((ctx)));
}
DUK_EXTERNAL void duk_time_to_components(duk_context *ctx, duk_double_t time, duk_time_components *comp) {
DUK_EXTERNAL void duk_time_to_components(duk_context *ctx, duk_double_t timeval, duk_time_components *comp) {
duk_int_t parts[DUK_DATE_IDX_NUM_PARTS];
duk_double_t dparts[DUK_DATE_IDX_NUM_PARTS];
duk_uint_t flags;
@ -20,7 +20,7 @@ DUK_EXTERNAL void duk_time_to_components(duk_context *ctx, duk_double_t time, du
/* XXX: one-based or zero-based? or expose flag(s)? */
flags = DUK_DATE_FLAG_ONEBASED | DUK_DATE_FLAG_NAN_TO_ZERO;
duk_bi_date_timeval_to_parts(time, parts, dparts, flags);
duk_bi_date_timeval_to_parts(timeval, parts, dparts, flags);
/* XXX: expensive conversion */
comp->year = (duk_uint_t) parts[DUK_DATE_IDX_YEAR];

20
src/duk_bi_array.c

@ -1117,7 +1117,7 @@ DUK_INTERNAL duk_ret_t duk_bi_array_prototype_unshift(duk_context *ctx) {
DUK_INTERNAL duk_ret_t duk_bi_array_prototype_indexof_shared(duk_context *ctx) {
duk_idx_t nargs;
duk_int_t i, len;
duk_int_t from_index;
duk_int_t from_idx;
duk_small_int_t idx_step = duk_get_current_magic(ctx); /* idx_step is +1 for indexOf, -1 for lastIndexOf */
/* lastIndexOf() needs to be a vararg function because we must distinguish
@ -1156,22 +1156,22 @@ DUK_INTERNAL duk_ret_t duk_bi_array_prototype_indexof_shared(duk_context *ctx) {
* lastIndexOf: clamp fromIndex to [-len - 1, len - 1]
* (if clamped to -len-1 -> fromIndex becomes -1, terminates for-loop directly)
*/
from_index = duk_to_int_clamped(ctx,
1,
(idx_step > 0 ? -len : -len - 1),
(idx_step > 0 ? len : len - 1));
if (from_index < 0) {
from_idx = duk_to_int_clamped(ctx,
1,
(idx_step > 0 ? -len : -len - 1),
(idx_step > 0 ? len : len - 1));
if (from_idx < 0) {
/* for lastIndexOf, result may be -1 (mark immediate termination) */
from_index = len + from_index;
from_idx = len + from_idx;
}
} else {
/* for indexOf, ToInteger(undefined) would be 0, i.e. correct, but
* handle both indexOf and lastIndexOf specially here.
*/
if (idx_step > 0) {
from_index = 0;
from_idx = 0;
} else {
from_index = len - 1;
from_idx = len - 1;
}
}
@ -1181,7 +1181,7 @@ DUK_INTERNAL duk_ret_t duk_bi_array_prototype_indexof_shared(duk_context *ctx) {
* stack[3] = length (not needed, but not popped above)
*/
for (i = from_index; i >= 0 && i < len; i += idx_step) {
for (i = from_idx; i >= 0 && i < len; i += idx_step) {
DUK_ASSERT_TOP(ctx, 4);
if (duk_get_prop_index(ctx, 2, (duk_uarridx_t) i)) {

6
src/duk_bi_buffer.c

@ -149,7 +149,7 @@ DUK_LOCAL duk_hbufobj *duk__require_bufobj_this(duk_context *ctx) {
#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
/* Check that value is a duk_hbufobj and return a pointer to it. */
DUK_LOCAL duk_hbufobj *duk__require_bufobj_value(duk_context *ctx, duk_idx_t index) {
DUK_LOCAL duk_hbufobj *duk__require_bufobj_value(duk_context *ctx, duk_idx_t idx) {
duk_hthread *thr;
duk_tval *tv;
duk_hbufobj *h_obj;
@ -157,9 +157,9 @@ DUK_LOCAL duk_hbufobj *duk__require_bufobj_value(duk_context *ctx, duk_idx_t ind
thr = (duk_hthread *) ctx;
/* Don't accept relative indices now. */
DUK_ASSERT(index >= 0);
DUK_ASSERT(idx >= 0);
tv = duk_require_tval(ctx, index);
tv = duk_require_tval(ctx, idx);
DUK_ASSERT(tv != NULL);
if (DUK_TVAL_IS_OBJECT(tv)) {
h_obj = (duk_hbufobj *) DUK_TVAL_GET_OBJECT(tv);

10
src/duk_bi_string.c

@ -1089,18 +1089,18 @@ DUK_INTERNAL duk_ret_t duk_bi_string_prototype_split(duk_context *ctx) {
*/
#ifdef DUK_USE_REGEXP_SUPPORT
DUK_LOCAL void duk__to_regexp_helper(duk_context *ctx, duk_idx_t index, duk_bool_t force_new) {
DUK_LOCAL void duk__to_regexp_helper(duk_context *ctx, duk_idx_t idx, duk_bool_t force_new) {
duk_hobject *h;
/* Shared helper for match() steps 3-4, search() steps 3-4. */
DUK_ASSERT(index >= 0);
DUK_ASSERT(idx >= 0);
if (force_new) {
goto do_new;
}
h = duk_get_hobject_with_class(ctx, index, DUK_HOBJECT_CLASS_REGEXP);
h = duk_get_hobject_with_class(ctx, idx, DUK_HOBJECT_CLASS_REGEXP);
if (!h) {
goto do_new;
}
@ -1108,9 +1108,9 @@ DUK_LOCAL void duk__to_regexp_helper(duk_context *ctx, duk_idx_t index, duk_bool
do_new:
duk_push_hobject_bidx(ctx, DUK_BIDX_REGEXP_CONSTRUCTOR);
duk_dup(ctx, index);
duk_dup(ctx, idx);
duk_new(ctx, 1); /* [ ... RegExp val ] -> [ ... res ] */
duk_replace(ctx, index);
duk_replace(ctx, idx);
}
#endif /* DUK_USE_REGEXP_SUPPORT */

8
src/duk_debug_heap.c

@ -44,14 +44,14 @@ DUK_LOCAL const char *duk__get_heap_type_string(duk_heaphdr *hdr) {
#endif
#if 0
DUK_LOCAL void duk__dump_indented(duk_heaphdr *obj, int index) {
DUK_LOCAL void duk__dump_indented(duk_heaphdr *obj, int idx) {
DUK_UNREF(obj);
DUK_UNREF(index);
DUK_UNREF(idx);
DUK_UNREF(duk__get_heap_type_string);
#ifdef DUK_USE_REFERENCE_COUNTING
DUK_D(DUK_DPRINT(" [%ld]: %p %s (flags: 0x%08lx, ref: %ld) -> %!O",
(long) index,
(long) idx,
(void *) obj,
(const char *) duk__get_heap_type_string(obj),
(unsigned long) DUK_HEAPHDR_GET_FLAGS(obj),
@ -59,7 +59,7 @@ DUK_LOCAL void duk__dump_indented(duk_heaphdr *obj, int index) {
(duk_heaphdr *) obj));
#else
DUK_D(DUK_DPRINT(" [%ld]: %p %s (flags: 0x%08lx) -> %!O",
(long) index,
(long) idx,
(void *) obj,
(const char *) duk__get_heap_type_string(obj),
(unsigned long) DUK_HEAPHDR_GET_FLAGS(obj),

22
src/duk_error.h

@ -243,12 +243,12 @@
* vs. non-paranoid distinction affects only a few specific errors.
*/
#if defined(DUK_USE_PARANOID_ERRORS)
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,index,expectname,lowmemstr) do { \
duk_err_require_type_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (index), (expectname)); \
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,idx,expectname,lowmemstr) do { \
duk_err_require_type_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (idx), (expectname)); \
} while (0)
#else /* DUK_USE_PARANOID_ERRORS */
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,index,expectname,lowmemstr) do { \
duk_err_require_type_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (index), (expectname)); \
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,idx,expectname,lowmemstr) do { \
duk_err_require_type_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (idx), (expectname)); \
} while (0)
#endif /* DUK_USE_PARANOID_ERRORS */
@ -277,8 +277,8 @@
DUK_ERROR_ALLOC((thr), DUK_STR_ALLOC_FAILED); \
} while (0)
/* DUK_ERR_ASSERTION_ERROR: no macros needed */
#define DUK_ERROR_API_INDEX(thr,index) do { \
duk_err_api_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (index)); \
#define DUK_ERROR_API_INDEX(thr,idx) do { \
duk_err_api_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (idx)); \
} while (0)
#define DUK_ERROR_API(thr,msg) do { \
duk_err_api((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (msg)); \
@ -300,7 +300,7 @@
#else /* DUK_USE_VERBOSE_ERRORS */
/* Non-verbose errors for low memory targets: no file, line, or message. */
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,index,expectname,lowmemstr) do { \
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,idx,expectname,lowmemstr) do { \
duk_err_type((thr)); \
} while (0)
@ -328,7 +328,7 @@
#define DUK_ERROR_ALLOC_DEFMSG(thr) do { \
duk_err_alloc((thr)); \
} while (0)
#define DUK_ERROR_API_INDEX(thr,index) do { \
#define DUK_ERROR_API_INDEX(thr,idx) do { \
duk_err_api((thr)); \
} while (0)
#define DUK_ERROR_API(thr,msg) do { \
@ -373,11 +373,11 @@ DUK_INTERNAL_DECL void duk_err_augment_error_throw(duk_hthread *thr);
#if defined(DUK_USE_VERBOSE_ERRORS)
#if defined(DUK_USE_PARANOID_ERRORS)
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index, const char *expect_name));
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx, const char *expect_name));
#else
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index, const char *expect_name));
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx, const char *expect_name));
#endif
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_api_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index));
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_api_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx));
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_api(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message));
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_range(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message));
DUK_NORETURN(DUK_INTERNAL_DECL void duk_err_unimplemented_defmsg(duk_hthread *thr, const char *filename, duk_int_t linenumber));

12
src/duk_error_macros.c

@ -36,21 +36,21 @@ DUK_INTERNAL void duk_err_handle_error(duk_hthread *thr, duk_errcode_t code) {
#if defined(DUK_USE_VERBOSE_ERRORS)
#if defined(DUK_USE_PARANOID_ERRORS)
DUK_INTERNAL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index, const char *expect_name) {
DUK_INTERNAL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx, const char *expect_name) {
DUK_ERROR_RAW_FMT3(thr, filename, linenumber, DUK_ERR_TYPE_ERROR, "%s required, found %s (stack index %ld)",
expect_name, duk_get_type_name((duk_context *) thr, index), (long) index);
expect_name, duk_get_type_name((duk_context *) thr, idx), (long) idx);
}
#else
DUK_INTERNAL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index, const char *expect_name) {
DUK_INTERNAL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx, const char *expect_name) {
DUK_ERROR_RAW_FMT3(thr, filename, linenumber, DUK_ERR_TYPE_ERROR, "%s required, found %s (stack index %ld)",
expect_name, duk_push_string_readable((duk_context *) thr, index), (long) index);
expect_name, duk_push_string_readable((duk_context *) thr, idx), (long) idx);
}
#endif
DUK_INTERNAL void duk_err_range(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message) {
DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_RANGE_ERROR, message);
}
DUK_INTERNAL void duk_err_api_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index) {
DUK_ERROR_RAW_FMT1(thr, filename, linenumber, DUK_ERR_API_ERROR, "invalid stack index %ld", (long) (index));
DUK_INTERNAL void duk_err_api_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx) {
DUK_ERROR_RAW_FMT1(thr, filename, linenumber, DUK_ERR_API_ERROR, "invalid stack index %ld", (long) (idx));
}
DUK_INTERNAL void duk_err_api(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message) {
DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_API_ERROR, message);

2
src/duk_lexer.c

@ -87,7 +87,7 @@
#define DUK__ISDIGIT47(x) ((x) >= DUK_ASC_4 && (x) <= DUK_ASC_7)
/* lexer character window helpers */
#define DUK__LOOKUP(lex_ctx,index) ((lex_ctx)->window[(index)].codepoint)
#define DUK__LOOKUP(lex_ctx,idx) ((lex_ctx)->window[(idx)].codepoint)
#define DUK__ADVANCECHARS(lex_ctx,count) duk__advance_bytes((lex_ctx), (count) * sizeof(duk_lexer_codepoint))
#define DUK__ADVANCEBYTES(lex_ctx,count) duk__advance_bytes((lex_ctx), (count))
#define DUK__INITBUFFER(lex_ctx) duk__initbuffer((lex_ctx))

Loading…
Cancel
Save