mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1231793: Part 1 - Added read functions for Little Endian integers to ByteReader.h. r=jya
This commit is contained in:
parent
48d0f8b9fa
commit
e7c36cac63
@ -87,6 +87,16 @@ public:
|
||||
return mozilla::BigEndian::readUint16(ptr);
|
||||
}
|
||||
|
||||
int16_t ReadLE16()
|
||||
{
|
||||
auto ptr = Read(2);
|
||||
if (!ptr) {
|
||||
MOZ_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
return mozilla::LittleEndian::readInt16(ptr);
|
||||
}
|
||||
|
||||
uint32_t ReadU24()
|
||||
{
|
||||
auto ptr = Read(3);
|
||||
@ -102,6 +112,20 @@ public:
|
||||
return (uint32_t)ReadU24();
|
||||
}
|
||||
|
||||
int32_t ReadLE24()
|
||||
{
|
||||
auto ptr = Read(3);
|
||||
if (!ptr) {
|
||||
MOZ_ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
int32_t result = int32_t(ptr[2] << 16 | ptr[1] << 8 | ptr[0]);
|
||||
if (result & 0x00800000u) {
|
||||
result -= 0x1000000;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CanRead32() { return mRemaining >= 4; }
|
||||
|
||||
uint32_t ReadU32()
|
||||
|
Loading…
Reference in New Issue
Block a user