Browse Source

use duk_check_type_mask() internally

pull/1/head
Sami Vaarala 11 years ago
parent
commit
8e78b61dab
  1. 10
      src/duk_api.c
  2. 2
      src/duk_builtin_json.c
  3. 5
      src/duk_builtin_object.c

10
src/duk_api.c

@ -2159,13 +2159,11 @@ int duk_is_primitive(duk_context *ctx, int index) {
}
int duk_is_object_coercible(duk_context *ctx, int index) {
int mask = DUK_TYPE_MASK_BOOLEAN |
DUK_TYPE_MASK_NUMBER |
DUK_TYPE_MASK_STRING |
DUK_TYPE_MASK_OBJECT;
/* FIXME: what about buffer and pointer? */
return (duk_get_type_mask(ctx, index) & mask ? 1 : 0);
return duk_check_type_mask(ctx, index, DUK_TYPE_MASK_BOOLEAN |
DUK_TYPE_MASK_NUMBER |
DUK_TYPE_MASK_STRING |
DUK_TYPE_MASK_OBJECT);
}
/*

2
src/duk_builtin_json.c

@ -1141,7 +1141,7 @@ static int json_enc_value1(duk_json_enc_ctx *js_ctx, int idx_holder) {
tv = duk_get_tval(ctx, -1);
DUK_ASSERT(tv != NULL);
if (duk_get_type_mask(ctx, -1) & js_ctx->mask_for_undefined) {
if (duk_check_type_mask(ctx, -1, js_ctx->mask_for_undefined)) {
/* will result in undefined */
DUK_DDDPRINT("-> will result in undefined (type mask check)");
goto undef;

5
src/duk_builtin_object.c

@ -15,8 +15,9 @@ int duk_builtin_object_constructor(duk_context *ctx) {
return 1;
}
if (duk_get_type_mask(ctx, 0) &
(DUK_TYPE_MASK_STRING | DUK_TYPE_MASK_BOOLEAN | DUK_TYPE_MASK_NUMBER)) {
if (duk_check_type_mask(ctx, 0, DUK_TYPE_MASK_STRING |
DUK_TYPE_MASK_BOOLEAN |
DUK_TYPE_MASK_NUMBER)) {
duk_to_object(ctx, 0);
return 1;
}

Loading…
Cancel
Save