PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - Zend - zend_iterators.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 25 27 92.6 %
Date: 2014-10-24 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend license,     |
       8             :    | that is bundled with this package in the file LICENSE, and is        | 
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Author: Wez Furlong <wez@thebrainroom.com>                           |
      16             :    |         Marcus Boerger <helly@php.net>                               |
      17             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #include "zend.h"
      23             : #include "zend_API.h"
      24             : 
      25             : static zend_class_entry zend_iterator_class_entry;
      26             : 
      27             : static zend_object_handlers iterator_object_handlers = {
      28             :         ZEND_OBJECTS_STORE_HANDLERS,
      29             :         NULL, /* prop read */
      30             :         NULL, /* prop write */
      31             :         NULL, /* read dim */
      32             :         NULL, /* write dim */
      33             :         NULL,
      34             :         NULL, /* get */
      35             :         NULL, /* set */
      36             :         NULL, /* has prop */
      37             :         NULL, /* unset prop */
      38             :         NULL, /* has dim */
      39             :         NULL, /* unset dim */
      40             :         NULL, /* props get */
      41             :         NULL, /* method get */
      42             :         NULL, /* call */
      43             :         NULL, /* get ctor */
      44             :         NULL, /* get_ce */
      45             :         NULL, /* get class name */
      46             :         NULL, /* compare */
      47             :         NULL, /* cast */
      48             :         NULL  /* count */
      49             : };
      50             : 
      51       20225 : ZEND_API void zend_register_iterator_wrapper(TSRMLS_D)
      52             : {
      53       20225 :         INIT_CLASS_ENTRY(zend_iterator_class_entry, "__iterator_wrapper", NULL);
      54       20225 :         str_free(zend_iterator_class_entry.name);
      55       20225 :         zend_iterator_class_entry.name = "__iterator_wrapper";
      56       20225 : }
      57             : 
      58         651 : static void iter_wrapper_dtor(void *object, zend_object_handle handle TSRMLS_DC)
      59             : {
      60         651 :         zend_object_iterator *iter = (zend_object_iterator*)object;
      61         651 :         iter->funcs->dtor(iter TSRMLS_CC);
      62         651 : }
      63             : 
      64         653 : ZEND_API zval *zend_iterator_wrap(zend_object_iterator *iter TSRMLS_DC)
      65             : {
      66             :         zval *wrapped;
      67             : 
      68         653 :         MAKE_STD_ZVAL(wrapped);
      69         653 :         Z_TYPE_P(wrapped) = IS_OBJECT;
      70         653 :         Z_OBJ_HANDLE_P(wrapped) = zend_objects_store_put(iter, iter_wrapper_dtor, NULL, NULL TSRMLS_CC);
      71         653 :         Z_OBJ_HT_P(wrapped) = &iterator_object_handlers;
      72             : 
      73         653 :         return wrapped;
      74             : }
      75             : 
      76     2137347 : ZEND_API enum zend_object_iterator_kind zend_iterator_unwrap(
      77             :         zval *array_ptr, zend_object_iterator **iter TSRMLS_DC)
      78             : {
      79     2137347 :         switch (Z_TYPE_P(array_ptr)) {
      80             :                 case IS_OBJECT:
      81        7035 :                         if (Z_OBJ_HT_P(array_ptr) == &iterator_object_handlers) {
      82        6706 :                                 *iter = (zend_object_iterator *)zend_object_store_get_object(array_ptr TSRMLS_CC);
      83        6706 :                                 return ZEND_ITER_OBJECT;
      84             :                         }
      85         329 :                         if (Z_OBJPROP_P(array_ptr)) {
      86         329 :                                 return ZEND_ITER_PLAIN_OBJECT;
      87             :                         }
      88           0 :                         return ZEND_ITER_INVALID;
      89             : 
      90             :                 case IS_ARRAY:
      91     2130310 :                         if (Z_ARRVAL_P(array_ptr)) {
      92     2130310 :                                 return ZEND_ITER_PLAIN_ARRAY;
      93             :                         }
      94           0 :                         return ZEND_ITER_INVALID;
      95             : 
      96             :                 default:
      97           2 :                         return ZEND_ITER_INVALID;
      98             :         }
      99             : }
     100             : 
     101             : /*
     102             :  * Local variables:
     103             :  * tab-width: 4
     104             :  * c-basic-offset: 4
     105             :  * indent-tabs-mode: t
     106             :  * End:
     107             :  */

Generated by: LCOV version 1.10

Generated at Fri, 24 Oct 2014 05:21:44 +0000 (27 hours ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.