Beispiel #1
0
/* {{{ proto mixed SplDoublyLinkedList::offsetGet(mixed index)
 Returns the value at the specified $index. */
SPL_METHOD(SplDoublyLinkedList, offsetGet)
{
	zval                  *zindex;
	zend_long                   index;
	spl_dllist_object     *intern;
	spl_ptr_llist_element *element;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zindex) == FAILURE) {
		return;
	}

	intern = Z_SPLDLLIST_P(ZEND_THIS);
	index  = spl_offset_convert_to_long(zindex);

	if (index < 0 || index >= intern->llist->count) {
		zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid or out of range", 0);
		return;
	}

	element = spl_ptr_llist_offset(intern->llist, index, intern->flags & SPL_DLLIST_IT_LIFO);

	if (element != NULL) {
		zval *value = &element->data;

		ZVAL_COPY_DEREF(return_value, value);
	} else {
		zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid", 0);
	}
} /* }}} */
Beispiel #2
0
static void curlfile_get_property(char *name, size_t name_len, INTERNAL_FUNCTION_PARAMETERS)
{
	zval *res, rv;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}
	res = zend_read_property(curl_CURLFile_class, getThis(), name, name_len, 1, &rv);
	ZVAL_COPY_DEREF(return_value, res);
}
Beispiel #3
0
/* {{{ proto SimpleXMLIterator SimpleXMLIterator::current()
 Get current element */
PHP_METHOD(ce_SimpleXMLIterator, current)
{
	php_sxe_object *sxe = Z_SXEOBJ_P(getThis());
	zval *data;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	if (Z_ISUNDEF(sxe->iter.data)) {
		return; /* return NULL */
	}

	data = &sxe->iter.data;
	ZVAL_COPY_DEREF(return_value, data);
}
Beispiel #4
0
/* {{{ proto SimpleXMLIterator SimpleXMLIterator::getChildren()
 Get child element iterator */
PHP_METHOD(ce_SimpleXMLIterator, getChildren)
{
	php_sxe_object *sxe = Z_SXEOBJ_P(getThis());
	zval *data;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	if (Z_ISUNDEF(sxe->iter.data) || sxe->iter.type == SXE_ITER_ATTRLIST) {
		return; /* return NULL */
	}

	data = &sxe->iter.data;
	ZVAL_COPY_DEREF(return_value, data);
}
Beispiel #5
0
/* {{{ proto mixed|NULL SplDoublyLinkedList::current()
   Return current datastructure entry */
SPL_METHOD(SplDoublyLinkedList, current)
{
	spl_dllist_object     *intern  = Z_SPLDLLIST_P(ZEND_THIS);
	spl_ptr_llist_element *element = intern->traverse_pointer;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	if (element == NULL || Z_ISUNDEF(element->data)) {
		RETURN_NULL();
	} else {
		zval *value = &element->data;

		ZVAL_COPY_DEREF(return_value, value);
	}
}
Beispiel #6
0
/* {{{ proto mixed SplDoublyLinkedList::bottom()
	   Peek at the bottom element of the SplDoublyLinkedList */
SPL_METHOD(SplDoublyLinkedList, bottom)
{
	zval *value;
	spl_dllist_object *intern;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	intern = Z_SPLDLLIST_P(ZEND_THIS);
	value  = spl_ptr_llist_first(intern->llist);

	if (value == NULL || Z_ISUNDEF_P(value)) {
		zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty datastructure", 0);
		return;
	}

	ZVAL_COPY_DEREF(return_value, value);
}