From dcc0fe553c7b0922d35af3f7c6f6095a9540e989 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 2 Dec 2015 18:59:45 +0900 Subject: [PATCH] Use a standard type rather than TagLib::ushort. This won't break the ABI compatibility. --- taglib/asf/asfutils.h | 2 +- taglib/it/itfile.cpp | 22 ++++---- taglib/it/itproperties.cpp | 50 ++++++++--------- taglib/it/itproperties.h | 34 ++++++------ taglib/mod/modfilebase.cpp | 8 +-- taglib/mod/modfilebase.h | 8 +-- taglib/mod/modfileprivate.h | 8 +-- taglib/mpc/mpcproperties.cpp | 2 +- .../id3v2/frames/synchronizedlyricsframe.cpp | 4 +- taglib/ogg/opus/opusproperties.cpp | 2 +- taglib/s3m/s3mfile.cpp | 14 ++--- taglib/s3m/s3mproperties.cpp | 40 +++++++------- taglib/s3m/s3mproperties.h | 26 ++++----- taglib/toolkit/tbytevector.cpp | 2 +- taglib/toolkit/tstring.cpp | 6 +- taglib/toolkit/tutils.h | 2 +- taglib/xm/xmfile.cpp | 55 +++++++++---------- taglib/xm/xmproperties.cpp | 50 ++++++++--------- taglib/xm/xmproperties.h | 32 +++++------ tests/test_it.cpp | 14 ++--- tests/test_s3m.cpp | 12 ++-- tests/test_xm.cpp | 32 +++++------ 22 files changed, 212 insertions(+), 213 deletions(-) diff --git a/taglib/asf/asfutils.h b/taglib/asf/asfutils.h index 21dbd034..9a949413 100644 --- a/taglib/asf/asfutils.h +++ b/taglib/asf/asfutils.h @@ -35,7 +35,7 @@ namespace TagLib namespace ASF { - inline ushort readWORD(File *file, bool *ok = 0) + inline unsigned short readWORD(File *file, bool *ok = 0) { const ByteVector v = file->readBlock(2); if(v.size() != 2) { diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index 51ad8ac1..7508cfcb 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -96,9 +96,9 @@ bool IT::File::save() seek(2, Current); - ushort length = 0; - ushort instrumentCount = 0; - ushort sampleCount = 0; + unsigned short length = 0; + unsigned short instrumentCount = 0; + unsigned short sampleCount = 0; if(!readU16L(length) || !readU16L(instrumentCount) || !readU16L(sampleCount)) return false; @@ -107,7 +107,7 @@ bool IT::File::save() // write comment as instrument and sample names: StringList lines = d->tag.comment().split("\n"); - for(ushort i = 0; i < instrumentCount; ++ i) { + for(unsigned short i = 0; i < instrumentCount; ++ i) { seek(192L + length + ((long)i << 2)); ulong instrumentOffset = 0; if(!readU32L(instrumentOffset)) @@ -122,7 +122,7 @@ bool IT::File::save() writeByte(0); } - for(ushort i = 0; i < sampleCount; ++ i) { + for(unsigned short i = 0; i < sampleCount; ++ i) { seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2)); ulong sampleOffset = 0; if(!readU32L(sampleOffset)) @@ -149,8 +149,8 @@ bool IT::File::save() message.resize(7999); message.append((char)0); - ushort special = 0; - ushort messageLength = 0; + unsigned short special = 0; + unsigned short messageLength = 0; ulong messageOffset = 0; seek(46); @@ -259,8 +259,8 @@ void IT::File::read(bool) d->properties.setChannels(channels); // real length might be shorter because of skips and terminator - ushort realLength = 0; - for(ushort i = 0; i < length; ++ i) { + unsigned short realLength = 0; + for(unsigned short i = 0; i < length; ++ i) { READ_BYTE_AS(order); if(order == 255) break; if(order != 254) ++ realLength; @@ -274,7 +274,7 @@ void IT::File::read(bool) // Currently I just discard anything after a nil, but // e.g. VLC seems to interprete a nil as a space. I // don't know what is the proper behaviour. - for(ushort i = 0; i < instrumentCount; ++ i) { + for(unsigned short i = 0; i < instrumentCount; ++ i) { seek(192L + length + ((long)i << 2)); READ_U32L_AS(instrumentOffset); seek(instrumentOffset); @@ -290,7 +290,7 @@ void IT::File::read(bool) comment.append(instrumentName); } - for(ushort i = 0; i < sampleCount; ++ i) { + for(unsigned short i = 0; i < sampleCount; ++ i) { seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2)); READ_U32L_AS(sampleOffset); diff --git a/taglib/it/itproperties.cpp b/taglib/it/itproperties.cpp index 8b1fc43c..426a6f2d 100644 --- a/taglib/it/itproperties.cpp +++ b/taglib/it/itproperties.cpp @@ -46,15 +46,15 @@ public: { } - int channels; - ushort lengthInPatterns; - ushort instrumentCount; - ushort sampleCount; - ushort patternCount; - ushort version; - ushort compatibleVersion; - ushort flags; - ushort special; + int channels; + unsigned short lengthInPatterns; + unsigned short instrumentCount; + unsigned short sampleCount; + unsigned short patternCount; + unsigned short version; + unsigned short compatibleVersion; + unsigned short flags; + unsigned short special; unsigned char globalVolume; unsigned char mixVolume; unsigned char tempo; @@ -104,7 +104,7 @@ int IT::Properties::channels() const return d->channels; } -TagLib::ushort IT::Properties::lengthInPatterns() const +unsigned short IT::Properties::lengthInPatterns() const { return d->lengthInPatterns; } @@ -114,37 +114,37 @@ bool IT::Properties::stereo() const return d->flags & Stereo; } -TagLib::ushort IT::Properties::instrumentCount() const +unsigned short IT::Properties::instrumentCount() const { return d->instrumentCount; } -TagLib::ushort IT::Properties::sampleCount() const +unsigned short IT::Properties::sampleCount() const { return d->sampleCount; } -TagLib::ushort IT::Properties::patternCount() const +unsigned short IT::Properties::patternCount() const { return d->patternCount; } -TagLib::ushort IT::Properties::version() const +unsigned short IT::Properties::version() const { return d->version; } -TagLib::ushort IT::Properties::compatibleVersion() const +unsigned short IT::Properties::compatibleVersion() const { return d->compatibleVersion; } -TagLib::ushort IT::Properties::flags() const +unsigned short IT::Properties::flags() const { return d->flags; } -TagLib::ushort IT::Properties::special() const +unsigned short IT::Properties::special() const { return d->special; } @@ -184,42 +184,42 @@ void IT::Properties::setChannels(int channels) d->channels = channels; } -void IT::Properties::setLengthInPatterns(ushort lengthInPatterns) +void IT::Properties::setLengthInPatterns(unsigned short lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } -void IT::Properties::setInstrumentCount(ushort instrumentCount) +void IT::Properties::setInstrumentCount(unsigned short instrumentCount) { d->instrumentCount = instrumentCount; } -void IT::Properties::setSampleCount(ushort sampleCount) +void IT::Properties::setSampleCount(unsigned short sampleCount) { d->sampleCount = sampleCount; } -void IT::Properties::setPatternCount(ushort patternCount) +void IT::Properties::setPatternCount(unsigned short patternCount) { d->patternCount = patternCount; } -void IT::Properties::setFlags(ushort flags) +void IT::Properties::setFlags(unsigned short flags) { d->flags = flags; } -void IT::Properties::setSpecial(ushort special) +void IT::Properties::setSpecial(unsigned short special) { d->special = special; } -void IT::Properties::setCompatibleVersion(ushort compatibleVersion) +void IT::Properties::setCompatibleVersion(unsigned short compatibleVersion) { d->compatibleVersion = compatibleVersion; } -void IT::Properties::setVersion(ushort version) +void IT::Properties::setVersion(unsigned short version) { d->version = version; } diff --git a/taglib/it/itproperties.h b/taglib/it/itproperties.h index e2da6e66..d65a8c28 100644 --- a/taglib/it/itproperties.h +++ b/taglib/it/itproperties.h @@ -58,15 +58,15 @@ namespace TagLib { int sampleRate() const; int channels() const; - ushort lengthInPatterns() const; - bool stereo() const; - ushort instrumentCount() const; - ushort sampleCount() const; - ushort patternCount() const; - ushort version() const; - ushort compatibleVersion() const; - ushort flags() const; - ushort special() const; + unsigned short lengthInPatterns() const; + bool stereo() const; + unsigned short instrumentCount() const; + unsigned short sampleCount() const; + unsigned short patternCount() const; + unsigned short version() const; + unsigned short compatibleVersion() const; + unsigned short flags() const; + unsigned short special() const; unsigned char globalVolume() const; unsigned char mixVolume() const; unsigned char tempo() const; @@ -75,14 +75,14 @@ namespace TagLib { unsigned char pitchWheelDepth() const; void setChannels(int channels); - void setLengthInPatterns(ushort lengthInPatterns); - void setInstrumentCount(ushort instrumentCount); - void setSampleCount (ushort sampleCount); - void setPatternCount(ushort patternCount); - void setVersion (ushort version); - void setCompatibleVersion(ushort compatibleVersion); - void setFlags (ushort flags); - void setSpecial (ushort special); + void setLengthInPatterns(unsigned short lengthInPatterns); + void setInstrumentCount(unsigned short instrumentCount); + void setSampleCount (unsigned short sampleCount); + void setPatternCount(unsigned short patternCount); + void setVersion (unsigned short version); + void setCompatibleVersion(unsigned short compatibleVersion); + void setFlags (unsigned short flags); + void setSpecial (unsigned short special); void setGlobalVolume(unsigned char globalVolume); void setMixVolume (unsigned char mixVolume); void setTempo (unsigned char tempo); diff --git a/taglib/mod/modfilebase.cpp b/taglib/mod/modfilebase.cpp index a73e9367..2ed16ae7 100644 --- a/taglib/mod/modfilebase.cpp +++ b/taglib/mod/modfilebase.cpp @@ -61,7 +61,7 @@ void Mod::FileBase::writeByte(unsigned char byte) writeBlock(data); } -void Mod::FileBase::writeU16L(ushort number) +void Mod::FileBase::writeU16L(unsigned short number) { writeBlock(ByteVector::fromShort(number, false)); } @@ -71,7 +71,7 @@ void Mod::FileBase::writeU32L(ulong number) writeBlock(ByteVector::fromUInt(number, false)); } -void Mod::FileBase::writeU16B(ushort number) +void Mod::FileBase::writeU16B(unsigned short number) { writeBlock(ByteVector::fromShort(number, true)); } @@ -89,7 +89,7 @@ bool Mod::FileBase::readByte(unsigned char &byte) return true; } -bool Mod::FileBase::readU16L(ushort &number) +bool Mod::FileBase::readU16L(unsigned short &number) { ByteVector data(readBlock(2)); if(data.size() < 2) return false; @@ -104,7 +104,7 @@ bool Mod::FileBase::readU32L(ulong &number) { return true; } -bool Mod::FileBase::readU16B(ushort &number) +bool Mod::FileBase::readU16B(unsigned short &number) { ByteVector data(readBlock(2)); if(data.size() < 2) return false; diff --git a/taglib/mod/modfilebase.h b/taglib/mod/modfilebase.h index 8b483d38..82f3122b 100644 --- a/taglib/mod/modfilebase.h +++ b/taglib/mod/modfilebase.h @@ -42,16 +42,16 @@ namespace TagLib { void writeString(const String &s, ulong size, char padding = 0); void writeByte(unsigned char byte); - void writeU16L(ushort number); + void writeU16L(unsigned short number); void writeU32L(ulong number); - void writeU16B(ushort number); + void writeU16B(unsigned short number); void writeU32B(ulong number); bool readString(String &s, ulong size); bool readByte(unsigned char &byte); - bool readU16L(ushort &number); + bool readU16L(unsigned short &number); bool readU32L(ulong &number); - bool readU16B(ushort &number); + bool readU16B(unsigned short &number); bool readU32B(ulong &number); }; diff --git a/taglib/mod/modfileprivate.h b/taglib/mod/modfileprivate.h index 7aa52db1..a4fc8d33 100644 --- a/taglib/mod/modfileprivate.h +++ b/taglib/mod/modfileprivate.h @@ -38,9 +38,9 @@ } #define READ_BYTE(setter) READ(setter,unsigned char,readByte) -#define READ_U16L(setter) READ(setter,ushort,readU16L) +#define READ_U16L(setter) READ(setter,unsigned short,readU16L) #define READ_U32L(setter) READ(setter,ulong,readU32L) -#define READ_U16B(setter) READ(setter,ushort,readU16B) +#define READ_U16B(setter) READ(setter,unsigned short,readU16B) #define READ_U32B(setter) READ(setter,ulong,readU32B) #define READ_STRING(setter,size) \ @@ -55,9 +55,9 @@ READ_ASSERT(read(name)); #define READ_BYTE_AS(name) READ_AS(unsigned char,name,readByte) -#define READ_U16L_AS(name) READ_AS(ushort,name,readU16L) +#define READ_U16L_AS(name) READ_AS(unsigned short,name,readU16L) #define READ_U32L_AS(name) READ_AS(ulong,name,readU32L) -#define READ_U16B_AS(name) READ_AS(ushort,name,readU16B) +#define READ_U16B_AS(name) READ_AS(unsigned short,name,readU16B) #define READ_U32B_AS(name) READ_AS(ulong,name,readU32B) #define READ_STRING_AS(name,size) \ diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 9437f22e..9c1274eb 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -253,7 +253,7 @@ void MPC::Properties::readSV8(File *file, long streamLength) break; } - const ushort flags = data.toUShort(pos, true); + const unsigned short flags = data.toUShort(pos, true); pos += 2; d->sampleRate = sftable[(flags >> 13) & 0x07]; diff --git a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp index 2ab46481..1d42e1c8 100644 --- a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp @@ -171,7 +171,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) */ String::Type encWithEndianness = d->textEncoding; if(d->textEncoding == String::UTF16) { - ushort bom = data.toUShort(6, true); + unsigned short bom = data.toUShort(6, true); if(bom == 0xfffe) { encWithEndianness = String::UTF16LE; } else if(bom == 0xfeff) { @@ -184,7 +184,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data) String::Type enc = d->textEncoding; // If a UTF16 string has no BOM, use the encoding found above. if(enc == String::UTF16 && pos + 1 < end) { - ushort bom = data.toUShort(pos, true); + unsigned short bom = data.toUShort(pos, true); if(bom != 0xfffe && bom != 0xfeff) { enc = encWithEndianness; } diff --git a/taglib/ogg/opus/opusproperties.cpp b/taglib/ogg/opus/opusproperties.cpp index 365658f8..43858da6 100644 --- a/taglib/ogg/opus/opusproperties.cpp +++ b/taglib/ogg/opus/opusproperties.cpp @@ -138,7 +138,7 @@ void Opus::Properties::read(File *file) pos += 1; // *Pre-skip* (16 bits, unsigned, little endian) - const ushort preSkip = data.toUShort(pos, false); + const unsigned short preSkip = data.toUShort(pos, false); pos += 2; // *Input Sample Rate* (32 bits, unsigned, little endian) diff --git a/taglib/s3m/s3mfile.cpp b/taglib/s3m/s3mfile.cpp index c83e09d7..923a80ad 100644 --- a/taglib/s3m/s3mfile.cpp +++ b/taglib/s3m/s3mfile.cpp @@ -100,8 +100,8 @@ bool S3M::File::save() seek(32); - ushort length = 0; - ushort sampleCount = 0; + unsigned short length = 0; + unsigned short sampleCount = 0; if(!readU16L(length) || !readU16L(sampleCount)) return false; @@ -123,10 +123,10 @@ bool S3M::File::save() StringList lines = d->tag.comment().split("\n"); // write comment as sample names: - for(ushort i = 0; i < sampleCount; ++ i) { + for(unsigned short i = 0; i < sampleCount; ++ i) { seek(96L + length + ((long)i << 1)); - ushort instrumentOffset = 0; + unsigned short instrumentOffset = 0; if(!readU16L(instrumentOffset)) return false; seek(((long)instrumentOffset << 4) + 48); @@ -193,8 +193,8 @@ void S3M::File::read(bool) d->properties.setChannels(channels); seek(96); - ushort realLength = 0; - for(ushort i = 0; i < length; ++ i) { + unsigned short realLength = 0; + for(unsigned short i = 0; i < length; ++ i) { READ_BYTE_AS(order); if(order == 255) break; if(order != 254) ++ realLength; @@ -208,7 +208,7 @@ void S3M::File::read(bool) // However, there I never found instruments (SCRI) but // instead samples (SCRS). StringList comment; - for(ushort i = 0; i < sampleCount; ++ i) { + for(unsigned short i = 0; i < sampleCount; ++ i) { seek(96L + length + ((long)i << 1)); READ_U16L_AS(sampleHeaderOffset); diff --git a/taglib/s3m/s3mproperties.cpp b/taglib/s3m/s3mproperties.cpp index de2d1ebe..9633a0fe 100644 --- a/taglib/s3m/s3mproperties.cpp +++ b/taglib/s3m/s3mproperties.cpp @@ -43,14 +43,14 @@ public: { } - ushort lengthInPatterns; - int channels; - bool stereo; - ushort sampleCount; - ushort patternCount; - ushort flags; - ushort trackerVersion; - ushort fileFormatVersion; + unsigned short lengthInPatterns; + int channels; + bool stereo; + unsigned short sampleCount; + unsigned short patternCount; + unsigned short flags; + unsigned short trackerVersion; + unsigned short fileFormatVersion; unsigned char globalVolume; unsigned char masterVolume; unsigned char tempo; @@ -98,7 +98,7 @@ int S3M::Properties::channels() const return d->channels; } -TagLib::ushort S3M::Properties::lengthInPatterns() const +unsigned short S3M::Properties::lengthInPatterns() const { return d->lengthInPatterns; } @@ -108,27 +108,27 @@ bool S3M::Properties::stereo() const return d->stereo; } -TagLib::ushort S3M::Properties::sampleCount() const +unsigned short S3M::Properties::sampleCount() const { return d->sampleCount; } -TagLib::ushort S3M::Properties::patternCount() const +unsigned short S3M::Properties::patternCount() const { return d->patternCount; } -TagLib::ushort S3M::Properties::flags() const +unsigned short S3M::Properties::flags() const { return d->flags; } -TagLib::ushort S3M::Properties::trackerVersion() const +unsigned short S3M::Properties::trackerVersion() const { return d->trackerVersion; } -TagLib::ushort S3M::Properties::fileFormatVersion() const +unsigned short S3M::Properties::fileFormatVersion() const { return d->fileFormatVersion; } @@ -153,7 +153,7 @@ unsigned char S3M::Properties::bpmSpeed() const return d->bpmSpeed; } -void S3M::Properties::setLengthInPatterns(ushort lengthInPatterns) +void S3M::Properties::setLengthInPatterns(unsigned short lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } @@ -168,27 +168,27 @@ void S3M::Properties::setStereo(bool stereo) d->stereo = stereo; } -void S3M::Properties::setSampleCount(ushort sampleCount) +void S3M::Properties::setSampleCount(unsigned short sampleCount) { d->sampleCount = sampleCount; } -void S3M::Properties::setPatternCount(ushort patternCount) +void S3M::Properties::setPatternCount(unsigned short patternCount) { d->patternCount = patternCount; } -void S3M::Properties::setFlags(ushort flags) +void S3M::Properties::setFlags(unsigned short flags) { d->flags = flags; } -void S3M::Properties::setTrackerVersion(ushort trackerVersion) +void S3M::Properties::setTrackerVersion(unsigned short trackerVersion) { d->trackerVersion = trackerVersion; } -void S3M::Properties::setFileFormatVersion(ushort fileFormatVersion) +void S3M::Properties::setFileFormatVersion(unsigned short fileFormatVersion) { d->fileFormatVersion = fileFormatVersion; } diff --git a/taglib/s3m/s3mproperties.h b/taglib/s3m/s3mproperties.h index f77d2204..4b14e97f 100644 --- a/taglib/s3m/s3mproperties.h +++ b/taglib/s3m/s3mproperties.h @@ -51,13 +51,13 @@ namespace TagLib { int sampleRate() const; int channels() const; - ushort lengthInPatterns() const; - bool stereo() const; - ushort sampleCount() const; - ushort patternCount() const; - ushort flags() const; - ushort trackerVersion() const; - ushort fileFormatVersion() const; + unsigned short lengthInPatterns() const; + bool stereo() const; + unsigned short sampleCount() const; + unsigned short patternCount() const; + unsigned short flags() const; + unsigned short trackerVersion() const; + unsigned short fileFormatVersion() const; unsigned char globalVolume() const; unsigned char masterVolume() const; unsigned char tempo() const; @@ -65,13 +65,13 @@ namespace TagLib { void setChannels(int channels); - void setLengthInPatterns (ushort lengthInPatterns); + void setLengthInPatterns (unsigned short lengthInPatterns); void setStereo (bool stereo); - void setSampleCount (ushort sampleCount); - void setPatternCount (ushort patternCount); - void setFlags (ushort flags); - void setTrackerVersion (ushort trackerVersion); - void setFileFormatVersion(ushort fileFormatVersion); + void setSampleCount (unsigned short sampleCount); + void setPatternCount (unsigned short patternCount); + void setFlags (unsigned short flags); + void setTrackerVersion (unsigned short trackerVersion); + void setFileFormatVersion(unsigned short fileFormatVersion); void setGlobalVolume (unsigned char globalVolume); void setMasterVolume (unsigned char masterVolume); void setTempo (unsigned char tempo); diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 71bcb43a..6aff6423 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -364,7 +364,7 @@ ByteVector ByteVector::fromUInt(uint value, bool mostSignificantByteFirst) ByteVector ByteVector::fromShort(short value, bool mostSignificantByteFirst) { - return fromNumber(value, mostSignificantByteFirst); + return fromNumber(value, mostSignificantByteFirst); } ByteVector ByteVector::fromLongLong(long long value, bool mostSignificantByteFirst) diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index f9884da7..6ad80528 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -174,7 +174,7 @@ namespace if(length > 0) { if(swap) { for(size_t i = 0; i < length; ++i) - data[i] = Utils::byteSwap(static_cast(s[i])); + data[i] = Utils::byteSwap(static_cast(s[i])); } else { ::wmemcpy(&data[0], s, length); @@ -194,7 +194,7 @@ namespace } // Uses memcpy instead of reinterpret_cast to avoid an alignment exception. - TagLib::ushort bom; + unsigned short bom; ::memcpy(&bom, s, 2); if(bom == 0xfeff) @@ -215,7 +215,7 @@ namespace data.resize(length / 2); for(size_t i = 0; i < length / 2; ++i) { - TagLib::ushort c; + unsigned short c; ::memcpy(&c, s, 2); if(swap) c = Utils::byteSwap(c); diff --git a/taglib/toolkit/tutils.h b/taglib/toolkit/tutils.h index 9855ed91..4e2c13ce 100644 --- a/taglib/toolkit/tutils.h +++ b/taglib/toolkit/tutils.h @@ -59,7 +59,7 @@ namespace TagLib /*! * Reverses the order of bytes in an 16-bit integer. */ - inline ushort byteSwap(ushort x) + inline unsigned short byteSwap(unsigned short x) { #if defined(HAVE_BOOST_BYTESWAP) diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index fc337ba4..7fa032c7 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -31,7 +31,6 @@ using namespace TagLib; using namespace XM; using TagLib::uint; -using TagLib::ushort; using TagLib::ulong; /*! @@ -180,11 +179,11 @@ protected: bool bigEndian; }; -class U16Reader : public NumberReader +class U16Reader : public NumberReader { public: - U16Reader(ushort &value, bool bigEndian) - : NumberReader(value, bigEndian) {} + U16Reader(unsigned short &value, bool bigEndian) + : NumberReader(value, bigEndian) {} uint read(TagLib::File &file, uint limit) { @@ -268,7 +267,7 @@ public: * Read a unsigned 16 Bit integer into \a number. The byte order * is controlled by \a bigEndian. */ - StructReader &u16(ushort &number, bool bigEndian) + StructReader &u16(unsigned short &number, bool bigEndian) { m_readers.append(new U16Reader(number, bigEndian)); return *this; @@ -277,7 +276,7 @@ public: /*! * Read a unsigned 16 Bit little endian integer into \a number. */ - StructReader &u16L(ushort &number) + StructReader &u16L(unsigned short &number) { return u16(number, false); } @@ -285,7 +284,7 @@ public: /*! * Read a unsigned 16 Bit big endian integer into \a number. */ - StructReader &u16B(ushort &number) + StructReader &u16B(unsigned short &number) { return u16(number, true); } @@ -416,22 +415,22 @@ bool XM::File::save() return false; seek(70); - ushort patternCount = 0; - ushort instrumentCount = 0; + unsigned short patternCount = 0; + unsigned short instrumentCount = 0; if(!readU16L(patternCount) || !readU16L(instrumentCount)) return false; long pos = 60 + headerSize; // should be long long in taglib2. // need to read patterns again in order to seek to the instruments: - for(ushort i = 0; i < patternCount; ++ i) { + for(unsigned short i = 0; i < patternCount; ++ i) { seek(pos); ulong patternHeaderLength = 0; if(!readU32L(patternHeaderLength) || patternHeaderLength < 4) return false; seek(pos + 7); - ushort dataSize = 0; + unsigned short dataSize = 0; if (!readU16L(dataSize)) return false; @@ -440,7 +439,7 @@ bool XM::File::save() const StringList lines = d->tag.comment().split("\n"); uint sampleNameIndex = instrumentCount; - for(ushort i = 0; i < instrumentCount; ++ i) { + for(unsigned short i = 0; i < instrumentCount; ++ i) { seek(pos); ulong instrumentHeaderSize = 0; if(!readU32L(instrumentHeaderSize) || instrumentHeaderSize < 4) @@ -453,7 +452,7 @@ bool XM::File::save() else writeString(lines[i], len); - ushort sampleCount = 0; + unsigned short sampleCount = 0; if(instrumentHeaderSize >= 29U) { seek(pos + 27); if(!readU16L(sampleCount)) @@ -469,7 +468,7 @@ bool XM::File::save() pos += instrumentHeaderSize; - for(ushort j = 0; j < sampleCount; ++ j) { + for(unsigned short j = 0; j < sampleCount; ++ j) { if(sampleHeaderSize > 4U) { seek(pos); ulong sampleLength = 0; @@ -513,14 +512,14 @@ void XM::File::read(bool) READ_U32L_AS(headerSize); READ_ASSERT(headerSize >= 4); - ushort length = 0; - ushort restartPosition = 0; - ushort channels = 0; - ushort patternCount = 0; - ushort instrumentCount = 0; - ushort flags = 0; - ushort tempo = 0; - ushort bpmSpeed = 0; + unsigned short length = 0; + unsigned short restartPosition = 0; + unsigned short channels = 0; + unsigned short patternCount = 0; + unsigned short instrumentCount = 0; + unsigned short flags = 0; + unsigned short tempo = 0; + unsigned short bpmSpeed = 0; StructReader header; header.u16L(length) @@ -549,13 +548,13 @@ void XM::File::read(bool) seek(60 + headerSize); // read patterns: - for(ushort i = 0; i < patternCount; ++ i) { + for(unsigned short i = 0; i < patternCount; ++ i) { READ_U32L_AS(patternHeaderLength); READ_ASSERT(patternHeaderLength >= 4); unsigned char packingType = 0; - ushort rowCount = 0; - ushort dataSize = 0; + unsigned short rowCount = 0; + unsigned short dataSize = 0; StructReader pattern; pattern.byte(packingType).u16L(rowCount).u16L(dataSize); @@ -570,13 +569,13 @@ void XM::File::read(bool) uint sumSampleCount = 0; // read instruments: - for(ushort i = 0; i < instrumentCount; ++ i) { + for(unsigned short i = 0; i < instrumentCount; ++ i) { READ_U32L_AS(instrumentHeaderSize); READ_ASSERT(instrumentHeaderSize >= 4); String instrumentName; unsigned char instrumentType = 0; - ushort sampleCount = 0; + unsigned short sampleCount = 0; StructReader instrument; instrument.string(instrumentName, 22).byte(instrumentType).u16L(sampleCount); @@ -594,7 +593,7 @@ void XM::File::read(bool) // skip unhandeled header proportion: seek(instrumentHeaderSize - count - 4, Current); - for(ushort j = 0; j < sampleCount; ++ j) { + for(unsigned short j = 0; j < sampleCount; ++ j) { ulong sampleLength = 0; ulong loopStart = 0; ulong loopLength = 0; diff --git a/taglib/xm/xmproperties.cpp b/taglib/xm/xmproperties.cpp index 3d4a3c38..9a7fa6b2 100644 --- a/taglib/xm/xmproperties.cpp +++ b/taglib/xm/xmproperties.cpp @@ -41,16 +41,16 @@ public: { } - ushort lengthInPatterns; - int channels; - ushort version; - ushort restartPosition; - ushort patternCount; - ushort instrumentCount; + unsigned short lengthInPatterns; + int channels; + unsigned short version; + unsigned short restartPosition; + unsigned short patternCount; + unsigned short instrumentCount; uint sampleCount; - ushort flags; - ushort tempo; - ushort bpmSpeed; + unsigned short flags; + unsigned short tempo; + unsigned short bpmSpeed; }; XM::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : @@ -94,27 +94,27 @@ int XM::Properties::channels() const return d->channels; } -TagLib::ushort XM::Properties::lengthInPatterns() const +unsigned short XM::Properties::lengthInPatterns() const { return d->lengthInPatterns; } -TagLib::ushort XM::Properties::version() const +unsigned short XM::Properties::version() const { return d->version; } -TagLib::ushort XM::Properties::restartPosition() const +unsigned short XM::Properties::restartPosition() const { return d->restartPosition; } -TagLib::ushort XM::Properties::patternCount() const +unsigned short XM::Properties::patternCount() const { return d->patternCount; } -TagLib::ushort XM::Properties::instrumentCount() const +unsigned short XM::Properties::instrumentCount() const { return d->instrumentCount; } @@ -124,22 +124,22 @@ TagLib::uint XM::Properties::sampleCount() const return d->sampleCount; } -TagLib::ushort XM::Properties::flags() const +unsigned short XM::Properties::flags() const { return d->flags; } -TagLib::ushort XM::Properties::tempo() const +unsigned short XM::Properties::tempo() const { return d->tempo; } -TagLib::ushort XM::Properties::bpmSpeed() const +unsigned short XM::Properties::bpmSpeed() const { return d->bpmSpeed; } -void XM::Properties::setLengthInPatterns(ushort lengthInPatterns) +void XM::Properties::setLengthInPatterns(unsigned short lengthInPatterns) { d->lengthInPatterns = lengthInPatterns; } @@ -149,22 +149,22 @@ void XM::Properties::setChannels(int channels) d->channels = channels; } -void XM::Properties::setVersion(ushort version) +void XM::Properties::setVersion(unsigned short version) { d->version = version; } -void XM::Properties::setRestartPosition(ushort restartPosition) +void XM::Properties::setRestartPosition(unsigned short restartPosition) { d->restartPosition = restartPosition; } -void XM::Properties::setPatternCount(ushort patternCount) +void XM::Properties::setPatternCount(unsigned short patternCount) { d->patternCount = patternCount; } -void XM::Properties::setInstrumentCount(ushort instrumentCount) +void XM::Properties::setInstrumentCount(unsigned short instrumentCount) { d->instrumentCount = instrumentCount; } @@ -174,17 +174,17 @@ void XM::Properties::setSampleCount(uint sampleCount) d->sampleCount = sampleCount; } -void XM::Properties::setFlags(ushort flags) +void XM::Properties::setFlags(unsigned short flags) { d->flags = flags; } -void XM::Properties::setTempo(ushort tempo) +void XM::Properties::setTempo(unsigned short tempo) { d->tempo = tempo; } -void XM::Properties::setBpmSpeed(ushort bpmSpeed) +void XM::Properties::setBpmSpeed(unsigned short bpmSpeed) { d->bpmSpeed = bpmSpeed; } diff --git a/taglib/xm/xmproperties.h b/taglib/xm/xmproperties.h index f929982b..4fdf8b4b 100644 --- a/taglib/xm/xmproperties.h +++ b/taglib/xm/xmproperties.h @@ -46,27 +46,27 @@ namespace TagLib { int sampleRate() const; int channels() const; - ushort lengthInPatterns() const; - ushort version() const; - ushort restartPosition() const; - ushort patternCount() const; - ushort instrumentCount() const; + unsigned short lengthInPatterns() const; + unsigned short version() const; + unsigned short restartPosition() const; + unsigned short patternCount() const; + unsigned short instrumentCount() const; uint sampleCount() const; - ushort flags() const; - ushort tempo() const; - ushort bpmSpeed() const; + unsigned short flags() const; + unsigned short tempo() const; + unsigned short bpmSpeed() const; void setChannels(int channels); - void setLengthInPatterns(ushort lengthInPatterns); - void setVersion(ushort version); - void setRestartPosition(ushort restartPosition); - void setPatternCount(ushort patternCount); - void setInstrumentCount(ushort instrumentCount); + void setLengthInPatterns(unsigned short lengthInPatterns); + void setVersion(unsigned short version); + void setRestartPosition(unsigned short restartPosition); + void setPatternCount(unsigned short patternCount); + void setInstrumentCount(unsigned short instrumentCount); void setSampleCount(uint sampleCount); - void setFlags(ushort flags); - void setTempo(ushort tempo); - void setBpmSpeed(ushort bpmSpeed); + void setFlags(unsigned short flags); + void setTempo(unsigned short tempo); + void setBpmSpeed(unsigned short bpmSpeed); private: Properties(const Properties&); diff --git a/tests/test_it.cpp b/tests/test_it.cpp index 7bb9084b..24cfb1a6 100644 --- a/tests/test_it.cpp +++ b/tests/test_it.cpp @@ -108,14 +108,14 @@ private: CPPUNIT_ASSERT_EQUAL( 0, p->bitrate()); CPPUNIT_ASSERT_EQUAL( 0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(64, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->lengthInPatterns()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->lengthInPatterns()); CPPUNIT_ASSERT_EQUAL(true, p->stereo()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->instrumentCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 5, p->sampleCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)535, p->version()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)532, p->compatibleVersion()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 9, p->flags()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->instrumentCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 5, p->sampleCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->patternCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short)535, p->version()); + CPPUNIT_ASSERT_EQUAL((unsigned short)532, p->compatibleVersion()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 9, p->flags()); CPPUNIT_ASSERT_EQUAL((unsigned char)128, p->globalVolume()); CPPUNIT_ASSERT_EQUAL((unsigned char) 48, p->mixVolume()); CPPUNIT_ASSERT_EQUAL((unsigned char)125, p->tempo()); diff --git a/tests/test_s3m.cpp b/tests/test_s3m.cpp index 41579d3c..8133e215 100644 --- a/tests/test_s3m.cpp +++ b/tests/test_s3m.cpp @@ -98,13 +98,13 @@ private: CPPUNIT_ASSERT_EQUAL( 0, p->bitrate()); CPPUNIT_ASSERT_EQUAL( 0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(16, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->lengthInPatterns()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->lengthInPatterns()); CPPUNIT_ASSERT_EQUAL(false, p->stereo()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 5, p->sampleCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->flags()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)4896, p->trackerVersion()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 2, p->fileFormatVersion()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 5, p->sampleCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->patternCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->flags()); + CPPUNIT_ASSERT_EQUAL((unsigned short)4896, p->trackerVersion()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 2, p->fileFormatVersion()); CPPUNIT_ASSERT_EQUAL((unsigned char) 64, p->globalVolume()); CPPUNIT_ASSERT_EQUAL((unsigned char) 48, p->masterVolume()); CPPUNIT_ASSERT_EQUAL((unsigned char)125, p->tempo()); diff --git a/tests/test_xm.cpp b/tests/test_xm.cpp index 48e6ec2c..e4527c74 100644 --- a/tests/test_xm.cpp +++ b/tests/test_xm.cpp @@ -130,14 +130,14 @@ public: CPPUNIT_ASSERT_EQUAL(0, p->bitrate()); CPPUNIT_ASSERT_EQUAL(0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(8, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->lengthInPatterns()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->version()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0 , p->restartPosition()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->instrumentCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->flags()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->lengthInPatterns()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->version()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0 , p->restartPosition()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->patternCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->instrumentCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->flags()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 6, p->tempo()); + CPPUNIT_ASSERT_EQUAL((unsigned short)125, p->bpmSpeed()); CPPUNIT_ASSERT_EQUAL(titleBefore, t->title()); CPPUNIT_ASSERT_EQUAL(String(), t->artist()); CPPUNIT_ASSERT_EQUAL(String(), t->album()); @@ -176,14 +176,14 @@ private: CPPUNIT_ASSERT_EQUAL(0, p->bitrate()); CPPUNIT_ASSERT_EQUAL(0, p->sampleRate()); CPPUNIT_ASSERT_EQUAL(8, p->channels()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->lengthInPatterns()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)260, p->version()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 0, p->restartPosition()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->patternCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)128, p->instrumentCount()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 1, p->flags()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort) 6, p->tempo()); - CPPUNIT_ASSERT_EQUAL((TagLib::ushort)125, p->bpmSpeed()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->lengthInPatterns()); + CPPUNIT_ASSERT_EQUAL((unsigned short)260, p->version()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 0, p->restartPosition()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->patternCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short)128, p->instrumentCount()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 1, p->flags()); + CPPUNIT_ASSERT_EQUAL((unsigned short) 6, p->tempo()); + CPPUNIT_ASSERT_EQUAL((unsigned short)125, p->bpmSpeed()); CPPUNIT_ASSERT_EQUAL(title, t->title()); CPPUNIT_ASSERT_EQUAL(String(), t->artist()); CPPUNIT_ASSERT_EQUAL(String(), t->album());