cvs: php-src /ext/spl spl_array.c spl_array.h spl_iterators.c spl_iterators.h

From: Date: Thu, 08 Feb 2007 20:13:49 +0000
Subject: cvs: php-src /ext/spl spl_array.c spl_array.h spl_iterators.c spl_iterators.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-42980@lists.php.net to get a copy of this message
helly Thu Feb 8 20:13:49 2007 UTC Modified files: /php-src/ext/spl spl_array.c spl_array.h spl_iterators.c spl_iterators.h Log: - Moving Countable from spl_array.c to spl_iterator.c allows CachingIterator to implement Countable http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_array.c?r1=1.120&r2=1.121&diff_format=u Index: php-src/ext/spl/spl_array.c diff -u php-src/ext/spl/spl_array.c:1.120 php-src/ext/spl/spl_array.c:1.121 --- php-src/ext/spl/spl_array.c:1.120 Sat Jan 20 16:19:20 2007 +++ php-src/ext/spl/spl_array.c Thu Feb 8 20:13:49 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_array.c,v 1.120 2007/01/20 16:19:20 helly Exp $ */ +/* $Id: spl_array.c,v 1.121 2007/02/08 20:13:49 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -42,8 +42,6 @@ PHPAPI zend_class_entry *spl_ce_ArrayIterator; PHPAPI zend_class_entry *spl_ce_RecursiveArrayIterator; -PHPAPI zend_class_entry *spl_ce_Countable; - #define SPL_ARRAY_STD_PROP_LIST 0x00000001 #define SPL_ARRAY_ARRAY_AS_PROPS 0x00000002 #define SPL_ARRAY_OVERLOADED_REWIND 0x00010000 @@ -1524,11 +1522,6 @@ {NULL, NULL, NULL} }; -static zend_function_entry spl_funcs_Countable[] = { - SPL_ABSTRACT_ME(Countable, count, NULL) - {NULL, NULL, NULL} -}; - /* {{{ PHP_MINIT_FUNCTION(spl_array) */ PHP_MINIT_FUNCTION(spl_array) { @@ -1563,8 +1556,6 @@ REGISTER_SPL_IMPLEMENTS(RecursiveArrayIterator, RecursiveIterator); spl_ce_RecursiveArrayIterator->get_iterator = spl_array_get_iterator; - REGISTER_SPL_INTERFACE(Countable); - REGISTER_SPL_IMPLEMENTS(ArrayObject, Countable); REGISTER_SPL_IMPLEMENTS(ArrayIterator, Countable); http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_array.h?r1=1.17&r2=1.18&diff_format=u Index: php-src/ext/spl/spl_array.h diff -u php-src/ext/spl/spl_array.h:1.17 php-src/ext/spl/spl_array.h:1.18 --- php-src/ext/spl/spl_array.h:1.17 Mon Jan 1 09:29:29 2007 +++ php-src/ext/spl/spl_array.h Thu Feb 8 20:13:49 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_array.h,v 1.17 2007/01/01 09:29:29 sebastian Exp $ */ +/* $Id: spl_array.h,v 1.18 2007/02/08 20:13:49 helly Exp $ */ #ifndef SPL_ARRAY_H #define SPL_ARRAY_H @@ -27,7 +27,6 @@ extern PHPAPI zend_class_entry *spl_ce_ArrayObject; extern PHPAPI zend_class_entry *spl_ce_ArrayIterator; extern PHPAPI zend_class_entry *spl_ce_RecursiveArrayIterator; -extern PHPAPI zend_class_entry *spl_ce_Countable; PHP_MINIT_FUNCTION(spl_array); http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.c?r1=1.157&r2=1.158&diff_format=u Index: php-src/ext/spl/spl_iterators.c diff -u php-src/ext/spl/spl_iterators.c:1.157 php-src/ext/spl/spl_iterators.c:1.158 --- php-src/ext/spl/spl_iterators.c:1.157 Fri Jan 19 10:19:50 2007 +++ php-src/ext/spl/spl_iterators.c Thu Feb 8 20:13:49 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_iterators.c,v 1.157 2007/01/19 10:19:50 helly Exp $ */ +/* $Id: spl_iterators.c,v 1.158 2007/02/08 20:13:49 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -57,6 +57,7 @@ PHPAPI zend_class_entry *spl_ce_AppendIterator; PHPAPI zend_class_entry *spl_ce_RegexIterator; PHPAPI zend_class_entry *spl_ce_RecursiveRegexIterator; +PHPAPI zend_class_entry *spl_ce_Countable; zend_function_entry spl_funcs_RecursiveIterator[] = { SPL_ABSTRACT_ME(RecursiveIterator, hasChildren, NULL) @@ -2272,6 +2273,23 @@ } /* }}} */ +/* {{{ proto void CachingIterator::count() + Number of cached elements */ +SPL_METHOD(CachingIterator, count) +{ + spl_dual_it_object *intern; + + intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + + if (!(intern->u.caching.flags & CIT_FULL_CACHE)) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "%v does not use a full cache (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name); + return; + } + + RETURN_LONG(zend_hash_num_elements(HASH_OF(intern->u.caching.zcache))); +} +/* }}} */ + static ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_it___construct, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0) @@ -2311,6 +2329,7 @@ SPL_ME(CachingIterator, offsetUnset, arginfo_caching_it_offsetGet, ZEND_ACC_PUBLIC) SPL_ME(CachingIterator, offsetExists, arginfo_caching_it_offsetGet, ZEND_ACC_PUBLIC) SPL_ME(CachingIterator, getCache, NULL, ZEND_ACC_PUBLIC) + SPL_ME(CachingIterator, count, NULL, ZEND_ACC_PUBLIC) {NULL, NULL, NULL} }; @@ -2897,6 +2916,11 @@ {NULL, NULL, NULL} }; +static zend_function_entry spl_funcs_Countable[] = { + SPL_ABSTRACT_ME(Countable, count, NULL) + {NULL, NULL, NULL} +}; + /* {{{ PHP_MINIT_FUNCTION(spl_iterators) */ PHP_MINIT_FUNCTION(spl_iterators) @@ -2939,6 +2963,7 @@ REGISTER_SPL_SUB_CLASS_EX(ParentIterator, RecursiveFilterIterator, spl_dual_it_new, spl_funcs_ParentIterator); + REGISTER_SPL_INTERFACE(Countable); REGISTER_SPL_INTERFACE(SeekableIterator); REGISTER_SPL_ITERATOR(SeekableIterator); @@ -2946,6 +2971,7 @@ REGISTER_SPL_SUB_CLASS_EX(CachingIterator, IteratorIterator, spl_dual_it_new, spl_funcs_CachingIterator); REGISTER_SPL_IMPLEMENTS(CachingIterator, ArrayAccess); + REGISTER_SPL_IMPLEMENTS(CachingIterator, Countable); REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CALL_TOSTRING", CIT_CALL_TOSTRING); REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CATCH_GET_CHILD", CIT_CATCH_GET_CHILD); http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.h?r1=1.40&r2=1.41&diff_format=u Index: php-src/ext/spl/spl_iterators.h diff -u php-src/ext/spl/spl_iterators.h:1.40 php-src/ext/spl/spl_iterators.h:1.41 --- php-src/ext/spl/spl_iterators.h:1.40 Mon Jan 1 09:29:29 2007 +++ php-src/ext/spl/spl_iterators.h Thu Feb 8 20:13:49 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_iterators.h,v 1.40 2007/01/01 09:29:29 sebastian Exp $ */ +/* $Id: spl_iterators.h,v 1.41 2007/02/08 20:13:49 helly Exp $ */ #ifndef SPL_ITERATORS_H #define SPL_ITERATORS_H @@ -50,6 +50,7 @@ extern PHPAPI zend_class_entry *spl_ce_AppendIterator; extern PHPAPI zend_class_entry *spl_ce_RegexIterator; extern PHPAPI zend_class_entry *spl_ce_RecursiveRegexIterator; +extern PHPAPI zend_class_entry *spl_ce_Countable; PHP_MINIT_FUNCTION(spl_iterators);

« previous php.cvs (#42980) next »