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.
23 lines
684 B
23 lines
684 B
name: duk_opt_int
|
|
|
|
proto: |
|
|
duk_int_t duk_opt_int(duk_context *ctx, duk_idx_t idx, duk_int_t def_value);
|
|
|
|
stack: |
|
|
[ ... val! ... ]
|
|
|
|
summary: |
|
|
<p>Get the number at <code>idx</code> and convert it to a C <code>duk_int_t</code>
|
|
by first clamping the value between [DUK_INT_MIN, DUK_INT_MAX] and then
|
|
truncating towards zero. The value on the stack is not modified.
|
|
If the value is <code>undefined</code> or the index is invalid,
|
|
<code>def_value</code> default value is returned. In other cases
|
|
(<code>null</code> or non-matching type) throws an error.</p>
|
|
|
|
example: |
|
|
int port = (int) duk_opt_int(ctx, 1, 80); /* default: 80 */
|
|
|
|
tags:
|
|
- stack
|
|
|
|
introduced: 2.1.0
|
|
|