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
|
|
|
|
unsigned int duk_to_uint16(duk_context *ctx, int index);
|
|
|
|
|
|
|
|
=stack
|
|
|
|
[ ... val! ... ] -> [ ... ToUint16(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.7">ToUint16()</a>
|
|
|
|
coerced value. Returns the coerced value. If <tt>index</tt> is invalid, throws
|
|
|
|
an error.</p>
|
|
|
|
|
|
|
|
<p>Custom type coercion:</p>
|
|
|
|
<ul>
|
|
|
|
<li>Buffer: <tt>0</tt> for zero-size buffer, <tt>1</tt> otherwise</li>
|
|
|
|
<li>Pointer: <tt>0</tt> for <tt>NULL</tt> pointer, <tt>1</tt> otherwise</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<div class="note">
|
|
|
|
The result of <tt>ToUint16()</tt> is an unsigned 16-bit integer and is assumed to
|
|
|
|
fit into the C <tt>unsigned int</tt> type. If the C type is smaller, the value will be
|
|
|
|
coerced by the C compiler (<tt>double</tt> to <tt>unsigned int</tt>).
|
|
|
|
</div>
|
|
|
|
|
|
|
|
=example
|
|
|
|
printf("ToUint16(): %u\n", duk_to_uint16(ctx, -3));
|
|
|
|
|
|
|
|
=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 16 bits, everything will break anyway.
|