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 - ext/intl/collator - collator_class.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 27 34 79.4 %
Date: 2016-08-24 Functions: 4 5 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 7                                                        |
       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             : static zend_object_handlers Collator_handlers;
      33             : 
      34             : /*
      35             :  * Auxiliary functions needed by objects of 'Collator' class
      36             :  */
      37             : 
      38             : /* {{{ Collator_objects_free */
      39          77 : void Collator_objects_free(zend_object *object )
      40             : {
      41          77 :         Collator_object* co = php_intl_collator_fetch_object(object);
      42             : 
      43          77 :         zend_object_std_dtor(&co->zo );
      44             : 
      45          77 :         collator_object_destroy(co );
      46          77 : }
      47             : /* }}} */
      48             : 
      49             : /* {{{ Collator_object_create */
      50          77 : zend_object *Collator_object_create(zend_class_entry *ce )
      51             : {
      52             :         Collator_object*     intern;
      53             : 
      54          77 :         intern = ecalloc(1, sizeof(Collator_object) + zend_object_properties_size(ce));
      55          77 :         intl_error_init(COLLATOR_ERROR_P(intern));
      56          77 :         zend_object_std_init(&intern->zo, ce );
      57          77 :         object_properties_init(&intern->zo, ce);
      58             : 
      59          77 :         intern->zo.handlers = &Collator_handlers;
      60             : 
      61          77 :         return &intern->zo;
      62             : }
      63             : /* }}} */
      64             : 
      65             : /*
      66             :  * 'Collator' class registration structures & functions
      67             :  */
      68             : 
      69             : /* {{{ Collator methods arguments info */
      70             : /* NOTE: modifying 'collator_XX_args' do not forget to
      71             :        modify approptiate 'collator_XX_args' for
      72             :        the procedural API.
      73             : */
      74             : ZEND_BEGIN_ARG_INFO_EX( collator_0_args, 0, 0, 0 )
      75             : ZEND_END_ARG_INFO()
      76             : 
      77             : ZEND_BEGIN_ARG_INFO_EX( collator_1_arg, 0, 0, 1 )
      78             :         ZEND_ARG_INFO( 0, arg1 )
      79             : ZEND_END_ARG_INFO()
      80             : 
      81             : ZEND_BEGIN_ARG_INFO_EX( collator_2_args, 0, 0, 2 )
      82             :         ZEND_ARG_INFO( 0, arg1 )
      83             :         ZEND_ARG_INFO( 0, arg2 )
      84             : ZEND_END_ARG_INFO()
      85             : 
      86             : ZEND_BEGIN_ARG_INFO_EX( collator_sort_args, 0, 0, 1 )
      87             :         ZEND_ARG_ARRAY_INFO( 1, arr, 0 )
      88             :         ZEND_ARG_INFO( 0, flags )
      89             : ZEND_END_ARG_INFO()
      90             : 
      91             : /* }}} */
      92             : 
      93             : /* {{{ Collator_class_functions
      94             :  * Every 'Collator' class method has an entry in this table
      95             :  */
      96             : 
      97             : zend_function_entry Collator_class_functions[] = {
      98             :         PHP_ME( Collator, __construct, collator_1_arg, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR )
      99             :         ZEND_FENTRY( create, ZEND_FN( collator_create ), collator_1_arg, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
     100             :         PHP_NAMED_FE( compare, ZEND_FN( collator_compare ), collator_2_args )
     101             :         PHP_NAMED_FE( sort, ZEND_FN( collator_sort ), collator_sort_args )
     102             :         PHP_NAMED_FE( sortWithSortKeys, ZEND_FN( collator_sort_with_sort_keys ), collator_sort_args )
     103             :         PHP_NAMED_FE( asort, ZEND_FN( collator_asort ), collator_sort_args )
     104             :         PHP_NAMED_FE( getAttribute, ZEND_FN( collator_get_attribute ), collator_1_arg )
     105             :         PHP_NAMED_FE( setAttribute, ZEND_FN( collator_set_attribute ), collator_2_args )
     106             :         PHP_NAMED_FE( getStrength, ZEND_FN( collator_get_strength ), collator_0_args )
     107             :         PHP_NAMED_FE( setStrength, ZEND_FN( collator_set_strength ), collator_1_arg )
     108             :         PHP_NAMED_FE( getLocale, ZEND_FN( collator_get_locale ), collator_1_arg )
     109             :         PHP_NAMED_FE( getErrorCode, ZEND_FN( collator_get_error_code ), collator_0_args )
     110             :         PHP_NAMED_FE( getErrorMessage, ZEND_FN( collator_get_error_message ), collator_0_args )
     111             :         PHP_NAMED_FE( getSortKey, ZEND_FN( collator_get_sort_key ), collator_2_args )
     112             :         PHP_FE_END
     113             : };
     114             : /* }}} */
     115             : 
     116             : /* {{{ collator_register_Collator_class
     117             :  * Initialize 'Collator' class
     118             :  */
     119       23504 : void collator_register_Collator_class( void )
     120             : {
     121             :         zend_class_entry ce;
     122             : 
     123             :         /* Create and register 'Collator' class. */
     124       23504 :         INIT_CLASS_ENTRY( ce, "Collator", Collator_class_functions );
     125       23504 :         ce.create_object = Collator_object_create;
     126       23504 :         Collator_ce_ptr = zend_register_internal_class( &ce );
     127             : 
     128       23504 :         memcpy(&Collator_handlers, zend_get_std_object_handlers(),
     129             :                 sizeof Collator_handlers);
     130             :         /* Collator has no usable clone semantics - ucol_cloneBinary/ucol_openBinary require binary buffer
     131             :            for which we don't have the place to keep */
     132       23504 :         Collator_handlers.offset = XtOffsetOf(Collator_object, zo);
     133       23504 :         Collator_handlers.clone_obj = NULL;
     134       23504 :         Collator_handlers.free_obj = Collator_objects_free;
     135             : 
     136             :         /* Declare 'Collator' class properties. */
     137       23504 :         if( !Collator_ce_ptr )
     138             :         {
     139           0 :                 zend_error( E_ERROR,
     140             :                         "Collator: attempt to create properties "
     141             :                         "on a non-registered class." );
     142           0 :                 return;
     143             :         }
     144             : }
     145             : /* }}} */
     146             : 
     147             : /* {{{ void collator_object_init( Collator_object* co )
     148             :  * Initialize internals of Collator_object.
     149             :  * Must be called before any other call to 'collator_object_...' functions.
     150             :  */
     151           0 : void collator_object_init( Collator_object* co )
     152             : {
     153           0 :         if( !co )
     154           0 :                 return;
     155             : 
     156           0 :         intl_error_init( COLLATOR_ERROR_P( co ) );
     157             : }
     158             : /* }}} */
     159             : 
     160             : /* {{{ void collator_object_destroy( Collator_object* co )
     161             :  * Clean up mem allocted by internals of Collator_object
     162             :  */
     163          77 : void collator_object_destroy( Collator_object* co )
     164             : {
     165          77 :         if( !co )
     166           0 :                 return;
     167             : 
     168          77 :         if( co->ucoll )
     169             :         {
     170          69 :                 ucol_close( co->ucoll );
     171          69 :                 co->ucoll = NULL;
     172             :         }
     173             : 
     174          77 :         intl_error_reset( COLLATOR_ERROR_P( co ) );
     175             : }
     176             : /* }}} */
     177             : 
     178             : /*
     179             :  * Local variables:
     180             :  * tab-width: 4
     181             :  * c-basic-offset: 4
     182             :  * End:
     183             :  * vim600: noet sw=4 ts=4 fdm=marker
     184             :  * vim<600: noet sw=4 ts=4
     185             :  */

Generated by: LCOV version 1.10

Generated at Wed, 24 Aug 2016 12:20:21 +0000 (3 days ago)

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