=proto int duk_to_int32(duk_context *ctx, int index); =stack [ ... val! ... ] -> [ ... ToInt32(val)! ... ] =summary

Replace the value at index with an Ecmascript ToInt32() coerced value. Returns the coerced value. If index is invalid, throws an error.

Custom type coercion:

The result of ToInt32() is a signed 32-bit integer and is assumed to fit into the C int type. If the C type is smaller, the value will be coerced by the C compiler (double to int).
=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.