From: Xinchen Hui Date: Sat, 28 Jun 2014 15:30:46 +0000 (+0800) Subject: Fixed get_debug_info X-Git-Tag: POST_PHPNG_MERGE~116 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1d793348067e5769144c0f7efd86428a4137baec;p=php Fixed get_debug_info --- diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index 73d4b7550f..ecaf503565 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -135,34 +135,39 @@ static zend_object *BreakIterator_clone_obj(zval *object TSRMLS_DC) /* {{{ get_debug_info handler for BreakIterator */ static HashTable *BreakIterator_get_debug_info(zval *object, int *is_temp TSRMLS_DC) { - zval zv; + zval val; + HashTable *debug_info; BreakIterator_object *bio; const BreakIterator *biter; *is_temp = 1; - array_init_size(&zv, 8); + ALLOC_HASHTABLE(debug_info); + zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); bio = Z_INTL_BREAKITERATOR_P(object); biter = bio->biter; if (biter == NULL) { - add_assoc_bool_ex(&zv, "valid", sizeof("valid") - 1, 0); - return Z_ARRVAL(zv); + ZVAL_FALSE(&val); + zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &val); + return debug_info; } - add_assoc_bool_ex(&zv, "valid", sizeof("valid") - 1, 1); + ZVAL_TRUE(&val); + zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &val); if (Z_ISUNDEF(bio->text)) { - add_assoc_null_ex(&zv, "text", sizeof("text") - 1); + ZVAL_NULL(&val); + zend_hash_str_update(debug_info, "text", sizeof("text") - 1, &val); } else { Z_TRY_ADDREF(bio->text); - add_assoc_zval_ex(&zv, "text", sizeof("text") - 1, &bio->text); + zend_hash_str_update(debug_info, "text", sizeof("text") - 1, &bio->text); } - add_assoc_string_ex(&zv, "type", sizeof("type") - 1, - const_cast(typeid(*biter).name())); + ZVAL_STRING(&val, const_cast(typeid(*biter).name())); + zend_hash_str_update(debug_info, "type", sizeof("type") - 1, &bio->text); - return Z_ARRVAL(zv); + return debug_info; } /* }}} */ diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp index e5d1ecd705..a62ad7b9d9 100644 --- a/ext/intl/calendar/calendar_class.cpp +++ b/ext/intl/calendar/calendar_class.cpp @@ -150,47 +150,53 @@ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp TSRMLS_DC) zfields; Calendar_object *co; const Calendar *cal; + HashTable *debug_info; *is_temp = 1; - array_init_size(&zv, 8); + ALLOC_HASHTABLE(debug_info); + zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); co = Z_INTL_CALENDAR_P(object); cal = co->ucal; if (cal == NULL) { - add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0); - return Z_ARRVAL(zv); + ZVAL_FALSE(&zv); + zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv); + return debug_info; } + ZVAL_TRUE(&zv); + zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv); - add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1); - - add_assoc_string_ex(&zv, "type", sizeof("type"), - const_cast(cal->getType())); - + ZVAL_STRING(&zv, const_cast(cal->getType())); + zend_hash_str_update(debug_info, "type", sizeof("type") - 1, &zv); { zval ztz, ztz_debug; int is_tmp; - HashTable *debug_info; + HashTable *debug_info_tz; timezone_object_construct(&cal->getTimeZone(), &ztz , 0 TSRMLS_CC); debug_info = Z_OBJ_HANDLER(ztz, get_debug_info)(&ztz, &is_tmp TSRMLS_CC); assert(is_tmp == 1); - zend_hash_copy(Z_ARRVAL(ztz_debug), debug_info, NULL); - add_assoc_zval_ex(&zv, "timeZone", sizeof("timeZone") - 1, &ztz_debug); + array_init(&ztz_debug); + zend_hash_copy(Z_ARRVAL(ztz_debug), debug_info_tz, zval_add_ref); + zend_hash_destroy(debug_info_tz); + FREE_HASHTABLE(debug_info_tz); + + zend_hash_str_update(debug_info, "timeZone", sizeof("timeZone") - 1, &ztz_debug); } { UErrorCode uec = U_ZERO_ERROR; Locale locale = cal->getLocale(ULOC_VALID_LOCALE, uec); if (U_SUCCESS(uec)) { - add_assoc_string_ex(&zv, "locale", sizeof("locale") - 1, - const_cast(locale.getName())); + ZVAL_STRING(&zv, const_cast(locale.getName())); + zend_hash_str_update(debug_info, "locale", sizeof("locale") - 1, &zv); } else { - add_assoc_string_ex(&zv, "locale", sizeof("locale") - 1, - const_cast(u_errorName(uec))); + ZVAL_STRING(&zv, const_cast(u_errorName(uec))); + zend_hash_str_update(debug_info, "locale", sizeof("locale") - 1, &zv); } } @@ -209,9 +215,9 @@ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp TSRMLS_DC) } } - add_assoc_zval_ex(&zv, "fields", sizeof("fields") - 1, &zfields); + zend_hash_str_update(debug_info, "fields", sizeof("fields") - 1, &zfields); - return Z_ARRVAL(zv); + return debug_info; } /* }}} */ diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp index 585c0ce48a..be30c2d541 100644 --- a/ext/intl/timezone/timezone_class.cpp +++ b/ext/intl/timezone/timezone_class.cpp @@ -293,44 +293,50 @@ static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp TSRMLS_DC) UnicodeString ustr; char *str; int str_len; + HashTable *debug_info; UErrorCode uec = U_ZERO_ERROR; *is_temp = 1; - array_init_size(&zv, 4); + ALLOC_HASHTABLE(debug_info); + zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); to = Z_INTL_TIMEZONE_P(object); tz = to->utimezone; if (tz == NULL) { - add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0); - return Z_ARRVAL(zv); + ZVAL_FALSE(&zv); + zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv); + return debug_info; } - add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 1); + ZVAL_TRUE(&zv); + zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv); tz->getID(ustr); intl_convert_utf16_to_utf8(&str, &str_len, ustr.getBuffer(), ustr.length(), &uec); if (U_FAILURE(uec)) { - return Z_ARRVAL(zv); + return debug_info; } + ZVAL_STRINGL(&zv, str, str_len); + zend_hash_str_update(debug_info, "id", sizeof("id") - 1, &zv); // TODO: avoid reallocation ??? - add_assoc_stringl_ex(&zv, "id", sizeof("id"), str, str_len); efree(str); int32_t rawOffset, dstOffset; UDate now = Calendar::getNow(); tz->getOffset(now, FALSE, rawOffset, dstOffset, uec); if (U_FAILURE(uec)) { - return Z_ARRVAL(zv); + return debug_info; } - add_assoc_long_ex(&zv, "rawOffset", sizeof("rawOffset"), (long)rawOffset); - add_assoc_long_ex(&zv, "currentOffset", sizeof("currentOffset"), - (long)(rawOffset + dstOffset)); + ZVAL_LONG(&zv, (long)rawOffset); + zend_hash_str_update(debug_info,"rawOffset", sizeof("rawOffset") - 1, &zv); + ZVAL_LONG(&zv, (long)(rawOffset + dstOffset)); + zend_hash_str_update(debug_info,"currentOffset", sizeof("currentOffset") - 1, &zv); - return Z_ARRVAL(zv); + return debug_info; } /* }}} */