mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 258058
nsValueArray needs a ReplaceValueAt() r=bsmedberg sr=alecf
This commit is contained in:
parent
60d9d2a397
commit
6b66156a30
@ -199,7 +199,7 @@ PRBool nsValueArray::InsertValueAt(nsValueArrayValue aValue, nsValueArrayIndex a
|
||||
NS_ASSERTION(*((PRUint32*)&mValueArray[aIndex * mBytesPerValue]) == aValue, "Lossy value array detected. Report a higher maximum upon construction!");
|
||||
break;
|
||||
default:
|
||||
NS_ASSERTION(0, "surely you've been warned prior to this!");
|
||||
NS_ERROR("surely you've been warned prior to this!");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -213,6 +213,37 @@ PRBool nsValueArray::InsertValueAt(nsValueArrayValue aValue, nsValueArrayIndex a
|
||||
return retval;
|
||||
}
|
||||
|
||||
//
|
||||
// Replace the item at aIndex with aValue
|
||||
// No validity checking other than index is done.
|
||||
//
|
||||
PRBool nsValueArray::ReplaceValueAt(nsValueArrayValue aValue, nsValueArrayIndex aIndex) {
|
||||
NS_ENSURE_TRUE(aIndex < Count(), PR_FALSE);
|
||||
|
||||
//
|
||||
// Do the assignment.
|
||||
//
|
||||
switch (mBytesPerValue) {
|
||||
case sizeof(PRUint8):
|
||||
*((PRUint8*)&mValueArray[aIndex * mBytesPerValue]) = (PRUint8)aValue;
|
||||
NS_ASSERTION(*((PRUint8*)&mValueArray[aIndex * mBytesPerValue]) == aValue, "Lossy value array detected. Report a higher maximum upon construction!");
|
||||
break;
|
||||
case sizeof(PRUint16):
|
||||
*((PRUint16*)&mValueArray[aIndex * mBytesPerValue]) = (PRUint16)aValue;
|
||||
NS_ASSERTION(*((PRUint16*)&mValueArray[aIndex * mBytesPerValue]) == aValue, "Lossy value array detected. Report a higher maximum upon construction!");
|
||||
break;
|
||||
case sizeof(PRUint32):
|
||||
*((PRUint32*)&mValueArray[aIndex * mBytesPerValue]) = (PRUint32)aValue;
|
||||
NS_ASSERTION(*((PRUint32*)&mValueArray[aIndex * mBytesPerValue]) == aValue, "Lossy value array detected. Report a higher maximum upon construction!");
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("surely you've been warned prior to this!");
|
||||
break;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove the index from the value array.
|
||||
// The array does not shrink until Compact() is invoked.
|
||||
|
@ -110,6 +110,8 @@ class NS_COM nsValueArray {
|
||||
|
||||
PRBool InsertValueAt(nsValueArrayValue aValue, nsValueArrayIndex aIndex);
|
||||
|
||||
PRBool ReplaceValueAt(nsValueArrayValue aValue, nsValueArrayIndex aIndex);
|
||||
|
||||
PRBool RemoveValueAt(nsValueArrayIndex aIndex);
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user