Diff for /embedaddon/php/ext/spl/spl_dllist.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:48:01 version 1.1.1.2, 2012/05/29 12:34:42
Line 27 Line 27
 #include "zend_hash.h"  #include "zend_hash.h"
   
 #include "php_spl.h"  #include "php_spl.h"
   #include "ext/standard/info.h"
   #include "ext/standard/php_var.h"
   #include "ext/standard/php_smart_str.h"
 #include "spl_functions.h"  #include "spl_functions.h"
 #include "spl_engine.h"  #include "spl_engine.h"
 #include "spl_iterators.h"  #include "spl_iterators.h"
Line 367  static zend_object_value spl_dllist_object_new_ex(zend Line 370  static zend_object_value spl_dllist_object_new_ex(zend
 {  {
         zend_object_value  retval;          zend_object_value  retval;
         spl_dllist_object *intern;          spl_dllist_object *intern;
         zval              *tmp;  
         zend_class_entry  *parent = class_type;          zend_class_entry  *parent = class_type;
         int                inherited = 0;          int                inherited = 0;
   
Line 376  static zend_object_value spl_dllist_object_new_ex(zend Line 378  static zend_object_value spl_dllist_object_new_ex(zend
         ALLOC_INIT_ZVAL(intern->retval);          ALLOC_INIT_ZVAL(intern->retval);
   
         zend_object_std_init(&intern->std, class_type TSRMLS_CC);          zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));        object_properties_init(&intern->std, class_type);
   
         intern->flags = 0;          intern->flags = 0;
         intern->traverse_position = 0;          intern->traverse_position = 0;
Line 523  static HashTable* spl_dllist_object_get_debug_info(zva Line 525  static HashTable* spl_dllist_object_get_debug_info(zva
                 INIT_PZVAL(&zrv);                  INIT_PZVAL(&zrv);
                 Z_ARRVAL(zrv) = intern->debug_info;                  Z_ARRVAL(zrv) = intern->debug_info;
   
                   if (!intern->std.properties) {
                           rebuild_object_properties(&intern->std);
                   }
                 zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));                  zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
   
                 pnstr = spl_gen_private_prop_name(spl_ce_SplDoublyLinkedList, "flags", sizeof("flags")-1, &pnlen TSRMLS_CC);                  pnstr = spl_gen_private_prop_name(spl_ce_SplDoublyLinkedList, "flags", sizeof("flags")-1, &pnlen TSRMLS_CC);
Line 1127  SPL_METHOD(SplDoublyLinkedList, current) Line 1132  SPL_METHOD(SplDoublyLinkedList, current)
         }          }
 }  }
 /* }}} */  /* }}} */
   /* {{{ proto string SplDoublyLinkedList::serialize()
    Serializes storage */
   SPL_METHOD(SplDoublyLinkedList, serialize)
   {
           spl_dllist_object     *intern   = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
           smart_str              buf      = {0};
           spl_ptr_llist_element *current  = intern->llist->head, *next;
       zval                   *flags;
           php_serialize_data_t   var_hash;
   
           if (zend_parse_parameters_none() == FAILURE) {
                   return;
           }
   
           PHP_VAR_SERIALIZE_INIT(var_hash);
   
           /* flags */
           MAKE_STD_ZVAL(flags);
           ZVAL_LONG(flags, intern->flags);
           php_var_serialize(&buf, &flags, &var_hash TSRMLS_CC);
           zval_ptr_dtor(&flags);
   
           /* elements */
           while (current) {
                   smart_str_appendc(&buf, ':');
                   next = current->next;
   
                   php_var_serialize(&buf, (zval **)&current->data, &var_hash TSRMLS_CC);
   
                   current = next;
           }
   
           smart_str_0(&buf);
   
           /* done */
           PHP_VAR_SERIALIZE_DESTROY(var_hash);
   
           if (buf.c) {
                   RETURN_STRINGL(buf.c, buf.len, 0);
           } else {
                   RETURN_NULL();
           }
           
   } /* }}} */
   
   /* {{{ proto void SplDoublyLinkedList::unserialize(string serialized)
    Unserializes storage */
   SPL_METHOD(SplDoublyLinkedList, unserialize)
   {
           spl_dllist_object     *intern   = (spl_dllist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
           zval                  *flags, *elem;
           char *buf;
           int buf_len;
           const unsigned char *p, *s;
           php_unserialize_data_t var_hash;
           
           if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
                   return;
           }
   
           if (buf_len == 0) {
                   zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Serialized string cannot be empty");
                   return;
           }
   
           s = p = (const unsigned char*)buf;
           PHP_VAR_UNSERIALIZE_INIT(var_hash);
   
           /* flags */
           ALLOC_INIT_ZVAL(flags);
           if (!php_var_unserialize(&flags, &p, s + buf_len, &var_hash TSRMLS_CC) || Z_TYPE_P(flags) != IS_LONG) {
                   zval_ptr_dtor(&flags);
                   goto error;
           }
           intern->flags = Z_LVAL_P(flags);
           zval_ptr_dtor(&flags);
   
           /* elements */
           while(*p == ':') {
                   ++p;
                   ALLOC_INIT_ZVAL(elem);
                   if (!php_var_unserialize(&elem, &p, s + buf_len, &var_hash TSRMLS_CC)) {
                           zval_ptr_dtor(&elem);
                           goto error;
                   }
   
                   spl_ptr_llist_push(intern->llist, elem TSRMLS_CC);
           }
   
           if (*p != '\0') {
                   goto error;
           }
   
           PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
           return;
   
   error:
           PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
           zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %ld of %d bytes", (long)((char*)p - buf), buf_len);
           return;
   
   } /* }}} */
   
 /* iterator handler table */  /* iterator handler table */
 zend_object_iterator_funcs spl_dllist_it_funcs = {  zend_object_iterator_funcs spl_dllist_it_funcs = {
         spl_dllist_it_dtor,          spl_dllist_it_dtor,
Line 1188  ZEND_END_ARG_INFO() Line 1295  ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_INFO(arginfo_dllist_void, 0)  ZEND_BEGIN_ARG_INFO(arginfo_dllist_void, 0)
 ZEND_END_ARG_INFO()  ZEND_END_ARG_INFO()
   
   ZEND_BEGIN_ARG_INFO(arginfo_dllist_serialized, 0)
           ZEND_ARG_INFO(0, serialized)
   ZEND_END_ARG_INFO();
   
 static const zend_function_entry spl_funcs_SplQueue[] = {  static const zend_function_entry spl_funcs_SplQueue[] = {
         SPL_MA(SplQueue, enqueue, SplDoublyLinkedList, push,  arginfo_dllist_push, ZEND_ACC_PUBLIC)          SPL_MA(SplQueue, enqueue, SplDoublyLinkedList, push,  arginfo_dllist_push, ZEND_ACC_PUBLIC)
         SPL_MA(SplQueue, dequeue, SplDoublyLinkedList, shift, arginfo_dllist_void, ZEND_ACC_PUBLIC)          SPL_MA(SplQueue, dequeue, SplDoublyLinkedList, shift, arginfo_dllist_void, ZEND_ACC_PUBLIC)
Line 1201  static const zend_function_entry spl_funcs_SplDoublyLi Line 1312  static const zend_function_entry spl_funcs_SplDoublyLi
         SPL_ME(SplDoublyLinkedList, unshift,         arginfo_dllist_push,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, unshift,         arginfo_dllist_push,            ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, top,             arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, top,             arginfo_dllist_void,            ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, bottom,          arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, bottom,          arginfo_dllist_void,            ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, count,           arginfo_dllist_void,            ZEND_ACC_PUBLIC)  
         SPL_ME(SplDoublyLinkedList, isEmpty,         arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, isEmpty,         arginfo_dllist_void,            ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, setIteratorMode, arginfo_dllist_setiteratormode, ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, setIteratorMode, arginfo_dllist_setiteratormode, ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, getIteratorMode, arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, getIteratorMode, arginfo_dllist_void,            ZEND_ACC_PUBLIC)
           /* Countable */
           SPL_ME(SplDoublyLinkedList, count,           arginfo_dllist_void,            ZEND_ACC_PUBLIC)
           /* ArrayAccess */
         SPL_ME(SplDoublyLinkedList, offsetExists,    arginfo_dllist_offsetGet,       ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, offsetExists,    arginfo_dllist_offsetGet,       ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, offsetGet,       arginfo_dllist_offsetGet,       ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, offsetGet,       arginfo_dllist_offsetGet,       ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, offsetSet,       arginfo_dllist_offsetSet,       ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, offsetSet,       arginfo_dllist_offsetSet,       ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, offsetUnset,     arginfo_dllist_offsetGet,       ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, offsetUnset,     arginfo_dllist_offsetGet,       ZEND_ACC_PUBLIC)
           /* Iterator */
         SPL_ME(SplDoublyLinkedList, rewind,          arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, rewind,          arginfo_dllist_void,            ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, current,         arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, current,         arginfo_dllist_void,            ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, key,             arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, key,             arginfo_dllist_void,            ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, next,            arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, next,            arginfo_dllist_void,            ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, prev,            arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, prev,            arginfo_dllist_void,            ZEND_ACC_PUBLIC)
         SPL_ME(SplDoublyLinkedList, valid,           arginfo_dllist_void,            ZEND_ACC_PUBLIC)          SPL_ME(SplDoublyLinkedList, valid,           arginfo_dllist_void,            ZEND_ACC_PUBLIC)
           /* Serializable */
           SPL_ME(SplDoublyLinkedList,  unserialize,    arginfo_dllist_serialized,      ZEND_ACC_PUBLIC)
           SPL_ME(SplDoublyLinkedList,  serialize,      arginfo_dllist_void,            ZEND_ACC_PUBLIC)
         PHP_FE_END          PHP_FE_END
 };  };
 /* }}} */  /* }}} */
Line 1236  PHP_MINIT_FUNCTION(spl_dllist) /* {{{ */ Line 1353  PHP_MINIT_FUNCTION(spl_dllist) /* {{{ */
         REGISTER_SPL_IMPLEMENTS(SplDoublyLinkedList, Iterator);          REGISTER_SPL_IMPLEMENTS(SplDoublyLinkedList, Iterator);
         REGISTER_SPL_IMPLEMENTS(SplDoublyLinkedList, Countable);          REGISTER_SPL_IMPLEMENTS(SplDoublyLinkedList, Countable);
         REGISTER_SPL_IMPLEMENTS(SplDoublyLinkedList, ArrayAccess);          REGISTER_SPL_IMPLEMENTS(SplDoublyLinkedList, ArrayAccess);
           REGISTER_SPL_IMPLEMENTS(SplDoublyLinkedList, Serializable);
   
         spl_ce_SplDoublyLinkedList->get_iterator = spl_dllist_get_iterator;          spl_ce_SplDoublyLinkedList->get_iterator = spl_dllist_get_iterator;
   

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>