#define COLLATOR_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Collator_ce_ptr, ZEND_STRS( #x ) - 1, UCOL_##x TSRMLS_CC );
#define COLLATOR_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( Collator_ce_ptr, ZEND_STRS( name ) - 1, value TSRMLS_CC );
- // UColAttributeValue constants
+ /* UColAttributeValue constants */
COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "DEFAULT_VALUE", UCOL_DEFAULT );
COLLATOR_EXPOSE_CLASS_CONST( PRIMARY );
COLLATOR_EXPOSE_CLASS_CONST( LOWER_FIRST );
COLLATOR_EXPOSE_CLASS_CONST( UPPER_FIRST );
- // UColAttribute constants
+ /* UColAttribute constants */
COLLATOR_EXPOSE_CLASS_CONST( FRENCH_COLLATION );
COLLATOR_EXPOSE_CLASS_CONST( ALTERNATE_HANDLING );
COLLATOR_EXPOSE_CLASS_CONST( CASE_FIRST );
COLLATOR_EXPOSE_CLASS_CONST( HIRAGANA_QUATERNARY_MODE );
COLLATOR_EXPOSE_CLASS_CONST( NUMERIC_COLLATION );
- // ULocDataLocaleType constants
+ /* ULocDataLocaleType constants */
COLLATOR_EXPOSE_CONST( ULOC_ACTUAL_LOCALE );
COLLATOR_EXPOSE_CONST( ULOC_VALID_LOCALE );
- // sort flags
+ /* sort flags */
COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_REGULAR", COLLATOR_SORT_REGULAR );
COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_STRING", COLLATOR_SORT_STRING );
COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_NUMERIC", COLLATOR_SORT_NUMERIC );
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
&object, Collator_ce_ptr, &attribute ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
value = ucol_getAttribute( co->ucoll, attribute, COLLATOR_ERROR_CODE_P( co ) );
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll",
&object, Collator_ce_ptr, &attribute, &value ) == FAILURE)
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Set new value for the given attribute.
+ /* Set new value for the given attribute. */
ucol_setAttribute( co->ucoll, attribute, value, COLLATOR_ERROR_CODE_P( co ) );
COLLATOR_CHECK_STATUS( co, "Error setting attribute value" );
{
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, Collator_ce_ptr ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Get current strength and return it.
+ /* Get current strength and return it. */
RETURN_LONG( ucol_getStrength( co->ucoll ) );
}
/* }}} */
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
&object, Collator_ce_ptr, &strength ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Set given strength.
+ /* Set given strength. */
ucol_setStrength( co->ucoll, strength );
RETURN_TRUE;
zend_class_entry *Collator_ce_ptr = NULL;
-/////////////////////////////////////////////////////////////////////////////
-// Auxiliary functions needed by objects of 'Collator' class
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * Auxiliary functions needed by objects of 'Collator' class
+ */
/* {{{ Collator_objects_dtor */
static void Collator_objects_dtor(
}
/* }}} */
-/////////////////////////////////////////////////////////////////////////////
-// 'Collator' class registration structures & functions
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * 'Collator' class registration structures & functions
+ */
/* {{{ Collator methods arguments info */
-// NOTE: modifying 'collator_XX_args' do not forget to
-// modify approptiate 'collator_XX_args' for
-// the procedural API.
+/* NOTE: modifying 'collator_XX_args' do not forget to
+ modify approptiate 'collator_XX_args' for
+ the procedural API.
+*/
static
ZEND_BEGIN_ARG_INFO_EX( collator_0_args, 0, 0, 0 )
{
zend_class_entry ce;
- // Create and register 'Collator' class.
+ /* Create and register 'Collator' class. */
INIT_CLASS_ENTRY( ce, "Collator", Collator_class_functions );
ce.create_object = Collator_object_create;
Collator_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC );
- // Declare 'Collator' class properties.
+ /* Declare 'Collator' class properties. */
if( !Collator_ce_ptr )
{
zend_error( E_ERROR,
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ouu",
&object, Collator_ce_ptr, &str1, &str1_len, &str2, &str2_len ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
* Compare given strings (converting them to UTF-16 first).
*/
- // Compare given strings.
+ /* Compare given strings. */
result = ucol_strcoll(
co->ucoll,
str1, str1_len,
str2, str2_len );
- // Return result of the comparison.
+ /* Return result of the comparison. */
RETURN_LONG( result );
}
/* }}} */
{
zval* zstr = NULL;
- // Bail out if it's not an object.
+ /* Bail out if it's not an object. */
if( Z_TYPE_P( obj ) != IS_OBJECT )
{
COLLATOR_CONVERT_RETURN_FAILED( obj );
}
- // Try object's handlers.
+ /* Try object's handlers. */
if( Z_OBJ_HT_P(obj)->get )
{
zstr = Z_OBJ_HT_P(obj)->get( obj TSRMLS_CC );
{
case IS_OBJECT:
{
- // Bail out.
+ /* Bail out. */
zval_ptr_dtor( &zstr );
COLLATOR_CONVERT_RETURN_FAILED( obj );
} break;
if( Z_OBJ_HT_P(obj)->cast_object( obj, zstr, IS_UNICODE, 0 TSRMLS_CC ) == FAILURE )
{
- // cast_object failed => bail out.
+ /* cast_object failed => bail out. */
zval_ptr_dtor( &zstr );
COLLATOR_CONVERT_RETURN_FAILED( obj );
}
}
- // Object wasn't successfuly converted => bail out.
+ /* Object wasn't successfuly converted => bail out. */
if( zstr == NULL )
{
COLLATOR_CONVERT_RETURN_FAILED( obj );
zval* num = collator_convert_string_to_number_if_possible( str );
if( num == str )
{
- // String wasn't converted => return zero.
+ /* String wasn't converted => return zero. */
zval_ptr_dtor( &num );
ALLOC_INIT_ZVAL( num );
if( use_copy )
{
- // Don't copy arg_copy data to str.
+ /* Don't copy arg_copy data to str. */
ALLOC_ZVAL( str );
*str = arg_copy;
- // Reset refcounter.
+ /* Reset refcounter. */
INIT_PZVAL( str );
}
else
if( Z_TYPE_P( arg ) != IS_UNICODE )
{
- // If its not a string then nothing to do.
- // Return original arg.
+ /* If its not a string then nothing to do.
+ * Return original arg.
+ */
COLLATOR_CONVERT_RETURN_FAILED( arg );
}
- // Try convert to number.
+ /* Try convert to number. */
n_arg = collator_convert_string_to_number_if_possible( arg );
if( n_arg == arg )
{
- // Conversion to number failed.
+ /* Conversion to number failed. */
zval_ptr_dtor( &n_arg );
zval_add_ref( &arg );
intl_error_reset( NULL TSRMLS_CC );
object = return_value;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
&locale, &locale_len ) == FAILURE )
{
locale = UG(default_locale);
}
- // Open ICU collator.
+ /* Open ICU collator. */
co->ucoll = ucol_open( locale, COLLATOR_ERROR_CODE_P( co ) );
INTL_CTOR_CHECK_STATUS(co, "collator_create: unable to open ICU collator");
}
{
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, Collator_ce_ptr ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object (without resetting its last error code).
+ /* Fetch the object (without resetting its last error code). */
co = (Collator_object *) zend_object_store_get_object(object TSRMLS_CC);
if( co == NULL )
RETURN_FALSE;
- // Return collator's last error code.
+ /* Return collator's last error code. */
RETURN_LONG( COLLATOR_ERROR_CODE( co ) );
}
/* }}} */
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, Collator_ce_ptr ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object (without resetting its last error code).
+ /* Fetch the object (without resetting its last error code). */
co = (Collator_object *) zend_object_store_get_object( object TSRMLS_CC );
if( co == NULL )
RETURN_FALSE;
- // Return last error message.
+ /* Return last error message. */
message = intl_error_get_message( COLLATOR_ERROR_P( co ) TSRMLS_CC );
RETURN_STRING( (char*)message, FALSE );
}
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
&object, Collator_ce_ptr, &type ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Get locale by specified type.
+ /* Get locale by specified type. */
locale_name = (char*) ucol_getLocaleByType(
co->ucoll, type, COLLATOR_ERROR_CODE_P( co ) );
COLLATOR_CHECK_STATUS( co, "Error getting locale by type" );
- // Return it.
+ /* Return it. */
RETURN_ASCII_STRINGL( locale_name, strlen(locale_name), TRUE );
}
/* }}} */
* buffer.
*/
typedef struct _collator_sort_key_index {
- char* key; // pointer to sort key
- zval** zstr; // pointer to original string(hash-item)
+ char* key; /* pointer to sort key */
+ zval** zstr; /* pointer to original string(hash-item) */
} collator_sort_key_index_t;
ZEND_EXTERN_MODULE_GLOBALS( intl )
zval* norm1 = NULL;
zval* norm2 = NULL;
- // If both args are strings AND either of args is not numeric string
- // then use ICU-compare. Otherwise PHP-compare.
+ /* If both args are strings AND either of args is not numeric string
+ * then use ICU-compare. Otherwise PHP-compare.
+ */
if( Z_TYPE_P(str1) == IS_UNICODE && Z_TYPE_P(str2) == IS_UNICODE &&
( str1 == ( num1 = collator_convert_string_to_number_if_possible( str1 ) ) ||
str2 == ( num2 = collator_convert_string_to_number_if_possible( str2 ) ) ) )
{
- // Fetch collator object.
+ /* Fetch collator object. */
co = (Collator_object *) zend_object_store_get_object( INTL_G(current_collator) TSRMLS_CC );
- // Compare the strings using ICU.
+ /* Compare the strings using ICU. */
result->value.lval = ucol_strcoll(
co->ucoll,
INTL_Z_STRVAL_P(str1), INTL_Z_STRLEN_P(str1),
}
else
{
- // num1 is set if str1 and str2 are strings.
+ /* num1 is set if str1 and str2 are strings. */
if( num1 )
{
if( num1 == str1 )
{
- // str1 is string but not numeric string
+ /* str1 is string but not numeric string */
zval_add_ref( &num1 );
norm1 = num1;
- // num2 is not set but str2 is string => do normalization.
+ /* num2 is not set but str2 is string => do normalization. */
norm2 = collator_normalize_sort_argument( str2 );
}
else
{
- // str1 is numeric strings => passthru to PHP-compare.
+ /* str1 is numeric strings => passthru to PHP-compare. */
zval_add_ref( &num1 );
norm1 = num1;
- // str2 is numeric strings => passthru to PHP-compare.
+ /* str2 is numeric strings => passthru to PHP-compare. */
zval_add_ref( &num2 );
norm2 = num2;
}
}
else
{
- // num1 is not set if str1 or str2 is not a string => do normalization.
+ /* num1 is not set if str1 or str2 is not a string => do normalization. */
norm1 = collator_normalize_sort_argument( str1 );
- // if num1 is not set then num2 is not set as well => do normalization.
+ /* if num1 is not set then num2 is not set as well => do normalization. */
norm2 = collator_normalize_sort_argument( str2 );
}
str1 = collator_make_printable_zval( op1 );
str2 = collator_make_printable_zval( op2 );
- // Fetch collator object.
+ /* Fetch collator object. */
co = (Collator_object *) zend_object_store_get_object( INTL_G(current_collator) TSRMLS_CC );
- // Compare the strings using ICU.
+ /* Compare the strings using ICU. */
result->value.lval = ucol_strcoll(
co->ucoll,
INTL_Z_STRVAL_P(str1), INTL_Z_STRLEN_P(str1),
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa|l",
&object, Collator_ce_ptr, &array, &sort_flags ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
- // Set 'compare function' according to sort flags.
+ /* Set 'compare function' according to sort flags. */
INTL_G(compare_func) = collator_get_compare_function( sort_flags );
hash = HASH_OF( array );
- // Save specified collator in the request-global (?) variable.
+ /* Save specified collator in the request-global (?) variable. */
saved_collator = INTL_G( current_collator );
INTL_G( current_collator ) = object;
- // Sort specified array.
+ /* Sort specified array. */
zend_hash_sort( hash, zend_qsort, collator_compare_func, renumber TSRMLS_CC );
- // Restore saved collator.
+ /* Restore saved collator. */
INTL_G( current_collator ) = saved_collator;
RETURN_TRUE;
{
zval* array = NULL;
HashTable* hash = NULL;
- zval** hashData = NULL; // currently processed item of input hash
+ zval** hashData = NULL; /* currently processed item of input hash */
- char* sortKeyBuf = NULL; // buffer to store sort keys
- uint32_t sortKeyBufSize = DEF_SORT_KEYS_BUF_SIZE; // buffer size
- ptrdiff_t sortKeyBufOffset = 0; // pos in buffer to store sort key
- int32_t sortKeyLen = 0; // the length of currently processing key
+ char* sortKeyBuf = NULL; /* buffer to store sort keys */
+ uint32_t sortKeyBufSize = DEF_SORT_KEYS_BUF_SIZE; /* buffer size */
+ ptrdiff_t sortKeyBufOffset = 0; /* pos in buffer to store sort key */
+ int32_t sortKeyLen = 0; /* the length of currently processing key */
uint32_t bufLeft = 0;
uint32_t bufIncrement = 0;
- collator_sort_key_index_t* sortKeyIndxBuf = NULL; // buffer to store 'indexes' which will be passed to 'qsort'
+ collator_sort_key_index_t* sortKeyIndxBuf = NULL; /* buffer to store 'indexes' which will be passed to 'qsort' */
uint32_t sortKeyIndxBufSize = DEF_SORT_KEYS_INDX_BUF_SIZE;
uint32_t sortKeyIndxSize = sizeof( collator_sort_key_index_t );
uint32_t sortKeyCount = 0;
uint32_t j = 0;
- UChar* utf16_buf = NULL; // tmp buffer to hold current processing string in utf-16
- int utf16_len = 0; // length of converted string
+ UChar* utf16_buf = NULL; /* tmp buffer to hold current processing string in utf-16 */
+ int utf16_len = 0; /* length of converted string */
HashTable* sortedHash = NULL;
COLLATOR_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa",
&object, Collator_ce_ptr, &array ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
COLLATOR_METHOD_FETCH_OBJECT;
if( !hash || zend_hash_num_elements( hash ) == 0 )
RETURN_TRUE;
- // Create bufers
+ /* Create bufers */
sortKeyBuf = ecalloc( sortKeyBufSize, sizeof( char ) );
sortKeyIndxBuf = ecalloc( sortKeyIndxBufSize, sizeof( uint8_t ) );
- // Iterate through input hash and create a sort key for each value.
+ /* Iterate through input hash and create a sort key for each value. */
zend_hash_internal_pointer_reset( hash );
while( zend_hash_get_current_data( hash, (void**) &hashData ) == SUCCESS )
{
- // Process string values only.
+ /* Process string values only. */
if( Z_TYPE_PP( hashData ) == IS_UNICODE )
{
}
else
{
- // Set empty string
+ /* Set empty string */
utf16_len = 0;
utf16_buf = (UChar*) "";
}
- // Get sort key, reallocating the buffer if needed.
+ /* Get sort key, reallocating the buffer if needed. */
bufLeft = sortKeyBufSize - sortKeyBufOffset;
sortKeyLen = ucol_getSortKey( co->ucoll,
(uint8_t*)sortKeyBuf + sortKeyBufOffset,
bufLeft );
- // check for sortKeyBuf overflow, increasing its size of the buffer if needed
+ /* check for sortKeyBuf overflow, increasing its size of the buffer if needed */
if( sortKeyLen > bufLeft )
{
bufIncrement = ( sortKeyLen > DEF_SORT_KEYS_BUF_INCREMENT ) ? sortKeyLen : DEF_SORT_KEYS_BUF_INCREMENT;
sortKeyLen = ucol_getSortKey( co->ucoll, utf16_buf, utf16_len, (uint8_t*)sortKeyBuf + sortKeyBufOffset, bufLeft );
}
- // check sortKeyIndxBuf overflow, increasing its size of the buffer if needed
+ /* check sortKeyIndxBuf overflow, increasing its size of the buffer if needed */
if( ( sortKeyCount + 1 ) * sortKeyIndxSize > sortKeyIndxBufSize )
{
bufIncrement = ( sortKeyIndxSize > DEF_SORT_KEYS_INDX_BUF_INCREMENT ) ? sortKeyIndxSize : DEF_SORT_KEYS_INDX_BUF_INCREMENT;
sortKeyIndxBuf = erealloc( sortKeyIndxBuf, sortKeyIndxBufSize );
}
- sortKeyIndxBuf[sortKeyCount].key = (char*)sortKeyBufOffset; // remeber just offset, cause address
- // of 'sortKeyBuf' may be changed due to realloc.
+ sortKeyIndxBuf[sortKeyCount].key = (char*)sortKeyBufOffset; /* remeber just offset, cause address */
+ /* of 'sortKeyBuf' may be changed due to realloc. */
sortKeyIndxBuf[sortKeyCount].zstr = hashData;
sortKeyBufOffset += sortKeyLen;
zend_hash_move_forward( hash );
}
- // update ptrs to point to valid keys.
+ /* update ptrs to point to valid keys. */
for( j = 0; j < sortKeyCount; j++ )
sortKeyIndxBuf[j].key = sortKeyBuf + (ptrdiff_t)sortKeyIndxBuf[j].key;
- // sort it
+ /* sort it */
zend_qsort( sortKeyIndxBuf, sortKeyCount, sortKeyIndxSize, collator_cmp_sort_keys TSRMLS_CC );
- // for resulting hash we'll assign new hash keys rather then reordering
+ /* for resulting hash we'll assign new hash keys rather then reordering */
ALLOC_HASHTABLE( sortedHash );
zend_hash_init( sortedHash, 0, NULL, ZVAL_PTR_DTOR, 0 );
zend_hash_next_index_insert( sortedHash, sortKeyIndxBuf[j].zstr, sizeof(zval **), NULL );
}
- // Save sorted hash into return variable.
+ /* Save sorted hash into return variable. */
zval_dtor( array );
(array)->value.ht = sortedHash;
(array)->type = IS_ARRAY;
{
long err_code;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "l",
&err_code ) == FAILURE )
{
{
long err_code;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "l",
&err_code ) == FAILURE )
{
{
#define INTL_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_CS)
- // Warnings
+ /* Warnings */
INTL_EXPOSE_CONST( U_USING_FALLBACK_WARNING );
INTL_EXPOSE_CONST( U_ERROR_WARNING_START );
INTL_EXPOSE_CONST( U_USING_DEFAULT_WARNING );
INTL_EXPOSE_CONST( U_DIFFERENT_UCA_VERSION );
INTL_EXPOSE_CONST( U_ERROR_WARNING_LIMIT );
- // Standard errors
+ /* Standard errors */
INTL_EXPOSE_CONST( U_ZERO_ERROR );
INTL_EXPOSE_CONST( U_ILLEGAL_ARGUMENT_ERROR );
INTL_EXPOSE_CONST( U_MISSING_RESOURCE_ERROR );
INTL_EXPOSE_CONST( U_NO_WRITE_PERMISSION );
INTL_EXPOSE_CONST( U_STANDARD_ERROR_LIMIT );
- // The error code range 0x10000 0x10100 are reserved for Transliterator
+ /* The error code range 0x10000 0x10100 are reserved for Transliterator */
INTL_EXPOSE_CONST( U_BAD_VARIABLE_DEFINITION );
INTL_EXPOSE_CONST( U_PARSE_ERROR_START );
INTL_EXPOSE_CONST( U_MALFORMED_RULE );
INTL_EXPOSE_CONST( U_INVALID_FUNCTION );
INTL_EXPOSE_CONST( U_PARSE_ERROR_LIMIT );
- // The error code range 0x10100 0x10200 are reserved for formatting API parsing error
+ /* The error code range 0x10100 0x10200 are reserved for formatting API parsing error */
INTL_EXPOSE_CONST( U_UNEXPECTED_TOKEN );
INTL_EXPOSE_CONST( U_FMT_PARSE_ERROR_START );
INTL_EXPOSE_CONST( U_MULTIPLE_DECIMAL_SEPARATORS );
- INTL_EXPOSE_CONST( U_MULTIPLE_DECIMAL_SEPERATORS ); // Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS
+ INTL_EXPOSE_CONST( U_MULTIPLE_DECIMAL_SEPERATORS ); /* Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS */
INTL_EXPOSE_CONST( U_MULTIPLE_EXPONENTIAL_SYMBOLS );
INTL_EXPOSE_CONST( U_MALFORMED_EXPONENTIAL_PATTERN );
INTL_EXPOSE_CONST( U_MULTIPLE_PERCENT_SYMBOLS );
INTL_EXPOSE_CONST( U_UNSUPPORTED_ATTRIBUTE );
INTL_EXPOSE_CONST( U_FMT_PARSE_ERROR_LIMIT );
- // The error code range 0x10200 0x102ff are reserved for Break Iterator related error
+ /* The error code range 0x10200 0x102ff are reserved for Break Iterator related error */
INTL_EXPOSE_CONST( U_BRK_INTERNAL_ERROR );
INTL_EXPOSE_CONST( U_BRK_ERROR_START );
INTL_EXPOSE_CONST( U_BRK_HEX_DIGITS_EXPECTED );
INTL_EXPOSE_CONST( U_BRK_MALFORMED_RULE_TAG );
INTL_EXPOSE_CONST( U_BRK_ERROR_LIMIT );
- // The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs
+ /* The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs */
INTL_EXPOSE_CONST( U_REGEX_INTERNAL_ERROR );
INTL_EXPOSE_CONST( U_REGEX_ERROR_START );
INTL_EXPOSE_CONST( U_REGEX_RULE_SYNTAX );
INTL_EXPOSE_CONST( U_REGEX_SET_CONTAINS_STRING );
INTL_EXPOSE_CONST( U_REGEX_ERROR_LIMIT );
- // The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes
+ /* The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes */
#if defined(U_IDNA_PROHIBITED_ERROR)
INTL_EXPOSE_CONST( U_IDNA_PROHIBITED_ERROR );
INTL_EXPOSE_CONST( U_IDNA_ERROR_START );
INTL_EXPOSE_CONST( U_IDNA_ERROR_LIMIT );
#endif
- // Aliases for StringPrep
+ /* Aliases for StringPrep */
INTL_EXPOSE_CONST( U_STRINGPREP_PROHIBITED_ERROR );
INTL_EXPOSE_CONST( U_STRINGPREP_UNASSIGNED_ERROR );
INTL_EXPOSE_CONST( U_STRINGPREP_CHECK_BIDI_ERROR );
#define DATEFORMATTER_EXPOSE_UCAL_CLASS_CONST(x) zend_declare_class_constant_long( IntlDateFormatter_ce_ptr, ZEND_STRS( #x ) - 1, UCAL_##x TSRMLS_CC );
- // UDateFormatStyle constants
+ /* UDateFormatStyle constants */
DATEFORMATTER_EXPOSE_CLASS_CONST( FULL );
DATEFORMATTER_EXPOSE_CLASS_CONST( LONG );
DATEFORMATTER_EXPOSE_CLASS_CONST( MEDIUM );
long calendar = 1;
UChar* pattern_str = NULL;
int pattern_str_len = 0;
- UChar* timezone_utf16 = NULL; //UTF-16 timezone_str
+ UChar* timezone_utf16 = NULL; /* UTF-16 timezone_str */
int timezone_utf16_len = 0;
UCalendar ucal_obj = NULL;
IntlDateFormatter_object* dfo;
intl_error_reset( NULL TSRMLS_CC );
object = return_value;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "sll|ulu",
&locale, &locale_len, &date_type, & time_type , &timezone_utf16, &timezone_utf16_len , &calendar ,&pattern_str , &pattern_str_len ) == FAILURE )
{
DATE_FORMAT_OBJECT(dfo) = udat_open(time_type,date_type, locale, timezone_utf16, timezone_utf16_len ,pattern_str ,pattern_str_len , &INTL_DATA_ERROR_CODE(dfo));
}
- //Set the calendar if passed
+ /* Set the calendar if passed */
if(!U_FAILURE(INTL_DATA_ERROR_CODE(dfo)) && calendar) {
ucal_obj = ucal_open( timezone_utf16 , timezone_utf16_len , locale , calendar , &INTL_DATA_ERROR_CODE(dfo) );
if(!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
INTL_CTOR_CHECK_STATUS(dfo, "datefmt_create: date formatter creation failed");
- //Set the class variables
+ /* Set the class variables */
dfo->date_type = date_type;
dfo->time_type = time_type;
dfo->calendar = calendar;
zval* object = NULL;
IntlDateFormatter_object* dfo = NULL;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
dfo = (IntlDateFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
- // Return formatter's last error code.
+ /* Return formatter's last error code. */
RETURN_LONG( INTL_DATA_ERROR_CODE(dfo) );
}
/* }}} */
zval* object = NULL;
IntlDateFormatter_object* dfo = NULL;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
dfo = (IntlDateFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
- // Return last error message.
+ /* Return last error message. */
message = intl_error_get_message( &dfo->datef_data.error TSRMLS_CC );
RETURN_STRING( message, 0);
}
#include <unicode/ucal.h>
static void internal_set_calendar(IntlDateFormatter_object *dfo, char* timezone_id , int timezone_id_len , int calendar ,zval* return_value TSRMLS_DC){
+ int timezone_utf16_len = 0;
+ UChar* timezone_utf16 = NULL; /* timezone_id in UTF-16 */
+ char* locale = NULL;
+ int locale_type =ULOC_ACTUAL_LOCALE;
- int timezone_utf16_len = 0;
- UChar* timezone_utf16 = NULL; //timezone_id in UTF-16
-
- char* locale = NULL;
- int locale_type =ULOC_ACTUAL_LOCALE;
-
- UCalendar* ucal_obj = NULL;
-
- //check for the validity of value of calendar passed
- intl_error_reset( NULL TSRMLS_CC );
- if( calendar > 1){
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC);
- RETURN_FALSE;
- }
-
- // Convert timezone to UTF-16.
- intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, timezone_id, timezone_id_len , &INTL_DATA_ERROR_CODE(dfo));
- INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
+ UCalendar* ucal_obj = NULL;
+ /* check for the validity of value of calendar passed */
+ intl_error_reset( NULL TSRMLS_CC );
+ if( calendar > 1){
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
- //Get the lcoale for the dateformatter
- locale = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), locale_type ,&INTL_DATA_ERROR_CODE(dfo));
+ /* Convert timezone to UTF-16. */
+ intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, timezone_id, timezone_id_len , &INTL_DATA_ERROR_CODE(dfo));
+ INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
- //Set the calendar if passed
- ucal_obj = ucal_open( timezone_utf16 , timezone_utf16_len , locale , calendar , &INTL_DATA_ERROR_CODE(dfo) );
- udat_setCalendar( DATE_FORMAT_OBJECT(dfo), ucal_obj );
- INTL_METHOD_CHECK_STATUS(dfo, "Error setting the calendar.");
+ /* Get the lcoale for the dateformatter */
+ locale = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), locale_type ,&INTL_DATA_ERROR_CODE(dfo));
- if( timezone_utf16){
- efree(timezone_utf16);
- }
+ /* Set the calendar if passed */
+ ucal_obj = ucal_open( timezone_utf16 , timezone_utf16_len , locale , calendar , &INTL_DATA_ERROR_CODE(dfo) );
+ udat_setCalendar( DATE_FORMAT_OBJECT(dfo), ucal_obj );
+ INTL_METHOD_CHECK_STATUS(dfo, "Error setting the calendar.");
+ if( timezone_utf16){
+ efree(timezone_utf16);
+ }
}
/* {{{ proto unicode IntlDateFormatter::getDateType( )
{
DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
intl_error_set( NULL , U_ILLEGAL_ARGUMENT_ERROR,
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter datetype." );
{
DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
intl_error_set( NULL , U_ILLEGAL_ARGUMENT_ERROR,
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter timetype." );
{
DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
intl_error_set( NULL , U_ILLEGAL_ARGUMENT_ERROR,
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter calendar." );
{
DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
intl_error_set( NULL , U_ILLEGAL_ARGUMENT_ERROR,
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter timezone_id." );
char* timezone_id = NULL;
int timezone_id_len = 0;
- DATE_FORMAT_METHOD_INIT_VARS;
+ DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, IntlDateFormatter_ce_ptr ,&timezone_id , &timezone_id_len) == FAILURE )
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_set_timezone_id: unable to parse input params", 0 TSRMLS_CC );
- RETURN_FALSE;
- }
+ /* Parse parameters. */
+ if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, IntlDateFormatter_ce_ptr ,&timezone_id , &timezone_id_len) == FAILURE )
+ {
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_set_timezone_id: unable to parse input params", 0 TSRMLS_CC );
+ RETURN_FALSE;
+ }
- // Fetch the object.
- DATE_FORMAT_METHOD_FETCH_OBJECT;
+ /* Fetch the object. */
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
- //set the timezone for the calendar
+ /* set the timezone for the calendar */
internal_set_calendar( dfo , timezone_id , timezone_id_len , dfo->calendar ,return_value TSRMLS_CC );
- //Set the IntlDateFormatter variable
- if( dfo->timezone_id ){
+ /* Set the IntlDateFormatter variable */
+ if( dfo->timezone_id ){
efree(dfo->timezone_id);
}
dfo->timezone_id = estrndup(timezone_id , timezone_id_len);
DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
length = udat_toPattern(DATE_FORMAT_OBJECT(dfo), is_pattern_localized, value, length, &INTL_DATA_ERROR_CODE(dfo));
if(INTL_DATA_ERROR_CODE(dfo) == U_BUFFER_OVERFLOW_ERROR && length >= USIZE( value_buf )) {
- ++length; // to avoid U_STRING_NOT_TERMINATED_WARNING
+ ++length; /* to avoid U_STRING_NOT_TERMINATED_WARNING */
INTL_DATA_ERROR_CODE(dfo) = U_ZERO_ERROR;
value = eumalloc(length);
length = udat_toPattern(DATE_FORMAT_OBJECT(dfo), is_pattern_localized , value, length, &INTL_DATA_ERROR_CODE(dfo) );
DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os",
&object, IntlDateFormatter_ce_ptr, &value, &value_len ) == FAILURE )
{
DATE_FORMAT_METHOD_FETCH_OBJECT;
- // Convert given pattern to UTF-16.
+ /* Convert given pattern to UTF-16. */
intl_convert_utf8_to_utf16(&svalue, &slength, value, value_len, &INTL_DATA_ERROR_CODE(dfo));
INTL_METHOD_CHECK_STATUS(dfo, "Error converting pattern to UTF-16" );
DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l",
&object, IntlDateFormatter_ce_ptr ,&loc_type) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
loc = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), loc_type ,&INTL_DATA_ERROR_CODE(dfo));
DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
RETVAL_BOOL(udat_isLenient(DATE_FORMAT_OBJECT(dfo)));
*/
PHP_FUNCTION( datefmt_set_lenient )
{
+ zend_bool isLenient = FALSE;
- zend_bool isLenient = FALSE;
-
- DATE_FORMAT_METHOD_INIT_VARS;
+ DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ob",
- &object, IntlDateFormatter_ce_ptr ,&isLenient ) == FAILURE )
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_set_lenient: unable to parse input params", 0 TSRMLS_CC );
+ /* Parse parameters. */
+ if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ob",
+ &object, IntlDateFormatter_ce_ptr ,&isLenient ) == FAILURE )
+ {
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_set_lenient: unable to parse input params", 0 TSRMLS_CC );
- RETURN_FALSE;
- }
+ RETURN_FALSE;
+ }
- // Fetch the object.
- DATE_FORMAT_METHOD_FETCH_OBJECT;
+ /* Fetch the object. */
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
- udat_setLenient(DATE_FORMAT_OBJECT(dfo) , (UBool)isLenient );
+ udat_setLenient(DATE_FORMAT_OBJECT(dfo) , (UBool)isLenient );
}
/* }}} */
{
long calendar = 0;
- DATE_FORMAT_METHOD_INIT_VARS;
+ DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
- &object, IntlDateFormatter_ce_ptr, &calendar ) == FAILURE )
- {
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_set_calendar: unable to parse input params", 0 TSRMLS_CC);
- RETURN_FALSE;
- }
+ /* Parse parameters. */
+ if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
+ &object, IntlDateFormatter_ce_ptr, &calendar ) == FAILURE )
+ {
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_set_calendar: unable to parse input params", 0 TSRMLS_CC);
+ RETURN_FALSE;
+ }
- //check for the validity of value of calendar passed
+ /* check for the validity of value of calendar passed */
intl_error_reset( NULL TSRMLS_CC );
if( calendar > 1){
- intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC);
- RETURN_FALSE;
+ intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+ "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC);
+ RETURN_FALSE;
}
- DATE_FORMAT_METHOD_FETCH_OBJECT;
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
internal_set_calendar( dfo , dfo->timezone_id , strlen(dfo->timezone_id) , calendar ,return_value TSRMLS_CC );
- //Set the calendar value in the IntlDateFormatter object
- dfo->calendar = calendar ;
+ /* Set the calendar value in the IntlDateFormatter object */
+ dfo->calendar = calendar ;
- RETURN_TRUE;
+ RETURN_TRUE;
}
/* }}} */
zend_class_entry *IntlDateFormatter_ce_ptr = NULL;
-/////////////////////////////////////////////////////////////////////////////
-// Auxiliary functions needed by objects of 'IntlDateFormatter' class
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * Auxiliary functions needed by objects of 'IntlDateFormatter' class
+ */
/* {{{ IntlDateFormatter_objects_dtor */
static void IntlDateFormatter_object_dtor(void *object, zend_object_handle handle TSRMLS_DC )
zend_object_std_init( &intern->zo, ce TSRMLS_CC );
intern->date_type = 0;
intern->time_type = 0;
- intern->calendar = 1; //Gregorian calendar
+ intern->calendar = 1; /* Gregorian calendar */
intern->timezone_id = NULL;
retval.handle = zend_objects_store_put(
}
/* }}} */
-/////////////////////////////////////////////////////////////////////////////
-// 'IntlDateFormatter' class registration structures & functions
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * 'IntlDateFormatter' class registration structures & functions
+ */
+
+/* {{{ arginfo */
+static ZEND_BEGIN_ARG_INFO_EX( datefmt_parse_args, 0, 0, 1 )
+ ZEND_ARG_INFO( 0, string )
+ ZEND_ARG_INFO( 1, position )
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_intldateformatter_format, 0, 0, 0)
+ ZEND_ARG_INFO(0, args)
+ ZEND_ARG_INFO(0, array)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_intldateformatter_getdatetype, 0)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_intldateformatter_settimezoneid, 0, 0, 1)
+ ZEND_ARG_INFO(0, zone)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_intldateformatter_setpattern, 0, 0, 1)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_intldateformatter_setlenient, 0, 0, 1)
+ ZEND_ARG_INFO(0, lenient)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_intldateformatter_setcalendar, 0, 0, 1)
+ ZEND_ARG_INFO(0, which)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_intldateformatter___construct, 0, 0, 3)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, datetype)
+ ZEND_ARG_INFO(0, timetype)
+ ZEND_ARG_INFO(0, timezone)
+ ZEND_ARG_INFO(0, calendar)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+/* }}} */
/* {{{ IntlDateFormatter_class_functions
* Every 'IntlDateFormatter' class method has an entry in this table
*/
-
static function_entry IntlDateFormatter_class_functions[] = {
- PHP_ME( IntlDateFormatter, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR )
- ZEND_FENTRY( create, ZEND_FN( datefmt_create ), NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
- PHP_NAMED_FE( getDateType, ZEND_FN( datefmt_get_datetype ), NULL )
- PHP_NAMED_FE( getTimeType, ZEND_FN( datefmt_get_timetype ), NULL )
- PHP_NAMED_FE( getCalendar, ZEND_FN( datefmt_get_calendar ), NULL )
- PHP_NAMED_FE( setCalendar, ZEND_FN( datefmt_set_calendar ), NULL )
- PHP_NAMED_FE( getTimeZoneId, ZEND_FN( datefmt_get_timezone_id ), NULL )
- PHP_NAMED_FE( setTimeZoneId, ZEND_FN( datefmt_set_timezone_id ), NULL )
- PHP_NAMED_FE( setPattern, ZEND_FN( datefmt_set_pattern ), NULL )
- PHP_NAMED_FE( getPattern, ZEND_FN( datefmt_get_pattern ), NULL )
- PHP_NAMED_FE( getLocale, ZEND_FN( datefmt_get_locale ), NULL )
- PHP_NAMED_FE( setLenient, ZEND_FN( datefmt_set_lenient ), NULL )
- PHP_NAMED_FE( isLenient, ZEND_FN( datefmt_is_lenient ), NULL )
- PHP_NAMED_FE( format, ZEND_FN( datefmt_format ), NULL )
- PHP_NAMED_FE( parse, ZEND_FN( datefmt_parse), NULL )
- PHP_NAMED_FE( localtime, ZEND_FN( datefmt_localtime ), NULL )
- PHP_NAMED_FE( getErrorCode, ZEND_FN( datefmt_get_error_code ), NULL )
- PHP_NAMED_FE( getErrorMessage, ZEND_FN( datefmt_get_error_message ), NULL )
+ PHP_ME( IntlDateFormatter, __construct, arginfo_intldateformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR )
+ ZEND_FENTRY( create, ZEND_FN( datefmt_create ), arginfo_intldateformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
+ PHP_NAMED_FE( getDateType, ZEND_FN( datefmt_get_datetype ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( getTimeType, ZEND_FN( datefmt_get_timetype ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( getCalendar, ZEND_FN( datefmt_get_calendar ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( setCalendar, ZEND_FN( datefmt_set_calendar ), arginfo_intldateformatter_setcalendar )
+ PHP_NAMED_FE( getTimeZoneId, ZEND_FN( datefmt_get_timezone_id ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( setTimeZoneId, ZEND_FN( datefmt_set_timezone_id ), arginfo_intldateformatter_settimezoneid )
+ PHP_NAMED_FE( setPattern, ZEND_FN( datefmt_set_pattern ), arginfo_intldateformatter_setpattern )
+ PHP_NAMED_FE( getPattern, ZEND_FN( datefmt_get_pattern ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( getLocale, ZEND_FN( datefmt_get_locale ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( setLenient, ZEND_FN( datefmt_set_lenient ), arginfo_intldateformatter_setlenient )
+ PHP_NAMED_FE( isLenient, ZEND_FN( datefmt_is_lenient ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( format, ZEND_FN( datefmt_format ), arginfo_intldateformatter_format )
+ PHP_NAMED_FE( parse, ZEND_FN( datefmt_parse), datefmt_parse_args )
+ PHP_NAMED_FE( localtime, ZEND_FN( datefmt_localtime ), datefmt_parse_args )
+ PHP_NAMED_FE( getErrorCode, ZEND_FN( datefmt_get_error_code ), arginfo_intldateformatter_getdatetype )
+ PHP_NAMED_FE( getErrorMessage, ZEND_FN( datefmt_get_error_message ), arginfo_intldateformatter_getdatetype )
{ NULL, NULL, NULL }
};
/* }}} */
{
zend_class_entry ce;
- // Create and register 'IntlDateFormatter' class.
+ /* Create and register 'IntlDateFormatter' class. */
INIT_CLASS_ENTRY( ce, "IntlDateFormatter", IntlDateFormatter_class_functions );
ce.create_object = IntlDateFormatter_object_create;
IntlDateFormatter_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC );
- // Declare 'IntlDateFormatter' class properties.
+ /* Declare 'IntlDateFormatter' class properties. */
if( !IntlDateFormatter_ce_ptr )
{
zend_error(E_ERROR, "Failed to register IntlDateFormatter class");
result = Z_LVAL_PP(ele_value);
}
}
- //printf("\n Inside internal_get_arr_ele key_name= %s , result = %g \n" , key_name, result);
+ /* printf("\n Inside internal_get_arr_ele key_name= %s , result = %g \n" , key_name, result); */
return result;
}
/* }}} */
long mday =0;
UBool isInDST = FALSE;
- //Fetch values from the incoming array
- year = internal_get_arr_ele( dfo , hash_arr , CALENDAR_YEAR TSRMLS_CC) + 1900; //tm_year is years since 1900
- //Month in ICU and PHP starts from January =0
+ /* Fetch values from the incoming array */
+ year = internal_get_arr_ele( dfo , hash_arr , CALENDAR_YEAR TSRMLS_CC) + 1900; /* tm_year is years since 1900 */
+ /* Month in ICU and PHP starts from January =0 */
month = internal_get_arr_ele( dfo , hash_arr , CALENDAR_MON TSRMLS_CC);
hour = internal_get_arr_ele( dfo , hash_arr , CALENDAR_HOUR TSRMLS_CC);
minute = internal_get_arr_ele( dfo , hash_arr , CALENDAR_MIN TSRMLS_CC);
wday = internal_get_arr_ele( dfo , hash_arr , CALENDAR_WDAY TSRMLS_CC);
yday = internal_get_arr_ele( dfo , hash_arr , CALENDAR_YDAY TSRMLS_CC);
isInDST = internal_get_arr_ele( dfo , hash_arr , CALENDAR_ISDST TSRMLS_CC);
- //For the ucal_setDateTime() function , this is the 'date' value
+ /* For the ucal_setDateTime() function , this is the 'date' value */
mday = internal_get_arr_ele( dfo , hash_arr , CALENDAR_MDAY TSRMLS_CC);
- //set the incoming values for the calendar
+ /* set the incoming values for the calendar */
ucal_setDateTime( pcal, year, month , mday , hour , minute , second , &INTL_DATA_ERROR_CODE(dfo));
if( INTL_DATA_ERROR_CODE(dfo) != U_ZERO_ERROR){
return;
}
- //ICU UCAL_DAY_OF_WEEK starts from SUNDAY=1 thru SATURDAY=7
- //whereas PHP localtime has tm_wday SUNDAY=0 thru SATURDAY=6
+ /* ICU UCAL_DAY_OF_WEEK starts from SUNDAY=1 thru SATURDAY=7
+ * whereas PHP localtime has tm_wday SUNDAY=0 thru SATURDAY=6
+ */
ucal_set( pcal, UCAL_DAY_OF_WEEK , (wday+1));
ucal_set( pcal, UCAL_DAY_OF_YEAR , yday);
- //TO DO :How to set the isInDST field?Is it required to set
+ /* TO DO: How to set the isInDST field?Is it required to set */
}
DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz", &object, IntlDateFormatter_ce_ptr ,&zarg ) == FAILURE )
- {
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_format: unable to parse input params", 0 TSRMLS_CC );
- RETURN_FALSE;
- }
-
+ {
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format: unable to parse input params", 0 TSRMLS_CC );
+ RETURN_FALSE;
+ }
- // Fetch the object.
+ /* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
-
switch(Z_TYPE_P(zarg) ){
case IS_LONG:
p_timestamp = Z_LVAL_P(zarg) ;
timestamp = p_timestamp * 1000;
break;
case IS_DOUBLE:
- //timestamp*1000 since ICU expects it in milliseconds
+ /* timestamp*1000 since ICU expects it in milliseconds */
p_timestamp = Z_DVAL_P(zarg) ;
timestamp = p_timestamp * 1000;
break;
hash_arr = Z_ARRVAL_P(zarg);
if( !hash_arr || zend_hash_num_elements( hash_arr ) == 0 )
RETURN_FALSE;
- //Create a UCalendar object from the array and then format it
+ /* Create a UCalendar object from the array and then format it */
temp_cal = ucal_open(NULL, -1, NULL, UCAL_GREGORIAN, &INTL_DATA_ERROR_CODE(dfo));
ucal_clear(temp_cal);
INTL_METHOD_CHECK_STATUS( dfo, "datefmt_format: Date formatting failed while creating calendar from the array" )
internal_create_ucal( dfo , hash_arr , temp_cal TSRMLS_CC);
INTL_METHOD_CHECK_STATUS( dfo, "datefmt_format: Date formatting failed while creating calendar from the array" )
- //Fetch the timestamp from the created UCalendar
+ /* Fetch the timestamp from the created UCalendar */
timestamp = ucal_getMillis(temp_cal , &INTL_DATA_ERROR_CODE(dfo) );
INTL_METHOD_CHECK_STATUS( dfo, "datefmt_format: Date formatting failed" )
break;
UChar* text_utf16 = NULL;
int32_t text_utf16_len = 0;
- // Convert timezone to UTF-16.
- intl_convert_utf8_to_utf16(&text_utf16 , &text_utf16_len , text_to_parse , text_len, &INTL_DATA_ERROR_CODE(dfo));
- INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
+ /* Convert timezone to UTF-16. */
+ intl_convert_utf8_to_utf16(&text_utf16 , &text_utf16_len , text_to_parse , text_len, &INTL_DATA_ERROR_CODE(dfo));
+ INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
timestamp = udat_parse( DATE_FORMAT_OBJECT(dfo), text_utf16 , text_utf16_len , &parse_pos , &INTL_DATA_ERROR_CODE(dfo));
if( text_utf16 ){
INTL_METHOD_CHECK_STATUS( dfo, "Date parsing failed" );
- //Since return is in sec.
+ /* Since return is in sec. */
result = (long )( timestamp / 1000 );
if( result != (timestamp/1000) ) {
intl_error_set( NULL, U_BUFFER_OVERFLOW_ERROR,
- "datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.\nThe valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.", 0 TSRMLS_CC );
+ "datefmt_parse: parsing of input parametrs resulted in value larger than data type long can handle.\nThe valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.", 0 TSRMLS_CC );
}
RETURN_LONG( result );
}
INTL_METHOD_CHECK_STATUS( dfo, "Date parsing - localtime failed : could not get a field from calendar" );
if( strcmp(key_name , CALENDAR_YEAR )==0 ){
- //since tm_year is years from 1900
+ /* since tm_year is years from 1900 */
add_assoc_long( return_value, key_name ,( calendar_field_val-1900) );
}else if( strcmp(key_name , CALENDAR_WDAY )==0 ){
- //since tm_wday starts from 0 whereas ICU WDAY start from 1
+ /* since tm_wday starts from 0 whereas ICU WDAY start from 1 */
add_assoc_long( return_value, key_name ,( calendar_field_val-1) );
}else{
add_assoc_long( return_value, key_name , calendar_field_val );
* Internal function which calls the udat_parseCalendar
*/
static void internal_parse_to_localtime(IntlDateFormatter_object *dfo, char* text_to_parse , int32_t text_len, int parse_pos , zval *return_value TSRMLS_DC){
- UCalendar* parsed_calendar = NULL ;
- UChar* text_utf16 = NULL;
- int32_t text_utf16_len = 0;
+ UCalendar* parsed_calendar = NULL;
+ UChar* text_utf16 = NULL;
+ int32_t text_utf16_len = 0;
long isInDST = 0;
- // Convert timezone to UTF-16.
- intl_convert_utf8_to_utf16(&text_utf16 , &text_utf16_len , text_to_parse , text_len, &INTL_DATA_ERROR_CODE(dfo));
- INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
+ /* Convert timezone to UTF-16. */
+ intl_convert_utf8_to_utf16(&text_utf16 , &text_utf16_len , text_to_parse , text_len, &INTL_DATA_ERROR_CODE(dfo));
+ INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
parsed_calendar = ucal_open(NULL, -1, NULL, UCAL_GREGORIAN, &INTL_DATA_ERROR_CODE(dfo));
- udat_parseCalendar( DATE_FORMAT_OBJECT(dfo), parsed_calendar , text_utf16 , text_utf16_len , &parse_pos , &INTL_DATA_ERROR_CODE(dfo));
- if( text_utf16 ){
- efree(text_utf16);
- }
-
- INTL_METHOD_CHECK_STATUS( dfo, "Date parsing failed" );
+ udat_parseCalendar( DATE_FORMAT_OBJECT(dfo), parsed_calendar , text_utf16 , text_utf16_len , &parse_pos , &INTL_DATA_ERROR_CODE(dfo));
+ if( text_utf16 ){
+ efree(text_utf16);
+ }
+ INTL_METHOD_CHECK_STATUS( dfo, "Date parsing failed" );
array_init( return_value );
- //Add entries from various fields of the obtained parsed_calendar
+ /* Add entries from various fields of the obtained parsed_calendar */
add_to_localtime_arr( dfo , return_value , parsed_calendar , UCAL_SECOND , CALENDAR_SEC TSRMLS_CC);
add_to_localtime_arr( dfo , return_value , parsed_calendar , UCAL_MINUTE , CALENDAR_MIN TSRMLS_CC);
add_to_localtime_arr( dfo , return_value , parsed_calendar , UCAL_HOUR_OF_DAY , CALENDAR_HOUR TSRMLS_CC);
add_to_localtime_arr( dfo , return_value , parsed_calendar , UCAL_DAY_OF_YEAR , CALENDAR_YDAY TSRMLS_CC);
add_to_localtime_arr( dfo , return_value , parsed_calendar , UCAL_MONTH , CALENDAR_MON TSRMLS_CC);
- //Is in DST?
+ /* Is in DST? */
isInDST = ucal_inDaylightTime(parsed_calendar , &INTL_DATA_ERROR_CODE(dfo));
- INTL_METHOD_CHECK_STATUS( dfo, "Date parsing - localtime failed : while checking if currently in DST." );
+ INTL_METHOD_CHECK_STATUS( dfo, "Date parsing - localtime failed : while checking if currently in DST." );
add_assoc_long( return_value, CALENDAR_ISDST ,(isInDST==1?1:0));
}
/* }}} */
* Parse the string $value starting at parse_pos to a Unix timestamp -int }}}*/
PHP_FUNCTION(datefmt_parse)
{
+ char* text_to_parse = NULL;
+ int32_t text_len =0;
+ long parse_pos =0;
- char* text_to_parse = NULL;
- int32_t text_len =0;
- long parse_pos =0;
+ DATE_FORMAT_METHOD_INIT_VARS;
- DATE_FORMAT_METHOD_INIT_VARS;
-
- // Parse parameters.
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l",
- &object, IntlDateFormatter_ce_ptr, &text_to_parse , &text_len , &parse_pos ) == FAILURE ){
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_parse: unable to parse input params", 0 TSRMLS_CC );
- RETURN_FALSE;
- }
+ /* Parse parameters. */
+ if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l",
+ &object, IntlDateFormatter_ce_ptr, &text_to_parse , &text_len , &parse_pos ) == FAILURE ){
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_parse: unable to parse input params", 0 TSRMLS_CC );
+ RETURN_FALSE;
+ }
- // Fetch the object.
- DATE_FORMAT_METHOD_FETCH_OBJECT;
+ /* Fetch the object. */
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
internal_parse_to_timestamp( dfo, text_to_parse , text_len ,
- parse_pos ,
- return_value TSRMLS_CC);
+ parse_pos ,
+ return_value TSRMLS_CC);
}
/* }}} */
PHP_FUNCTION(datefmt_localtime)
{
- char* text_to_parse = NULL;
- int32_t text_len =0;
- long parse_pos =0;
+ char* text_to_parse = NULL;
+ int32_t text_len =0;
+ long parse_pos =0;
- DATE_FORMAT_METHOD_INIT_VARS;
+ DATE_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osl",
- &object, IntlDateFormatter_ce_ptr, &text_to_parse , &text_len , &parse_pos ) == FAILURE ){
-
- intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
- "datefmt_parse_to_localtime: unable to parse input params", 0 TSRMLS_CC );
- RETURN_FALSE;
- }
-
- // Fetch the object.
- DATE_FORMAT_METHOD_FETCH_OBJECT;
+ &object, IntlDateFormatter_ce_ptr, &text_to_parse , &text_len , &parse_pos ) == FAILURE ){
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_parse_to_localtime: unable to parse input params", 0 TSRMLS_CC );
+ RETURN_FALSE;
+ }
- internal_parse_to_localtime( dfo, text_to_parse , text_len ,
- parse_pos,
- return_value TSRMLS_CC);
+ /* Fetch the object. */
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
+ internal_parse_to_localtime( dfo, text_to_parse , text_len ,
+ parse_pos,
+ return_value TSRMLS_CC);
}
/* }}} */
#define FORMATTER_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( NumberFormatter_ce_ptr, ZEND_STRS( #x ) - 1, UNUM_##x TSRMLS_CC );
#define FORMATTER_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( NumberFormatter_ce_ptr, ZEND_STRS( name ) - 1, value TSRMLS_CC );
- // UNumberFormatStyle constants
+ /* UNumberFormatStyle constants */
FORMATTER_EXPOSE_CLASS_CONST( PATTERN_DECIMAL );
FORMATTER_EXPOSE_CLASS_CONST( DECIMAL );
FORMATTER_EXPOSE_CLASS_CONST( CURRENCY );
#define UNUM_ROUND_HALFEVEN UNUM_FOUND_HALFEVEN
#endif
- // UNumberFormatRoundingMode
+ /* UNumberFormatRoundingMode */
FORMATTER_EXPOSE_CLASS_CONST( ROUND_CEILING );
FORMATTER_EXPOSE_CLASS_CONST( ROUND_FLOOR );
FORMATTER_EXPOSE_CLASS_CONST( ROUND_DOWN );
FORMATTER_EXPOSE_CLASS_CONST( ROUND_HALFDOWN );
FORMATTER_EXPOSE_CLASS_CONST( ROUND_HALFUP );
- // UNumberFormatPadPosition
+ /* UNumberFormatPadPosition */
FORMATTER_EXPOSE_CLASS_CONST( PAD_BEFORE_PREFIX );
FORMATTER_EXPOSE_CLASS_CONST( PAD_AFTER_PREFIX );
FORMATTER_EXPOSE_CLASS_CONST( PAD_BEFORE_SUFFIX );
FORMATTER_EXPOSE_CLASS_CONST( PAD_AFTER_SUFFIX );
- // UNumberFormatAttribute
+ /* UNumberFormatAttribute */
FORMATTER_EXPOSE_CLASS_CONST( PARSE_INT_ONLY );
FORMATTER_EXPOSE_CLASS_CONST( GROUPING_USED );
FORMATTER_EXPOSE_CLASS_CONST( DECIMAL_ALWAYS_SHOWN );
FORMATTER_EXPOSE_CLASS_CONST( MAX_SIGNIFICANT_DIGITS );
FORMATTER_EXPOSE_CLASS_CONST( LENIENT_PARSE );
- // UNumberFormatTextAttribute
+ /* UNumberFormatTextAttribute */
FORMATTER_EXPOSE_CLASS_CONST( POSITIVE_PREFIX );
FORMATTER_EXPOSE_CLASS_CONST( POSITIVE_SUFFIX );
FORMATTER_EXPOSE_CLASS_CONST( NEGATIVE_PREFIX );
FORMATTER_EXPOSE_CLASS_CONST( DEFAULT_RULESET );
FORMATTER_EXPOSE_CLASS_CONST( PUBLIC_RULESETS );
- // UNumberFormatSymbol
+ /* UNumberFormatSymbol */
FORMATTER_EXPOSE_CLASS_CONST( DECIMAL_SEPARATOR_SYMBOL );
FORMATTER_EXPOSE_CLASS_CONST( GROUPING_SEPARATOR_SYMBOL );
FORMATTER_EXPOSE_CLASS_CONST( PATTERN_SEPARATOR_SYMBOL );
long attribute, value;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
&object, NumberFormatter_ce_ptr, &attribute ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
switch(attribute) {
int length = 0;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
&object, NumberFormatter_ce_ptr, &attribute ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
length = unum_getTextAttribute( FORMATTER_OBJECT(nfo), attribute, value, value_buf_size, &INTL_DATA_ERROR_CODE(nfo) );
if(INTL_DATA_ERROR_CODE(nfo) == U_BUFFER_OVERFLOW_ERROR && length >= value_buf_size) {
- ++length; // to avoid U_STRING_NOT_TERMINATED_WARNING
+ ++length; /* to avoid U_STRING_NOT_TERMINATED_WARNING */
INTL_DATA_ERROR_CODE(nfo) = U_ZERO_ERROR;
value = eumalloc(length);
length = unum_getTextAttribute( FORMATTER_OBJECT(nfo), attribute, value, length, &INTL_DATA_ERROR_CODE(nfo) );
zval **value;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OlZ",
&object, NumberFormatter_ce_ptr, &attribute, &value ) == FAILURE)
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
switch(attribute) {
int len;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olu",
&object, NumberFormatter_ce_ptr, &attribute, &value, &len ) == FAILURE)
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
- // Actually set new attribute value.
+ /* Actually set new attribute value. */
unum_setTextAttribute(FORMATTER_OBJECT(nfo), attribute, value, len, &INTL_DATA_ERROR_CODE(nfo));
INTL_METHOD_CHECK_STATUS( nfo, "Error setting text attribute" );
int length = USIZE(value);
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
&object, NumberFormatter_ce_ptr, &symbol ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
length = unum_getSymbol(FORMATTER_OBJECT(nfo), symbol, value_buf, length, &INTL_DATA_ERROR_CODE(nfo));
if(INTL_DATA_ERROR_CODE(nfo) == U_BUFFER_OVERFLOW_ERROR && length >= USIZE( value )) {
- ++length; // to avoid U_STRING_NOT_TERMINATED_WARNING
+ ++length; /* to avoid U_STRING_NOT_TERMINATED_WARNING */
INTL_DATA_ERROR_CODE(nfo) = U_ZERO_ERROR;
value = eumalloc(length);
length = unum_getSymbol(FORMATTER_OBJECT(nfo), symbol, value, length, &INTL_DATA_ERROR_CODE(nfo));
int value_len = 0;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olu",
&object, NumberFormatter_ce_ptr, &symbol, &value, &value_len ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
- // Actually set the symbol.
+ /* Actually set the symbol. */
unum_setSymbol(FORMATTER_OBJECT(nfo), symbol, value, value_len, &INTL_DATA_ERROR_CODE(nfo));
INTL_METHOD_CHECK_STATUS( nfo, "Error setting symbol value" );
UChar* value = value_buf;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, NumberFormatter_ce_ptr ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
length = unum_toPattern(FORMATTER_OBJECT(nfo), 0, value, length, &INTL_DATA_ERROR_CODE(nfo));
if(INTL_DATA_ERROR_CODE(nfo) == U_BUFFER_OVERFLOW_ERROR && length >= USIZE( value_buf )) {
- ++length; // to avoid U_STRING_NOT_TERMINATED_WARNING
+ ++length; /* to avoid U_STRING_NOT_TERMINATED_WARNING */
INTL_DATA_ERROR_CODE(nfo) = U_ZERO_ERROR;
value = eumalloc(length);
length = unum_toPattern( FORMATTER_OBJECT(nfo), 0, value, length, &INTL_DATA_ERROR_CODE(nfo) );
int value_len = 0;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ou",
&object, NumberFormatter_ce_ptr, &value, &value_len ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
unum_applyPattern(FORMATTER_OBJECT(nfo), 0, value, value_len, NULL, &INTL_DATA_ERROR_CODE(nfo));
char* loc;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l",
&object, NumberFormatter_ce_ptr, &type ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
loc = (char *)unum_getLocaleByType(FORMATTER_OBJECT(nfo), type, &INTL_DATA_ERROR_CODE(nfo));
zend_class_entry *NumberFormatter_ce_ptr = NULL;
-/////////////////////////////////////////////////////////////////////////////
-// Auxiliary functions needed by objects of 'NumberFormatter' class
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * Auxiliary functions needed by objects of 'NumberFormatter' class
+ */
/* {{{ NumberFormatter_objects_dtor */
static void NumberFormatter_object_dtor(
}
/* }}} */
-/////////////////////////////////////////////////////////////////////////////
-// 'NumberFormatter' class registration structures & functions
-/////////////////////////////////////////////////////////////////////////////
-
-/* {{{ NumberFormatter_class_functions
- * Every 'NumberFormatter' class method has an entry in this table
+/*
+ * 'NumberFormatter' class registration structures & functions
*/
+
+/* {{{ arginfo */
static ZEND_BEGIN_ARG_INFO_EX( number_parse_arginfo, 0, 0, 1 )
ZEND_ARG_INFO( 0, string )
ZEND_ARG_INFO( 0, type )
ZEND_ARG_INFO( 1, position )
ZEND_END_ARG_INFO()
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_getattribute, 0, 0, 1)
+ ZEND_ARG_INFO(0, attr)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_setattribute, 0, 0, 2)
+ ZEND_ARG_INFO(0, attr)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_getsymbol, 0, 0, 1)
+ ZEND_ARG_INFO(0, attr)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_setsymbol, 0, 0, 2)
+ ZEND_ARG_INFO(0, attr)
+ ZEND_ARG_INFO(0, symbol)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_numberformatter_getpattern, 0)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_setpattern, 0, 0, 1)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_getlocale, 0, 0, 0)
+ ZEND_ARG_INFO(0, type)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter___construct, 0, 0, 2)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, style)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_formatcurrency, 0, 0, 2)
+ ZEND_ARG_INFO(0, num)
+ ZEND_ARG_INFO(0, currency)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numberformatter_format, 0, 0, 1)
+ ZEND_ARG_INFO(0, num)
+ ZEND_ARG_INFO(0, type)
+ZEND_END_ARG_INFO()
+/* }}} */
+
+/* {{{ NumberFormatter_class_functions
+ * Every 'NumberFormatter' class method has an entry in this table
+ */
static function_entry NumberFormatter_class_functions[] = {
- PHP_ME( NumberFormatter, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR )
- ZEND_FENTRY( create, ZEND_FN( numfmt_create ), NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
- PHP_NAMED_FE( format, ZEND_FN( numfmt_format ), NULL )
+ PHP_ME( NumberFormatter, __construct, arginfo_numberformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR )
+ ZEND_FENTRY( create, ZEND_FN( numfmt_create ), arginfo_numberformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
+ PHP_NAMED_FE( format, ZEND_FN( numfmt_format ), arginfo_numberformatter_format )
PHP_NAMED_FE( parse, ZEND_FN( numfmt_parse ), number_parse_arginfo )
- PHP_NAMED_FE( formatCurrency, ZEND_FN( numfmt_format_currency ), NULL )
+ PHP_NAMED_FE( formatCurrency, ZEND_FN( numfmt_format_currency ), arginfo_numberformatter_formatcurrency )
PHP_NAMED_FE( parseCurrency, ZEND_FN( numfmt_parse_currency ), number_parse_currency_arginfo )
- PHP_NAMED_FE( setAttribute, ZEND_FN( numfmt_set_attribute ), NULL )
- PHP_NAMED_FE( getAttribute, ZEND_FN( numfmt_get_attribute ), NULL )
- PHP_NAMED_FE( setTextAttribute, ZEND_FN( numfmt_set_text_attribute ), NULL )
- PHP_NAMED_FE( getTextAttribute, ZEND_FN( numfmt_get_text_attribute ), NULL )
- PHP_NAMED_FE( setSymbol, ZEND_FN( numfmt_set_symbol ), NULL )
- PHP_NAMED_FE( getSymbol, ZEND_FN( numfmt_get_symbol ), NULL )
- PHP_NAMED_FE( setPattern, ZEND_FN( numfmt_set_pattern ), NULL )
- PHP_NAMED_FE( getPattern, ZEND_FN( numfmt_get_pattern ), NULL )
- PHP_NAMED_FE( getLocale, ZEND_FN( numfmt_get_locale ), NULL )
- PHP_NAMED_FE( getErrorCode, ZEND_FN( numfmt_get_error_code ), NULL )
- PHP_NAMED_FE( getErrorMessage, ZEND_FN( numfmt_get_error_message ), NULL )
+ PHP_NAMED_FE( setAttribute, ZEND_FN( numfmt_set_attribute ), arginfo_numberformatter_setattribute )
+ PHP_NAMED_FE( getAttribute, ZEND_FN( numfmt_get_attribute ), arginfo_numberformatter_getattribute )
+ PHP_NAMED_FE( setTextAttribute, ZEND_FN( numfmt_set_text_attribute ), arginfo_numberformatter_setattribute )
+ PHP_NAMED_FE( getTextAttribute, ZEND_FN( numfmt_get_text_attribute ), arginfo_numberformatter_getattribute )
+ PHP_NAMED_FE( setSymbol, ZEND_FN( numfmt_set_symbol ), arginfo_numberformatter_setsymbol )
+ PHP_NAMED_FE( getSymbol, ZEND_FN( numfmt_get_symbol ), arginfo_numberformatter_getsymbol )
+ PHP_NAMED_FE( setPattern, ZEND_FN( numfmt_set_pattern ), arginfo_numberformatter_setpattern )
+ PHP_NAMED_FE( getPattern, ZEND_FN( numfmt_get_pattern ), arginfo_numberformatter_getpattern )
+ PHP_NAMED_FE( getLocale, ZEND_FN( numfmt_get_locale ), arginfo_numberformatter_getlocale )
+ PHP_NAMED_FE( getErrorCode, ZEND_FN( numfmt_get_error_code ), arginfo_numberformatter_getpattern )
+ PHP_NAMED_FE( getErrorMessage, ZEND_FN( numfmt_get_error_message ), arginfo_numberformatter_getpattern )
{ NULL, NULL, NULL }
};
/* }}} */
{
zend_class_entry ce;
- // Create and register 'NumberFormatter' class.
+ /* Create and register 'NumberFormatter' class. */
INIT_CLASS_ENTRY( ce, "NumberFormatter", NumberFormatter_class_functions );
ce.create_object = NumberFormatter_object_create;
NumberFormatter_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC );
- // Declare 'NumberFormatter' class properties.
+ /* Declare 'NumberFormatter' class properties. */
if( !NumberFormatter_ce_ptr )
{
zend_error(E_ERROR, "Failed to register NumberFormatter class");
int formatted_len = USIZE(format_buf);
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OZ|l",
&object, NumberFormatter_ce_ptr, &number, &type ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
if(type == FORMAT_TYPE_DEFAULT) {
}
if(Z_TYPE_PP(number) == IS_LONG) {
- // take INT32 on 32-bit, int64 on 64-bit
+ /* take INT32 on 32-bit, int64 on 64-bit */
type = (sizeof(long) == 8)?FORMAT_TYPE_INT64:FORMAT_TYPE_INT32;
} else if(Z_TYPE_PP(number) == IS_DOUBLE) {
type = FORMAT_TYPE_DOUBLE;
int currency_len;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odu",
&object, NumberFormatter_ce_ptr, &number, ¤cy, ¤cy_len ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
- // Format the number using a fixed-length buffer.
+ /* Format the number using a fixed-length buffer. */
formatted_len = unum_formatDoubleCurrency(nfo->nf_data.unum, number, currency, formatted, formatted_len, NULL, &INTL_DATA_ERROR_CODE(nfo));
- // If the buffer turned out to be too small
- // then allocate another buffer dynamically
- // and use it to format the number.
+ /* If the buffer turned out to be too small
+ * then allocate another buffer dynamically
+ * and use it to format the number.
+ */
if (INTL_DATA_ERROR_CODE(nfo) == U_BUFFER_OVERFLOW_ERROR) {
intl_error_reset(INTL_DATA_ERROR_P(nfo) TSRMLS_CC);
formatted = eumalloc(formatted_len+1);
long style;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "sl|u",
&locale, &locale_len, &style, &pattern, &pattern_len ) == FAILURE )
{
{
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, NumberFormatter_ce_ptr ) == FAILURE )
{
nfo = (NumberFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
- // Return formatter's last error code.
+ /* Return formatter's last error code. */
RETURN_LONG( INTL_DATA_ERROR_CODE(nfo) );
}
/* }}} */
char* message = NULL;
FORMATTER_METHOD_INIT_VARS
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, NumberFormatter_ce_ptr ) == FAILURE )
{
RETURN_FALSE;
}
- // Create an ICU number formatter.
+ /* Create an ICU number formatter. */
nfo = (NumberFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
- // Return last error message.
+ /* Return last error message. */
message = intl_error_get_message( &INTL_DATA_ERROR(nfo) TSRMLS_CC );
RETURN_STRING( message, 0);
}
zval *zposition = NULL;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ou|lz!",
&object, NumberFormatter_ce_ptr, &str, &str_len, &type, &zposition ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
if(zposition) {
zval *zcurrency = NULL, *zposition = NULL;
FORMATTER_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ouz|z!",
&object, NumberFormatter_ce_ptr, &str, &str_len, &zcurrency, &zposition ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
FORMATTER_METHOD_FETCH_OBJECT;
if(zposition) {
unsigned char u_break_iterator_buffer[U_BRK_SAFECLONE_BUFFERSIZE];
UBreakIterator* bi = NULL;
int ret_pos;
- zval *next = NULL; // return offset of next part of the string
+ zval *next = NULL; /* return offset of next part of the string */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|llz", (char **)&str, &str_len, &size, &extract_type, &lstart, &next) == FAILURE) {
UChar* dst_buf = NULL;
int32_t dst_len = 0;
- // If *target is NULL determine required destination buffer size (pre-flighting).
- // Otherwise, attempt to convert source string; if *target buffer is not large enough
- // it will be resized appropriately.
+ /* If *target is NULL determine required destination buffer size (pre-flighting).
+ * Otherwise, attempt to convert source string; if *target buffer is not large enough
+ * it will be resized appropriately.
+ */
*status = U_ZERO_ERROR;
u_strFromUTF8( *target, *target_len, &dst_len, src, src_len, status );
if( *status == U_ZERO_ERROR )
{
- // String is converted successfuly
+ /* String is converted successfuly */
(*target)[dst_len] = 0;
*target_len = dst_len;
return;
}
- // Bail out if an unexpected error occured.
- // (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough).
- // (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty).
+ /* Bail out if an unexpected error occured.
+ * (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough).
+ * (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty).
+ */
if( *status != U_BUFFER_OVERFLOW_ERROR && *status != U_STRING_NOT_TERMINATED_WARNING )
return;
- // Allocate memory for the destination buffer (it will be zero-terminated).
+ /* Allocate memory for the destination buffer (it will be zero-terminated). */
dst_buf = eumalloc( dst_len + 1 );
- // Convert source string from UTF-8 to UTF-16.
+ /* Convert source string from UTF-8 to UTF-16. */
*status = U_ZERO_ERROR;
u_strFromUTF8( dst_buf, dst_len+1, NULL, src, src_len, status );
if( U_FAILURE( *status ) )
char* dst_buf = NULL;
int32_t dst_len;
- // Determine required destination buffer size (pre-flighting).
+ /* Determine required destination buffer size (pre-flighting). */
*status = U_ZERO_ERROR;
u_strToUTF8( NULL, 0, &dst_len, src, src_len, status );
- // Bail out if an unexpected error occured.
- // (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough).
- // (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty).
+ /* Bail out if an unexpected error occured.
+ * (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough).
+ * (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty).
+ */
if( *status != U_BUFFER_OVERFLOW_ERROR && *status != U_STRING_NOT_TERMINATED_WARNING )
return;
- // Allocate memory for the destination buffer (it will be zero-terminated).
+ /* Allocate memory for the destination buffer (it will be zero-terminated). */
dst_buf = emalloc( dst_len+1 );
- // Convert source string from UTF-8 to UTF-16.
+ /* Convert source string from UTF-8 to UTF-16. */
*status = U_ZERO_ERROR;
u_strToUTF8( dst_buf, dst_len, NULL, src, src_len, status );
if( U_FAILURE( *status ) )
return;
}
- // U_STRING_NOT_TERMINATED_WARNING is OK for us => reset 'status'.
+ /* U_STRING_NOT_TERMINATED_WARNING is OK for us => reset 'status'. */
*status = U_ZERO_ERROR;
dst_buf[dst_len] = 0;
if( !err && !( err = intl_g_error_get( TSRMLS_C ) ) )
return;
- // Free previous message if any
+ /* Free previous message if any */
intl_free_custom_error_msg( err TSRMLS_CC );
- // Mark message copied if any
+ /* Mark message copied if any */
err->free_custom_error_message = copyMsg;
- // Set user's error text message
+ /* Set user's error text message */
err->custom_error_message = copyMsg ? estrdup( msg ) : msg;
}
/* }}} */
uErrorName = u_errorName( err->code );
- // Format output string
+ /* Format output string */
if( err->custom_error_message )
{
spprintf( &errMessage, 0, "%s: %s", err->custom_error_message, uErrorName );
#include "intl_data.h"
/* {{{ */
-static msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
{
char* locale;
int locale_len = 0;
intl_error_reset( NULL TSRMLS_CC );
object = return_value;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "su",
&locale, &locale_len, &spattern, &spattern_len ) == FAILURE )
{
INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
MSG_FORMAT_METHOD_FETCH_OBJECT;
- // Convert pattern (if specified) to UTF-16.
+ /* Convert pattern (if specified) to UTF-16. */
if(locale_len == 0) {
locale = UG(default_locale);
}
INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to quote-friendly format");
}
- // Create an ICU message formatter.
+ /* Create an ICU message formatter. */
MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, locale, NULL, &INTL_DATA_ERROR_CODE(mfo));
if(free_pattern) {
efree(spattern);
zval* object = NULL;
MessageFormatter_object* mfo = NULL;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, MessageFormatter_ce_ptr ) == FAILURE )
{
mfo = (MessageFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
- // Return formatter's last error code.
+ /* Return formatter's last error code. */
RETURN_LONG( INTL_DATA_ERROR_CODE(mfo) );
}
/* }}} */
zval* object = NULL;
MessageFormatter_object* mfo = NULL;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, MessageFormatter_ce_ptr ) == FAILURE )
{
mfo = (MessageFormatter_object *) zend_object_store_get_object( object TSRMLS_CC );
- // Return last error message.
+ /* Return last error message. */
message = intl_error_get_message( &mfo->mf_data.error TSRMLS_CC );
RETURN_STRING( message, 0);
}
{
MSG_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, MessageFormatter_ce_ptr ) == FAILURE )
{
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
MSG_FORMAT_METHOD_FETCH_OBJECT;
if(mfo->mf_data.orig_format) {
int free_pattern = 0;
MSG_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ou",
&object, MessageFormatter_ce_ptr, &svalue, &slength ) == FAILURE )
{
RETURN_FALSE;
}
- // TODO: add parse error information
+ /* TODO: add parse error information */
umsg_applyPattern(MSG_FORMAT_OBJECT(mfo), svalue, slength, NULL, &INTL_DATA_ERROR_CODE(mfo));
if(free_pattern) {
efree(svalue);
char *loc;
MSG_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&object, MessageFormatter_ce_ptr ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
MSG_FORMAT_METHOD_FETCH_OBJECT;
loc = (char *)umsg_getLocale(MSG_FORMAT_OBJECT(mfo));
zend_class_entry *MessageFormatter_ce_ptr = NULL;
-/////////////////////////////////////////////////////////////////////////////
-// Auxiliary functions needed by objects of 'MessageFormatter' class
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * Auxiliary functions needed by objects of 'MessageFormatter' class
+ */
/* {{{ MessageFormatter_objects_dtor */
static void MessageFormatter_object_dtor(void *object, zend_object_handle handle TSRMLS_DC )
}
/* }}} */
-/////////////////////////////////////////////////////////////////////////////
-// 'MessageFormatter' class registration structures & functions
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * 'MessageFormatter' class registration structures & functions
+ */
+
+/* {{{ arginfo */
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_messageformatter___construct, 0, 0, 2)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO(arginfo_messageformatter_geterrormessage, 0)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_messageformatter_formatmessage, 0, 0, 3)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, pattern)
+ ZEND_ARG_INFO(0, args)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_messageformatter_format, 0, 0, 1)
+ ZEND_ARG_INFO(0, args)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_messageformatter_setpattern, 0, 0, 1)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_messageformatter_parse, 0, 0, 1)
+ ZEND_ARG_INFO(0, source)
+ZEND_END_ARG_INFO()
+/* }}} */
/* {{{ MessageFormatter_class_functions
* Every 'MessageFormatter' class method has an entry in this table
*/
-
static function_entry MessageFormatter_class_functions[] = {
- PHP_ME( MessageFormatter, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR )
- ZEND_FENTRY( create, ZEND_FN( msgfmt_create ), NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
- PHP_NAMED_FE( format, ZEND_FN( msgfmt_format ), NULL )
- ZEND_FENTRY( formatMessage, ZEND_FN( msgfmt_format_message ), NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
- PHP_NAMED_FE( parse, ZEND_FN( msgfmt_parse ), NULL )
- ZEND_FENTRY( parseMessage, ZEND_FN( msgfmt_parse_message ), NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
- PHP_NAMED_FE( setPattern, ZEND_FN( msgfmt_set_pattern ), NULL )
- PHP_NAMED_FE( getPattern, ZEND_FN( msgfmt_get_pattern ), NULL )
- PHP_NAMED_FE( getLocale, ZEND_FN( msgfmt_get_locale ), NULL )
- PHP_NAMED_FE( getErrorCode, ZEND_FN( msgfmt_get_error_code ), NULL )
- PHP_NAMED_FE( getErrorMessage, ZEND_FN( msgfmt_get_error_message ), NULL )
+ PHP_ME( MessageFormatter, __construct, arginfo_messageformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR )
+ ZEND_FENTRY( create, ZEND_FN( msgfmt_create ), arginfo_messageformatter___construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
+ PHP_NAMED_FE( format, ZEND_FN( msgfmt_format ), arginfo_messageformatter_format )
+ ZEND_FENTRY( formatMessage, ZEND_FN( msgfmt_format_message ), arginfo_messageformatter_formatmessage, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
+ PHP_NAMED_FE( parse, ZEND_FN( msgfmt_parse ), arginfo_messageformatter_parse )
+ ZEND_FENTRY( parseMessage, ZEND_FN( msgfmt_parse_message ), arginfo_messageformatter_formatmessage, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
+ PHP_NAMED_FE( setPattern, ZEND_FN( msgfmt_set_pattern ), arginfo_messageformatter_setpattern )
+ PHP_NAMED_FE( getPattern, ZEND_FN( msgfmt_get_pattern ), arginfo_messageformatter_geterrormessage )
+ PHP_NAMED_FE( getLocale, ZEND_FN( msgfmt_get_locale ), arginfo_messageformatter_geterrormessage )
+ PHP_NAMED_FE( getErrorCode, ZEND_FN( msgfmt_get_error_code ), arginfo_messageformatter_geterrormessage )
+ PHP_NAMED_FE( getErrorMessage, ZEND_FN( msgfmt_get_error_message ), arginfo_messageformatter_geterrormessage )
{ NULL, NULL, NULL }
};
/* }}} */
{
zend_class_entry ce;
- // Create and register 'MessageFormatter' class.
+ /* Create and register 'MessageFormatter' class. */
INIT_CLASS_ENTRY( ce, "MessageFormatter", MessageFormatter_class_functions );
ce.create_object = MessageFormatter_object_create;
MessageFormatter_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC );
- // Declare 'MessageFormatter' class properties.
+ /* Declare 'MessageFormatter' class properties. */
if( !MessageFormatter_ce_ptr )
{
zend_error(E_ERROR, "Failed to register MessageFormatter class");
count = zend_hash_num_elements(Z_ARRVAL_P(args));
if(count < umsg_format_arg_count(MSG_FORMAT_OBJECT(mfo))) {
- // Not enough aguments for format!
+ /* Not enough aguments for format! */
intl_error_set( INTL_DATA_ERROR_P(mfo), U_ILLEGAL_ARGUMENT_ERROR,
"msgfmt_format: not enough parameters", 0 TSRMLS_CC );
RETVAL_FALSE;
MSG_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa",
&object, MessageFormatter_ce_ptr, &args ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
MSG_FORMAT_METHOD_FETCH_OBJECT;
msgfmt_do_format(mfo, args, return_value TSRMLS_CC);
MessageFormatter_object mf = {0};
MessageFormatter_object *mfo = &mf;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "sua",
&slocale, &slocale_len, &spattern, &spattern_len, &args ) == FAILURE )
{
RETURN_FALSE;
}
- // Create an ICU message formatter.
+ /* Create an ICU message formatter. */
MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo));
if(free_pattern) {
efree(spattern);
msgfmt_do_format(mfo, args, return_value TSRMLS_CC);
- // drop the temporary formatter
+ /* drop the temporary formatter */
msgformat_data_free(&mfo->mf_data TSRMLS_CC);
}
/* }}} */
MSG_FORMAT_METHOD_INIT_VARS;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ou",
&object, MessageFormatter_ce_ptr, &source, &source_len ) == FAILURE )
{
RETURN_FALSE;
}
- // Fetch the object.
+ /* Fetch the object. */
MSG_FORMAT_METHOD_FETCH_OBJECT;
msgfmt_do_parse(mfo, source, source_len, return_value TSRMLS_CC);
MessageFormatter_object mf={0};
MessageFormatter_object *mfo = &mf;
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "suu",
&slocale, &slocale_len, &spattern, &spattern_len, &source, &source_len ) == FAILURE )
{
RETURN_FALSE;
}
- // Create an ICU message formatter.
+ /* Create an ICU message formatter. */
MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo));
if(free_pattern) {
efree(spattern);
INTL_METHOD_CHECK_STATUS(mfo, "Creating message formatter failed");
msgfmt_do_parse(mfo, source, source_len, return_value TSRMLS_CC);
- // drop the temporary formatter
+ /* drop the temporary formatter */
msgformat_data_free(&mfo->mf_data TSRMLS_CC);
}
/* }}} */
#define NORMALIZER_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Normalizer_ce_ptr, ZEND_STRS( #x ) - 1, NORMALIZER_##x TSRMLS_CC );
#define NORMALIZER_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( Normalizer_ce_ptr, ZEND_STRS( name ) - 1, value TSRMLS_CC );
- // Normalization form constants
+ /* Normalization form constants */
NORMALIZER_EXPOSE_CLASS_CONST( NONE );
NORMALIZER_EXPOSE_CLASS_CONST( FORM_D );
NORMALIZER_EXPOSE_CLASS_CONST( NFD );
zend_class_entry *Normalizer_ce_ptr = NULL;
-/////////////////////////////////////////////////////////////////////////////
-// 'Normalizer' class registration structures & functions
-/////////////////////////////////////////////////////////////////////////////
+/*
+ * 'Normalizer' class registration structures & functions
+ */
/* {{{ Normalizer methods arguments info */
{
zend_class_entry ce;
- // Create and register 'Normalizer' class.
+ /* Create and register 'Normalizer' class. */
INIT_CLASS_ENTRY( ce, "Normalizer", Normalizer_class_functions );
ce.create_object = NULL;
Normalizer_ce_ptr = zend_register_internal_class( &ce TSRMLS_CC );
- // Declare 'Normalizer' class properties.
+ /* Declare 'Normalizer' class properties. */
if( !Normalizer_ce_ptr )
{
zend_error( E_ERROR,
*/
PHP_FUNCTION( normalizer_normalize )
{
- // form is optional, defaults to FORM_C
+ /* form is optional, defaults to FORM_C */
long form = NORMALIZER_DEFAULT;
UChar* uinput = NULL;
intl_error_reset( NULL TSRMLS_CC );
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "u|l",
&uinput, &uinput_len, &form ) == FAILURE )
{
* Normalize string
*/
- // Allocate memory for the destination buffer for normalization
+ /* Allocate memory for the destination buffer for normalization */
uret_len = uinput_len * expansion_factor;
uret_buf = eumalloc( uret_len + 1 );
- // normalize
+ /* normalize */
size_needed = unorm_normalize( uinput, uinput_len, form, (int32_t) 0 /* options */, uret_buf, uret_len, &status);
- // Bail out if an unexpected error occured.
- // (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough).
- // (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty).
+ /* Bail out if an unexpected error occured.
+ * (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough).
+ * (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty).
+ */
if( U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR && status != U_STRING_NOT_TERMINATED_WARNING ) {
efree( uret_buf );
RETURN_NULL();
}
if ( size_needed > uret_len ) {
- // realloc does not seem to work properly - memory is corrupted
- // uret_buf = eurealloc(uret_buf, size_needed + 1);
+ /* realloc does not seem to work properly - memory is corrupted
+ * uret_buf = eurealloc(uret_buf, size_needed + 1);
+ */
efree( uret_buf );
uret_buf = eumalloc( size_needed + 1 );
uret_len = size_needed;
status = U_ZERO_ERROR;
- // try normalize again
+ /* try normalize again */
size_needed = unorm_normalize( uinput, uinput_len, form, (int32_t) 0 /* options */, uret_buf, uret_len, &status);
- // Bail out if an unexpected error occured.
+ /* Bail out if an unexpected error occured. */
if( U_FAILURE(status) ) {
- // Set error messages.
+ /* Set error messages. */
intl_error_set_custom_msg( NULL,"Error normalizing string", 1 TSRMLS_CC );
efree( uret_buf );
RETURN_NULL();
}
}
- // the buffer we actually used
+ /* the buffer we actually used */
uret_len = size_needed;
uret_buf[uret_len] = 0;
RETURN_UNICODEL(uret_buf, uret_len, 0);
*/
PHP_FUNCTION( normalizer_is_normalized )
{
- // form is optional, defaults to FORM_C
+ /* form is optional, defaults to FORM_C */
long form = NORMALIZER_DEFAULT;
UChar* uinput = NULL;
intl_error_reset( NULL TSRMLS_CC );
- // Parse parameters.
+ /* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "u|l",
&uinput, &uinput_len, &form) == FAILURE )
{
}
switch(form) {
- // case NORMALIZER_NONE: not allowed - doesn't make sense
+ /* case NORMALIZER_NONE: not allowed - doesn't make sense */
case NORMALIZER_FORM_D:
case NORMALIZER_FORM_KD:
* Test normalization of string
*/
- // test string
+ /* test string */
uret = unorm_isNormalizedWithOptions( uinput, uinput_len, form, (int32_t) 0 /* options */, &status);
- // Bail out if an unexpected error occured.
+ /* Bail out if an unexpected error occured. */
if( U_FAILURE(status) ) {
- // Set error messages.
+ /* Set error messages. */
intl_error_set_custom_msg( NULL,"Error testing if string is the given normalization form.", 1 TSRMLS_CC );
RETURN_FALSE;
}
/* {{{ Arguments info */
static
-ZEND_BEGIN_ARG_INFO_EX( collator_static_0_args, 0, 0, 0 )
+ZEND_BEGIN_ARG_INFO_EX(collator_static_0_args, 0, 0, 0)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( collator_static_1_arg, 0, 0, 1 )
- ZEND_ARG_INFO( 0, arg1 )
+ZEND_BEGIN_ARG_INFO_EX(collator_static_1_arg, 0, 0, 1)
+ ZEND_ARG_INFO(0, arg1)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( collator_static_2_args, 0, 0, 2 )
- ZEND_ARG_INFO( 0, arg1 )
- ZEND_ARG_INFO( 0, arg2 )
+ZEND_BEGIN_ARG_INFO_EX(collator_static_2_args, 0, 0, 2)
+ ZEND_ARG_INFO(0, arg1)
+ ZEND_ARG_INFO(0, arg2)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( collator_0_args, 0, 0, 1 )
- ZEND_ARG_OBJ_INFO( 0, object, Collator, 0 )
+ZEND_BEGIN_ARG_INFO_EX(collator_0_args, 0, 0, 1)
+ ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( collator_1_arg, 0, 0, 2 )
- ZEND_ARG_OBJ_INFO( 0, object, Collator, 0 )
- ZEND_ARG_INFO( 0, arg1 )
+ZEND_BEGIN_ARG_INFO_EX(collator_1_arg, 0, 0, 2)
+ ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
+ ZEND_ARG_INFO(0, arg1)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( collator_2_args, 0, 0, 3 )
- ZEND_ARG_OBJ_INFO( 0, object, Collator, 0 )
- ZEND_ARG_INFO( 0, arg1 )
- ZEND_ARG_INFO( 0, arg2 )
+ZEND_BEGIN_ARG_INFO_EX(collator_2_args, 0, 0, 3)
+ ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
+ ZEND_ARG_INFO(0, arg1)
+ ZEND_ARG_INFO(0, arg2)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( collator_sort_args, 0, 0, 2 )
- ZEND_ARG_OBJ_INFO( 0, object, Collator, 0 )
- ZEND_ARG_ARRAY_INFO( 1, arr, 0 )
- ZEND_ARG_INFO( 0, sort_flags )
+ZEND_BEGIN_ARG_INFO_EX(collator_sort_args, 0, 0, 2)
+ ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
+ ZEND_ARG_ARRAY_INFO(1, arr, 0)
+ ZEND_ARG_INFO(0, sort_flags)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX( numfmt_parse_arginfo, 0, 0, 2 )
- ZEND_ARG_INFO( 0, formatter )
- ZEND_ARG_INFO( 0, string )
- ZEND_ARG_INFO( 0, type )
- ZEND_ARG_INFO( 1, position )
+static
+ZEND_BEGIN_ARG_INFO_EX(numfmt_parse_arginfo, 0, 0, 2)
+ ZEND_ARG_INFO(0, formatter)
+ ZEND_ARG_INFO(0, string)
+ ZEND_ARG_INFO(0, type)
+ ZEND_ARG_INFO(1, position)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX( numfmt_parse_currency_arginfo, 0, 0, 3 )
- ZEND_ARG_INFO( 0, formatter )
- ZEND_ARG_INFO( 0, string )
- ZEND_ARG_INFO( 1, currency )
- ZEND_ARG_INFO( 1, position )
+static
+ZEND_BEGIN_ARG_INFO_EX(numfmt_parse_currency_arginfo, 0, 0, 3)
+ ZEND_ARG_INFO(0, formatter)
+ ZEND_ARG_INFO(0, string)
+ ZEND_ARG_INFO(1, currency)
+ ZEND_ARG_INFO(1, position)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( locale_0_args, 0, 0, 0 )
+ZEND_BEGIN_ARG_INFO_EX(locale_0_args, 0, 0, 0)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( locale_1_arg, 0, 0, 1 )
- ZEND_ARG_INFO( 0, arg1 )
+ZEND_BEGIN_ARG_INFO_EX(locale_1_arg, 0, 0, 1)
+ ZEND_ARG_INFO(0, arg1)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( locale_2_args, 0, 0, 2 )
- ZEND_ARG_INFO( 0, arg1 )
- ZEND_ARG_INFO( 0, arg2 )
+ZEND_BEGIN_ARG_INFO_EX(locale_2_args, 0, 0, 2)
+ ZEND_ARG_INFO(0, arg1)
+ ZEND_ARG_INFO(0, arg2)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( locale_get_args, 0, 0, 1 )
- ZEND_ARG_INFO( 0, locale )
- ZEND_ARG_INFO( 0, in_locale )
+ZEND_BEGIN_ARG_INFO_EX(locale_get_args, 0, 0, 1)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, in_locale)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( locale_filter_args, 0, 0, 3 )
- ZEND_ARG_INFO( 0, langtag )
- ZEND_ARG_INFO( 0, range )
- ZEND_ARG_INFO( 0, canonical )
+ZEND_BEGIN_ARG_INFO_EX(locale_filter_args, 0, 0, 3)
+ ZEND_ARG_INFO(0, langtag)
+ ZEND_ARG_INFO(0, range)
+ ZEND_ARG_INFO(0, canonical)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( locale_lookup_args, 0, 0, 3 )
- ZEND_ARG_INFO( 0, langtag )
- ZEND_ARG_INFO( 0, locale )
- ZEND_ARG_INFO( 0, canonical )
- ZEND_ARG_INFO( 0, fallback )
+ZEND_BEGIN_ARG_INFO_EX(locale_lookup_args, 0, 0, 3)
+ ZEND_ARG_INFO(0, langtag)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, canonical)
+ ZEND_ARG_INFO(0, fallback)
ZEND_END_ARG_INFO()
#define intl_1_arg collator_static_1_arg
static
-ZEND_BEGIN_ARG_INFO_EX( normalizer_args, 0, 0, 1 )
- ZEND_ARG_INFO( 0, input )
- ZEND_ARG_INFO( 0, form )
+ZEND_BEGIN_ARG_INFO_EX(normalizer_args, 0, 0, 1)
+ ZEND_ARG_INFO(0, input)
+ ZEND_ARG_INFO(0, form)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(grapheme_1_arg, 0, 0, 1)
+ ZEND_ARG_INFO(0, string)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(grapheme_search_args, 0, 0, 2)
+ ZEND_ARG_INFO(0, haystack)
+ ZEND_ARG_INFO(0, needle)
+ ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(grapheme_substr_args, 0, 0, 2)
+ ZEND_ARG_INFO(0, string)
+ ZEND_ARG_INFO(0, start)
+ ZEND_ARG_INFO(0, length)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(grapheme_strstr_args, 0, 0, 2)
+ ZEND_ARG_INFO(0, haystack)
+ ZEND_ARG_INFO(0, needle)
+ ZEND_ARG_INFO(0, before_needle)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(grapheme_extract_args, 0, 0, 2)
+ ZEND_ARG_INFO(0, arg1)
+ ZEND_ARG_INFO(0, arg2)
+ ZEND_ARG_INFO(0, arg3)
+ ZEND_ARG_INFO(0, arg4)
+ ZEND_ARG_INFO(1, arg5) /* 1 = pass by reference */
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_create, 0, 0, 2)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, style)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_error_code, 0, 0, 1)
+ ZEND_ARG_INFO(0, nf)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_format, 0, 0, 2)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, num)
+ ZEND_ARG_INFO(0, type)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_format_currency, 0, 0, 3)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, num)
+ ZEND_ARG_INFO(0, currency)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( grapheme_1_arg, 0, 0, 1 )
- ZEND_ARG_INFO( 0, string )
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_attribute, 0, 0, 2)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, attr)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( grapheme_search_args, 0, 0, 2 )
- ZEND_ARG_INFO( 0, haystack )
- ZEND_ARG_INFO( 0, needle )
- ZEND_ARG_INFO( 0, offset )
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_set_attribute, 0, 0, 3)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, attr)
+ ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( grapheme_substr_args, 0, 0, 2 )
- ZEND_ARG_INFO( 0, string )
- ZEND_ARG_INFO( 0, start )
- ZEND_ARG_INFO( 0, length )
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_symbol, 0, 0, 2)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, attr)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( grapheme_strstr_args, 0, 0, 2 )
- ZEND_ARG_INFO( 0, haystack )
- ZEND_ARG_INFO( 0, needle )
- ZEND_ARG_INFO( 0, before_needle )
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_set_symbol, 0, 0, 3)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, attr)
+ ZEND_ARG_INFO(0, symbol)
ZEND_END_ARG_INFO()
static
-ZEND_BEGIN_ARG_INFO_EX( grapheme_extract_args, 0, 0, 2 )
- ZEND_ARG_INFO( 0, arg1 )
- ZEND_ARG_INFO( 0, arg2 )
- ZEND_ARG_INFO( 0, arg3 )
- ZEND_ARG_INFO( 0, arg4 )
- ZEND_ARG_INFO( 1, arg5 ) /* 1 = pass by reference */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_set_pattern, 0, 0, 2)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, pattern)
ZEND_END_ARG_INFO()
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_locale, 0, 0, 1)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, type)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_create, 0, 0, 2)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_get_error_message, 0, 0, 1)
+ ZEND_ARG_INFO(0, coll)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_format, 0, 0, 2)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, args)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_format_message, 0, 0, 3)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, pattern)
+ ZEND_ARG_INFO(0, args)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_parse, 0, 0, 2)
+ ZEND_ARG_INFO(0, nf)
+ ZEND_ARG_INFO(0, source)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_parse_message, 0, 0, 3)
+ ZEND_ARG_INFO(0, locale)
+ ZEND_ARG_INFO(0, pattern)
+ ZEND_ARG_INFO(0, source)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_set_pattern, 0, 0, 2)
+ ZEND_ARG_INFO(0, mf)
+ ZEND_ARG_INFO(0, pattern)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_get_locale, 0, 0, 1)
+ ZEND_ARG_INFO(0, mf)
+ZEND_END_ARG_INFO()
/* }}} */
/* {{{ intl_functions[]
*/
zend_function_entry intl_functions[] = {
- // collator functions
+ /* collator functions */
PHP_FE( collator_create, collator_static_1_arg )
PHP_FE( collator_compare, collator_2_args )
PHP_FE( collator_get_attribute, collator_1_arg )
PHP_FE( collator_get_error_code, collator_0_args )
PHP_FE( collator_get_error_message, collator_0_args )
- // formatter functions
- PHP_FE( numfmt_create, NULL )
- PHP_FE( numfmt_format, NULL )
+ /* formatter functions */
+ PHP_FE( numfmt_create, arginfo_numfmt_create )
+ PHP_FE( numfmt_format, arginfo_numfmt_format )
PHP_FE( numfmt_parse, numfmt_parse_arginfo )
- PHP_FE( numfmt_format_currency, NULL )
+ PHP_FE( numfmt_format_currency, arginfo_numfmt_format_currency )
PHP_FE( numfmt_parse_currency, numfmt_parse_currency_arginfo )
- PHP_FE( numfmt_set_attribute, NULL )
- PHP_FE( numfmt_get_attribute, NULL )
- PHP_FE( numfmt_set_text_attribute, NULL )
- PHP_FE( numfmt_get_text_attribute, NULL )
- PHP_FE( numfmt_set_symbol, NULL )
- PHP_FE( numfmt_get_symbol, NULL )
- PHP_FE( numfmt_set_pattern, NULL )
- PHP_FE( numfmt_get_pattern, NULL )
- PHP_FE( numfmt_get_locale, NULL )
- PHP_FE( numfmt_get_error_code, NULL )
- PHP_FE( numfmt_get_error_message, NULL )
-
- // normalizer functions
+ PHP_FE( numfmt_set_attribute, arginfo_numfmt_set_attribute )
+ PHP_FE( numfmt_get_attribute, arginfo_numfmt_get_attribute )
+ PHP_FE( numfmt_set_text_attribute, arginfo_numfmt_set_attribute )
+ PHP_FE( numfmt_get_text_attribute, arginfo_numfmt_get_attribute )
+ PHP_FE( numfmt_set_symbol, arginfo_numfmt_set_symbol )
+ PHP_FE( numfmt_get_symbol, arginfo_numfmt_get_symbol )
+ PHP_FE( numfmt_set_pattern, arginfo_numfmt_set_pattern )
+ PHP_FE( numfmt_get_pattern, arginfo_numfmt_get_error_code )
+ PHP_FE( numfmt_get_locale, arginfo_numfmt_get_locale )
+ PHP_FE( numfmt_get_error_code, arginfo_numfmt_get_error_code )
+ PHP_FE( numfmt_get_error_message, arginfo_numfmt_get_error_code )
+
+ /* normalizer functions */
PHP_FE( normalizer_normalize, normalizer_args )
PHP_FE( normalizer_is_normalized, normalizer_args )
- //Locale functions
- PHP_NAMED_FE( locale_get_default, zif_locale_get_default, locale_0_args)
- PHP_NAMED_FE( locale_set_default, zif_locale_set_default, locale_1_arg )
+ /* Locale functions */
+ PHP_NAMED_FE( locale_get_default, zif_locale_get_default, locale_0_args)
+ PHP_NAMED_FE( locale_set_default, zif_locale_set_default, locale_1_arg )
PHP_FE( locale_get_primary_language, locale_1_arg )
PHP_FE( locale_get_script, locale_1_arg )
PHP_FE( locale_get_region, locale_1_arg )
PHP_FE( locale_lookup, locale_lookup_args )
PHP_FE( locale_accept_from_http, locale_1_arg )
- // MessageFormatter functions
- PHP_FE( msgfmt_create, NULL )
- PHP_FE( msgfmt_format, NULL )
- PHP_FE( msgfmt_format_message, NULL )
- PHP_FE( msgfmt_parse, NULL )
- PHP_FE( msgfmt_parse_message, NULL )
- PHP_FE( msgfmt_set_pattern, NULL )
- PHP_FE( msgfmt_get_pattern, NULL )
- PHP_FE( msgfmt_get_locale, NULL )
- PHP_FE( msgfmt_get_error_code, NULL )
- PHP_FE( msgfmt_get_error_message, NULL )
-
- // grapheme functions
+ /* MessageFormatter functions */
+ PHP_FE( msgfmt_create, arginfo_msgfmt_create )
+ PHP_FE( msgfmt_format, arginfo_msgfmt_format )
+ PHP_FE( msgfmt_format_message, arginfo_msgfmt_format_message )
+ PHP_FE( msgfmt_parse, arginfo_msgfmt_parse )
+ PHP_FE( msgfmt_parse_message, arginfo_numfmt_parse_message )
+ PHP_FE( msgfmt_set_pattern, arginfo_msgfmt_set_pattern )
+ PHP_FE( msgfmt_get_pattern, arginfo_msgfmt_get_locale )
+ PHP_FE( msgfmt_get_locale, arginfo_msgfmt_get_locale )
+ PHP_FE( msgfmt_get_error_code, arginfo_numfmt_get_error_code )
+ PHP_FE( msgfmt_get_error_message, arginfo_msgfmt_get_error_message )
+
+ /* grapheme functions */
PHP_FE( grapheme_strlen, grapheme_1_arg )
PHP_FE( grapheme_strpos, grapheme_search_args )
PHP_FE( grapheme_stripos, grapheme_search_args )
PHP_FE( grapheme_stristr, grapheme_strstr_args )
PHP_FE( grapheme_extract, grapheme_extract_args )
- // common functions
+ /* common functions */
PHP_FE( intl_get_error_code, intl_0_args )
PHP_FE( intl_get_error_message, intl_0_args )
PHP_FE( intl_is_failure, intl_1_arg )
*/
PHP_MINIT_FUNCTION( intl )
{
- //For the default locale php.ini setting
- REGISTER_INI_ENTRIES();
+ /* For the default locale php.ini setting */
+ REGISTER_INI_ENTRIES();
REGISTER_LONG_CONSTANT("INTL_MAX_LOCALE_LEN", INTL_MAX_LOCALE_LEN, CONST_CS);
- // Register 'Collator' PHP class
+ /* Register 'Collator' PHP class */
collator_register_Collator_class( TSRMLS_C );
- // Expose Collator constants to PHP scripts
+ /* Expose Collator constants to PHP scripts */
collator_register_constants( INIT_FUNC_ARGS_PASSTHRU );
- // Register 'NumberFormatter' PHP class
+ /* Register 'NumberFormatter' PHP class */
formatter_register_class( TSRMLS_C );
- // Expose NumberFormatter constants to PHP scripts
+ /* Expose NumberFormatter constants to PHP scripts */
formatter_register_constants( INIT_FUNC_ARGS_PASSTHRU );
- // Register 'Normalizer' PHP class
+ /* Register 'Normalizer' PHP class */
normalizer_register_Normalizer_class( TSRMLS_C );
- // Expose Normalizer constants to PHP scripts
+ /* Expose Normalizer constants to PHP scripts */
normalizer_register_constants( INIT_FUNC_ARGS_PASSTHRU );
- // Register 'Locale' PHP class
+ /* Register 'Locale' PHP class */
locale_register_Locale_class( TSRMLS_C );
- // Expose Locale constants to PHP scripts
+ /* Expose Locale constants to PHP scripts */
locale_register_constants( INIT_FUNC_ARGS_PASSTHRU );
msgformat_register_class(TSRMLS_C);
grapheme_register_constants( INIT_FUNC_ARGS_PASSTHRU );
- // Expose ICU error codes to PHP scripts.
+ /* Expose ICU error codes to PHP scripts. */
intl_expose_icu_error_codes( INIT_FUNC_ARGS_PASSTHRU );
- // Global error handling.
+ /* Global error handling. */
intl_error_init( NULL TSRMLS_CC );
- //Set the default_locale value
- if( INTL_G(default_locale) == NULL ) {
- INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ;
- }
+ /* Set the default_locale value */
+ if( INTL_G(default_locale) == NULL ) {
+ INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ;
+ }
return SUCCESS;
}
*/
PHP_MSHUTDOWN_FUNCTION( intl )
{
- //For the default locale php.ini setting
- UNREGISTER_INI_ENTRIES();
+ /* For the default locale php.ini setting */
+ UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
*/
PHP_RINIT_FUNCTION( intl )
{
- //Set the default_locale value
+ /* Set the default_locale value */
if( INTL_G(default_locale) == NULL ) {
INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ;
}
php_info_print_table_row( 2, "ICU version", U_ICU_VERSION );
php_info_print_table_end();
- //For the default locale php.ini setting
+ /* For the default locale php.ini setting */
DISPLAY_INI_ENTRIES() ;
}