colder          Fri Jan 16 22:20:54 2009 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/spl    spl_observer.c 
    /php-src    NEWS 
  Log:
  MFH: Implement SplObjectStorage::addAll/removeAll
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_observer.c?r1=1.2.2.6.2.3.2.15&r2=1.2.2.6.2.3.2.16&diff_format=u
Index: php-src/ext/spl/spl_observer.c
diff -u php-src/ext/spl/spl_observer.c:1.2.2.6.2.3.2.15 
php-src/ext/spl/spl_observer.c:1.2.2.6.2.3.2.16
--- php-src/ext/spl/spl_observer.c:1.2.2.6.2.3.2.15     Wed Jan 14 15:53:03 2009
+++ php-src/ext/spl/spl_observer.c      Fri Jan 16 22:20:53 2009
@@ -13,10 +13,11 @@
    | lice...@php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
    | Authors: Marcus Boerger <he...@php.net>                              |
+   |          Etienne Kneuss <col...@php.net>                             |
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_observer.c,v 1.2.2.6.2.3.2.15 2009/01/14 15:53:03 colder Exp $ */
+/* $Id: spl_observer.c,v 1.2.2.6.2.3.2.16 2009/01/16 22:20:53 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -237,7 +238,6 @@
        }
 } /* }}} */
 
-
 void spl_object_storage_attach(spl_SplObjectStorage *intern, zval *obj, zval 
*inf TSRMLS_DC) /* {{{ */
 {
        spl_SplObjectStorageElement *pelement, element;
@@ -332,6 +332,62 @@
        }
 } /* }}} */
 
+/* {{{ proto bool SplObjectStorage::addAll(SplObjectStorage $os)
+ Add all elements contained in $os */
+SPL_METHOD(SplObjectStorage, addAll)
+{
+       zval *obj;
+       spl_SplObjectStorage *intern = (spl_SplObjectStorage 
*)zend_object_store_get_object(getThis() TSRMLS_CC);
+       spl_SplObjectStorage *other;
+       spl_SplObjectStorageElement *element;
+       HashPosition pos;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, 
spl_ce_SplObjectStorage) == FAILURE) {
+               return;
+       }
+
+       other = (spl_SplObjectStorage *)zend_object_store_get_object(obj 
TSRMLS_CC);
+
+       zend_hash_internal_pointer_reset_ex(&other->storage, &pos);
+       while (zend_hash_get_current_data_ex(&other->storage, (void 
**)&element, &pos) == SUCCESS) {
+               spl_object_storage_attach(intern, element->obj, element->inf 
TSRMLS_CC);
+               zend_hash_move_forward_ex(&other->storage, &pos);
+       }
+
+       zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
+       intern->index = 0;
+
+       RETURN_LONG(zend_hash_num_elements(&intern->storage));
+} /* }}} */
+
+/* {{{ proto bool SplObjectStorage::removeAll(SplObjectStorage $os)
+ Remove all elements contained in $os */
+SPL_METHOD(SplObjectStorage, removeAll)
+{
+       zval *obj;
+       spl_SplObjectStorage *intern = (spl_SplObjectStorage 
*)zend_object_store_get_object(getThis() TSRMLS_CC);
+       spl_SplObjectStorage *other;
+       spl_SplObjectStorageElement *element;
+       HashPosition pos;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, 
spl_ce_SplObjectStorage) == FAILURE) {
+               return;
+       }
+
+       other = (spl_SplObjectStorage *)zend_object_store_get_object(obj 
TSRMLS_CC);
+
+       zend_hash_internal_pointer_reset_ex(&other->storage, &pos);
+       while (zend_hash_get_current_data_ex(&other->storage, (void 
**)&element, &pos) == SUCCESS) {
+               spl_object_storage_detach(intern, element->obj TSRMLS_CC);
+               zend_hash_move_forward_ex(&other->storage, &pos);
+       }
+
+       zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
+       intern->index = 0;
+
+       RETURN_LONG(zend_hash_num_elements(&intern->storage));
+} /* }}} */
+
 /* {{{ proto bool SplObjectStorage::contains($obj)
  Determine whethe an object is contained in the storage */
 SPL_METHOD(SplObjectStorage, contains)
@@ -618,6 +674,8 @@
        SPL_ME(SplObjectStorage,  attach,      arginfo_attach,        0)
        SPL_ME(SplObjectStorage,  detach,      arginfo_Object,        0)
        SPL_ME(SplObjectStorage,  contains,    arginfo_Object,        0)
+       SPL_ME(SplObjectStorage,  addAll,      arginfo_Object,        0)
+       SPL_ME(SplObjectStorage,  removeAll,   arginfo_Object,        0)
        SPL_ME(SplObjectStorage,  getInfo,     NULL,                  0)
        SPL_ME(SplObjectStorage,  setInfo,     arginfo_setInfo,       0)
        /* Countable */
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.460&r2=1.2027.2.547.2.965.2.461&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.460 
php-src/NEWS:1.2027.2.547.2.965.2.461
--- php-src/NEWS:1.2027.2.547.2.965.2.460       Fri Jan 16 11:31:02 2009
+++ php-src/NEWS        Fri Jan 16 22:20:53 2009
@@ -38,6 +38,7 @@
   maximum if required. (Scott)
 - Added ICU support to SQLite3 when using the bundled version. (Scott)
 - Added pixelation support in imagefilter(). (Takeshi Abe, Kalle)
+- Added SplObjectStorage::addAll/removeAll. (Etienne)
 
 - Re-added socket_create_pair() for Windows in sockets extension. (Kalle)
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to