From 58fd7c758341aa7edd1198619d442063b93e1c25 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Fri, 20 Sep 2013 21:17:16 +0000 Subject: [PATCH] ICU-7912 more review comments X-SVN-Rev: 34428 --- icu4c/source/i18n/fmtable.cpp | 2 +- icu4c/source/i18n/unicode/fmtable.h | 12 ++++++++++++ icu4c/source/i18n/unicode/unum.h | 20 ++++++++++---------- icu4c/source/test/cintltst/cnumtst.c | 4 ++-- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/icu4c/source/i18n/fmtable.cpp b/icu4c/source/i18n/fmtable.cpp index 2454337f2b6..87d6a4ca30b 100644 --- a/icu4c/source/i18n/fmtable.cpp +++ b/icu4c/source/i18n/fmtable.cpp @@ -922,7 +922,7 @@ ufmt_close(UFormattable *fmt) { U_INTERNAL UFormattableType U_EXPORT2 ufmt_getType(const UFormattable *fmt, UErrorCode *status) { if(U_FAILURE(*status)) { - return (UFormattableType)-1; + return (UFormattableType)UFMT_COUNT; } const Formattable *obj = Formattable::fromUFormattable(fmt); return (UFormattableType)obj->getType(); diff --git a/icu4c/source/i18n/unicode/fmtable.h b/icu4c/source/i18n/unicode/fmtable.h index e4a11c0cee3..9a9d5b56b30 100644 --- a/icu4c/source/i18n/unicode/fmtable.h +++ b/icu4c/source/i18n/unicode/fmtable.h @@ -624,6 +624,14 @@ public: */ inline UFormattable *toUFormattable(); + /** + * Convert this object pointer to a UFormattable. + * @return this object as a UFormattable pointer. This is an alias to this object, + * and so is only valid while this object remains in scope. + * @draft ICU 52 + */ + inline const UFormattable *toUFormattable() const; + #ifndef U_HIDE_DEPRECATED_API /** * Deprecated variant of getLong(UErrorCode&). @@ -732,6 +740,10 @@ inline UFormattable* Formattable::toUFormattable() { return reinterpret_cast(this); } +inline const UFormattable* Formattable::toUFormattable() const { + return reinterpret_cast(this); +} + inline Formattable* Formattable::fromUFormattable(UFormattable *fmt) { return reinterpret_cast(fmt); } diff --git a/icu4c/source/i18n/unicode/unum.h b/icu4c/source/i18n/unicode/unum.h index 5efb555b0d4..2635b6dfc9e 100644 --- a/icu4c/source/i18n/unicode/unum.h +++ b/icu4c/source/i18n/unicode/unum.h @@ -596,8 +596,8 @@ unum_formatUFormattable(const UNumberFormat* fmt, * @param fmt The formatter to use. * @param text The text to parse. * @param textLength The length of text, or -1 if null-terminated. -* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which -* to begin parsing. If not 0, on output the offset at which parsing ended. +* @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which +* to begin parsing. If not NULL, on output the offset at which parsing ended. * @param status A pointer to an UErrorCode to receive any errors * @return The value of the parsed integer * @see unum_parseInt64 @@ -620,8 +620,8 @@ unum_parse( const UNumberFormat* fmt, * @param fmt The formatter to use. * @param text The text to parse. * @param textLength The length of text, or -1 if null-terminated. -* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which -* to begin parsing. If not 0, on output the offset at which parsing ended. +* @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which +* to begin parsing. If not NULL, on output the offset at which parsing ended. * @param status A pointer to an UErrorCode to receive any errors * @return The value of the parsed integer * @see unum_parse @@ -644,8 +644,8 @@ unum_parseInt64(const UNumberFormat* fmt, * @param fmt The formatter to use. * @param text The text to parse. * @param textLength The length of text, or -1 if null-terminated. -* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which -* to begin parsing. If not 0, on output the offset at which parsing ended. +* @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which +* to begin parsing. If not NULL, on output the offset at which parsing ended. * @param status A pointer to an UErrorCode to receive any errors * @return The value of the parsed double * @see unum_parse @@ -672,8 +672,8 @@ unum_parseDouble( const UNumberFormat* fmt, * @param fmt The formatter to use. * @param text The text to parse. * @param textLength The length of text, or -1 if null-terminated. -* @param parsePos If not 0, on input a pointer to an integer specifying the offset at which -* to begin parsing. If not 0, on output the offset at which parsing ended. +* @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which +* to begin parsing. If not NULL, on output the offset at which parsing ended. * @param outBuf A (char *) buffer to receive the parsed number as a string. The output string * will be nul-terminated if there is sufficient space. * @param outBufLength The size of the output buffer. May be zero, in which case @@ -705,7 +705,7 @@ unum_parseDecimal(const UNumberFormat* fmt, * @param textLength the length of text, or -1 if null-terminated * @param parsePos a pointer to an offset index into text at which to * begin parsing. On output, *parsePos will point after the last - * parsed character. This parameter may be 0, in which case parsing + * parsed character. This parameter may be NULL, in which case parsing * begins at offset 0. * @param currency a pointer to the buffer to receive the parsed null- * terminated currency. This buffer must have a capacity of at least @@ -734,7 +734,7 @@ unum_parseDoubleCurrency(const UNumberFormat* fmt, * @param textLength the length of text, or -1 if null-terminated * @param parsePos a pointer to an offset index into text at which to * begin parsing. On output, *parsePos will point after the last - * parsed character. This parameter may be 0, in which case parsing + * parsed character. This parameter may be NULL in which case parsing * begins at offset 0. * @param status a pointer to an input-output UErrorCode * @return the UFormattable. Will be ==result unless NULL was passed in for result, in which case it will be the newly opened UFormattable. diff --git a/icu4c/source/test/cintltst/cnumtst.c b/icu4c/source/test/cintltst/cnumtst.c index 23671c554c1..4a8f366d1db 100644 --- a/icu4c/source/test/cintltst/cnumtst.c +++ b/icu4c/source/test/cintltst/cnumtst.c @@ -2219,7 +2219,7 @@ static void TestUFormattable(void) { log_verbose("-- pattern: %s\n", pattern); u_uastrcpy(buffer, pattern); unum_parseToUFormattable(unum, ufmt, buffer, -1, NULL, &status); - if(assertSuccess("unum_parseToUFormattable[31337]", &status)) { + if(assertSuccess("unum_parseToUFormattable(31337)", &status)) { assertTrue("ufmt_getLong()=31337", ufmt_getLong(ufmt, &status) == 31337); assertTrue("ufmt_getType()=UFMT_LONG", ufmt_getType(ufmt, &status) == UFMT_LONG); log_verbose("long = %d\n", ufmt_getLong(ufmt, &status)); @@ -2234,7 +2234,7 @@ static void TestUFormattable(void) { log_verbose("-- pattern: %s\n", pattern); u_uastrcpy(buffer, pattern); unum_parseToUFormattable(unum, ufmt, buffer, -1, NULL, &status); - if(assertSuccess("unum_parseToUFormattable[3.14159]", &status)) { + if(assertSuccess("unum_parseToUFormattable(3.14159)", &status)) { assertTrue("ufmt_getDouble()==3.14159", withinErr(ufmt_getDouble(ufmt, &status), 3.14159, 1e-15)); assertSuccess("ufmt_getDouble()", &status); assertTrue("ufmt_getType()=UFMT_DOUBLE", ufmt_getType(ufmt, &status) == UFMT_DOUBLE);