20#include <unicode/utypes.h>
33#define INTL_METHOD_INIT_VARS(oclass, obj) \
34 zval* object = NULL; \
35 oclass##_object* obj = NULL; \
36 intl_error_reset( NULL );
38#define INTL_DATA_ERROR(obj) (((intl_object *)(obj))->error)
39#define INTL_DATA_ERROR_P(obj) (&(INTL_DATA_ERROR((obj))))
40#define INTL_DATA_ERROR_CODE(obj) INTL_ERROR_CODE(INTL_DATA_ERROR((obj)))
42#define INTL_METHOD_FETCH_OBJECT(oclass, obj) \
43 obj = Z_##oclass##_P( object ); \
44 intl_error_reset( INTL_DATA_ERROR_P(obj) ); \
47#define INTL_CHECK_STATUS(err, msg) \
48 intl_error_set_code( NULL, (err) ); \
49 if( U_FAILURE((err)) ) \
51 intl_error_set_custom_msg( NULL, msg, 0 ); \
56#define INTL_CHECK_STATUS_OR_NULL(err, msg) \
57 intl_error_set_code( NULL, (err) ); \
58 if( U_FAILURE((err)) ) \
60 intl_error_set_custom_msg( NULL, msg, 0 ); \
66#define INTL_METHOD_CHECK_STATUS(obj, msg) \
67 intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
68 if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
70 intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
75#define INTL_METHOD_CHECK_STATUS_OR_GOTO(obj, msg, label) \
76 intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
77 if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
79 intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
85#define INTL_METHOD_CHECK_STATUS_OR_NULL(obj, msg) \
86 intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
87 if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
89 intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
90 zval_ptr_dtor(return_value); \
95#define INTL_CTOR_CHECK_STATUS(obj, msg) \
96 intl_error_set_code( NULL, INTL_DATA_ERROR_CODE((obj)) ); \
97 if( U_FAILURE( INTL_DATA_ERROR_CODE((obj)) ) ) \
99 intl_errors_set_custom_msg( INTL_DATA_ERROR_P((obj)), msg, 0 ); \
103#define INTL_METHOD_RETVAL_UTF8(obj, ustring, ulen, free_it) \
105 zend_string *u8str; \
106 u8str = intl_convert_utf16_to_utf8(ustring, ulen, &INTL_DATA_ERROR_CODE((obj))); \
110 INTL_METHOD_CHECK_STATUS((obj), "Error converting value to UTF-8"); \
111 RETVAL_NEW_STR(u8str); \
114#define INTL_MAX_LOCALE_LEN (ULOC_FULLNAME_CAPACITY-1)
116#define INTL_CHECK_LOCALE_LEN(locale_len) \
117 if((locale_len) > INTL_MAX_LOCALE_LEN) { \
119 spprintf(&_msg, 0, "Locale string too long, should be no longer than %d characters", INTL_MAX_LOCALE_LEN); \
120 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg, 1); \
125#define INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len) \
126 if((locale_len) > INTL_MAX_LOCALE_LEN) { \
128 spprintf(&_msg, 0, "Locale string too long, should be no longer than %d characters", INTL_MAX_LOCALE_LEN); \
129 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, _msg, 1); \
struct _intl_data intl_object
struct _intl_error intl_error
struct _zend_object zend_object