mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
11 years ago
2 changed files with 33 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||
=proto |
|||
int duk_get_type(duk_context *ctx, int index); |
|||
|
|||
=stack |
|||
[ ... val! ... ] |
|||
|
|||
=summary |
|||
<p>Returns type of value at <tt>index</tt>. The return value is one of |
|||
<tt>DUK_TYPE_xxx</tt> or <tt>DUK_TYPE_NONE</tt> if <tt>index</tt> is |
|||
invalid.</p> |
|||
|
|||
=example |
|||
if (duk_get_type(ctx, -3) == DUK_TYPE_NUMBER) { |
|||
printf("value is a number\n"); |
|||
} |
@ -0,0 +1,18 @@ |
|||
=proto |
|||
int duk_get_type_mask(duk_context *ctx, int index); |
|||
|
|||
=stack |
|||
[ ... val! ... ] |
|||
|
|||
=summary |
|||
<p>Returns type mask of value at <tt>index</tt>. The return value is one of |
|||
<tt>DUK_TYPE_MASK_xxx</tt> or <tt>DUK_TYPE_MASK_NONE</tt> if <tt>index</tt> |
|||
is invalid.</p> |
|||
|
|||
<p>Type masks allow for a convenient comparison for multiple types at once.</p> |
|||
|
|||
=example |
|||
if (duk_get_type_mask(ctx, -3) & (DUK_TYPE_MASK_STRING | |
|||
DUK_TYPE_MASK_NUMBER)) { |
|||
printf("value is a string or a number\n"); |
|||
} |
Loading…
Reference in new issue