fixing some bugs in the new parser string code; changing some names

This commit is contained in:
scc%mozilla.org 2000-09-09 11:31:04 +00:00
Родитель ea2b0fd9c3
Коммит 6c54834914
16 изменённых файлов: 143 добавлений и 45 удалений

Просмотреть файл

@ -47,7 +47,12 @@ class nsSharedBufferList
: public nsXXXBufferHandle<PRUnichar>
{
public:
Buffer( PRUnichar* aDataStart, PRUnichar* aDataEnd, PRUnichar* aStorageStart, PRUnichar* aStorageEnd ) : nsXXXBufferHandle<PRUnichar>(aDataStart, aDataEnd, aStorageStart, aStorageEnd) { }
Buffer( PRUnichar* aDataStart, PRUnichar* aDataEnd, PRUnichar* aStorageStart, PRUnichar* aStorageEnd, PRBool aIsSingleAllocation=PR_FALSE )
: nsXXXBufferHandle<PRUnichar>(aDataStart, aDataEnd, aStorageStart, aStorageEnd)
{
if ( aIsSingleAllocation )
mFlags |= kIsSingleAllocationWithBuffer;
}
Buffer* mPrev;
Buffer* mNext;
@ -57,12 +62,26 @@ class nsSharedBufferList
{
Buffer* mBuffer;
PRUnichar* mPosInBuffer;
Position() { }
Position( Buffer* aBuffer, PRUnichar* aPosInBuffer ) : mBuffer(aBuffer), mPosInBuffer(aPosInBuffer) { }
};
public:
nsSharedBufferList() : mFirstBuffer(0), mLastBuffer(0), mTotalDataLength(0) { }
nsSharedBufferList( Buffer* aBuffer = 0 )
: mFirstBuffer(aBuffer),
mLastBuffer(aBuffer),
mTotalDataLength(0)
{
if ( aBuffer )
{
aBuffer->mPrev = aBuffer->mNext = 0;
mTotalDataLength = aBuffer->DataLength();
}
}
virtual ~nsSharedBufferList();
private:
@ -75,7 +94,8 @@ class nsSharedBufferList
Buffer* UnlinkBuffer( Buffer* );
void SplitBuffer( const Position& );
static Buffer* NewBuffer( const PRUnichar*, PRUint32, PRUint32 = 0 );
static Buffer* NewSingleAllocationBuffer( const PRUnichar*, PRUint32, PRUint32 = 0 );
static Buffer* NewWrappingBuffer( PRUnichar*, PRUnichar*, PRUnichar* );
void DiscardSuffix( PRUint32 );
// need other discards: prefix, and by iterator or pointer or something

Просмотреть файл

@ -49,7 +49,7 @@ class nsSlidingSharedBufferList
: public nsSharedBufferList
{
public:
nsSlidingSharedBufferList() : mRefCount(0) { }
nsSlidingSharedBufferList( Buffer* aBuffer ) : nsSharedBufferList(aBuffer), mRefCount(0) { }
void AcquireReference() { ++mRefCount; }
void ReleaseReference() { if ( !--mRefCount ) delete this; }
@ -87,7 +87,8 @@ class nsSlidingSubstring
virtual const PRUnichar* GetReadableFragment( nsReadableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) const;
protected:
nsSharedBufferList::Position mStart, mEnd;
nsSharedBufferList::Position mStart;
nsSharedBufferList::Position mEnd;
nsSlidingSharedBufferList& mBufferList;
PRUint32 mLength;
};
@ -103,7 +104,7 @@ class nsSlidingString
: public nsSlidingSubstring
{
public:
nsSlidingString();
nsSlidingString( PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd );
// you are giving ownership to the string, it takes and keeps your buffer, deleting it when done
void AppendBuffer( PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd );

Просмотреть файл

@ -133,7 +133,7 @@ nsFragmentedString::SetLength( PRUint32 aNewLength )
else if ( aNewLength > mBufferList.GetDataLength() )
{
size_t empty_space_to_add = aNewLength - mBufferList.GetDataLength();
nsSharedBufferList::Buffer* new_buffer = nsSharedBufferList::NewBuffer(0, 0, empty_space_to_add);
nsSharedBufferList::Buffer* new_buffer = nsSharedBufferList::NewSingleAllocationBuffer(0, 0, empty_space_to_add);
new_buffer->DataEnd(new_buffer->DataStart()+empty_space_to_add);
mBufferList.LinkBuffer(mBufferList.GetLastBuffer(), new_buffer, 0);
}

Просмотреть файл

@ -49,7 +49,7 @@ nsSharedBufferList::~nsSharedBufferList()
nsSharedBufferList::Buffer*
nsSharedBufferList::NewBuffer( const PRUnichar* aData, PRUint32 aDataLength, PRUint32 aAdditionalSpace )
nsSharedBufferList::NewSingleAllocationBuffer( const PRUnichar* aData, PRUint32 aDataLength, PRUint32 aAdditionalSpace )
{
size_t object_size = ((sizeof(Buffer) + sizeof(PRUnichar) - 1) / sizeof(PRUnichar)) * sizeof(PRUnichar);
PRUint32 buffer_length = aDataLength + aAdditionalSpace;
@ -65,12 +65,18 @@ nsSharedBufferList::NewBuffer( const PRUnichar* aData, PRUint32 aDataLength, PRU
PRUnichar* toBegin = buffer_ptr;
copy_string(aData, aData+aDataLength, toBegin);
}
return new (object_ptr) Buffer(buffer_ptr, buffer_ptr+aDataLength, buffer_ptr, buffer_ptr+buffer_length);
return new (object_ptr) Buffer(buffer_ptr, buffer_ptr+aDataLength, buffer_ptr, buffer_ptr+buffer_length, PR_TRUE);
}
return 0;
}
nsSharedBufferList::Buffer*
nsSharedBufferList::NewWrappingBuffer( PRUnichar* aDataStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd )
{
return new Buffer(aDataStart, aDataEnd, aDataStart, aStorageEnd);
}
void
@ -108,13 +114,13 @@ nsSharedBufferList::SplitBuffer( const Position& aSplitPosition )
if ( (bufferToSplit->DataLength() >> 1) > splitOffset )
{
Buffer* new_buffer = NewBuffer(bufferToSplit->DataStart(), PRUint32(splitOffset));
Buffer* new_buffer = NewSingleAllocationBuffer(bufferToSplit->DataStart(), PRUint32(splitOffset));
LinkBuffer(bufferToSplit->mPrev, new_buffer, bufferToSplit);
bufferToSplit->DataStart(aSplitPosition.mPosInBuffer);
}
else
{
Buffer* new_buffer = NewBuffer(bufferToSplit->DataStart()+splitOffset, PRUint32(bufferToSplit->DataLength()-splitOffset));
Buffer* new_buffer = NewSingleAllocationBuffer(bufferToSplit->DataStart()+splitOffset, PRUint32(bufferToSplit->DataLength()-splitOffset));
LinkBuffer(bufferToSplit, new_buffer, bufferToSplit->mNext);
bufferToSplit->DataEnd(aSplitPosition.mPosInBuffer);
}

Просмотреть файл

@ -61,11 +61,13 @@ nsSlidingSubstring::nsSlidingSubstring( nsSlidingSharedBufferList& aBufferList,
}
nsSlidingSubstring::nsSlidingSubstring( nsSlidingSharedBufferList& aBufferList )
: /* mStart(aBufferList.First(), ...), mEnd(aEnd),*/ mBufferList(aBufferList)
: mBufferList(aBufferList)
{
mBufferList.AcquireReference();
// mStart, mEnd, mLength
mStart = nsSlidingSharedBufferList::Position(mBufferList.GetFirstBuffer(), mBufferList.GetFirstBuffer()->DataStart());
mEnd = nsSlidingSharedBufferList::Position(mBufferList.GetLastBuffer(), mBufferList.GetLastBuffer()->DataEnd());
mLength = PRUint32(Distance(mStart, mEnd));
}
nsSlidingSubstring::~nsSlidingSubstring()
@ -115,8 +117,8 @@ nsSlidingSubstring::GetReadableFragment( nsReadableFragment<PRUnichar>& aFragmen
nsSlidingString::nsSlidingString()
: nsSlidingSubstring(*(new nsSlidingSharedBufferList))
nsSlidingString::nsSlidingString( PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd )
: nsSlidingSubstring(*(new nsSlidingSharedBufferList(nsSlidingSharedBufferList::NewWrappingBuffer(aStorageStart, aDataEnd, aStorageEnd))))
{
// nothing else to do here
}

Просмотреть файл

@ -133,7 +133,7 @@ nsFragmentedString::SetLength( PRUint32 aNewLength )
else if ( aNewLength > mBufferList.GetDataLength() )
{
size_t empty_space_to_add = aNewLength - mBufferList.GetDataLength();
nsSharedBufferList::Buffer* new_buffer = nsSharedBufferList::NewBuffer(0, 0, empty_space_to_add);
nsSharedBufferList::Buffer* new_buffer = nsSharedBufferList::NewSingleAllocationBuffer(0, 0, empty_space_to_add);
new_buffer->DataEnd(new_buffer->DataStart()+empty_space_to_add);
mBufferList.LinkBuffer(mBufferList.GetLastBuffer(), new_buffer, 0);
}

Просмотреть файл

@ -49,7 +49,7 @@ nsSharedBufferList::~nsSharedBufferList()
nsSharedBufferList::Buffer*
nsSharedBufferList::NewBuffer( const PRUnichar* aData, PRUint32 aDataLength, PRUint32 aAdditionalSpace )
nsSharedBufferList::NewSingleAllocationBuffer( const PRUnichar* aData, PRUint32 aDataLength, PRUint32 aAdditionalSpace )
{
size_t object_size = ((sizeof(Buffer) + sizeof(PRUnichar) - 1) / sizeof(PRUnichar)) * sizeof(PRUnichar);
PRUint32 buffer_length = aDataLength + aAdditionalSpace;
@ -65,12 +65,18 @@ nsSharedBufferList::NewBuffer( const PRUnichar* aData, PRUint32 aDataLength, PRU
PRUnichar* toBegin = buffer_ptr;
copy_string(aData, aData+aDataLength, toBegin);
}
return new (object_ptr) Buffer(buffer_ptr, buffer_ptr+aDataLength, buffer_ptr, buffer_ptr+buffer_length);
return new (object_ptr) Buffer(buffer_ptr, buffer_ptr+aDataLength, buffer_ptr, buffer_ptr+buffer_length, PR_TRUE);
}
return 0;
}
nsSharedBufferList::Buffer*
nsSharedBufferList::NewWrappingBuffer( PRUnichar* aDataStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd )
{
return new Buffer(aDataStart, aDataEnd, aDataStart, aStorageEnd);
}
void
@ -108,13 +114,13 @@ nsSharedBufferList::SplitBuffer( const Position& aSplitPosition )
if ( (bufferToSplit->DataLength() >> 1) > splitOffset )
{
Buffer* new_buffer = NewBuffer(bufferToSplit->DataStart(), PRUint32(splitOffset));
Buffer* new_buffer = NewSingleAllocationBuffer(bufferToSplit->DataStart(), PRUint32(splitOffset));
LinkBuffer(bufferToSplit->mPrev, new_buffer, bufferToSplit);
bufferToSplit->DataStart(aSplitPosition.mPosInBuffer);
}
else
{
Buffer* new_buffer = NewBuffer(bufferToSplit->DataStart()+splitOffset, PRUint32(bufferToSplit->DataLength()-splitOffset));
Buffer* new_buffer = NewSingleAllocationBuffer(bufferToSplit->DataStart()+splitOffset, PRUint32(bufferToSplit->DataLength()-splitOffset));
LinkBuffer(bufferToSplit, new_buffer, bufferToSplit->mNext);
bufferToSplit->DataEnd(aSplitPosition.mPosInBuffer);
}

Просмотреть файл

@ -47,7 +47,12 @@ class nsSharedBufferList
: public nsXXXBufferHandle<PRUnichar>
{
public:
Buffer( PRUnichar* aDataStart, PRUnichar* aDataEnd, PRUnichar* aStorageStart, PRUnichar* aStorageEnd ) : nsXXXBufferHandle<PRUnichar>(aDataStart, aDataEnd, aStorageStart, aStorageEnd) { }
Buffer( PRUnichar* aDataStart, PRUnichar* aDataEnd, PRUnichar* aStorageStart, PRUnichar* aStorageEnd, PRBool aIsSingleAllocation=PR_FALSE )
: nsXXXBufferHandle<PRUnichar>(aDataStart, aDataEnd, aStorageStart, aStorageEnd)
{
if ( aIsSingleAllocation )
mFlags |= kIsSingleAllocationWithBuffer;
}
Buffer* mPrev;
Buffer* mNext;
@ -57,12 +62,26 @@ class nsSharedBufferList
{
Buffer* mBuffer;
PRUnichar* mPosInBuffer;
Position() { }
Position( Buffer* aBuffer, PRUnichar* aPosInBuffer ) : mBuffer(aBuffer), mPosInBuffer(aPosInBuffer) { }
};
public:
nsSharedBufferList() : mFirstBuffer(0), mLastBuffer(0), mTotalDataLength(0) { }
nsSharedBufferList( Buffer* aBuffer = 0 )
: mFirstBuffer(aBuffer),
mLastBuffer(aBuffer),
mTotalDataLength(0)
{
if ( aBuffer )
{
aBuffer->mPrev = aBuffer->mNext = 0;
mTotalDataLength = aBuffer->DataLength();
}
}
virtual ~nsSharedBufferList();
private:
@ -75,7 +94,8 @@ class nsSharedBufferList
Buffer* UnlinkBuffer( Buffer* );
void SplitBuffer( const Position& );
static Buffer* NewBuffer( const PRUnichar*, PRUint32, PRUint32 = 0 );
static Buffer* NewSingleAllocationBuffer( const PRUnichar*, PRUint32, PRUint32 = 0 );
static Buffer* NewWrappingBuffer( PRUnichar*, PRUnichar*, PRUnichar* );
void DiscardSuffix( PRUint32 );
// need other discards: prefix, and by iterator or pointer or something

Просмотреть файл

@ -61,11 +61,13 @@ nsSlidingSubstring::nsSlidingSubstring( nsSlidingSharedBufferList& aBufferList,
}
nsSlidingSubstring::nsSlidingSubstring( nsSlidingSharedBufferList& aBufferList )
: /* mStart(aBufferList.First(), ...), mEnd(aEnd),*/ mBufferList(aBufferList)
: mBufferList(aBufferList)
{
mBufferList.AcquireReference();
// mStart, mEnd, mLength
mStart = nsSlidingSharedBufferList::Position(mBufferList.GetFirstBuffer(), mBufferList.GetFirstBuffer()->DataStart());
mEnd = nsSlidingSharedBufferList::Position(mBufferList.GetLastBuffer(), mBufferList.GetLastBuffer()->DataEnd());
mLength = PRUint32(Distance(mStart, mEnd));
}
nsSlidingSubstring::~nsSlidingSubstring()
@ -115,8 +117,8 @@ nsSlidingSubstring::GetReadableFragment( nsReadableFragment<PRUnichar>& aFragmen
nsSlidingString::nsSlidingString()
: nsSlidingSubstring(*(new nsSlidingSharedBufferList))
nsSlidingString::nsSlidingString( PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd )
: nsSlidingSubstring(*(new nsSlidingSharedBufferList(nsSlidingSharedBufferList::NewWrappingBuffer(aStorageStart, aDataEnd, aStorageEnd))))
{
// nothing else to do here
}

Просмотреть файл

@ -49,7 +49,7 @@ class nsSlidingSharedBufferList
: public nsSharedBufferList
{
public:
nsSlidingSharedBufferList() : mRefCount(0) { }
nsSlidingSharedBufferList( Buffer* aBuffer ) : nsSharedBufferList(aBuffer), mRefCount(0) { }
void AcquireReference() { ++mRefCount; }
void ReleaseReference() { if ( !--mRefCount ) delete this; }
@ -87,7 +87,8 @@ class nsSlidingSubstring
virtual const PRUnichar* GetReadableFragment( nsReadableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) const;
protected:
nsSharedBufferList::Position mStart, mEnd;
nsSharedBufferList::Position mStart;
nsSharedBufferList::Position mEnd;
nsSlidingSharedBufferList& mBufferList;
PRUint32 mLength;
};
@ -103,7 +104,7 @@ class nsSlidingString
: public nsSlidingSubstring
{
public:
nsSlidingString();
nsSlidingString( PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd );
// you are giving ownership to the string, it takes and keeps your buffer, deleting it when done
void AppendBuffer( PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd );

Просмотреть файл

@ -47,7 +47,12 @@ class nsSharedBufferList
: public nsXXXBufferHandle<PRUnichar>
{
public:
Buffer( PRUnichar* aDataStart, PRUnichar* aDataEnd, PRUnichar* aStorageStart, PRUnichar* aStorageEnd ) : nsXXXBufferHandle<PRUnichar>(aDataStart, aDataEnd, aStorageStart, aStorageEnd) { }
Buffer( PRUnichar* aDataStart, PRUnichar* aDataEnd, PRUnichar* aStorageStart, PRUnichar* aStorageEnd, PRBool aIsSingleAllocation=PR_FALSE )
: nsXXXBufferHandle<PRUnichar>(aDataStart, aDataEnd, aStorageStart, aStorageEnd)
{
if ( aIsSingleAllocation )
mFlags |= kIsSingleAllocationWithBuffer;
}
Buffer* mPrev;
Buffer* mNext;
@ -57,12 +62,26 @@ class nsSharedBufferList
{
Buffer* mBuffer;
PRUnichar* mPosInBuffer;
Position() { }
Position( Buffer* aBuffer, PRUnichar* aPosInBuffer ) : mBuffer(aBuffer), mPosInBuffer(aPosInBuffer) { }
};
public:
nsSharedBufferList() : mFirstBuffer(0), mLastBuffer(0), mTotalDataLength(0) { }
nsSharedBufferList( Buffer* aBuffer = 0 )
: mFirstBuffer(aBuffer),
mLastBuffer(aBuffer),
mTotalDataLength(0)
{
if ( aBuffer )
{
aBuffer->mPrev = aBuffer->mNext = 0;
mTotalDataLength = aBuffer->DataLength();
}
}
virtual ~nsSharedBufferList();
private:
@ -75,7 +94,8 @@ class nsSharedBufferList
Buffer* UnlinkBuffer( Buffer* );
void SplitBuffer( const Position& );
static Buffer* NewBuffer( const PRUnichar*, PRUint32, PRUint32 = 0 );
static Buffer* NewSingleAllocationBuffer( const PRUnichar*, PRUint32, PRUint32 = 0 );
static Buffer* NewWrappingBuffer( PRUnichar*, PRUnichar*, PRUnichar* );
void DiscardSuffix( PRUint32 );
// need other discards: prefix, and by iterator or pointer or something

Просмотреть файл

@ -49,7 +49,7 @@ class nsSlidingSharedBufferList
: public nsSharedBufferList
{
public:
nsSlidingSharedBufferList() : mRefCount(0) { }
nsSlidingSharedBufferList( Buffer* aBuffer ) : nsSharedBufferList(aBuffer), mRefCount(0) { }
void AcquireReference() { ++mRefCount; }
void ReleaseReference() { if ( !--mRefCount ) delete this; }
@ -87,7 +87,8 @@ class nsSlidingSubstring
virtual const PRUnichar* GetReadableFragment( nsReadableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) const;
protected:
nsSharedBufferList::Position mStart, mEnd;
nsSharedBufferList::Position mStart;
nsSharedBufferList::Position mEnd;
nsSlidingSharedBufferList& mBufferList;
PRUint32 mLength;
};
@ -103,7 +104,7 @@ class nsSlidingString
: public nsSlidingSubstring
{
public:
nsSlidingString();
nsSlidingString( PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd );
// you are giving ownership to the string, it takes and keeps your buffer, deleting it when done
void AppendBuffer( PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd );

Просмотреть файл

@ -133,7 +133,7 @@ nsFragmentedString::SetLength( PRUint32 aNewLength )
else if ( aNewLength > mBufferList.GetDataLength() )
{
size_t empty_space_to_add = aNewLength - mBufferList.GetDataLength();
nsSharedBufferList::Buffer* new_buffer = nsSharedBufferList::NewBuffer(0, 0, empty_space_to_add);
nsSharedBufferList::Buffer* new_buffer = nsSharedBufferList::NewSingleAllocationBuffer(0, 0, empty_space_to_add);
new_buffer->DataEnd(new_buffer->DataStart()+empty_space_to_add);
mBufferList.LinkBuffer(mBufferList.GetLastBuffer(), new_buffer, 0);
}

Просмотреть файл

@ -49,7 +49,7 @@ nsSharedBufferList::~nsSharedBufferList()
nsSharedBufferList::Buffer*
nsSharedBufferList::NewBuffer( const PRUnichar* aData, PRUint32 aDataLength, PRUint32 aAdditionalSpace )
nsSharedBufferList::NewSingleAllocationBuffer( const PRUnichar* aData, PRUint32 aDataLength, PRUint32 aAdditionalSpace )
{
size_t object_size = ((sizeof(Buffer) + sizeof(PRUnichar) - 1) / sizeof(PRUnichar)) * sizeof(PRUnichar);
PRUint32 buffer_length = aDataLength + aAdditionalSpace;
@ -65,12 +65,18 @@ nsSharedBufferList::NewBuffer( const PRUnichar* aData, PRUint32 aDataLength, PRU
PRUnichar* toBegin = buffer_ptr;
copy_string(aData, aData+aDataLength, toBegin);
}
return new (object_ptr) Buffer(buffer_ptr, buffer_ptr+aDataLength, buffer_ptr, buffer_ptr+buffer_length);
return new (object_ptr) Buffer(buffer_ptr, buffer_ptr+aDataLength, buffer_ptr, buffer_ptr+buffer_length, PR_TRUE);
}
return 0;
}
nsSharedBufferList::Buffer*
nsSharedBufferList::NewWrappingBuffer( PRUnichar* aDataStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd )
{
return new Buffer(aDataStart, aDataEnd, aDataStart, aStorageEnd);
}
void
@ -108,13 +114,13 @@ nsSharedBufferList::SplitBuffer( const Position& aSplitPosition )
if ( (bufferToSplit->DataLength() >> 1) > splitOffset )
{
Buffer* new_buffer = NewBuffer(bufferToSplit->DataStart(), PRUint32(splitOffset));
Buffer* new_buffer = NewSingleAllocationBuffer(bufferToSplit->DataStart(), PRUint32(splitOffset));
LinkBuffer(bufferToSplit->mPrev, new_buffer, bufferToSplit);
bufferToSplit->DataStart(aSplitPosition.mPosInBuffer);
}
else
{
Buffer* new_buffer = NewBuffer(bufferToSplit->DataStart()+splitOffset, PRUint32(bufferToSplit->DataLength()-splitOffset));
Buffer* new_buffer = NewSingleAllocationBuffer(bufferToSplit->DataStart()+splitOffset, PRUint32(bufferToSplit->DataLength()-splitOffset));
LinkBuffer(bufferToSplit, new_buffer, bufferToSplit->mNext);
bufferToSplit->DataEnd(aSplitPosition.mPosInBuffer);
}

Просмотреть файл

@ -61,11 +61,13 @@ nsSlidingSubstring::nsSlidingSubstring( nsSlidingSharedBufferList& aBufferList,
}
nsSlidingSubstring::nsSlidingSubstring( nsSlidingSharedBufferList& aBufferList )
: /* mStart(aBufferList.First(), ...), mEnd(aEnd),*/ mBufferList(aBufferList)
: mBufferList(aBufferList)
{
mBufferList.AcquireReference();
// mStart, mEnd, mLength
mStart = nsSlidingSharedBufferList::Position(mBufferList.GetFirstBuffer(), mBufferList.GetFirstBuffer()->DataStart());
mEnd = nsSlidingSharedBufferList::Position(mBufferList.GetLastBuffer(), mBufferList.GetLastBuffer()->DataEnd());
mLength = PRUint32(Distance(mStart, mEnd));
}
nsSlidingSubstring::~nsSlidingSubstring()
@ -115,8 +117,8 @@ nsSlidingSubstring::GetReadableFragment( nsReadableFragment<PRUnichar>& aFragmen
nsSlidingString::nsSlidingString()
: nsSlidingSubstring(*(new nsSlidingSharedBufferList))
nsSlidingString::nsSlidingString( PRUnichar* aStorageStart, PRUnichar* aDataEnd, PRUnichar* aStorageEnd )
: nsSlidingSubstring(*(new nsSlidingSharedBufferList(nsSlidingSharedBufferList::NewWrappingBuffer(aStorageStart, aDataEnd, aStorageEnd))))
{
// nothing else to do here
}

Просмотреть файл

@ -8,6 +8,7 @@
#include "nsSharedString.h"
#include "nsFragmentedString.h"
#include "nsReadableUtils.h"
#include "nsSlidingString.h"
#ifdef TEST_STD_STRING
#include "nsStdStringWrapper.h"
@ -436,6 +437,16 @@ main()
}
#endif
{
NS_NAMED_LITERAL_STRING(literal, "Hello");
PRUnichar* buffer = ToNewUnicode(literal);
nsSlidingString ss0(buffer, buffer+5, buffer+6);
// ss0.AppendBuffer(buffer, buffer+5, buffer+6);
tests_failed += test_readable_hello(ss0);
}
{
nsLiteralCString s0("Patrick Beard made me write this: \"This is just a test\"\n");