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

LTP GCOV extension - code coverage report
Current view: directory - intl/collator - collator_class.c
Test: PHP Code Coverage
Date: 2009-11-21 Instrumented lines: 34
Code covered: 79.4 % Executed lines: 27
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | PHP Version 5                                                        |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | This source file is subject to version 3.01 of the PHP license,      |
       6                 :    | that is bundled with this package in the file LICENSE, and is        |
       7                 :    | available through the world-wide-web at the following url:           |
       8                 :    | http://www.php.net/license/3_01.txt                                  |
       9                 :    | If you did not receive a copy of the PHP license and are unable to   |
      10                 :    | obtain it through the world-wide-web, please send a note to          |
      11                 :    | license@php.net so we can mail you a copy immediately.               |
      12                 :    +----------------------------------------------------------------------+
      13                 :    | Authors: Vadim Savchuk <vsavchuk@productengine.com>                  |
      14                 :    |          Dmitry Lakhtyuk <dlakhtyuk@productengine.com>               |
      15                 :    +----------------------------------------------------------------------+
      16                 :  */
      17                 : 
      18                 : #include "collator_class.h"
      19                 : #include "php_intl.h"
      20                 : #include "collator_attr.h"
      21                 : #include "collator_compare.h"
      22                 : #include "collator_sort.h"
      23                 : #include "collator_convert.h"
      24                 : #include "collator_locale.h"
      25                 : #include "collator_create.h"
      26                 : #include "collator_error.h"
      27                 : #include "intl_error.h"
      28                 : 
      29                 : #include <unicode/ucol.h>
      30                 : 
      31                 : zend_class_entry *Collator_ce_ptr = NULL;
      32                 : 
      33                 : /*
      34                 :  * Auxiliary functions needed by objects of 'Collator' class
      35                 :  */
      36                 : 
      37                 : /* {{{ Collator_objects_dtor */
      38                 : static void Collator_objects_dtor(
      39                 :         void *object,
      40                 :         zend_object_handle handle TSRMLS_DC )
      41              76 : {
      42              76 :         zend_objects_destroy_object( object, handle TSRMLS_CC );
      43              76 : }
      44                 : /* }}} */
      45                 : 
      46                 : /* {{{ Collator_objects_free */
      47                 : void Collator_objects_free( zend_object *object TSRMLS_DC )
      48              76 : {
      49              76 :         Collator_object* co = (Collator_object*)object;
      50                 : 
      51              76 :         zend_object_std_dtor( &co->zo TSRMLS_CC );
      52                 : 
      53              76 :         collator_object_destroy( co TSRMLS_CC );
      54                 : 
      55              76 :         efree( co );
      56              76 : }
      57                 : /* }}} */
      58                 : 
      59                 : /* {{{ Collator_object_create */
      60                 : zend_object_value Collator_object_create(
      61                 :         zend_class_entry *ce TSRMLS_DC )
      62              76 : {
      63                 :         zend_object_value    retval;
      64                 :         Collator_object*     intern;
      65                 : 
      66              76 :         intern = ecalloc( 1, sizeof(Collator_object) );
      67              76 :         intl_error_init( COLLATOR_ERROR_P( intern ) TSRMLS_CC );
      68              76 :         zend_object_std_init( &intern->zo, ce TSRMLS_CC );
      69                 : 
      70              76 :         retval.handle = zend_objects_store_put(
      71                 :                 intern,
      72                 :                 Collator_objects_dtor,
      73                 :                 (zend_objects_free_object_storage_t)Collator_objects_free,
      74                 :                 NULL TSRMLS_CC );
      75                 : 
      76              76 :         retval.handlers = zend_get_std_object_handlers();
      77                 : 
      78              76 :         return retval;
      79                 : }
      80                 : /* }}} */
      81                 : 
      82                 : /*
      83                 :  * 'Collator' class registration structures & functions
      84                 :  */
      85                 : 
      86                 : /* {{{ Collator methods arguments info */
      87                 : /* NOTE: modifying 'collator_XX_args' do not forget to
      88                 :        modify approptiate 'collator_XX_args' for
      89                 :        the procedural API.
      90                 : */
      91                 : ZEND_BEGIN_ARG_INFO_EX( collator_0_args, 0, 0, 0 )
      92                 : ZEND_END_ARG_INFO()
      93                 : 
      94                 : ZEND_BEGIN_ARG_INFO_EX( collator_1_arg, 0, 0, 1 )
      95                 :         ZEND_ARG_INFO( 0, arg1 )
      96                 : ZEND_END_ARG_INFO()
      97                 : 
      98                 : ZEND_BEGIN_ARG_INFO_EX( collator_2_args, 0, 0, 2 )
      99                 :         ZEND_ARG_INFO( 0, arg1 )
     100                 :         ZEND_ARG_INFO( 0, arg2 )
     101                 : ZEND_END_ARG_INFO()
     102                 : 
     103                 : ZEND_BEGIN_ARG_INFO_EX( collator_sort_args, 0, 0, 1 )
     104                 :         ZEND_ARG_ARRAY_INFO( 1, arr, 0 )
     105                 :         ZEND_ARG_INFO( 0, flags )
     106                 : ZEND_END_ARG_INFO()
     107                 : 
     108                 : /* }}} */
     109                 : 
     110                 : /* {{{ Collator_class_functions
     111                 :  * Every 'Collator' class method has an entry in this table
     112                 :  */
     113                 : 
     114                 : function_entry Collator_class_functions[] = {
     115                 :         PHP_ME( Collator, __construct, collator_1_arg, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR )
     116                 :         ZEND_FENTRY( create, ZEND_FN( collator_create ), collator_1_arg, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
     117                 :         PHP_NAMED_FE( compare, ZEND_FN( collator_compare ), collator_2_args )
     118                 :         PHP_NAMED_FE( sort, ZEND_FN( collator_sort ), collator_sort_args )
     119                 :         PHP_NAMED_FE( sortWithSortKeys, ZEND_FN( collator_sort_with_sort_keys ), collator_sort_args )
     120                 :         PHP_NAMED_FE( asort, ZEND_FN( collator_asort ), collator_sort_args )
     121                 :         PHP_NAMED_FE( getAttribute, ZEND_FN( collator_get_attribute ), collator_1_arg )
     122                 :         PHP_NAMED_FE( setAttribute, ZEND_FN( collator_set_attribute ), collator_2_args )
     123                 :         PHP_NAMED_FE( getStrength, ZEND_FN( collator_get_strength ), collator_0_args )
     124                 :         PHP_NAMED_FE( setStrength, ZEND_FN( collator_set_strength ), collator_1_arg )
     125                 :         PHP_NAMED_FE( getLocale, ZEND_FN( collator_get_locale ), collator_1_arg )
     126                 :         PHP_NAMED_FE( getErrorCode, ZEND_FN( collator_get_error_code ), collator_0_args )
     127                 :         PHP_NAMED_FE( getErrorMessage, ZEND_FN( collator_get_error_message ), collator_0_args )
     128                 :         PHP_NAMED_FE( getSortKey, ZEND_FN( collator_get_sort_key ), collator_2_args )
     129                 :         { NULL, NULL, NULL }
     130                 : };
     131                 : /* }}} */
     132                 : 
     133                 : /* {{{ collator_register_Collator_class
     134                 :  * Initialize 'Collator' class
     135                 :  */
     136                 : void collator_register_Collator_class( TSRMLS_D )
     137           17633 : {
     138                 :         zend_class_entry ce;
     139                 : 
     140                 :         /* Create and register 'Collator' class. */
     141           17633 :         INIT_CLASS_ENTRY( ce, "Collator", Collator_class_functions );
     142           17633 :         ce.create_object = Collator_object_create;
     143           17633 :         Collator_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC );
     144                 : 
     145                 :         /* Declare 'Collator' class properties. */
     146           17633 :         if( !Collator_ce_ptr )
     147                 :         {
     148               0 :                 zend_error( E_ERROR,
     149                 :                         "Collator: attempt to create properties "
     150                 :                         "on a non-registered class." );
     151               0 :                 return;
     152                 :         }
     153                 : }
     154                 : /* }}} */
     155                 : 
     156                 : /* {{{ void collator_object_init( Collator_object* co )
     157                 :  * Initialize internals of Collator_object.
     158                 :  * Must be called before any other call to 'collator_object_...' functions.
     159                 :  */
     160                 : void collator_object_init( Collator_object* co TSRMLS_DC )
     161               0 : {
     162               0 :         if( !co )
     163               0 :                 return;
     164                 : 
     165               0 :         intl_error_init( COLLATOR_ERROR_P( co ) TSRMLS_CC );
     166                 : }
     167                 : /* }}} */
     168                 : 
     169                 : /* {{{ void collator_object_destroy( Collator_object* co )
     170                 :  * Clean up mem allocted by internals of Collator_object
     171                 :  */
     172                 : void collator_object_destroy( Collator_object* co TSRMLS_DC )
     173              76 : {
     174              76 :         if( !co )
     175               0 :                 return;
     176                 : 
     177              76 :         if( co->ucoll )
     178                 :         {
     179              74 :                 ucol_close( co->ucoll );
     180              74 :                 co->ucoll = NULL;
     181                 :         }
     182                 : 
     183              76 :         intl_error_reset( COLLATOR_ERROR_P( co ) TSRMLS_CC );
     184                 : }
     185                 : /* }}} */
     186                 : 
     187                 : /*
     188                 :  * Local variables:
     189                 :  * tab-width: 4
     190                 :  * c-basic-offset: 4
     191                 :  * End:
     192                 :  * vim600: noet sw=4 ts=4 fdm=marker
     193                 :  * vim<600: noet sw=4 ts=4
     194                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Sat, 21 Nov 2009 12:27:01 +0000 (3 days ago)

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