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
757 B
34 lines
757 B
name: duk_copy
|
|
|
|
proto: |
|
|
void duk_copy(duk_context *ctx, duk_idx_t from_idx, duk_idx_t to_idx);
|
|
|
|
stack: |
|
|
[ ... old(to_idx)! ... val(from_idx)! ... ] -> [ ... val(to_idx)! ... val(from_idx)! ... ]
|
|
|
|
summary: |
|
|
<p>Copy a value from <code>from_idx</code> to <code>to_idx</code>,
|
|
overwriting the previous value. If either index is invalid, throws an
|
|
error.</p>
|
|
|
|
<p>This is a shorthand for:</p>
|
|
<pre class="c-code">
|
|
/* to_index must be normalize in case it is negative and would change its
|
|
* meaning after duk_dup().
|
|
*/
|
|
to_idx = duk_normalize_idx(ctx, to_idx);
|
|
duk_dup(ctx, from_idx);
|
|
duk_replace(ctx, to_idx);
|
|
</pre>
|
|
|
|
example: |
|
|
duk_copy(ctx, -3, 1);
|
|
|
|
tags:
|
|
- stack
|
|
|
|
seealso:
|
|
- duk_insert
|
|
- duk_replace
|
|
|
|
introduced: 1.0.0
|
|
|