pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2019-06-23
2019-06-23 22:51:07 by Tobias S. Josefowitz <tobij@tobij.de>
392a2da645457e7a2b05adf3ff85a650283777e2 (
28
lines) (+
28
/-
0
)
[
Show
|
Annotate
]
Branch:
master
ADT.List: Make iterators copyable
6228:
} }
+
/*! @decl @[_get_iterator] copy_iterator()
+
*!
+
*! @returns
+
*! Returns a copy of the iterator at its current position.
+
*/
+
PIKEFUN object copy_iterator()
+
{
+
struct object *ret;
+
+
if (Pike_fp->current_object->prog != List_cq__get_iterator_program)
+
Pike_error("Cannot copy overloaded iterators.\n");
+
+
ret = low_clone(List_cq__get_iterator_program);
+
+
pop_n_elems(args);
+
+
add_ref(PARENT_INFO(ret)->parent =
+
PARENT_INFO(Pike_fp->current_object)->parent);
+
PARENT_INFO(ret)->parent_identifier =
+
PARENT_INFO(Pike_fp->current_object)->parent_identifier;
+
+
add_ref(OBJ2_LIST_CQ__GET_ITERATOR(ret)->cur = THIS->cur);
+
OBJ2_LIST_CQ__GET_ITERATOR(ret)->ind = THIS->ind;
+
+
push_object(ret);
+
}
+
/* These two functions perform the same thing, * but are optimized to minimize recursion. */