mirror of https://github.com/svaarala/duktape.git
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.
34 lines
1.1 KiB
34 lines
1.1 KiB
=proto
|
|
int duk_to_int32(duk_context *ctx, int index);
|
|
|
|
=stack
|
|
[ ... val! ... ] -> [ ... ToInt32(val)! ... ]
|
|
|
|
=summary
|
|
<p>Replace the value at <code>index</code> with an Ecmascript
|
|
<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-9.5">ToInt32()</a>
|
|
coerced value. Returns the coerced value. If <code>index</code> is invalid, throws
|
|
an error.</p>
|
|
|
|
<p>Custom type coercion:</p>
|
|
<ul>
|
|
<li>Buffer: <code>0</code> for zero-size buffer, <code>1</code> otherwise</li>
|
|
<li>Pointer: <code>0</code> for <code>NULL</code> pointer, <code>1</code> otherwise</li>
|
|
</ul>
|
|
|
|
<div class="note">
|
|
The result of <code>ToInt32()</code> is a signed 32-bit integer and is assumed to
|
|
fit into the C <code>int</code> type. If the C type is smaller, the value will be
|
|
coerced by the C compiler (<code>double</code> to <code>int</code>).
|
|
</div>
|
|
|
|
=example
|
|
printf("ToInt32(): %d\n", duk_to_int32(ctx, -3));
|
|
|
|
=tags
|
|
stack
|
|
|
|
=fixme
|
|
Apply the duk_get_int() coercion to the result just in case? It would clamp
|
|
output values to INT_MIN and INT_MAX. This is not very relevant because if
|
|
int is smaller than 32 bits, everything will break anyway.
|
|
|