You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
=proto
|
|
|
|
int duk_to_boolean(duk_context *ctx, int index);
|
|
|
|
|
|
|
|
=stack
|
|
|
|
[ ... val! ... ] -> [ ... ToBoolean(val)! ... ]
|
|
|
|
|
|
|
|
=summary
|
|
|
|
<p>Replace the value at <tt>index</tt> with an Ecmascript
|
|
|
|
<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-9.2">ToBoolean()</a>
|
|
|
|
coerced value. Returns 1 if the result of the coercion <tt>true</tt>, 0 otherwise.
|
|
|
|
If <tt>index</tt> is invalid, throws an error.</p>
|
|
|
|
|
|
|
|
<p>Custom type coercion:</p>
|
|
|
|
<ul>
|
|
|
|
<li>Buffer: <tt>false</tt> for zero-size buffer, <tt>true</tt> otherwise</li>
|
|
|
|
<li>Pointer: <tt>false</tt> for <tt>NULL</tt> pointer, <tt>true</tt> otherwise</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
=example
|
|
|
|
if (duk_to_boolean(ctx, -3)) {
|
|
|
|
printf("coerced value is true\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
=tags
|
|
|
|
stack
|
|
|
|
|
|
|
|
=fixme
|
|
|
|
Describe coercion rules for custom types in a central location and just link
|
|
|
|
there?
|