Bug 538476 Allow ToInteger to take an nsresult* parameter to match the external string API r=bsmedberg

This commit is contained in:
Neil Rashbrook 2010-01-08 23:43:50 +00:00
parent 17e7509306
commit 546b738179
2 changed files with 8 additions and 2 deletions

View File

@ -280,7 +280,9 @@ class nsTString_CharT : public nsTSubstring_CharT
* @return int rep of string value, and possible (out) error code
*/
NS_COM PRInt32 ToInteger( PRInt32* aErrorCode, PRUint32 aRadix=kRadix10 ) const;
PRInt32 ToInteger( nsresult* aErrorCode, PRUint32 aRadix=kRadix10 ) const {
return ToInteger(reinterpret_cast<PRInt32*>(aErrorCode), aRadix);
}
/**
* |Left|, |Mid|, and |Right| are annoying signatures that seem better almost

View File

@ -982,11 +982,15 @@ static const ToIntegerTest kToIntegerTests[] = {
PRBool test_string_tointeger()
{
PRInt32 rv;
PRInt32 i;
nsresult rv;
for (const ToIntegerTest* t = kToIntegerTests; t->str; ++t) {
PRInt32 result = nsCAutoString(t->str).ToInteger(&rv, t->radix);
if (rv != t->rv || result != t->result)
return PR_FALSE;
result = nsCAutoString(t->str).ToInteger(&i, t->radix);
if ((nsresult)i != t->rv || result != t->result)
return PR_FALSE;
}
return PR_TRUE;
}