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
783 B
34 lines
783 B
name: duk_copy
|
|
|
|
proto: |
|
|
void duk_copy(duk_context *ctx, duk_idx_t from_index, duk_idx_t to_index);
|
|
|
|
stack: |
|
|
[ ... old(to_index)! ... val(from_index)! ... ] -> [ ... val(to_index)! ... val(from_index)! ... ]
|
|
|
|
summary: |
|
|
<p>Copy a value from <code>from_index</code> to <code>to_index</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_index = duk_normalize_index(ctx, to_index);
|
|
duk_dup(ctx, from_index);
|
|
duk_replace(ctx, to_index);
|
|
</pre>
|
|
|
|
example: |
|
|
duk_copy(ctx, -3, 1);
|
|
|
|
tags:
|
|
- stack
|
|
|
|
seealso:
|
|
- duk_insert
|
|
- duk_replace
|
|
|
|
introduced: 1.0.0
|
|
|