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/calendar - calendar_class.cpp (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 84 141 59.6 %
Date: 2014-04-16 Functions: 8 10 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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: Gustavo Lopes <cataphract@php.net>                          |
      14             :    +----------------------------------------------------------------------+
      15             : */
      16             : 
      17             : #ifdef HAVE_CONFIG_H
      18             : #include "config.h"
      19             : #endif
      20             : 
      21             : #include "../intl_cppshims.h"
      22             : 
      23             : #include <unicode/calendar.h>
      24             : #include <unicode/gregocal.h>
      25             : 
      26             : extern "C" {
      27             : #define USE_TIMEZONE_POINTER 1
      28             : #include "../timezone/timezone_class.h"
      29             : #define USE_CALENDAR_POINTER 1
      30             : #include "calendar_class.h"
      31             : #include "calendar_methods.h"
      32             : #include "gregoriancalendar_methods.h"
      33             : #include <zend_exceptions.h>
      34             : #include <assert.h>
      35             : }
      36             : 
      37             : /* {{{ Global variables */
      38             : zend_class_entry *Calendar_ce_ptr;
      39             : zend_class_entry *GregorianCalendar_ce_ptr;
      40             : zend_object_handlers Calendar_handlers;
      41             : /* }}} */
      42             : 
      43          42 : U_CFUNC void calendar_object_create(zval *object,
      44             :                                                                         Calendar *calendar TSRMLS_DC)
      45             : {
      46          42 :         UClassID classId = calendar->getDynamicClassID();
      47             :         zend_class_entry *ce;
      48             : 
      49             :         //if (dynamic_cast<GregorianCalendar*>(calendar) != NULL) {
      50          42 :         if (classId == GregorianCalendar::getStaticClassID()) {
      51          35 :                 ce = GregorianCalendar_ce_ptr;
      52             :         } else {
      53           7 :                 ce = Calendar_ce_ptr;
      54             :         }
      55             : 
      56          42 :         object_init_ex(object, ce);
      57          42 :         calendar_object_construct(object, calendar TSRMLS_CC);
      58          42 : }
      59             : 
      60          15 : U_CFUNC Calendar *calendar_fetch_native_calendar(zval *object TSRMLS_DC)
      61             : {
      62             :         Calendar_object *co = (Calendar_object*)
      63          15 :                         zend_object_store_get_object(object TSRMLS_CC);
      64             : 
      65          15 :         return co->ucal;
      66             : }
      67             : 
      68          42 : U_CFUNC void calendar_object_construct(zval *object,
      69             :                                                                            Calendar *calendar TSRMLS_DC)
      70             : {
      71             :         Calendar_object *co;
      72             : 
      73          42 :         CALENDAR_METHOD_FETCH_OBJECT_NO_CHECK; //populate to from object
      74             :         assert(co->ucal == NULL);
      75          42 :         co->ucal = (Calendar*)calendar;
      76          42 : }
      77             : 
      78             : /* {{{ clone handler for Calendar */
      79           0 : static zend_object_value Calendar_clone_obj(zval *object TSRMLS_DC)
      80             : {
      81             :         Calendar_object         *co_orig,
      82             :                                                 *co_new;
      83             :         zend_object_value   ret_val;
      84           0 :         intl_error_reset(NULL TSRMLS_CC);
      85             : 
      86           0 :         co_orig = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC);
      87           0 :         intl_error_reset(INTL_DATA_ERROR_P(co_orig) TSRMLS_CC);
      88             : 
      89           0 :         ret_val = Calendar_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC);
      90           0 :         co_new  = (Calendar_object*)zend_object_store_get_object_by_handle(ret_val.handle TSRMLS_CC);
      91             : 
      92             :         zend_objects_clone_members(&co_new->zo, ret_val,
      93           0 :                 &co_orig->zo, Z_OBJ_HANDLE_P(object) TSRMLS_CC);
      94             : 
      95           0 :         if (co_orig->ucal != NULL) {
      96             :                 Calendar        *newCalendar;
      97             : 
      98           0 :                 newCalendar = co_orig->ucal->clone();
      99           0 :                 if (!newCalendar) {
     100             :                         char *err_msg;
     101             :                         intl_errors_set_code(CALENDAR_ERROR_P(co_orig),
     102           0 :                                 U_MEMORY_ALLOCATION_ERROR TSRMLS_CC);
     103             :                         intl_errors_set_custom_msg(CALENDAR_ERROR_P(co_orig),
     104           0 :                                 "Could not clone IntlCalendar", 0 TSRMLS_CC);
     105           0 :                         err_msg = intl_error_get_message(CALENDAR_ERROR_P(co_orig) TSRMLS_CC);
     106           0 :                         zend_throw_exception(NULL, err_msg, 0 TSRMLS_CC);
     107           0 :                         efree(err_msg);
     108             :                 } else {
     109           0 :                         co_new->ucal = newCalendar;
     110             :                 }
     111             :         } else {
     112           0 :                 zend_throw_exception(NULL, "Cannot clone unconstructed IntlCalendar", 0 TSRMLS_CC);
     113             :         }
     114             : 
     115           0 :         return ret_val;
     116             : }
     117             : /* }}} */
     118             : 
     119             : static const struct {
     120             :         UCalendarDateFields field;
     121             :         const char                      *name;
     122             : } debug_info_fields[] = {
     123             :         {UCAL_ERA,                                      "era"},
     124             :         {UCAL_YEAR,                                     "year"},
     125             :         {UCAL_MONTH,                            "month"},
     126             :         {UCAL_WEEK_OF_YEAR,                     "week of year"},
     127             :         {UCAL_WEEK_OF_MONTH,            "week of month"},
     128             :         {UCAL_DAY_OF_YEAR,                      "day of year"},
     129             :         {UCAL_DAY_OF_MONTH,                     "day of month"},
     130             :         {UCAL_DAY_OF_WEEK,                      "day of week"},
     131             :         {UCAL_DAY_OF_WEEK_IN_MONTH,     "day of week in month"},
     132             :         {UCAL_AM_PM,                            "AM/PM"},
     133             :         {UCAL_HOUR,                                     "hour"},
     134             :         {UCAL_HOUR_OF_DAY,                      "hour of day"},
     135             :         {UCAL_MINUTE,                           "minute"},
     136             :         {UCAL_SECOND,                           "second"},
     137             :         {UCAL_MILLISECOND,                      "millisecond"},
     138             :         {UCAL_ZONE_OFFSET,                      "zone offset"},
     139             :         {UCAL_DST_OFFSET,                       "DST offset"},
     140             :         {UCAL_YEAR_WOY,                         "year for week of year"},
     141             :         {UCAL_DOW_LOCAL,                        "localized day of week"},
     142             :         {UCAL_EXTENDED_YEAR,            "extended year"},
     143             :         {UCAL_JULIAN_DAY,                       "julian day"},
     144             :         {UCAL_MILLISECONDS_IN_DAY,      "milliseconds in day"},
     145             :         {UCAL_IS_LEAP_MONTH,            "is leap month"},
     146             : };
     147             : 
     148             : /* {{{ get_debug_info handler for Calendar */
     149           0 : static HashTable *Calendar_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
     150             : {
     151           0 :         zval                    zv = zval_used_for_init,
     152             :                                         *zfields;
     153             :         Calendar_object *co;
     154             :         const Calendar  *cal;
     155             :         
     156           0 :         *is_temp = 1;
     157             : 
     158           0 :         array_init_size(&zv, 8);
     159             : 
     160           0 :         co  = (Calendar_object*)zend_object_store_get_object(object TSRMLS_CC);
     161           0 :         cal = co->ucal;
     162             : 
     163           0 :         if (cal == NULL) {
     164           0 :                 add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0);
     165           0 :                 return Z_ARRVAL(zv);
     166             :         }
     167             : 
     168           0 :         add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1);
     169             : 
     170             :         add_assoc_string_ex(&zv, "type", sizeof("type"),
     171           0 :                 const_cast<char*>(cal->getType()), 1);
     172             : 
     173             :         {
     174           0 :                 zval               ztz = zval_used_for_init,
     175             :                                            *ztz_debug;
     176             :                 int                        is_tmp;
     177             :                 HashTable          *debug_info;
     178             : 
     179           0 :                 timezone_object_construct(&cal->getTimeZone(), &ztz , 0 TSRMLS_CC);
     180           0 :                 debug_info = Z_OBJ_HANDLER(ztz, get_debug_info)(&ztz, &is_tmp TSRMLS_CC);
     181             :                 assert(is_tmp == 1);
     182             : 
     183           0 :                 ALLOC_INIT_ZVAL(ztz_debug);
     184           0 :                 Z_TYPE_P(ztz_debug) = IS_ARRAY;
     185           0 :                 Z_ARRVAL_P(ztz_debug) = debug_info;
     186           0 :                 add_assoc_zval_ex(&zv, "timeZone", sizeof("timeZone"), ztz_debug);
     187             :         }
     188             : 
     189             :         {
     190           0 :                 UErrorCode      uec             = U_ZERO_ERROR;
     191           0 :                 Locale          locale  = cal->getLocale(ULOC_VALID_LOCALE, uec);
     192           0 :                 if (U_SUCCESS(uec)) {
     193             :                         add_assoc_string_ex(&zv, "locale", sizeof("locale"),
     194           0 :                                 const_cast<char*>(locale.getName()), 1);
     195             :                 } else {
     196             :                         add_assoc_string_ex(&zv, "locale", sizeof("locale"),
     197           0 :                                 const_cast<char*>(u_errorName(uec)), 1);
     198           0 :                 }
     199             :         }
     200             : 
     201           0 :         ALLOC_INIT_ZVAL(zfields);
     202           0 :         array_init_size(zfields, UCAL_FIELD_COUNT);
     203             : 
     204           0 :         for (int i = 0;
     205             :                          i < sizeof(debug_info_fields) / sizeof(*debug_info_fields);
     206             :                          i++) {
     207           0 :                 UErrorCode      uec             = U_ZERO_ERROR;
     208           0 :                 const char      *name   = debug_info_fields[i].name; 
     209           0 :                 int32_t         res             = cal->get(debug_info_fields[i].field, uec);
     210           0 :                 if (U_SUCCESS(uec)) {
     211           0 :                         add_assoc_long(zfields, name, (long)res);
     212             :                 } else {
     213           0 :                         add_assoc_string(zfields, name, const_cast<char*>(u_errorName(uec)), 1);
     214             :                 }
     215             :         }
     216             : 
     217           0 :         add_assoc_zval_ex(&zv, "fields", sizeof("fields"), zfields);
     218             : 
     219           0 :         return Z_ARRVAL(zv);
     220             : }
     221             : /* }}} */
     222             : 
     223             : /* {{{ void calendar_object_init(Calendar_object* to)
     224             :  * Initialize internals of Calendar_object not specific to zend standard objects.
     225             :  */
     226          98 : static void calendar_object_init(Calendar_object *co TSRMLS_DC)
     227             : {
     228          98 :         intl_error_init(CALENDAR_ERROR_P(co) TSRMLS_CC);
     229          98 :         co->ucal = NULL;
     230          98 : }
     231             : /* }}} */
     232             : 
     233             : /* {{{ Calendar_objects_dtor */
     234          69 : static void Calendar_objects_dtor(void *object,
     235             :                                                                   zend_object_handle handle TSRMLS_DC)
     236             : {
     237          69 :         zend_objects_destroy_object((zend_object*)object, handle TSRMLS_CC);
     238          69 : }
     239             : /* }}} */
     240             : 
     241             : /* {{{ Calendar_objects_free */
     242          98 : static void Calendar_objects_free(zend_object *object TSRMLS_DC)
     243             : {
     244          98 :         Calendar_object* co = (Calendar_object*) object;
     245             : 
     246          98 :         if (co->ucal) {
     247          92 :                 delete co->ucal;
     248          92 :                 co->ucal = NULL;
     249             :         }
     250          98 :         intl_error_reset(CALENDAR_ERROR_P(co) TSRMLS_CC);
     251             : 
     252          98 :         zend_object_std_dtor(&co->zo TSRMLS_CC);
     253             : 
     254          98 :         efree(co);
     255          98 : }
     256             : /* }}} */
     257             : 
     258             : /* {{{ Calendar_object_create */
     259          98 : static zend_object_value Calendar_object_create(zend_class_entry *ce TSRMLS_DC)
     260             : {
     261             :         zend_object_value   retval;
     262             :         Calendar_object*        intern;
     263             : 
     264          98 :         intern = (Calendar_object*)ecalloc(1, sizeof(Calendar_object));
     265             :         
     266          98 :         zend_object_std_init(&intern->zo, ce TSRMLS_CC);
     267             : #if PHP_VERSION_ID < 50399
     268             :     zend_hash_copy(intern->zo.properties, &(ce->default_properties),
     269             :         (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*));
     270             : #else
     271          98 :     object_properties_init((zend_object*) intern, ce);
     272             : #endif
     273          98 :         calendar_object_init(intern TSRMLS_CC);
     274             : 
     275             :         retval.handle = zend_objects_store_put(
     276             :                 intern,
     277             :                 Calendar_objects_dtor,
     278             :                 (zend_objects_free_object_storage_t) Calendar_objects_free,
     279          98 :                 NULL TSRMLS_CC);
     280             : 
     281          98 :         retval.handlers = &Calendar_handlers;
     282             : 
     283          98 :         return retval;
     284             : }
     285             : /* }}} */
     286             : 
     287             : /* {{{ Calendar methods arguments info */
     288             : 
     289             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_void, 0, 0, 0)
     290             : ZEND_END_ARG_INFO()
     291             : 
     292             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_field, 0, 0, 1)
     293             :         ZEND_ARG_INFO(0, field)
     294             : ZEND_END_ARG_INFO()
     295             : 
     296             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_dow, 0, 0, 1)
     297             :         ZEND_ARG_INFO(0, dayOfWeek)
     298             : ZEND_END_ARG_INFO()
     299             : 
     300             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_other_cal, 0, 0, 1)
     301             :         ZEND_ARG_OBJ_INFO(0, calendar, IntlCalendar, 0)
     302             : ZEND_END_ARG_INFO()
     303             : 
     304             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_date, 0, 0, 1)
     305             :         ZEND_ARG_INFO(0, date)
     306             : ZEND_END_ARG_INFO()
     307             : 
     308             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_date_optional, 0, 0, 0)
     309             :         ZEND_ARG_INFO(0, date)
     310             : ZEND_END_ARG_INFO()
     311             : 
     312             : 
     313             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_createInstance, 0, 0, 0)
     314             :         ZEND_ARG_INFO(0, timeZone)
     315             :         ZEND_ARG_INFO(0, locale)
     316             : ZEND_END_ARG_INFO()
     317             : 
     318             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_get_keyword_values_for_locale, 0, 0, 3)
     319             :         ZEND_ARG_INFO(0, key)
     320             :         ZEND_ARG_INFO(0, locale)
     321             :         ZEND_ARG_INFO(0, commonlyUsed)
     322             : ZEND_END_ARG_INFO()
     323             : 
     324             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_add, 0, 0, 2)
     325             :         ZEND_ARG_INFO(0, field)
     326             :         ZEND_ARG_INFO(0, amount)
     327             : ZEND_END_ARG_INFO()
     328             : 
     329             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setTimeZone, 0, 0, 1)
     330             :         ZEND_ARG_INFO(0, timeZone)
     331             : ZEND_END_ARG_INFO()
     332             : 
     333             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_set, 0, 0, 2)
     334             :         ZEND_ARG_INFO(0, fieldOrYear)
     335             :         ZEND_ARG_INFO(0, valueOrMonth)
     336             :         ZEND_ARG_INFO(0, dayOfMonth)
     337             :         ZEND_ARG_INFO(0, hour)
     338             :         ZEND_ARG_INFO(0, minute)
     339             :         ZEND_ARG_INFO(0, second)
     340             : ZEND_END_ARG_INFO()
     341             : 
     342             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_roll, 0, 0, 2)
     343             :         ZEND_ARG_INFO(0, field)
     344             :         ZEND_ARG_INFO(0, amountOrUpOrDown)
     345             : ZEND_END_ARG_INFO()
     346             : 
     347             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_clear, 0, 0, 0)
     348             :         ZEND_ARG_INFO(0, field)
     349             : ZEND_END_ARG_INFO()
     350             : 
     351             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_field_difference, 0, 0, 2)
     352             :         ZEND_ARG_INFO(0, when)
     353             :         ZEND_ARG_INFO(0, field)
     354             : ZEND_END_ARG_INFO()
     355             : 
     356             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_get_locale, 0, 0, 1)
     357             :         ZEND_ARG_INFO(0, localeType)
     358             : ZEND_END_ARG_INFO()
     359             : 
     360             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_setLenient, 0, 0, 1)
     361             :         ZEND_ARG_INFO(0, isLenient)
     362             : ZEND_END_ARG_INFO()
     363             : 
     364             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_set_minimal_days_in_first_week, 0, 0, 1)
     365             :         ZEND_ARG_INFO(0, numberOfDays)
     366             : ZEND_END_ARG_INFO()
     367             : 
     368             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_from_date_time, 0, 0, 1)
     369             :         ZEND_ARG_INFO(0, dateTime)
     370             : ZEND_END_ARG_INFO()
     371             : 
     372             : ZEND_BEGIN_ARG_INFO_EX(ainfo_cal_wall_time_option, 0, 0, 1)
     373             :         ZEND_ARG_INFO(0, wallTimeOption)
     374             : ZEND_END_ARG_INFO()
     375             : 
     376             : /* Gregorian Calendar */
     377             : ZEND_BEGIN_ARG_INFO_EX(ainfo_gregcal___construct, 0, 0, 0)
     378             :         ZEND_ARG_INFO(0, timeZoneOrYear)
     379             :         ZEND_ARG_INFO(0, localeOrMonth)
     380             :         ZEND_ARG_INFO(0, dayOfMonth)
     381             :         ZEND_ARG_INFO(0, hour)
     382             :         ZEND_ARG_INFO(0, minute)
     383             :         ZEND_ARG_INFO(0, second)
     384             : ZEND_END_ARG_INFO()
     385             : 
     386             : ZEND_BEGIN_ARG_INFO_EX(ainfo_gregcal_isLeapYear, 0, 0, 1)
     387             :         ZEND_ARG_INFO(0, year)
     388             : ZEND_END_ARG_INFO()
     389             : 
     390             : /* }}} */
     391             : 
     392             : /* {{{ Calendar_class_functions
     393             :  * Every 'IntlCalendar' class method has an entry in this table
     394             :  */
     395             : static const zend_function_entry Calendar_class_functions[] = {
     396             :         PHP_ME(IntlCalendar,                            __construct,                            ainfo_cal_void,                                         ZEND_ACC_PRIVATE)
     397             :         PHP_ME_MAPPING(createInstance,          intlcal_create_instance,        ainfo_cal_createInstance,                       ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
     398             : #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 42
     399             :         PHP_ME_MAPPING(getKeywordValuesForLocale, intlcal_get_keyword_values_for_locale, ainfo_cal_get_keyword_values_for_locale, ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
     400             : #endif
     401             :         PHP_ME_MAPPING(getNow,                          intlcal_get_now,                        ainfo_cal_void,                                         ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
     402             :         PHP_ME_MAPPING(getAvailableLocales,     intlcal_get_available_locales, ainfo_cal_void,                                  ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
     403             :         PHP_ME_MAPPING(get,                                     intlcal_get,                            ainfo_cal_field,                                        ZEND_ACC_PUBLIC)
     404             :         PHP_ME_MAPPING(getTime,                         intlcal_get_time,                       ainfo_cal_void,                                         ZEND_ACC_PUBLIC)
     405             :         PHP_ME_MAPPING(setTime,                         intlcal_set_time,                       ainfo_cal_date,                                         ZEND_ACC_PUBLIC)
     406             :         PHP_ME_MAPPING(add,                                     intlcal_add,                            ainfo_cal_add,                                          ZEND_ACC_PUBLIC)
     407             :         PHP_ME_MAPPING(setTimeZone,                     intlcal_set_time_zone,          ainfo_cal_setTimeZone,                          ZEND_ACC_PUBLIC)
     408             :         PHP_ME_MAPPING(after,                           intlcal_after,                          ainfo_cal_other_cal,                            ZEND_ACC_PUBLIC)
     409             :         PHP_ME_MAPPING(before,                          intlcal_before,                         ainfo_cal_other_cal,                            ZEND_ACC_PUBLIC)
     410             :         PHP_ME_MAPPING(set,                                     intlcal_set,                            ainfo_cal_set,                                          ZEND_ACC_PUBLIC)
     411             :         PHP_ME_MAPPING(roll,                            intlcal_roll,                           ainfo_cal_roll,                                         ZEND_ACC_PUBLIC)
     412             :         PHP_ME_MAPPING(clear,                           intlcal_clear,                          ainfo_cal_clear,                                        ZEND_ACC_PUBLIC)
     413             :         PHP_ME_MAPPING(fieldDifference,         intlcal_field_difference,       ainfo_cal_field_difference,                     ZEND_ACC_PUBLIC)
     414             :         PHP_ME_MAPPING(getActualMaximum,        intlcal_get_actual_maximum,     ainfo_cal_field,                                        ZEND_ACC_PUBLIC)
     415             :         PHP_ME_MAPPING(getActualMinimum,        intlcal_get_actual_minimum,     ainfo_cal_field,                                        ZEND_ACC_PUBLIC)
     416             : #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
     417             :         PHP_ME_MAPPING(getDayOfWeekType,        intlcal_get_day_of_week_type, ainfo_cal_dow,                                    ZEND_ACC_PUBLIC)
     418             : #endif
     419             :         PHP_ME_MAPPING(getFirstDayOfWeek,       intlcal_get_first_day_of_week, ainfo_cal_void,                                  ZEND_ACC_PUBLIC)
     420             :         PHP_ME_MAPPING(getGreatestMinimum,      intlcal_get_greatest_minimum, ainfo_cal_field,                                  ZEND_ACC_PUBLIC)
     421             :         PHP_ME_MAPPING(getLeastMaximum,         intlcal_get_least_maximum,      ainfo_cal_field,                                        ZEND_ACC_PUBLIC)
     422             :         PHP_ME_MAPPING(getLocale,                       intlcal_get_locale,                     ainfo_cal_get_locale,                           ZEND_ACC_PUBLIC)
     423             :         PHP_ME_MAPPING(getMaximum,                      intlcal_get_maximum,            ainfo_cal_field,                                        ZEND_ACC_PUBLIC)
     424             :         PHP_ME_MAPPING(getMinimalDaysInFirstWeek, intlcal_get_minimal_days_in_first_week, ainfo_cal_void,       ZEND_ACC_PUBLIC)
     425             :         PHP_ME_MAPPING(getMinimum,                      intlcal_get_minimum,            ainfo_cal_field,                                        ZEND_ACC_PUBLIC)
     426             :         PHP_ME_MAPPING(getTimeZone,                     intlcal_get_time_zone,          ainfo_cal_void,                                         ZEND_ACC_PUBLIC)
     427             :         PHP_ME_MAPPING(getType,                         intlcal_get_type,                       ainfo_cal_void,                                         ZEND_ACC_PUBLIC)
     428             : #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
     429             :         PHP_ME_MAPPING(getWeekendTransition,intlcal_get_weekend_transition, ainfo_cal_dow,                                      ZEND_ACC_PUBLIC)
     430             : #endif
     431             :         PHP_ME_MAPPING(inDaylightTime,          intlcal_in_daylight_time,       ainfo_cal_void,                                         ZEND_ACC_PUBLIC)
     432             :         PHP_ME_MAPPING(isEquivalentTo,          intlcal_is_equivalent_to,       ainfo_cal_other_cal,                            ZEND_ACC_PUBLIC)
     433             :         PHP_ME_MAPPING(isLenient,                       intlcal_is_lenient,                     ainfo_cal_void,                                         ZEND_ACC_PUBLIC)
     434             :         PHP_ME_MAPPING(isSet,                           intlcal_is_set,                         ainfo_cal_field,                                        ZEND_ACC_PUBLIC)
     435             : #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
     436             :         PHP_ME_MAPPING(isWeekend,                       intlcal_is_weekend,                     ainfo_cal_date_optional,                        ZEND_ACC_PUBLIC)
     437             : #endif
     438             :         PHP_ME_MAPPING(setFirstDayOfWeek,       intlcal_set_first_day_of_week, ainfo_cal_dow,                                   ZEND_ACC_PUBLIC)
     439             :         PHP_ME_MAPPING(setLenient,                      intlcal_set_lenient,            ainfo_cal_setLenient,                           ZEND_ACC_PUBLIC)
     440             :         PHP_ME_MAPPING(setMinimalDaysInFirstWeek,intlcal_set_minimal_days_in_first_week,ainfo_cal_set_minimal_days_in_first_week,ZEND_ACC_PUBLIC)
     441             :         PHP_ME_MAPPING(equals,                          intlcal_equals,                         ainfo_cal_other_cal,                            ZEND_ACC_PUBLIC)
     442             : #if U_ICU_VERSION_MAJOR_NUM >= 49
     443             :         PHP_ME_MAPPING(getRepeatedWallTimeOption,intlcal_get_repeated_wall_time_option,ainfo_cal_void,          ZEND_ACC_PUBLIC)
     444             :         PHP_ME_MAPPING(getSkippedWallTimeOption,intlcal_get_skipped_wall_time_option,ainfo_cal_void,            ZEND_ACC_PUBLIC)
     445             :         PHP_ME_MAPPING(setRepeatedWallTimeOption,intlcal_set_repeated_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC)
     446             :         PHP_ME_MAPPING(setSkippedWallTimeOption,intlcal_set_skipped_wall_time_option,ainfo_cal_wall_time_option,ZEND_ACC_PUBLIC)
     447             : #endif
     448             :         PHP_ME_MAPPING(fromDateTime,            intlcal_from_date_time,         ainfo_cal_from_date_time,                       ZEND_ACC_STATIC | ZEND_ACC_PUBLIC)
     449             :         PHP_ME_MAPPING(toDateTime,                      intlcal_to_date_time,           ainfo_cal_void,                                         ZEND_ACC_PUBLIC)
     450             :         PHP_ME_MAPPING(getErrorCode,            intlcal_get_error_code,         ainfo_cal_void,                                         ZEND_ACC_PUBLIC)
     451             :         PHP_ME_MAPPING(getErrorMessage,         intlcal_get_error_message,      ainfo_cal_void,                                         ZEND_ACC_PUBLIC)
     452             :         PHP_FE_END
     453             : };
     454             : /* }}} */
     455             : 
     456             : /* {{{ GregorianCalendar_class_functions
     457             :  */
     458             : static const zend_function_entry GregorianCalendar_class_functions[] = {
     459             :         PHP_ME(IntlGregorianCalendar,           __construct,                            ainfo_gregcal___construct,                      ZEND_ACC_PUBLIC)
     460             :         PHP_ME_MAPPING(setGregorianChange,      intlgregcal_set_gregorian_change, ainfo_cal_date,                               ZEND_ACC_PUBLIC)
     461             :         PHP_ME_MAPPING(getGregorianChange,      intlgregcal_get_gregorian_change, ainfo_cal_void,                               ZEND_ACC_PUBLIC)
     462             :         PHP_ME_MAPPING(isLeapYear,                      intlgregcal_is_leap_year,       ainfo_gregcal_isLeapYear,                       ZEND_ACC_PUBLIC)
     463             :         PHP_FE_END
     464             : };
     465             : /* }}} */
     466             : 
     467             : 
     468             : /* {{{ calendar_register_IntlCalendar_class
     469             :  * Initialize 'IntlCalendar' class
     470             :  */
     471       21159 : void calendar_register_IntlCalendar_class(TSRMLS_D)
     472             : {
     473             :         zend_class_entry ce;
     474             : 
     475             :         /* Create and register 'IntlCalendar' class. */
     476       21159 :         INIT_CLASS_ENTRY(ce, "IntlCalendar", Calendar_class_functions);
     477       21159 :         ce.create_object = Calendar_object_create;
     478       21159 :         Calendar_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
     479       21159 :         if (!Calendar_ce_ptr) {
     480             :                 //can't happen now without bigger problems before
     481             :                 php_error_docref0(NULL TSRMLS_CC, E_ERROR,
     482           0 :                         "IntlCalendar: class registration has failed.");
     483           0 :                 return;
     484             :         }
     485             :         memcpy( &Calendar_handlers, zend_get_std_object_handlers(),
     486       21159 :                 sizeof Calendar_handlers);
     487       21159 :         Calendar_handlers.clone_obj = Calendar_clone_obj;
     488       21159 :         Calendar_handlers.get_debug_info = Calendar_get_debug_info;
     489             : 
     490             :         /* Create and register 'IntlGregorianCalendar' class. */
     491       21159 :         INIT_CLASS_ENTRY(ce, "IntlGregorianCalendar", GregorianCalendar_class_functions);
     492             :         GregorianCalendar_ce_ptr = zend_register_internal_class_ex(&ce,
     493       21159 :                 Calendar_ce_ptr, NULL TSRMLS_CC);
     494       21159 :         if (!GregorianCalendar_ce_ptr) {
     495             :                 //can't happen know without bigger problems before
     496             :                 php_error_docref0(NULL TSRMLS_CC, E_ERROR,
     497           0 :                         "IntlGregorianCalendar: class registration has failed.");
     498           0 :                 return;
     499             :         }
     500             : 
     501             :         /* Declare 'IntlCalendar' class constants */
     502             : #define CALENDAR_DECL_LONG_CONST(name, val) \
     503             :         zend_declare_class_constant_long(Calendar_ce_ptr, name, sizeof(name) - 1, \
     504             :                 val TSRMLS_CC)
     505             : 
     506       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_ERA",                                 UCAL_ERA);
     507       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_YEAR",                                        UCAL_YEAR);
     508       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_MONTH",                                       UCAL_MONTH);
     509       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_WEEK_OF_YEAR",                        UCAL_WEEK_OF_YEAR);
     510       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_WEEK_OF_MONTH",                       UCAL_WEEK_OF_MONTH);
     511       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_DATE",                                        UCAL_DATE);
     512       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_YEAR",                 UCAL_DAY_OF_YEAR);
     513       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_WEEK",                 UCAL_DAY_OF_WEEK);
     514       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_WEEK_IN_MONTH",        UCAL_DAY_OF_WEEK_IN_MONTH);
     515       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_AM_PM",                                       UCAL_AM_PM);
     516       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_HOUR",                                        UCAL_HOUR);
     517       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY",                 UCAL_HOUR_OF_DAY);
     518       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_HOUR",                                        UCAL_HOUR);
     519       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_HOUR_OF_DAY",                 UCAL_HOUR_OF_DAY);
     520       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_MINUTE",                              UCAL_MINUTE);
     521       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_SECOND",                              UCAL_SECOND);
     522       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_MILLISECOND",                 UCAL_MILLISECOND);
     523       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_ZONE_OFFSET",                 UCAL_ZONE_OFFSET);
     524       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_DST_OFFSET",                  UCAL_DST_OFFSET);
     525       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_YEAR_WOY",                            UCAL_YEAR_WOY);
     526       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_DOW_LOCAL",                           UCAL_DOW_LOCAL);
     527       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_EXTENDED_YEAR",                       UCAL_EXTENDED_YEAR);
     528       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_JULIAN_DAY",                  UCAL_JULIAN_DAY);
     529       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_MILLISECONDS_IN_DAY", UCAL_MILLISECONDS_IN_DAY);
     530       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_IS_LEAP_MONTH",                       UCAL_IS_LEAP_MONTH);
     531       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_FIELD_COUNT",                 UCAL_FIELD_COUNT);
     532       21159 :         CALENDAR_DECL_LONG_CONST("FIELD_DAY_OF_MONTH",                        UCAL_DAY_OF_MONTH);
     533             : 
     534       21159 :         CALENDAR_DECL_LONG_CONST("DOW_SUNDAY",                                        UCAL_SUNDAY);
     535       21159 :         CALENDAR_DECL_LONG_CONST("DOW_MONDAY",                                        UCAL_MONDAY);
     536       21159 :         CALENDAR_DECL_LONG_CONST("DOW_TUESDAY",                                       UCAL_TUESDAY);
     537       21159 :         CALENDAR_DECL_LONG_CONST("DOW_WEDNESDAY",                             UCAL_WEDNESDAY);
     538       21159 :         CALENDAR_DECL_LONG_CONST("DOW_THURSDAY",                              UCAL_THURSDAY);
     539       21159 :         CALENDAR_DECL_LONG_CONST("DOW_FRIDAY",                                        UCAL_FRIDAY);
     540       21159 :         CALENDAR_DECL_LONG_CONST("DOW_SATURDAY",                              UCAL_SATURDAY);
     541             : 
     542             : #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
     543             :         CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKDAY",                  UCAL_WEEKDAY);
     544             :         CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND",                  UCAL_WEEKEND);
     545             :         CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_OFFSET",           UCAL_WEEKEND_ONSET);
     546             :         CALENDAR_DECL_LONG_CONST("DOW_TYPE_WEEKEND_CEASE",            UCAL_WEEKEND_CEASE);
     547             : #endif
     548             : 
     549             : #if U_ICU_VERSION_MAJOR_NUM >= 49
     550             :         CALENDAR_DECL_LONG_CONST("WALLTIME_FIRST",                            UCAL_WALLTIME_FIRST);
     551             :         CALENDAR_DECL_LONG_CONST("WALLTIME_LAST",                             UCAL_WALLTIME_LAST);
     552             :         CALENDAR_DECL_LONG_CONST("WALLTIME_NEXT_VALID",                       UCAL_WALLTIME_NEXT_VALID);
     553             : #endif
     554             : }
     555             : /* }}} */

Generated by: LCOV version 1.10

Generated at Wed, 16 Apr 2014 12:47:48 +0000 (8 days ago)

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