Skip to content

Commit

Permalink
Bug 1751102, part 4 - Make VTYPE_CHAR and _WCHAR act like normal int …
Browse files Browse the repository at this point in the history
…conversion. r=xpcom-reviewers,nika

This is probably less bad than what it is doing. I think the only
difference is that for doubles we won't just do a straight cast,
but will instead do some bounds checking. Thanks to the prior patch,
it will also produce an error for NaN. This might make us start to
fail if you try to convert, say, 3.3 to a char but hopefully that
doesn't matter.

Differential Revision: https://phabricator.services.mozilla.com/D137100
  • Loading branch information
amccreight committed Feb 3, 2022
1 parent 5feb2c5 commit bc61bb2
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions xpcom/ds/nsVariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,18 +526,11 @@ CASE__NUMERIC_CONVERSION_DOUBLE_JUST_CAST(double)
NUMERIC_CONVERSION_METHOD_END

// XXX toChar conversions need to be fixed!
NUMERIC_CONVERSION_METHOD_BEGIN(VTYPE_CHAR, char, Char)
CASE__NUMERIC_CONVERSION_INT32_JUST_CAST(char)
CASE__NUMERIC_CONVERSION_UINT32_JUST_CAST(char)
CASE__NUMERIC_CONVERSION_DOUBLE_JUST_CAST(char)
NUMERIC_CONVERSION_METHOD_END
NUMERIC_CONVERSION_METHOD_NORMAL(VTYPE_CHAR, char, Char, CHAR_MIN, CHAR_MAX)

// XXX toWChar conversions need to be fixed!
NUMERIC_CONVERSION_METHOD_BEGIN(VTYPE_WCHAR, char16_t, WChar)
CASE__NUMERIC_CONVERSION_INT32_JUST_CAST(char16_t)
CASE__NUMERIC_CONVERSION_UINT32_JUST_CAST(char16_t)
CASE__NUMERIC_CONVERSION_DOUBLE_JUST_CAST(char16_t)
NUMERIC_CONVERSION_METHOD_END
NUMERIC_CONVERSION_METHOD_NORMAL(VTYPE_WCHAR, char16_t, WChar, 0,
std::numeric_limits<char16_t>::max())

#undef NUMERIC_CONVERSION_METHOD_BEGIN
#undef CASE__NUMERIC_CONVERSION_INT32_JUST_CAST
Expand Down

0 comments on commit bc61bb2

Please sign in to comment.