diff --git a/core/abstractbytearraymodel.h b/core/abstractbytearraymodel.h --- a/core/abstractbytearraymodel.h +++ b/core/abstractbytearraymodel.h @@ -144,7 +144,7 @@ * @param insertLength number of bytes to copy * @return length of inserted data */ - virtual Size insert(Address offset, const Byte* insertData, int insertLength); + virtual Size insert(Address offset, const Byte* insertData, Size insertLength); Size insert(Address offset, const QByteArray& insertData); /** removes beginning with position as much as possible @@ -161,7 +161,7 @@ * @param insertLength * @return length of inserted data */ - virtual Size replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) = 0; + virtual Size replace(const AddressRange& removeRange, const Byte* insertData, Size insertLength) = 0; /** convenience function, behaves as above */ Size replace(const AddressRange& removeRange, const QByteArray& insertData); /** convenience function, behaves as above */ @@ -223,7 +223,7 @@ * @param fromOffset the position to start the search * @return index of the first or -1 */ - virtual Address indexOf(const Byte* pattern, int patternLength, Address fromOffset = 0, Address toOffset = -1) const; + virtual Address indexOf(const Byte* pattern, Size patternLength, Address fromOffset = 0, Address toOffset = -1) const; Address indexOf(const QByteArray& pattern, Address fromOffset = 0, Address toOffset = -1) const; Address indexOfCaseInsensitive(const CharCodec* charCodec, const QByteArray& pattern, Address fromOffset = 0, Address toOffset = -1) const; @@ -242,7 +242,7 @@ * @param fromOffset the position to start the search. If -1 the search starts at the end. * @return index of the first or -1 */ - virtual Address lastIndexOf(const Byte* pattern, int patternLength, Address fromOffset = -1, Address toOffset = 0) const; + virtual Address lastIndexOf(const Byte* pattern, Size patternLength, Address fromOffset = -1, Address toOffset = 0) const; Address lastIndexOf(const QByteArray& pattern, Address fromOffset = -1, Address toOffset = 0) const; Address lastIndexOfCaseInsensitive(const CharCodec* charCodec, const QByteArray& pattern, Address fromOffset = -1, Address toOffset = 0) const; diff --git a/core/abstractbytearraymodel.cpp b/core/abstractbytearraymodel.cpp --- a/core/abstractbytearraymodel.cpp +++ b/core/abstractbytearraymodel.cpp @@ -43,7 +43,7 @@ Q_UNUSED(isReadOnly) } -Size AbstractByteArrayModel::insert(Address offset, const Byte* insertData, int insertLength) +Size AbstractByteArrayModel::insert(Address offset, const Byte* insertData, Size insertLength) { return replace(offset, 0, insertData, insertLength); } @@ -67,7 +67,7 @@ return copyRange.width(); } -Address AbstractByteArrayModel::indexOf(const Byte* pattern, int patternLength, Address fromOffset, Address toOffset) const +Address AbstractByteArrayModel::indexOf(const Byte* pattern, Size patternLength, Address fromOffset, Address toOffset) const { Address result = -1; @@ -76,7 +76,7 @@ Size nextSignalByteCount = fromOffset + SearchedByteCountSignalLimit; for (Address i = fromOffset; i <= lastFrom; ++i) { - int c = 0; + Size c = 0; for (; c < patternLength; ++c) { if (pattern[c] != byte(i + c)) { break; @@ -97,7 +97,7 @@ return result; } -Address AbstractByteArrayModel::lastIndexOf(const Byte* pattern, int patternLength, Address fromOffset, Address toOffset) const +Address AbstractByteArrayModel::lastIndexOf(const Byte* pattern, Size patternLength, Address fromOffset, Address toOffset) const { Address result = -1; @@ -116,7 +116,7 @@ Size nextSignalByteCount = fromOffset - SearchedByteCountSignalLimit; for (Address i = fromOffset; i >= toOffset; --i) { - int c = 0; + Size c = 0; for (; c < patternLength; ++c) { if (pattern[c] != byte(i + c)) { break; diff --git a/core/address.h b/core/address.h --- a/core/address.h +++ b/core/address.h @@ -28,8 +28,7 @@ namespace Okteta { -// Address needs to be <= int, as long as we use QByteArray and its int parameters -using Address = qint32; +using Address = qint64; } diff --git a/core/arraychangemetrics.h b/core/arraychangemetrics.h --- a/core/arraychangemetrics.h +++ b/core/arraychangemetrics.h @@ -59,7 +59,7 @@ public: ArrayChangeMetrics(); - ArrayChangeMetrics(Type type, Address offset, qint32 secondArgument, qint32 thirdArgument); + ArrayChangeMetrics(Type type, Address offset, qint64 secondArgument, qint64 thirdArgument); public: bool operator==(const ArrayChangeMetrics& other) const; @@ -89,13 +89,13 @@ // TODO: how to make the arguments of the size of the largest union member? union { - qint32 mSecondArgument = 0; + qint64 mSecondArgument = 0; Size mRemoveLength; Address mSecondStart; }; union { - qint32 mThirdArgument = 0; + qint64 mThirdArgument = 0; Size mInsertLength; Size mSecondLength; }; @@ -112,7 +112,7 @@ return {Swapping, firstOffset, secondOffset, secondLength}; } -inline ArrayChangeMetrics::ArrayChangeMetrics(Type type, Address offset, qint32 secondArgument, qint32 thirdArgument) +inline ArrayChangeMetrics::ArrayChangeMetrics(Type type, Address offset, qint64 secondArgument, qint64 thirdArgument) : mType(type) , mOffset(offset) , mSecondArgument(secondArgument) diff --git a/core/bookmarkable.h b/core/bookmarkable.h --- a/core/bookmarkable.h +++ b/core/bookmarkable.h @@ -23,6 +23,8 @@ #ifndef OKTETA_BOOKMARKABLE_H #define OKTETA_BOOKMARKABLE_H +#include +#include // Qt #include @@ -49,8 +51,8 @@ virtual Okteta::BookmarksConstIterator createBookmarksConstIterator() const = 0; // virtual BookmarksMutableIterator createBookmarksMutableIterator() const = 0; virtual const Okteta::Bookmark& bookmarkAt(unsigned int index) const = 0; - virtual const Okteta::Bookmark& bookmarkFor(int offset) const = 0; - virtual bool containsBookmarkFor(int offset) const = 0; + virtual const Okteta::Bookmark& bookmarkFor(Okteta::Address offset) const = 0; + virtual bool containsBookmarkFor(Okteta::Address offset) const = 0; virtual unsigned int bookmarksCount() const = 0; public: // signal diff --git a/core/bytearraymodel.h b/core/bytearraymodel.h --- a/core/bytearraymodel.h +++ b/core/bytearraymodel.h @@ -59,9 +59,9 @@ bool isReadOnly() const override; bool isModified() const override; - Size insert(Address offset, const Byte* insertData, int insertLength) override; + Size insert(Address offset, const Byte* insertData, Size insertLength) override; Size remove(const AddressRange& removeRange) override; - Size replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) override; + Size replace(const AddressRange& removeRange, const Byte* insertData, Size insertLength) override; bool swap(Address firstStart, const AddressRange& secondRange) override; Size fill(Byte fillByte, Address offset = 0, Size fillLength = -1) override; void setByte(Address offset, Byte byte) override; @@ -77,8 +77,8 @@ Okteta::BookmarksConstIterator createBookmarksConstIterator() const override; const Okteta::Bookmark& bookmarkAt(unsigned int index) const override; - const Okteta::Bookmark& bookmarkFor(int offset) const override; - bool containsBookmarkFor(int offset) const override; + const Okteta::Bookmark& bookmarkFor(Okteta::Address offset) const override; + bool containsBookmarkFor(Okteta::Address offset) const override; unsigned int bookmarksCount() const override; Q_SIGNALS: // Okteta::Bookmarkable API diff --git a/core/bytearraymodel.cpp b/core/bytearraymodel.cpp --- a/core/bytearraymodel.cpp +++ b/core/bytearraymodel.cpp @@ -81,7 +81,7 @@ d->setByte(offset, byte); } -Size ByteArrayModel::insert(Address offset, const Byte* insertData, int insertLength) +Size ByteArrayModel::insert(Address offset, const Byte* insertData, Size insertLength) { return d->insert(offset, insertData, insertLength); } @@ -91,7 +91,7 @@ return d->remove(removeRange); } -Size ByteArrayModel::replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) +Size ByteArrayModel::replace(const AddressRange& removeRange, const Byte* insertData, Size insertLength) { return d->replace(removeRange, insertData, insertLength); } @@ -131,7 +131,7 @@ return d->createBookmarksConstIterator(); } -const Okteta::Bookmark& ByteArrayModel::bookmarkFor(int offset) const +const Okteta::Bookmark& ByteArrayModel::bookmarkFor(Address offset) const { return d->bookmarkFor(offset); } @@ -141,7 +141,7 @@ return d->bookmarkAt(index); } -bool ByteArrayModel::containsBookmarkFor(int offset) const +bool ByteArrayModel::containsBookmarkFor(Address offset) const { return d->containsBookmarkFor(offset); } diff --git a/core/changesdatastorage.h b/core/changesdatastorage.h --- a/core/changesdatastorage.h +++ b/core/changesdatastorage.h @@ -23,6 +23,8 @@ #ifndef OKTETA_CHANGESDATASTORAGE_H #define OKTETA_CHANGESDATASTORAGE_H +#include +#include // Qt #include @@ -34,15 +36,15 @@ ChangesDataStorage(); public: // set/action - void append(int from, char byte); - void append(int from, const char* data, int dataLength); - void appendFill(int from, char fillDatum, int fillLength); + void append(Address from, char byte); + void append(Address from, const char* data, Size dataLength); + void appendFill(Address from, char fillDatum, Size fillLength); void clear(); public: // get - QByteArray data(int offset, int length) const; - char operator[](int offset) const; + QByteArray data(Address offset, Size length) const; + char operator[](Address offset) const; protected: QByteArray mData; @@ -50,28 +52,28 @@ inline ChangesDataStorage::ChangesDataStorage() = default; -inline QByteArray ChangesDataStorage::data(int offset, int length) const +inline QByteArray ChangesDataStorage::data(Address offset, Size length) const { return mData.mid(offset, length); } -inline char ChangesDataStorage::operator[](int offset) const { return mData[offset]; } +inline char ChangesDataStorage::operator[](Address offset) const { return mData[(int)offset]; } inline void ChangesDataStorage::clear() { mData.clear(); } -inline void ChangesDataStorage::append(int from, char datum) +inline void ChangesDataStorage::append(Address from, char datum) { mData.resize(from); mData.append(datum); } -inline void ChangesDataStorage::append(int from, const char* data, int dataLength) +inline void ChangesDataStorage::append(Address from, const char* data, Size dataLength) { mData.resize(from + dataLength); memcpy(mData.data() + from, data, dataLength); } -inline void ChangesDataStorage::appendFill(int from, char fillDatum, int fillLength) +inline void ChangesDataStorage::appendFill(Address from, char fillDatum, Size fillLength) { mData.resize(from + fillLength); memset(mData.data() + from, fillDatum, fillLength); diff --git a/core/filebytearraymodel.h b/core/filebytearraymodel.h --- a/core/filebytearraymodel.h +++ b/core/filebytearraymodel.h @@ -51,9 +51,9 @@ bool isReadOnly() const override; bool isModified() const override; - Size insert(Address offset, const Byte* insertData, int insertLength) override; + Size insert(Address offset, const Byte* insertData, Size insertLength) override; Size remove(const AddressRange& removeRange) override; - Size replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) override; + Size replace(const AddressRange& removeRange, const Byte* insertData, Size insertLength) override; bool swap(Address firstStart, const AddressRange& secondRange) override; Size fill(Byte fillByte, Address offset = 0, Size fillLength = -1) override; void setByte(Address offset, Byte byte) override; diff --git a/core/filebytearraymodel.cpp b/core/filebytearraymodel.cpp --- a/core/filebytearraymodel.cpp +++ b/core/filebytearraymodel.cpp @@ -50,9 +50,9 @@ void FileByteArrayModel::setByte(Address, Byte) {} Byte FileByteArrayModel::byte(Address offset) const { return d->byte(offset); } -Size FileByteArrayModel::insert(Address /*Pos*/, const Byte*, int /*Length*/) { return 0; } +Size FileByteArrayModel::insert(Address /*Pos*/, const Byte*, Size /*Length*/) { return 0; } Size FileByteArrayModel::remove(const AddressRange& /*Section*/) { return 0; } -Size FileByteArrayModel::replace(const AddressRange& /*Section*/, const Byte*, int /*Length*/) { return 0; } +Size FileByteArrayModel::replace(const AddressRange& /*Section*/, const Byte*, Size /*Length*/) { return 0; } Size FileByteArrayModel::fill(Byte /*FillChar*/, Address /*Pos*/, Size /*Length*/) { return 0; } bool FileByteArrayModel::swap(Address /*DestPos*/, const AddressRange& /*SourceSection*/) { return false; } diff --git a/core/filebytearraymodel_p.h b/core/filebytearraymodel_p.h --- a/core/filebytearraymodel_p.h +++ b/core/filebytearraymodel_p.h @@ -76,7 +76,7 @@ /** */ mutable KPageOfChar mData; /** */ - int mSize = 0; + Size mSize = 0; /** current offset */ mutable unsigned int mOffsetOfActualPage; diff --git a/core/filebytearraymodel_p.cpp b/core/filebytearraymodel_p.cpp --- a/core/filebytearraymodel_p.cpp +++ b/core/filebytearraymodel_p.cpp @@ -73,7 +73,7 @@ return false; } - int fileSize = mFile.size(); + const qint64 fileSize = mFile.size(); mSize = fileSize; // calculate necessary number of pages diff --git a/core/fixedsizebytearraymodel.h b/core/fixedsizebytearraymodel.h --- a/core/fixedsizebytearraymodel.h +++ b/core/fixedsizebytearraymodel.h @@ -40,9 +40,9 @@ public: /** creates a readonly buffer around the given data */ - FixedSizeByteArrayModel(Byte* data, int size, Byte fillUpChar = '\0', QObject* parent = nullptr); + FixedSizeByteArrayModel(Byte* data, Size size, Byte fillUpChar = '\0', QObject* parent = nullptr); /** creates a writeable buffer which is deleted at the end */ - explicit FixedSizeByteArrayModel(int size, Byte fillUpChar = '\0', QObject* parent = nullptr); + explicit FixedSizeByteArrayModel(Size size, Byte fillUpChar = '\0', QObject* parent = nullptr); ~FixedSizeByteArrayModel() override; @@ -52,9 +52,9 @@ bool isReadOnly() const override; bool isModified() const override; - Size insert(Address offset, const Byte* insertData, int insertLength) override; + Size insert(Address offset, const Byte* insertData, Size insertLength) override; Size remove(const AddressRange& removeRange) override; - Size replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) override; + Size replace(const AddressRange& removeRange, const Byte* insertData, Size insertLength) override; bool swap(Address firstStart, const AddressRange& secondRange) override; Size fill(Byte fillByte, Address offset = 0, Size fillLength = -1) override; void setByte(Address offset, Byte byte) override; @@ -71,13 +71,13 @@ Byte* rawData() const; protected: - void reset(unsigned int pos, unsigned int length); + void reset(Address pos, Size length); protected: /** */ Byte* mData; /***/ - int mSize; + Size mSize; /** */ Byte mFillUpByte; /** */ diff --git a/core/fixedsizebytearraymodel.cpp b/core/fixedsizebytearraymodel.cpp --- a/core/fixedsizebytearraymodel.cpp +++ b/core/fixedsizebytearraymodel.cpp @@ -29,7 +29,7 @@ namespace Okteta { -FixedSizeByteArrayModel::FixedSizeByteArrayModel(Byte* data, int size, Byte fillUpByte, QObject* parent) +FixedSizeByteArrayModel::FixedSizeByteArrayModel(Byte* data, Size size, Byte fillUpByte, QObject* parent) : AbstractByteArrayModel(parent) , mData(data) , mSize(size) @@ -40,7 +40,7 @@ { } -FixedSizeByteArrayModel::FixedSizeByteArrayModel(int size, Byte fillUpByte, QObject* parent) +FixedSizeByteArrayModel::FixedSizeByteArrayModel(Size size, Byte fillUpByte, QObject* parent) : AbstractByteArrayModel(parent) , mData(new Byte[size]) , mSize(size) @@ -72,7 +72,7 @@ } } -Size FixedSizeByteArrayModel::insert(Address offset, const Byte* insertData, int insertLength) +Size FixedSizeByteArrayModel::insert(Address offset, const Byte* insertData, Size insertLength) { // check all parameters if (offset >= mSize || insertLength == 0) { @@ -131,7 +131,7 @@ return removeLength; } -Size FixedSizeByteArrayModel::replace(const AddressRange& _removeRange, const Byte* insertData, int insertLength) +Size FixedSizeByteArrayModel::replace(const AddressRange& _removeRange, const Byte* insertData, Size insertLength) { AddressRange removeRange(_removeRange); // check all parameters @@ -329,7 +329,7 @@ return valueByLength; } -void FixedSizeByteArrayModel::reset(unsigned int offset, unsigned int length) +void FixedSizeByteArrayModel::reset(Address offset, Size length) { memset(&mData[offset], mFillUpByte, length); } diff --git a/core/piecetable/tests/revertablepiecetabletest.cpp b/core/piecetable/tests/revertablepiecetabletest.cpp --- a/core/piecetable/tests/revertablepiecetabletest.cpp +++ b/core/piecetable/tests/revertablepiecetabletest.cpp @@ -54,7 +54,7 @@ pieceTable.init(BaseSize); int storageId; - int storageOffset; + Address storageOffset; QCOMPARE(pieceTable.size(), BaseSize); QCOMPARE(pieceTable.changesCount(), 0); @@ -86,7 +86,7 @@ static void fillWithSize(RevertablePieceTable* pieceTable, int count) { - int dummy; + Size dummy; pieceTable->init(0); for (int i = 0; i < count; ++i) { pieceTable->insert(0, BaseSize, &dummy); @@ -98,7 +98,7 @@ RevertablePieceTable pieceTable; int storageId; - int storageOffset; + Address storageOffset; bool result; // inserting to empty @@ -465,7 +465,7 @@ int changeStarts[6]; int storageId; - int storageOffset; + Address storageOffset; bool result; // removing at begin @@ -862,7 +862,7 @@ RevertablePieceTable pieceTable; int storageId; - int storageOffset; + Address storageOffset; bool result; // moving end at begin diff --git a/core/piecetable/tests/testpiecetablechange.h b/core/piecetable/tests/testpiecetablechange.h --- a/core/piecetable/tests/testpiecetablechange.h +++ b/core/piecetable/tests/testpiecetablechange.h @@ -35,8 +35,8 @@ { public: TestPieceTableChange(int typeId = -1, const QString& description = QString(), - int position = 0, int storagePosition = 0, int storageId = Piece::ChangeStorage, - int replacedStoragePosition = 0, int replacedStorageId = Piece::ChangeStorage); + Address position = 0, Address storagePosition = 0, int storageId = Piece::ChangeStorage, + Address replacedStoragePosition = 0, int replacedStorageId = Piece::ChangeStorage); ~TestPieceTableChange() override; @@ -47,22 +47,22 @@ AddressRange apply(PieceTable* pieceTable) const override; AddressRange revert(PieceTable* pieceTable) const override; ArrayChangeMetrics metrics() const override; - int dataSize() const override; + Size dataSize() const override; protected: int mTypeId; QString mDescription; - int mPosition; - int mStoragePosition; + Address mPosition; + Address mStoragePosition; int mStorageId; - int mReplacedStoragePosition; + Address mReplacedStoragePosition; int mReplacedStorageId; }; inline TestPieceTableChange::TestPieceTableChange(int typeId, const QString& description, - int position, int storagePosition, int storageId, - int replacedStoragePosition, int replacedStorageId) + Address position, Address storagePosition, int storageId, + Address replacedStoragePosition, int replacedStorageId) : mTypeId(typeId) , mDescription(description) , mPosition(position) diff --git a/core/piecetable/tests/testpiecetablechange.cpp b/core/piecetable/tests/testpiecetablechange.cpp --- a/core/piecetable/tests/testpiecetablechange.cpp +++ b/core/piecetable/tests/testpiecetablechange.cpp @@ -70,6 +70,6 @@ return ArrayChangeMetrics::asReplacement(mPosition, 1, 1); } -int TestPieceTableChange::dataSize() const { return 1; } +Size TestPieceTableChange::dataSize() const { return 1; } } diff --git a/core/piecetablebytearraymodel.h b/core/piecetablebytearraymodel.h --- a/core/piecetablebytearraymodel.h +++ b/core/piecetablebytearraymodel.h @@ -66,9 +66,9 @@ bool isReadOnly() const override; bool isModified() const override; - Size insert(Address offset, const Byte* insertData, int insertLength) override; + Size insert(Address offset, const Byte* insertData, Size insertLength) override; Size remove(const AddressRange& removeRange) override; - Size replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) override; + Size replace(const AddressRange& removeRange, const Byte* insertData, Size insertLength) override; bool swap(Address firstStart, const AddressRange& secondRange) override; Size fill(Byte fillByte, Address offset = 0, Size fillLength = -1) override; void setByte(Address offset, Byte byte) override; @@ -95,8 +95,8 @@ Okteta::BookmarksConstIterator createBookmarksConstIterator() const override; const Okteta::Bookmark& bookmarkAt(unsigned int index) const override; - const Okteta::Bookmark& bookmarkFor(int offset) const override; - bool containsBookmarkFor(int offset) const override; + const Okteta::Bookmark& bookmarkFor(Address offset) const override; + bool containsBookmarkFor(Address offset) const override; unsigned int bookmarksCount() const override; public: // ChangesDescribable API diff --git a/core/piecetablebytearraymodel.cpp b/core/piecetablebytearraymodel.cpp --- a/core/piecetablebytearraymodel.cpp +++ b/core/piecetablebytearraymodel.cpp @@ -60,7 +60,7 @@ d->setByte(offset, byte); } -Size PieceTableByteArrayModel::insert(Address offset, const Byte* insertData, int insertLength) +Size PieceTableByteArrayModel::insert(Address offset, const Byte* insertData, Size insertLength) { return d->insert(offset, insertData, insertLength); } @@ -70,7 +70,7 @@ return d->remove(removeRange); } -Size PieceTableByteArrayModel::replace(const AddressRange& removeRange, const Byte* insertData, int insertLength) +Size PieceTableByteArrayModel::replace(const AddressRange& removeRange, const Byte* insertData, Size insertLength) { return d->replace(removeRange, insertData, insertLength); } @@ -132,12 +132,12 @@ return d->bookmarkAt(index); } -const Okteta::Bookmark& PieceTableByteArrayModel::bookmarkFor(int offset) const +const Okteta::Bookmark& PieceTableByteArrayModel::bookmarkFor(Address offset) const { return d->bookmarkFor(offset); } -bool PieceTableByteArrayModel::containsBookmarkFor(int offset) const +bool PieceTableByteArrayModel::containsBookmarkFor(Address offset) const { return d->containsBookmarkFor(offset); } diff --git a/core/piecetablebytearraymodel_p.h b/core/piecetablebytearraymodel_p.h --- a/core/piecetablebytearraymodel_p.h +++ b/core/piecetablebytearraymodel_p.h @@ -41,7 +41,7 @@ /** */ explicit PieceTableByteArrayModelPrivate(PieceTableByteArrayModel* parent, const QByteArray& data); /** creates a writeable buffer which is deleted at the end */ - explicit PieceTableByteArrayModelPrivate(PieceTableByteArrayModel* parent, int size, Byte fillByte = '\0'); + explicit PieceTableByteArrayModelPrivate(PieceTableByteArrayModel* parent, Size size, Byte fillByte = '\0'); PieceTableByteArrayModelPrivate() = delete; ~PieceTableByteArrayModelPrivate(); @@ -52,9 +52,9 @@ bool isReadOnly() const; bool isModified() const; - Size insert(Address offset, const Byte* insertData, int insertLength); + Size insert(Address offset, const Byte* insertData, Size insertLength); Size remove(const AddressRange& removeRange); - Size replace(const AddressRange& removeRange, const Byte* insertData, int insertLength); + Size replace(const AddressRange& removeRange, const Byte* insertData, Size insertLength); bool swap(Address firstStart, const AddressRange& secondRange); Size fill(Byte fillByte, Address offset = 0, Size fillLength = -1); void setByte(Address offset, Byte byte); @@ -78,8 +78,8 @@ BookmarksConstIterator createBookmarksConstIterator() const; const Bookmark& bookmarkAt(unsigned int index) const; - const Bookmark& bookmarkFor(int offset) const; - bool containsBookmarkFor(int offset) const; + const Bookmark& bookmarkFor(Address offset) const; + bool containsBookmarkFor(Address offset) const; unsigned int bookmarksCount() const; public: // ChangesDescribable API @@ -97,12 +97,12 @@ void setData(const QByteArray& data); protected: - void doInsertChange(Address offset, const Byte* insertData, int insertLength); + void doInsertChange(Address offset, const Byte* insertData, Size insertLength); void doRemoveChange(const AddressRange& removeRange); - void doReplaceChange(const AddressRange& removeRange, const Byte* insertData, int insertLength); + void doReplaceChange(const AddressRange& removeRange, const Byte* insertData, Size insertLength); void doSwapChange(Address firstStart, const AddressRange& secondRange); void doFillChange(Address offset, Size filledLength, - Byte fillByte, int fillLength); + Byte fillByte, Size fillLength); void beginChanges(); void endChanges(); @@ -190,11 +190,11 @@ { return mBookmarks.at(index); } -inline const Bookmark& PieceTableByteArrayModelPrivate::bookmarkFor(int offset) const +inline const Bookmark& PieceTableByteArrayModelPrivate::bookmarkFor(Address offset) const { return mBookmarks.bookmark(offset); } -inline bool PieceTableByteArrayModelPrivate::containsBookmarkFor(int offset) const { return mBookmarks.contains(offset); } +inline bool PieceTableByteArrayModelPrivate::containsBookmarkFor(Address offset) const { return mBookmarks.contains(offset); } inline unsigned int PieceTableByteArrayModelPrivate::bookmarksCount() const { return mBookmarks.size(); } } diff --git a/core/piecetablebytearraymodel_p.cpp b/core/piecetablebytearraymodel_p.cpp --- a/core/piecetablebytearraymodel_p.cpp +++ b/core/piecetablebytearraymodel_p.cpp @@ -38,7 +38,7 @@ mPieceTable.init(data.size()); } -PieceTableByteArrayModelPrivate::PieceTableByteArrayModelPrivate(PieceTableByteArrayModel* parent, int size, Byte fillByte) +PieceTableByteArrayModelPrivate::PieceTableByteArrayModelPrivate(PieceTableByteArrayModel* parent, Size size, Byte fillByte) : p(parent) , mReadOnly(false) , mInitialData(size, fillByte) @@ -56,14 +56,14 @@ mPieceTable.getStorageData(&storageId, &storageOffset, offset); const Byte result = (storageId == KPieceTable::Piece::OriginalStorage) ? - mInitialData[storageOffset] : + mInitialData[(int)storageOffset] : mChangesDataStorage[storageOffset]; return result; } void PieceTableByteArrayModelPrivate::setData(const QByteArray& data) { - const int oldSize = mPieceTable.size(); + const Size oldSize = mPieceTable.size(); const bool wasModifiedBefore = isModified(); const QList bookmarks = mBookmarks.list(); @@ -115,10 +115,10 @@ } } -Size PieceTableByteArrayModelPrivate::insert(Address offset, const Byte* insertData, int insertLength) +Size PieceTableByteArrayModelPrivate::insert(Address offset, const Byte* insertData, Size insertLength) { // correct parameters - const int oldSize = mPieceTable.size(); + const Size oldSize = mPieceTable.size(); if (offset > oldSize) { offset = oldSize; } @@ -141,7 +141,7 @@ { AddressRange removeRange(_removeRange); // correct parameters - const int oldSize = mPieceTable.size(); + const Size oldSize = mPieceTable.size(); removeRange.restrictEndTo(oldSize - 1); // check parameters if (removeRange.start() >= oldSize || removeRange.width() == 0) { @@ -157,11 +157,11 @@ return removeRange.width(); } -Size PieceTableByteArrayModelPrivate::replace(const AddressRange& _removeRange, const Byte* insertData, int insertLength) +Size PieceTableByteArrayModelPrivate::replace(const AddressRange& _removeRange, const Byte* insertData, Size insertLength) { AddressRange removeRange(_removeRange); // correct parameters - const int oldSize = mPieceTable.size(); + const Size oldSize = mPieceTable.size(); removeRange.restrictEndTo(oldSize - 1); // check parameters if ((removeRange.startsBehind(oldSize - 1) && removeRange.width() > 0) @@ -201,13 +201,13 @@ Size PieceTableByteArrayModelPrivate::fill(Byte fillByte, Address offset, Size fillLength) { // correct parameters - const int lengthToEnd = mPieceTable.size() - offset; + const Size lengthToEnd = mPieceTable.size() - offset; if (fillLength < 0) { fillLength = lengthToEnd; } - const int filledLength = (fillLength < lengthToEnd) ? fillLength : lengthToEnd; + const Size filledLength = (fillLength < lengthToEnd) ? fillLength : lengthToEnd; // check parameters - const bool nothingToFill = (((int)offset >= mPieceTable.size()) || (fillLength == 0)); + const bool nothingToFill = (((Size)offset >= mPieceTable.size()) || (fillLength == 0)); if (nothingToFill) { return 0; } @@ -317,7 +317,7 @@ { case ArrayChangeMetrics::Replacement: { - const int oldSize = mPieceTable.size(); + const Size oldSize = mPieceTable.size(); const AddressRange removeRange = AddressRange::fromWidth(metrics.offset(), metrics.removeLength()); // check parameters if (removeRange.startsBehind(oldSize - 1) && (removeRange.width() > 0)) { @@ -382,7 +382,7 @@ } void PieceTableByteArrayModelPrivate::doInsertChange(Address offset, - const Byte* insertData, int insertLength) + const Byte* insertData, Size insertLength) { Address storageOffset; mPieceTable.insert(offset, insertLength, &storageOffset); @@ -412,7 +412,7 @@ } void PieceTableByteArrayModelPrivate::doReplaceChange(const AddressRange& removeRange, - const Byte* insertData, int insertLength) + const Byte* insertData, Size insertLength) { Address storageOffset; mPieceTable.replace(removeRange, insertLength, &storageOffset); @@ -443,7 +443,7 @@ } void PieceTableByteArrayModelPrivate::doFillChange(Address offset, Size filledLength, - Byte fillByte, int fillLength) + Byte fillByte, Size fillLength) { Address storageOffset; mPieceTable.replace(offset, filledLength, fillLength, &storageOffset); diff --git a/core/size.h b/core/size.h --- a/core/size.h +++ b/core/size.h @@ -28,7 +28,7 @@ namespace Okteta { -using Size = qint32; +using Size = qint64; } diff --git a/gui/abstractbytearraycolumnrenderer.h b/gui/abstractbytearraycolumnrenderer.h --- a/gui/abstractbytearraycolumnrenderer.h +++ b/gui/abstractbytearraycolumnrenderer.h @@ -79,7 +79,7 @@ public: // void renderLine( QPainter* painter, int lineIndex ); - void renderLinePositions(QPainter* painter, Line lineIndex, const LineRange& linePositions); + void renderLinePositions(QPainter* painter, Line lineIndex, const LinePositionRange& linePositions); /** paints a cursor based on the type of the byte. * @param byteIndex Index of the byte to paint the cursor for. If -1 a space is used as char. */ diff --git a/gui/abstractbytearrayview.h b/gui/abstractbytearrayview.h --- a/gui/abstractbytearrayview.h +++ b/gui/abstractbytearrayview.h @@ -461,7 +461,7 @@ bool viewportEvent(QEvent* event) override; protected: // ColumnsView API - void setNoOfLines(int newNoOfLines) override; + void setNoOfLines(LineSize newNoOfLines) override; protected: // Q_SLOTS QWidget API void changeEvent(QEvent* event) override; diff --git a/gui/abstractbytearrayview.cpp b/gui/abstractbytearrayview.cpp --- a/gui/abstractbytearrayview.cpp +++ b/gui/abstractbytearrayview.cpp @@ -455,7 +455,7 @@ d->setZoomLevel(zoomLevel); } -void AbstractByteArrayView::setNoOfLines(int newNoOfLines) +void AbstractByteArrayView::setNoOfLines(LineSize newNoOfLines) { ColumnsView::setNoOfLines(newNoOfLines > 1 ? newNoOfLines : 1); } diff --git a/gui/abstractbytearrayview_p.cpp b/gui/abstractbytearrayview_p.cpp --- a/gui/abstractbytearrayview_p.cpp +++ b/gui/abstractbytearrayview_p.cpp @@ -82,7 +82,7 @@ bool isModified() const override; public: // modification API - Size replace(const AddressRange& removeSection, const Byte* insertData, int insertLength) override; + Size replace(const AddressRange& removeSection, const Byte* insertData, Size insertLength) override; bool swap(Address firstStart, const AddressRange& secondRange) override; Size fill(Byte fillByte, Address offset = 0, Size fillLength = -1) override; void setByte(Address offset, Byte byte) override; @@ -95,7 +95,7 @@ Byte NullModel::byte(Address offset) const { Q_UNUSED(offset) return 0; } Size NullModel::size() const { return 0; } bool NullModel::isModified() const { return false; } -Size NullModel::replace(const AddressRange& removeSection, const Byte* insertData, int insertLength) +Size NullModel::replace(const AddressRange& removeSection, const Byte* insertData, Size insertLength) { Q_UNUSED(removeSection) Q_UNUSED(insertData) Q_UNUSED(insertLength) return 0; diff --git a/gui/libcolumnsview/abstractcolumnrenderer.h b/gui/libcolumnsview/abstractcolumnrenderer.h --- a/gui/libcolumnsview/abstractcolumnrenderer.h +++ b/gui/libcolumnsview/abstractcolumnrenderer.h @@ -24,6 +24,7 @@ #define OKTETA_ABSTRACTCOLUMNRENDERER_H // lib +#include #include #include @@ -59,7 +60,7 @@ * @param xSpan * @param firstLineIndex no of the first of the range of lines to paint */ - virtual void renderFirstLine(QPainter* painter, const PixelXRange& xSpan, int firstLineIndex); + virtual void renderFirstLine(QPainter* painter, const PixelXRange& xSpan, Line firstLineIndex); /** the actual painting call for a column's line. * The default implementation simply paints the background */ diff --git a/gui/libcolumnsview/abstractcolumnrenderer.cpp b/gui/libcolumnsview/abstractcolumnrenderer.cpp --- a/gui/libcolumnsview/abstractcolumnrenderer.cpp +++ b/gui/libcolumnsview/abstractcolumnrenderer.cpp @@ -58,7 +58,7 @@ bool AbstractColumnRenderer::overlaps(const PixelXRange& xSpan) const { return d->mXSpan.overlaps(xSpan); } -void AbstractColumnRenderer::renderFirstLine(QPainter* painter, const PixelXRange& xSpan, int firstLineIndex) +void AbstractColumnRenderer::renderFirstLine(QPainter* painter, const PixelXRange& xSpan, Line firstLineIndex) { Q_UNUSED(xSpan) Q_UNUSED(firstLineIndex) diff --git a/gui/line.h b/gui/line.h --- a/gui/line.h +++ b/gui/line.h @@ -28,8 +28,8 @@ namespace Okteta { -using Line = qint32; -using LineSize = qint32; +using Line = qint64; +using LineSize = qint64; } diff --git a/gui/lineposition.h b/gui/lineposition.h --- a/gui/lineposition.h +++ b/gui/lineposition.h @@ -28,6 +28,7 @@ namespace Okteta { +// Number type for positions within a line using LinePosition = qint32; using LinePositionSize = qint32; diff --git a/kasten/gui/io/streamencoder/ihex/bytearrayihexstreamencoder.cpp b/kasten/gui/io/streamencoder/ihex/bytearrayihexstreamencoder.cpp --- a/kasten/gui/io/streamencoder/ihex/bytearrayihexstreamencoder.cpp +++ b/kasten/gui/io/streamencoder/ihex/bytearrayihexstreamencoder.cpp @@ -180,8 +180,8 @@ } } nextUpperAddressChangeDataEnd = 0x10000 - (i & 0xFFFF); - nextDataEnd = qMin(dataPerLineCount, - qMin(range.end() - i + 1, nextUpperAddressChangeDataEnd)); + nextDataEnd = (int)qMin((Okteta::Address)dataPerLineCount, + qMin(range.end() - i + 1, (Okteta::Address)nextUpperAddressChangeDataEnd)); d = 0; } } diff --git a/kasten/gui/io/streamencoder/srec/bytearraysrecstreamencoder.cpp b/kasten/gui/io/streamencoder/srec/bytearraysrecstreamencoder.cpp --- a/kasten/gui/io/streamencoder/srec/bytearraysrecstreamencoder.cpp +++ b/kasten/gui/io/streamencoder/srec/bytearraysrecstreamencoder.cpp @@ -189,7 +189,7 @@ ++recordCount; recordOffset = i; d = 0; - nextDataEnd = qMin(range.end() - i + 1, dataPerLineCount); + nextDataEnd = (int)qMin(range.end() - i + 1, (Okteta::Address)dataPerLineCount); } } diff --git a/kasten/gui/io/streamencoder/uuencoding/bytearrayuuencodingstreamencoder.cpp b/kasten/gui/io/streamencoder/uuencoding/bytearrayuuencodingstreamencoder.cpp --- a/kasten/gui/io/streamencoder/uuencoding/bytearrayuuencodingstreamencoder.cpp +++ b/kasten/gui/io/streamencoder/uuencoding/bytearrayuuencodingstreamencoder.cpp @@ -109,7 +109,7 @@ // header textStream << encodeData->header << " 644 " << mSettings.fileName.toLatin1(); - const int firstLineLength = qMin(range.width(), uuInputLineLength); + const int firstLineLength = (int)qMin(range.width(), (Okteta::Size)uuInputLineLength); if (firstLineLength > 0) { textStream << '\n'; if (encodeData->hasLength) { diff --git a/kasten/gui/io/streamencoder/xxencoding/bytearrayxxencodingstreamencoder.cpp b/kasten/gui/io/streamencoder/xxencoding/bytearrayxxencodingstreamencoder.cpp --- a/kasten/gui/io/streamencoder/xxencoding/bytearrayxxencodingstreamencoder.cpp +++ b/kasten/gui/io/streamencoder/xxencoding/bytearrayxxencodingstreamencoder.cpp @@ -90,7 +90,7 @@ // header textStream << header << " 644 " << mSettings.fileName.toLatin1(); - const int firstLineLength = qMin(range.width(), xxInputLineLength); + const int firstLineLength = (int)qMin(range.width(), (Okteta::Size)xxInputLineLength); if (firstLineLength > 0) { textStream << '\n'; textStream << xxmapByte(firstLineLength); diff --git a/libs/kasten/core/tests/testdocumentfileloadthread.cpp b/libs/kasten/core/tests/testdocumentfileloadthread.cpp --- a/libs/kasten/core/tests/testdocumentfileloadthread.cpp +++ b/libs/kasten/core/tests/testdocumentfileloadthread.cpp @@ -40,7 +40,7 @@ void TestDocumentFileLoadThread::run() { QDataStream inStream(mFile); - const int fileSize = mFile->size(); + const qint64 fileSize = mFile->size(); // test header const int headerSize = mHeader.size(); diff --git a/libs/kasten/core/tests/testdocumentfilereloadthread.cpp b/libs/kasten/core/tests/testdocumentfilereloadthread.cpp --- a/libs/kasten/core/tests/testdocumentfilereloadthread.cpp +++ b/libs/kasten/core/tests/testdocumentfilereloadthread.cpp @@ -49,7 +49,7 @@ void TestDocumentFileReloadThread::run() { QDataStream inStream(mFile); - const int fileSize = mFile->size(); + const qint64 fileSize = mFile->size(); // test header const int headerSize = mHeader.size();