diff options
Diffstat (limited to 'zend/iteratorimpl.cpp')
-rw-r--r-- | zend/iteratorimpl.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/zend/iteratorimpl.cpp b/zend/iteratorimpl.cpp index 49526b1..4861e9e 100644 --- a/zend/iteratorimpl.cpp +++ b/zend/iteratorimpl.cpp @@ -20,7 +20,7 @@ namespace Php { */ static IteratorImpl *self(zend_object_iterator *iter) { - return (IteratorImpl *)iter->data; + return (IteratorImpl *)Z_PTR(iter->data); } /** @@ -49,21 +49,22 @@ int IteratorImpl::valid(zend_object_iterator *iter TSRMLS_DC) /** * Fetch the current item - * @param iter - * @param data - * @param tsrm_ls + * + * @param iter The iterator to retrieve the value from + * @param tsrm_ls Thread safety variable + * @return The current value of the iterator */ -void IteratorImpl::current(zend_object_iterator *iter, zval ***data TSRMLS_DC) +zval *IteratorImpl::current(zend_object_iterator *iter TSRMLS_DC) { // get the actual iterator - IteratorImpl *iterator = self(iter); + auto *iterator = self(iter); // retrieve the value (and store it in a member so that it is not // destructed when the function returns) iterator->_current = iterator->current(); - // copy the value - *data = &iterator->_current._val; + // return the value + return iterator->_current._val; } /** @@ -100,14 +101,14 @@ int IteratorImpl::key(zend_object_iterator *iter, char **str_key, uint *str_key_ { // retrieve the key Value retval(self(iter)->key()); - + // is this a numeric string? if (retval.isString()) { // copy the key and the from the value *str_key = estrndup(retval.rawValue(), retval.size()); *str_key_len = retval.size() + 1; - + // done return HASH_KEY_IS_STRING; } @@ -115,7 +116,7 @@ int IteratorImpl::key(zend_object_iterator *iter, char **str_key, uint *str_key_ { // convert to a numeric *int_key = retval.numericValue(); - + // done return HASH_KEY_IS_LONG; } @@ -151,13 +152,13 @@ zend_object_iterator_funcs *IteratorImpl::functions() { // static variable with all functions static zend_object_iterator_funcs funcs; - + // static variable that knows if the funcs are already initialized static bool initialized = false; - + // no need to set anything if already initialized if (initialized) return &funcs; - + // set the members funcs.dtor = &IteratorImpl::destructor; funcs.valid = &IteratorImpl::valid; @@ -165,13 +166,13 @@ zend_object_iterator_funcs *IteratorImpl::functions() funcs.get_current_key = &IteratorImpl::key; funcs.move_forward = &IteratorImpl::next; funcs.rewind = &IteratorImpl::rewind; - + // invalidate is not yet supported funcs.invalidate_current = nullptr; - + // remember that functions are initialized initialized = true; - + // done return &funcs; } |