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

Generated by: LCOV version 1.10

Generated at Sat, 13 Dec 2014 06:16:14 +0000 (5 days ago)

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