helly Wed Apr 28 17:45:41 2004 EDT
Modified files:
/php-src/ext/spl spl_array.c
Log:
Count() was missing
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.41&r2=1.42&ty=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.41 php-src/ext/spl/spl_array.c:1.42
--- php-src/ext/spl/spl_array.c:1.41 Tue Apr 27 11:42:45 2004
+++ php-src/ext/spl/spl_array.c Wed Apr 28 17:45:41 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.41 2004/04/27 15:42:45 helly Exp $ */
+/* $Id: spl_array.c,v 1.42 2004/04/28 21:45:41 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -47,6 +47,7 @@
SPL_METHOD(Array, append);
SPL_METHOD(Array, getArrayCopy);
SPL_METHOD(Array, seek);
+SPL_METHOD(Array, count);
static
ZEND_BEGIN_ARG_INFO(arginfo_array___construct, 0)
@@ -83,6 +84,7 @@
SPL_ME(Array, offsetUnset, arginfo_array_offsetGet, ZEND_ACC_PUBLIC)
SPL_ME(Array, append, arginfo_array_append, ZEND_ACC_PUBLIC)
SPL_ME(Array, getArrayCopy, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, count, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
@@ -100,6 +102,7 @@
SPL_ME(Array, append, arginfo_array_append, ZEND_ACC_PUBLIC)
SPL_ME(Array, getArrayCopy, NULL, ZEND_ACC_PUBLIC)
SPL_ME(Array, seek, arginfo_array_seek, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, count, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
@@ -716,6 +719,24 @@
while (position-- > 0 && spl_array_next(intern TSRMLS_CC));
} /* }}} */
+/* {{{ proto bool ArrayObject::count()
+ Return the number of elements in the Iterator. */
+SPL_METHOD(Array, count)
+{
+ long position;
+ zval *object = getThis();
+ spl_array_object *intern =
(spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+ HashTable *aht = HASH_OF(intern->array);
+ HashPosition pos;
+
+ if (!aht) {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside
object and is no longer an array");
+ RETURN_LONG(0);
+ }
+
+ RETURN_LONG(zend_hash_num_elements(aht));
+} /* }}} */
+
/* {{{ proto mixed|NULL ArrayIterator::current()
Return current array entry */
SPL_METHOD(Array, current)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php