/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// XXX null terminate. this shouldn't be required, but we do it because // nsScanner erroneously thinks it can dereference DataEnd :-(
*buf->mDataEnd = char16_t(0); return buf;
}
void nsScannerBufferList::SplitBuffer(const Position& pos) { // splitting to the right keeps the work string and any extant token // pointing to and holding a reference count on the same buffer.
void nsScannerSubstring::Rebind(const nsScannerSubstring& aString, const nsScannerIterator& aStart, const nsScannerIterator& aEnd) { // allow for the case where &aString == this
iter.mPosition = mEnd.mPosition; // must not |normalize_backward| as that would likely invalidate tests like // |while ( first != last )| return iter;
}
bool nsScannerSubstring::GetNextFragment(nsScannerFragment& frag) const { // check to see if we are at the end of the buffer list if (frag.mBuffer == mEnd.mBuffer) returnfalse;
bool nsScannerSubstring::GetPrevFragment(nsScannerFragment& frag) const { // check to see if we are at the beginning of the buffer list if (frag.mBuffer == mStart.mBuffer) returnfalse;
void nsScannerString::UngetReadable(const nsAString& aReadable, const nsScannerIterator& aInsertPoint) /* * Warning: this routine manipulates the shared buffer list in an * unexpected way. The original design did not really allow for * insertions, but this call promises that if called for a point after the * end of all extant token strings, that no token string or the work string * will be invalidated. * * This routine is protected because it is the responsibility of the * derived class to keep those promises.
*/
{
Position insertPos(aInsertPoint);
mBufferList->SplitBuffer(insertPos); // splitting to the right keeps the work string and any extant token // pointing to and holding a reference count on the same buffer
Buffer* new_buffer = AllocBufferFromString(aReadable); // make a new buffer with all the data to insert... // ALERT: we may have empty space to re-use in the split buffer, // measure the cost of this and decide if we should do the work to fill // it
void nsScannerSharedSubstring::Rebind(const nsScannerIterator& aStart, const nsScannerIterator& aEnd) { // If the start and end positions are inside the same buffer, we must // acquire ownership of the buffer. If not, we can optimize by not holding // onto it.
void nsScannerSharedSubstring::ReleaseBuffer() {
NS_ASSERTION(mBufferList, "Should only be called with non-null mBufferList");
mBuffer->DecrementUsageCount();
mBufferList->DiscardUnreferencedPrefix(mBuffer);
mBufferList->Release();
}
/** * utils -- based on code from nsReadableUtils.cpp
*/
if (!aDest.SetLength(distance.value(), mozilla::fallible)) {
aDest.Truncate(); returnfalse; // out of memory
} auto writer = aDest.BeginWriting();
nsScannerIterator fromBegin(aSrcStart);
if (!aDest.SetLength(newLen.value(), mozilla::fallible)) returnfalse; // out of memory auto writer = aDest.BeginWriting();
std::advance(writer, oldLength);
nsScannerIterator fromBegin(aSrcStart);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.