Use NS_PTR_TO_INT32 macros to do 64-bit safe pointer conversions.

Bug #20860 r=peterv sr=brendan@mozilla.org


git-svn-id: svn://10.0.0.236/trunk@101007 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
cls%seawood.org
2001-08-14 07:58:24 +00:00
parent a6ebce76c8
commit e82eded973
6 changed files with 17 additions and 11 deletions

View File

@@ -283,9 +283,9 @@ void txListIterator::addBefore(void* objPtr) {
MBool txListIterator::hasNext() {
MBool hasNext = MB_FALSE;
if (currentItem)
hasNext = (MBool) currentItem->nextItem;
hasNext = (currentItem->nextItem != 0);
else if (!atEndOfList)
hasNext = (MBool) list->firstItem;
hasNext = (list->firstItem != 0);
return hasNext;
} //-- hasNext
@@ -298,9 +298,9 @@ MBool txListIterator::hasNext() {
MBool txListIterator::hasPrevious() {
MBool hasPrevious = MB_FALSE;
if (currentItem)
hasPrevious = (MBool) currentItem->prevItem;
hasPrevious = (currentItem->prevItem != 0);
else if (atEndOfList)
hasPrevious = (MBool) list->lastItem;
hasPrevious = (list->lastItem != 0);
return hasPrevious;
} //-- hasPrevious

View File

@@ -239,9 +239,9 @@ void StringListIterator::add(String* strptr) {
**/
MBool StringListIterator::hasNext() {
if (currentItem) {
return (MBool)(currentItem->nextItem);
return (currentItem->nextItem != 0);
}
return (MBool)(stringList->firstItem);
return (stringList->firstItem != 0);
} //-- hasNext
/**
@@ -249,7 +249,7 @@ MBool StringListIterator::hasNext() {
**/
MBool StringListIterator::hasPrevious() {
if (currentItem) {
return (MBool)(currentItem->prevItem);
return (currentItem->prevItem != 0);
}
return MB_FALSE;
} //-- hasPrevious

View File

@@ -45,7 +45,7 @@ class TxObject {
* Returns the Hashcode for this TxObject
**/
virtual PRInt32 hashCode() {
return (PRInt32)this;
return NS_PTR_TO_INT32(this);
} //-- hashCode
/**

View File

@@ -51,9 +51,14 @@
#else
#define NS_ASSERTION(_cond, _msg) {}
#endif
#define NS_PTR_TO_INT32(x) ((char *)(x) - (char *)0)
#define NS_INT32_TO_PTR(x) ((void *)((char *)0 + (x)))
#else
// Mozilla module
#include "prtypes.h"
#include "nscore.h"
typedef PRBool MBool;

View File

@@ -25,6 +25,7 @@
* A class used to overcome DOM 1.0 deficiencies
**/
#include "baseutils.h"
#include "DOMHelper.h"
#include "primitives.h"
@@ -83,11 +84,11 @@ void DOMHelper::generateId(Node* node, String& dest) {
dest.append("id");
if (node->getNodeType() == Node::DOCUMENT_NODE) {
Integer::toString((int)node,dest);
Integer::toString(NS_PTR_TO_INT32(node),dest);
return;
}
Integer::toString((int)node->getOwnerDocument(), dest);
Integer::toString(NS_PTR_TO_INT32(node->getOwnerDocument()), dest);
OrderInfo* orderInfo = getDocumentOrder(node);

View File

@@ -168,7 +168,7 @@ ExprLexer::~ExprLexer()
MBool ExprLexer::hasMoreTokens()
{
return (MBool)currentItem;
return (currentItem != 0);
} //-- hasMoreTokens
Token* ExprLexer::nextToken()