예제 #1
0
  void moduleInit() override {
    HHVM_ME(DateTime, __construct);
    HHVM_ME(DateTime, add);
    HHVM_ME(DateTime, diff);
    HHVM_ME(DateTime, format);
    HHVM_ME(DateTime, getOffset);
    HHVM_ME(DateTime, getTimestamp);
    HHVM_ME(DateTime, getTimezone);
    HHVM_ME(DateTime, modify);
    HHVM_ME(DateTime, setDate);
    HHVM_ME(DateTime, setISODate);
    HHVM_ME(DateTime, setTime);
    HHVM_ME(DateTime, setTimestamp);
    HHVM_ME(DateTime, setTimezone);
    HHVM_ME(DateTime, sub);
    HHVM_ME(DateTime, __sleep);
    HHVM_ME(DateTime, __wakeup);
    HHVM_ME(DateTime, __debuginfo);
    HHVM_STATIC_ME(DateTime, createFromFormat);
    HHVM_STATIC_ME(DateTime, getLastErrors);

    Native::registerNativeDataInfo<DateTimeData>(
      DateTimeData::s_className.get(), Native::NDIFlags::NO_SWEEP);

    HHVM_RC_STR_SAME(DATE_ATOM);
    HHVM_RCC_STR(DateTime, ATOM, DATE_ATOM);
    HHVM_RC_STR_SAME(DATE_COOKIE);
    HHVM_RCC_STR(DateTime, COOKIE, DATE_COOKIE);
    HHVM_RC_STR_SAME(DATE_ISO8601);
    HHVM_RCC_STR(DateTime, ISO8601, DATE_ISO8601);
    HHVM_RC_STR_SAME(DATE_RFC822);
    HHVM_RCC_STR(DateTime, RFC822, DATE_RFC822);
    HHVM_RC_STR_SAME(DATE_RFC850);
    HHVM_RCC_STR(DateTime, RFC850, DATE_RFC850);
    HHVM_RC_STR_SAME(DATE_RFC1036);
    HHVM_RCC_STR(DateTime, RFC1036, DATE_RFC1036);
    HHVM_RC_STR_SAME(DATE_RFC1123);
    HHVM_RCC_STR(DateTime, RFC1123, DATE_RFC1123);
    HHVM_RC_STR_SAME(DATE_RFC2822);
    HHVM_RCC_STR(DateTime, RFC2822, DATE_RFC2822);
    HHVM_RC_STR_SAME(DATE_RFC3339);
    HHVM_RCC_STR(DateTime, RFC3339, DATE_RFC3339);
    HHVM_RC_STR_SAME(DATE_RSS);
    HHVM_RCC_STR(DateTime, RSS, DATE_RSS);
    HHVM_RC_STR_SAME(DATE_W3C);
    HHVM_RCC_STR(DateTime, W3C, DATE_W3C);

    HHVM_RCC_INT(DateTimeZone, AFRICA, DateTimeZoneData::AFRICA);
    HHVM_RCC_INT(DateTimeZone, AMERICA, DateTimeZoneData::AMERICA);
    HHVM_RCC_INT(DateTimeZone, ANTARCTICA, DateTimeZoneData::ANTARCTICA);
    HHVM_RCC_INT(DateTimeZone, ARCTIC, DateTimeZoneData::ARCTIC);
    HHVM_RCC_INT(DateTimeZone, ASIA, DateTimeZoneData::ASIA);
    HHVM_RCC_INT(DateTimeZone, ATLANTIC, DateTimeZoneData::ATLANTIC);
    HHVM_RCC_INT(DateTimeZone, AUSTRALIA, DateTimeZoneData::AUSTRALIA);
    HHVM_RCC_INT(DateTimeZone, EUROPE, DateTimeZoneData::EUROPE);
    HHVM_RCC_INT(DateTimeZone, INDIAN, DateTimeZoneData::INDIAN);
    HHVM_RCC_INT(DateTimeZone, PACIFIC, DateTimeZoneData::PACIFIC);
    HHVM_RCC_INT(DateTimeZone, UTC, DateTimeZoneData::UTC);
    HHVM_RCC_INT(DateTimeZone, ALL, DateTimeZoneData::ALL);
    HHVM_RCC_INT(DateTimeZone, ALL_WITH_BC, DateTimeZoneData::ALL_WITH_BC);
    HHVM_RCC_INT(DateTimeZone, PER_COUNTRY, DateTimeZoneData::PER_COUNTRY);

    HHVM_ME(DateTimeZone, __construct);
    HHVM_ME(DateTimeZone, getLocation);
    HHVM_ME(DateTimeZone, getName);
    HHVM_ME(DateTimeZone, getOffset);
    HHVM_ME(DateTimeZone, getTransitions);
    HHVM_STATIC_ME(DateTimeZone, listAbbreviations);
    HHVM_STATIC_ME(DateTimeZone, listIdentifiers);

    Native::registerNativeDataInfo<DateTimeZoneData>(
      DateTimeZoneData::s_className.get(), Native::NDIFlags::NO_SWEEP);

    HHVM_ME(DateInterval, __construct);
    HHVM_ME(DateInterval, __get);
    HHVM_ME(DateInterval, __set);
    HHVM_ME(DateInterval, format);
    HHVM_STATIC_ME(DateInterval, createFromDateString);

    Native::registerNativeDataInfo<DateIntervalData>(
      DateIntervalData::s_className.get(), Native::NDIFlags::NO_SWEEP);

    HHVM_FE(checkdate);
    HHVM_FE(date_parse_from_format);
    HHVM_FE(date_create);
    HHVM_FE(date_default_timezone_get);
    HHVM_FE(date_default_timezone_set);
    HHVM_FE(date_format);
    HHVM_FE(date_parse);
    HHVM_FE(date_sun_info);
    HHVM_NAMED_FE(date_sunrise, date_sunrise_sunset<false>);
    HHVM_NAMED_FE(date_sunset, date_sunrise_sunset<true>);
    HHVM_NAMED_FE(date, date_impl<false>);
    HHVM_NAMED_FE(gmdate, date_impl<true>);
    HHVM_FE(getdate);
    HHVM_FE(gettimeofday);
    HHVM_FE(gmmktime);
    HHVM_NAMED_FE(strftime, strftime_impl<false>);
    HHVM_NAMED_FE(gmstrftime, strftime_impl<true>);
    HHVM_FE(idate);
    HHVM_FE(localtime);
    HHVM_FE(microtime);
    HHVM_FE(mktime);
    HHVM_FE(strptime);
    HHVM_FE(strtotime);
    HHVM_FE(time);
    HHVM_FE(timezone_name_from_abbr);
    HHVM_FE(timezone_version_get);

    HHVM_RC_INT(SUNFUNCS_RET_DOUBLE, DateTime::SunInfoFormat::ReturnDouble);
    HHVM_RC_INT(SUNFUNCS_RET_STRING, DateTime::SunInfoFormat::ReturnString);
    HHVM_RC_INT(SUNFUNCS_RET_TIMESTAMP,
                DateTime::SunInfoFormat::ReturnTimeStamp);

    loadSystemlib("datetime");
  }
예제 #2
0
void IntlExtension::initUChar() {
  HHVM_RCC_STR(IntlChar, UNICODE_VERSION, U_UNICODE_VERSION);

  HHVM_RCC_INT(IntlChar, CODEPOINT_MIN, UCHAR_MIN_VALUE);
  HHVM_RCC_INT(IntlChar, CODEPOINT_MAX, UCHAR_MAX_VALUE);
  HHVM_RCC_INT(IntlChar, FOLD_CASE_DEFAULT, U_FOLD_CASE_DEFAULT);
  HHVM_RCC_INT(IntlChar, FOLD_CASE_EXCLUDE_SPECIAL_I,
               U_FOLD_CASE_EXCLUDE_SPECIAL_I);
  HHVM_RCC_DBL(IntlChar, NO_NUMERIC_VALUE, U_NO_NUMERIC_VALUE);

/* All enums used by the uchar APIs.  There are a LOT of them,
  * so they're separated out into include files,
  * leaving this source file for actual implementation.
  *
  * Note that these includes are shared between PHP and HHVM
  */
#define IC_CONSTL(name, val) HHVM_RCC_INT(IntlChar, name, val);
#define UPROPERTY(name) IC_CONSTL(PROPERTY_##name, UCHAR_##name)
#define UCHARCATEGORY(name) IC_CONSTL(CHAR_CATEGORY_##name, U_##name)
#define UCHARDIRECTION(name) IC_CONSTL(CHAR_DIRECTION_##name, U_##name)
#define UBLOCKCODE(name) IC_CONSTL(BLOCK_CODE_##name, UBLOCK_##name)
#define UOTHER(name) IC_CONSTL(name, U_##name)

#include "hphp/runtime/ext/icu/uproperty-enum.h"
#include "hphp/runtime/ext/icu/ucharcategory-enum.h"
#include "hphp/runtime/ext/icu/uchardirection-enum.h"
#include "hphp/runtime/ext/icu/ublockcode-enum.h"
  /* Smaller, self-destribing enums */
#include "hphp/runtime/ext/icu/uother-enum.h"

#undef UPROPERTY
#undef UCHARCATEGORY
#undef UCHARDIRECTION
#undef UBLOCKCODE
#undef UOTHER
#undef IC_CONSTL

// Methods returning bool/UChar32 and taking a single UChar32 argument
#define UCHAR_ME(name) \
  HHVM_NAMED_STATIC_ME(IntlChar, name, uchar_method<u_##name>)
  UCHAR_ME(isUAlphabetic);
  UCHAR_ME(isULowercase);
  UCHAR_ME(isUUppercase);
  UCHAR_ME(isUWhiteSpace);
  UCHAR_ME(islower);
  UCHAR_ME(isupper);
  UCHAR_ME(istitle);
  UCHAR_ME(isdigit);
  UCHAR_ME(isalpha);
  UCHAR_ME(isalnum);
  UCHAR_ME(isxdigit);
  UCHAR_ME(ispunct);
  UCHAR_ME(isgraph);
  UCHAR_ME(isblank);
  UCHAR_ME(isdefined);
  UCHAR_ME(isspace);
  UCHAR_ME(isJavaSpaceChar);
  UCHAR_ME(isWhitespace);
  UCHAR_ME(iscntrl);
  UCHAR_ME(isISOControl);
  UCHAR_ME(isprint);
  UCHAR_ME(isbase);
  UCHAR_ME(isMirrored);
  UCHAR_ME(isIDStart);
  UCHAR_ME(isIDPart);
  UCHAR_ME(isIDIgnorable);
  UCHAR_ME(isJavaIDStart);
  UCHAR_ME(isJavaIDPart);
  UCHAR_ME(charMirror);
  UCHAR_ME(tolower);
  UCHAR_ME(toupper);
  UCHAR_ME(totitle);
#if U_ICU_VERSION_MAJOR_NUM >= 52
  UCHAR_ME(getBidiPairedBracket);
#endif /* ICU >= 52 */
#undef UCHAR_ME

// Methods with unique signatures
#define ICS_ME(name) HHVM_STATIC_ME(IntlChar, name)
  ICS_ME(chr);
  ICS_ME(ord);
  ICS_ME(hasBinaryProperty);
  ICS_ME(getIntPropertyValue);
  ICS_ME(getIntPropertyMinValue);
  ICS_ME(getIntPropertyMaxValue);
  ICS_ME(getNumericValue);
  ICS_ME(enumCharTypes);
  ICS_ME(getBlockCode);
  ICS_ME(getBlockCode);
  ICS_ME(charName);
  ICS_ME(charFromName);
  ICS_ME(enumCharNames);
  ICS_ME(getPropertyName);
  ICS_ME(getPropertyEnum);
  ICS_ME(getPropertyValueName);
  ICS_ME(getPropertyValueEnum);
  ICS_ME(foldCase);
  ICS_ME(digit);
  ICS_ME(forDigit);
  ICS_ME(charAge);
  ICS_ME(getUnicodeVersion);
  ICS_ME(getFC_NFKC_Closure);

  ICS_ME(charDirection);
  ICS_ME(charType);
  ICS_ME(getCombiningClass);
  ICS_ME(charDigitValue);
#undef ICS_ME
  loadSystemlib("icu_uchar");
}