Bug 646071 - Part 2: Replace nsInt64 with a typedef to PRInt64; r=bsmedberg

This commit is contained in:
Jeff Muizelaar 2011-03-31 20:15:04 -04:00
parent 3e62f06d3f
commit 4e1b7d656b
4 changed files with 7 additions and 380 deletions

View File

@ -614,7 +614,7 @@ nsIncrementalDownload::OnStartRequest(nsIRequest *request,
if (NS_FAILED(rv))
return rv;
rv = props->GetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
&mTotalSize.mValue);
&mTotalSize);
// We need to know the total size of the thing we're trying to download.
if (mTotalSize == nsInt64(-1)) {
NS_WARNING("server returned no content-length header!");

View File

@ -566,7 +566,7 @@ nsHttpTransaction::Close(nsresult reason)
NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_COMPLETE,
PR_Now(),
static_cast<PRUint64>(mContentRead.mValue),
static_cast<PRUint64>(mContentRead),
EmptyCString());
// report that this transaction is closing
@ -1065,7 +1065,7 @@ nsHttpTransaction::HandleContent(char *buf,
}
LOG(("nsHttpTransaction::HandleContent [this=%x count=%u read=%u mContentRead=%lld mContentLength=%lld]\n",
this, count, *contentRead, mContentRead.mValue, mContentLength.mValue));
this, count, *contentRead, mContentRead, mContentLength));
// check for end-of-file
if ((mContentRead == mContentLength) ||
@ -1081,7 +1081,7 @@ nsHttpTransaction::HandleContent(char *buf,
NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_COMPLETE,
PR_Now(),
static_cast<PRUint64>(mContentRead.mValue),
static_cast<PRUint64>(mContentRead),
EmptyCString());
}

View File

@ -1579,7 +1579,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
mIsFileChannel = fileChan != nsnull;
// Get content length
mContentLength.mValue = GetContentLengthAsInt64(request);
mContentLength = GetContentLengthAsInt64(request);
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(request, &rv));
// Determine whether a new window was opened specifically for this request

View File

@ -38,380 +38,7 @@
#ifndef nsInt64_h__
#define nsInt64_h__
#include "prlong.h"
#include "nscore.h"
/**
* This class encapsulates full 64-bit integer functionality and
* provides simple arithmetic and conversion operations.
*/
// If you ever decide that you need to add a non-inline method to this
// class, be sure to change the class declaration to "class NS_BASE
// nsInt64".
template<class T>
class nsTInt64
{
public: //XXX should be private
T mValue;
public:
/**
* Construct a new 64-bit integer.
*/
nsTInt64(void) : mValue(LL_ZERO) {
}
/**
* Construct a new 64-bit integer from a 32-bit signed integer
*/
nsTInt64(const PRInt32 aInt32) {
LL_I2L(mValue, aInt32);
}
/**
* Construct a new 64-bit integer from a 32-bit unsigned integer
*/
nsTInt64(const PRUint32 aUint32) {
LL_UI2L(mValue, aUint32);
}
/**
* Construct a new 64-bit integer from a floating point value.
*/
nsTInt64(const PRFloat64 aFloat64) {
LL_D2L(mValue, aFloat64);
}
/**
* Construct a new 64-bit integer from a native 64-bit integer
*/
nsTInt64(const T aInt64) : mValue(aInt64) {
}
/**
* Construct a new 64-bit integer from another 64-bit integer
*/
nsTInt64(const nsTInt64& aObject) : mValue(aObject.mValue) {
}
// ~nsTInt64(void) -- XXX destructor unnecessary
/**
* Assign a 64-bit integer to another 64-bit integer
*/
const nsTInt64& operator =(const nsTInt64& aObject) {
mValue = aObject.mValue;
return *this;
}
/**
* Convert a 64-bit integer to a signed 32-bit value
*/
operator PRInt32(void) const {
PRInt32 result;
LL_L2I(result, mValue);
return result;
}
/**
* Convert a 64-bit integer to an unsigned 32-bit value
*/
operator PRUint32(void) const {
PRUint32 result;
LL_L2UI(result, mValue);
return result;
}
/**
* Convert a 64-bit integer to a floating point value
*/
operator PRFloat64(void) const {
PRFloat64 result;
LL_L2D(result, mValue);
return result;
}
/**
* Convert a 64-bit integer to a native 64-bit integer.
*/
operator T() const {
return mValue;
}
/**
* Perform unary negation on a 64-bit integer.
*/
const nsTInt64 operator -(void) {
nsTInt64 result;
LL_NEG(result.mValue, mValue);
return result;
}
// Arithmetic operators
/**
* Increment a 64-bit integer by a 64-bit integer amount.
*/
nsTInt64& operator +=(const nsTInt64& aObject) {
LL_ADD(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Decrement a 64-bit integer by a 64-bit integer amount.
*/
nsTInt64& operator -=(const nsTInt64& aObject) {
LL_SUB(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Multiply a 64-bit integer by a 64-bit integer amount.
*/
nsTInt64& operator *=(const nsTInt64& aObject) {
LL_MUL(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Divide a 64-bit integer by a 64-bit integer amount.
*/
nsTInt64& operator /=(const nsTInt64& aObject) {
LL_DIV(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Compute the modulus of a 64-bit integer to a 64-bit value.
*/
nsTInt64& operator %=(const nsTInt64& aObject) {
LL_MOD(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Shift a 64-bit integer left.
*/
nsTInt64& operator <<=(int aCount) {
LL_SHL(mValue, mValue, aCount);
return *this;
}
/**
* Shift a 64-bit signed integer right.
*/
nsTInt64& operator >>=(int aCount) {
LL_SHR(mValue, mValue, aCount);
return *this;
}
// Comparison operators
/**
* Add two 64-bit integers.
*/
inline const nsTInt64
operator +(const nsTInt64& aObject2) const {
return nsTInt64(*this) += aObject2;
}
/**
* Subtract one 64-bit integer from another.
*/
inline const nsTInt64
operator -(const nsTInt64& aObject2) const {
return nsTInt64(*this) -= aObject2;
}
/**
* Multiply two 64-bit integers
*/
inline const nsTInt64
operator *(const nsTInt64& aObject2) const {
return nsTInt64(*this) *= aObject2;
}
/**
* Divide one 64-bit integer by another
*/
inline const nsTInt64
operator /(const nsTInt64& aObject2) const {
return nsTInt64(*this) /= aObject2;
}
/**
* Compute the modulus of two 64-bit integers
*/
inline const nsTInt64
operator %(const nsTInt64& aObject2) const {
return nsTInt64(*this) %= aObject2;
}
/**
* Shift left a 64-bit integer
*/
inline const nsTInt64
operator <<(int aCount) const {
return nsTInt64(*this) <<= aCount;
}
/**
* Shift right a signed 64-bit integer
*/
inline const nsTInt64
operator >>(int aCount) const {
return nsTInt64(*this) >>= aCount;
}
/**
* Determine if two 64-bit integers are equal
*/
inline PRBool
operator ==(const nsTInt64& aObject2) const {
return LL_EQ(mValue, aObject2.mValue);
}
inline PRBool
operator ==(T aValue) const {
return LL_EQ(mValue, aValue);
}
/**
* Determine if two 64-bit integers are not equal
*/
inline PRBool
operator !=(const nsTInt64& aObject2) const {
return LL_NE(mValue, aObject2.mValue);
}
inline PRBool
operator !=(T aValue) const {
return LL_NE(mValue, aValue);
}
/**
* Perform a bitwise AND of two 64-bit integers
*/
inline const nsTInt64
operator &(const nsTInt64& aObject2) const {
return nsTInt64(*this) &= aObject2;
}
/**
* Perform a bitwise OR of two 64-bit integers
*/
inline const nsTInt64
operator |(const nsTInt64& aObject2) const {
return nsTInt64(*this) |= aObject2;
}
/**
* Perform a bitwise XOR of two 64-bit integers
*/
inline const nsTInt64
operator ^(const nsTInt64& aObject2) const {
return nsTInt64(*this) ^= aObject2;
}
// Bitwise operators
/**
* Compute the bitwise NOT of a 64-bit integer
*/
const nsTInt64 operator ~(void) const {
nsTInt64 result;
LL_NOT(result.mValue, mValue);
return result;
}
/**
* Compute the bitwise AND with another 64-bit integer
*/
nsTInt64& operator &=(const nsTInt64& aObject) {
LL_AND(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Compute the bitwise OR with another 64-bit integer
*/
nsTInt64& operator |=(const nsTInt64& aObject) {
LL_OR(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Compute the bitwise XOR with another 64-bit integer
*/
nsTInt64& operator ^=(const nsTInt64& aObject) {
LL_XOR(mValue, mValue, aObject.mValue);
return *this;
}
/**
* Allow doing if (!some_nsInt64)
*/
PRBool operator!() const {
return LL_IS_ZERO(mValue);
}
};
typedef nsTInt64<PRInt64> nsInt64;
typedef nsTInt64<PRUint64> nsUint64;
/**
* Determine if one 64-bit integer is strictly greater than another, using signed values
*/
inline PRBool
operator >(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_CMP(aObject1.mValue, >, aObject2.mValue);
}
inline PRBool
operator >(const nsUint64& aObject1, const nsUint64& aObject2) {
return LL_UCMP(aObject1.mValue, >, aObject2.mValue);
}
/**
* Determine if one 64-bit integer is greater than or equal to another, using signed values
*/
inline PRBool
operator >=(const nsInt64& aObject1, const nsInt64& aObject2) {
return ! LL_CMP(aObject1.mValue, <, aObject2.mValue);
}
inline PRBool
operator >=(const nsUint64& aObject1, const nsUint64& aObject2) {
return ! LL_UCMP(aObject1.mValue, <, aObject2.mValue);
}
/**
* Determine if one 64-bit integer is strictly less than another, using signed values
*/
inline PRBool
operator <(const nsInt64& aObject1, const nsInt64& aObject2) {
return LL_CMP(aObject1.mValue, <, aObject2.mValue);
}
inline PRBool
operator <(const nsUint64& aObject1, const nsUint64& aObject2) {
return LL_UCMP(aObject1.mValue, <, aObject2.mValue);
}
/**
* Determine if one 64-bit integers is less than or equal to another, using signed values
*/
inline PRBool
operator <=(const nsInt64& aObject1, const nsInt64& aObject2) {
return ! LL_CMP(aObject1.mValue, >, aObject2.mValue);
}
inline PRBool
operator <=(const nsUint64& aObject1, const nsUint64& aObject2) {
return ! LL_UCMP(aObject1.mValue, >, aObject2.mValue);
}
typedef PRInt64 nsInt64;
typedef PRUint64 nsUint64;
#endif // nsInt64_h__