Mercurial > code
changeset 416:a93dfbb65648
Js:
- add copy
- add dup
- add insert
- add remove
- add replace
- add swap
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 08 Oct 2015 08:39:47 +0200 |
parents | ac4573b9bb4b |
children | 865224c2191a |
files | C++/modules/Js/Js.h |
diffstat | 1 files changed, 68 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/C++/modules/Js/Js.h Thu Oct 08 08:29:48 2015 +0200 +++ b/C++/modules/Js/Js.h Thu Oct 08 08:39:47 2015 +0200 @@ -553,6 +553,74 @@ } /** + * Copy a value from from to to, overwriting the previous value. If either index is invalid, throws an error. + * + * @param from the from index + * @param to the destination + */ + inline void copy(int from, int to) + { + duk_copy(m_handle.get(), from, to); + } + + /** + * Push a duplicate of value at from_index to the stack. If from_index is invalid, throws an error. + * + * @param index the value to copy + */ + inline void dup(int index = -1) + { + duk_dup(m_handle.get(), index); + } + + /** + * Insert a value at to with a value popped from the stack top. The previous value at to and any values above + * it are moved up the stack by a step. If to is an invalid index, throws an error. + * + * @note Negative indices are evaluated prior to popping the value at the stack top + * @param to the destination + */ + inline void insert(int to) + { + duk_insert(m_handle.get(), to); + } + + /** + * Remove value at index. Elements above index are shifted down the stack by a step. If to is an invalid index, + * throws an error. + * + * @param index the value to remove + */ + inline void remove(int index) + { + duk_remove(m_handle.get(), index); + } + + /** + * Replace value at to_index with a value popped from the stack top. If to_index is an invalid index, + * throws an error. + * + * @param index the value to replace by the value at the top of the stack + * @note Negative indices are evaluated prior to popping the value at the stack top. + */ + inline void replace(int index) + { + duk_replace(m_handle.get(), index); + } + + /** + * Swap values at indices index1 and index2. If the indices are the same, the call is a no-op. If either index + * is invalid, throws an error. + * + * @param index1 the first index + * @param index2 the second index + */ + inline void swap(int index1, int index2) + { + duk_swap(m_handle.get(), index1, index2); + } + + /** * Call in protected mode the object at the top of the stack. * * @param ctx the context