From 762081f29fd5375b0644ee177b8ffb46432849a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sun, 12 Oct 2014 12:28:02 +0300 Subject: [PATCH] libcore|Xcode: Fixed a bunch of benign integer conversion warnings --- doomsday/libcore/include/de/data/arrayvalue.h | 2 +- doomsday/libcore/include/de/data/date.h | 2 +- doomsday/libcore/include/de/data/string.h | 1 + doomsday/libcore/include/de/scriptsys/tokenbuffer.h | 2 +- doomsday/libcore/src/core/logbuffer.cpp | 2 +- doomsday/libcore/src/core/loop.cpp | 2 +- doomsday/libcore/src/data/bitfield.cpp | 2 +- doomsday/libcore/src/data/block.cpp | 2 +- doomsday/libcore/src/data/huffman.cpp | 2 +- doomsday/libcore/src/data/string.cpp | 6 +++++- doomsday/libcore/src/filesys/fileindex.cpp | 2 +- doomsday/libcore/src/scriptsys/nameexpression.cpp | 2 +- doomsday/libcore/src/scriptsys/process.cpp | 2 +- 13 files changed, 17 insertions(+), 12 deletions(-) diff --git a/doomsday/libcore/include/de/data/arrayvalue.h b/doomsday/libcore/include/de/data/arrayvalue.h index ce499de062..343a14bb54 100644 --- a/doomsday/libcore/include/de/data/arrayvalue.h +++ b/doomsday/libcore/include/de/data/arrayvalue.h @@ -147,7 +147,7 @@ class DENG2_PUBLIC ArrayValue : public Value Value const &front() const { return at(0); } - Value const &back() const { return at(size() - 1); } + Value const &back() const { return at(dint(size()) - 1); } /** * Empties the array of all values. diff --git a/doomsday/libcore/include/de/data/date.h b/doomsday/libcore/include/de/data/date.h index 0958fef5f6..1f564b3785 100644 --- a/doomsday/libcore/include/de/data/date.h +++ b/doomsday/libcore/include/de/data/date.h @@ -48,7 +48,7 @@ class DENG2_PUBLIC Date : public Time, public LogEntry::Arg::Base int hours() const { return asDateTime().time().hour(); } int minutes() const { return asDateTime().time().minute(); } int seconds() const { return asDateTime().time().second(); } - int daysTo(Date const &other) const { return asDateTime().date().daysTo(other.asDateTime().date()); } + int daysTo(Date const &other) const { return int(asDateTime().date().daysTo(other.asDateTime().date())); } /** * Forms a textual representation of the date. diff --git a/doomsday/libcore/include/de/data/string.h b/doomsday/libcore/include/de/data/string.h index 748992a638..1202a90e30 100644 --- a/doomsday/libcore/include/de/data/string.h +++ b/doomsday/libcore/include/de/data/string.h @@ -84,6 +84,7 @@ class DENG2_PUBLIC String : public QString String(char const *nullTerminatedCStr); String(wchar_t const *nullTerminatedWideStr); String(char const *cStr, size_type length); + String(char const *cStr, dsize length); String(QChar const *nullTerminatedStr); String(QChar const *str, size_type length); String(size_type length, QChar ch); diff --git a/doomsday/libcore/include/de/scriptsys/tokenbuffer.h b/doomsday/libcore/include/de/scriptsys/tokenbuffer.h index 12851f2f77..781c46ea2a 100644 --- a/doomsday/libcore/include/de/scriptsys/tokenbuffer.h +++ b/doomsday/libcore/include/de/scriptsys/tokenbuffer.h @@ -89,7 +89,7 @@ class Token /// @return Length of the token as number of characters. int size() const { if(!_begin || !_end) return 0; - return _end - _begin; + return int(_end - _begin); } bool isEmpty() const { diff --git a/doomsday/libcore/src/core/logbuffer.cpp b/doomsday/libcore/src/core/logbuffer.cpp index 6579eb098d..69dc31fe1a 100644 --- a/doomsday/libcore/src/core/logbuffer.cpp +++ b/doomsday/libcore/src/core/logbuffer.cpp @@ -105,7 +105,7 @@ DENG2_PIMPL_NOREF(LogBuffer) if(!autoFlushTimer->isActive()) { // Every now and then the buffer will be flushed. - autoFlushTimer->start(FLUSH_INTERVAL.asMilliSeconds()); + autoFlushTimer->start(int(FLUSH_INTERVAL.asMilliSeconds())); } } else diff --git a/doomsday/libcore/src/core/loop.cpp b/doomsday/libcore/src/core/loop.cpp index 4cbd838adf..da2ad335ca 100644 --- a/doomsday/libcore/src/core/loop.cpp +++ b/doomsday/libcore/src/core/loop.cpp @@ -62,7 +62,7 @@ Loop::Loop() : d(new Instance(this)) void Loop::setRate(int freqHz) { d->interval = 1.0 / freqHz; - d->timer->setInterval(de::max(duint64(1), d->interval.asMilliSeconds())); + d->timer->setInterval(de::max(1, int(d->interval.asMilliSeconds()))); } void Loop::start() diff --git a/doomsday/libcore/src/data/bitfield.cpp b/doomsday/libcore/src/data/bitfield.cpp index 17c566c72d..9fe75331d5 100644 --- a/doomsday/libcore/src/data/bitfield.cpp +++ b/doomsday/libcore/src/data/bitfield.cpp @@ -242,7 +242,7 @@ String BitField::asText() const QTextStream os(&str); os << "BitField (" << d->elements->bitCount() << " bits, " << d->elements->size() << " elements):"; os.setIntegerBase(2); - for(int i = d->packed.size() - 1; i >= 0; --i) + for(int i = int(d->packed.size()) - 1; i >= 0; --i) { os << " " << qSetPadChar('0') << qSetFieldWidth(8) << dbyte(d->packed[i]) << qSetFieldWidth(0); diff --git a/doomsday/libcore/src/data/block.cpp b/doomsday/libcore/src/data/block.cpp index 72cc20a51f..7406ef1c21 100644 --- a/doomsday/libcore/src/data/block.cpp +++ b/doomsday/libcore/src/data/block.cpp @@ -47,7 +47,7 @@ Block::Block(char const *nullTerminatedCStr) {} Block::Block(void const *data, Size length) - : QByteArray(reinterpret_cast(data), length), IByteArray(), IBlock() + : QByteArray(reinterpret_cast(data), int(length)), IByteArray(), IBlock() {} Block::Block(IIStream &stream) diff --git a/doomsday/libcore/src/data/huffman.cpp b/doomsday/libcore/src/data/huffman.cpp index 624a344246..57bed6236e 100644 --- a/doomsday/libcore/src/data/huffman.cpp +++ b/doomsday/libcore/src/data/huffman.cpp @@ -125,7 +125,7 @@ struct HuffCode { struct HuffBuffer { dbyte *data; - duint size; + dsize size; }; struct Huffman diff --git a/doomsday/libcore/src/data/string.cpp b/doomsday/libcore/src/data/string.cpp index 0e3ac41785..6ba52a097d 100644 --- a/doomsday/libcore/src/data/string.cpp +++ b/doomsday/libcore/src/data/string.cpp @@ -62,6 +62,10 @@ String::String(char const *cStr, size_type length) : QString(QString::fromUtf8(cStr, length)) {} +String::String(char const *cStr, dsize length) + : QString(QString::fromUtf8(cStr, int(length))) +{} + String::String(size_type length, QChar ch) : QString(length, ch) {} @@ -435,7 +439,7 @@ int String::commonPrefixLength(String const &str, Qt::CaseSensitivity sensitivit dint String::compareWithCase(QChar const *a, QChar const *b, dsize count) { - return QString(a, count).compare(QString(b, count), Qt::CaseSensitive); + return QString(a, int(count)).compare(QString(b, int(count)), Qt::CaseSensitive); } void String::skipSpace(String::const_iterator &i, String::const_iterator const &end) diff --git a/doomsday/libcore/src/filesys/fileindex.cpp b/doomsday/libcore/src/filesys/fileindex.cpp index fe717cd4ca..54610b03a5 100644 --- a/doomsday/libcore/src/filesys/fileindex.cpp +++ b/doomsday/libcore/src/filesys/fileindex.cpp @@ -138,7 +138,7 @@ void FileIndex::remove(File const &file) int FileIndex::size() const { - return d->index.size(); + return int(d->index.size()); } static bool fileNotInAnyLoadedPackage(File *file) diff --git a/doomsday/libcore/src/scriptsys/nameexpression.cpp b/doomsday/libcore/src/scriptsys/nameexpression.cpp index 716dac9e7a..d2dc299fb5 100644 --- a/doomsday/libcore/src/scriptsys/nameexpression.cpp +++ b/doomsday/libcore/src/scriptsys/nameexpression.cpp @@ -62,7 +62,7 @@ DENG2_PIMPL_NOREF(NameExpression) // The namespace is derived from another record. Let's look into each // super-record in turn. ArrayValue const &supers = where.geta(Record::SUPER_NAME); - for(dsize i = 0; i < supers.size(); ++i) + for(int i = 0; i < int(supers.size()); ++i) { if(Variable *found = findInRecord( name, supers.at(i).as().dereference(), foundIn)) diff --git a/doomsday/libcore/src/scriptsys/process.cpp b/doomsday/libcore/src/scriptsys/process.cpp index f941e8bc5b..45ad671d6e 100644 --- a/doomsday/libcore/src/scriptsys/process.cpp +++ b/doomsday/libcore/src/scriptsys/process.cpp @@ -240,7 +240,7 @@ void Process::execute() } // We will execute until this depth is complete. - duint startDepth = d->depth(); + dsize startDepth = d->depth(); if(startDepth == 1) { // Mark the start time.