mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-09-25 08:10:46 +00:00
fix: remove byte type alias
This commit is contained in:
@@ -10,7 +10,7 @@ void ConsoleSaveFileConverter::ProcessSimpleFile(ConsoleSaveFile *sourceSave, Fi
|
||||
DWORD numberOfBytesRead = 0;
|
||||
DWORD numberOfBytesWritten = 0;
|
||||
|
||||
byte *data = new byte[sourceFileEntry->getFileSize()];
|
||||
uint8_t *data = new uint8_t[sourceFileEntry->getFileSize()];
|
||||
|
||||
// Read from source
|
||||
sourceSave->readFile(sourceFileEntry, data, sourceFileEntry->getFileSize(), &numberOfBytesRead);
|
||||
|
||||
@@ -25,7 +25,7 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile
|
||||
//the next byte of data, or -1 if the end of the file is reached.
|
||||
int ConsoleSaveFileInputStream::read()
|
||||
{
|
||||
byte byteRead = static_cast<byte>(0);
|
||||
uint8_t byteRead = static_cast<uint8_t>(0);
|
||||
DWORD numberOfBytesRead;
|
||||
|
||||
BOOL result = m_saveFile->readFile(
|
||||
|
||||
@@ -243,7 +243,7 @@ void ConsoleSaveFileOriginal::deleteFile( FileEntry *file )
|
||||
|
||||
const int bufferSize = 4096;
|
||||
int amountToRead = bufferSize;
|
||||
byte buffer[bufferSize];
|
||||
uint8_t buffer[bufferSize];
|
||||
DWORD bufferDataSize = 0;
|
||||
|
||||
|
||||
@@ -474,8 +474,8 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt
|
||||
const DWORD bufferSize = 4096;
|
||||
DWORD amountToRead = bufferSize;
|
||||
//assert( nNumberOfBytesToWrite <= bufferSize );
|
||||
static byte buffer1[bufferSize];
|
||||
static byte buffer2[bufferSize];
|
||||
static uint8_t buffer1[bufferSize];
|
||||
static uint8_t buffer2[bufferSize];
|
||||
DWORD buffer1Size = 0;
|
||||
DWORD buffer2Size = 0;
|
||||
|
||||
@@ -666,11 +666,11 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
|
||||
// On PS3, don't compress the data as we can't really afford the extra memory this requires for the output buffer. Instead we'll be writing
|
||||
// directly from the save data.
|
||||
StorageManager.SetSaveData(pvSaveMem,fileSize);
|
||||
byte *compData = (byte *)pvSaveMem;
|
||||
uint8_t *compData = (uint8_t *)pvSaveMem;
|
||||
#else
|
||||
// Attempt to allocate the required memory
|
||||
// We do not own this, it belongs to the StorageManager
|
||||
byte *compData = (byte *)StorageManager.AllocateSaveData( compLength );
|
||||
uint8_t *compData = (uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
|
||||
#ifdef __PSVITA__
|
||||
// AP - make sure we always allocate just what is needed so it will only SAVE what is needed.
|
||||
@@ -708,7 +708,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail )
|
||||
compLength = compLength+8;
|
||||
|
||||
// Attempt to allocate the required memory
|
||||
compData = (byte *)StorageManager.AllocateSaveData( compLength );
|
||||
compData = (uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ void ConsoleSaveFileOutputStream::write(unsigned int b)
|
||||
{
|
||||
DWORD numberOfBytesWritten;
|
||||
|
||||
byte value = (byte) b;
|
||||
uint8_t value = (uint8_t) b;
|
||||
|
||||
BOOL result = m_saveFile->writeFile(
|
||||
m_file,
|
||||
|
||||
@@ -641,7 +641,7 @@ void ConsoleSaveFileSplit::deleteFile( FileEntry *file )
|
||||
|
||||
const int bufferSize = 4096;
|
||||
int amountToRead = bufferSize;
|
||||
byte buffer[bufferSize];
|
||||
uint8_t buffer[bufferSize];
|
||||
DWORD bufferDataSize = 0;
|
||||
|
||||
|
||||
@@ -1044,8 +1044,8 @@ void ConsoleSaveFileSplit::MoveDataBeyond(FileEntry *file, DWORD nNumberOfBytesT
|
||||
const DWORD bufferSize = 4096;
|
||||
DWORD amountToRead = bufferSize;
|
||||
//assert( nNumberOfBytesToWrite <= bufferSize );
|
||||
static byte buffer1[bufferSize];
|
||||
static byte buffer2[bufferSize];
|
||||
static uint8_t buffer1[bufferSize];
|
||||
static uint8_t buffer2[bufferSize];
|
||||
DWORD buffer1Size = 0;
|
||||
DWORD buffer2Size = 0;
|
||||
|
||||
@@ -1352,7 +1352,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail)
|
||||
|
||||
// Attempt to allocate the required memory
|
||||
// We do not own this, it belongs to the StorageManager
|
||||
byte *compData = (byte *)StorageManager.AllocateSaveData( compLength );
|
||||
uint8_t *compData = (uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
|
||||
// If we failed to allocate then compData will be NULL
|
||||
// Pre-calculate the compressed data size so that we can attempt to allocate a smaller buffer
|
||||
@@ -1379,7 +1379,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail)
|
||||
compLength = compLength+8;
|
||||
|
||||
// Attempt to allocate the required memory
|
||||
compData = (byte *)StorageManager.AllocateSaveData( compLength );
|
||||
compData = (uint8_t *)StorageManager.AllocateSaveData( compLength );
|
||||
}
|
||||
|
||||
if(compData != NULL)
|
||||
|
||||
@@ -84,7 +84,7 @@ ssize_t ReadFile(int fd, void* buffer, size_t byteRead, DWORD* numberOfBytesRead
|
||||
//the next byte of data, or -1 if the end of the file is reached.
|
||||
int FileInputStream::read()
|
||||
{
|
||||
byte byteRead = static_cast<byte>(0);
|
||||
uint8_t byteRead = static_cast<uint8_t>(0);
|
||||
DWORD numberOfBytesRead;
|
||||
|
||||
BOOL bSuccess = ReadFile(
|
||||
|
||||
@@ -74,7 +74,7 @@ FileOutputStream::~FileOutputStream()
|
||||
//b - the byte to be written.
|
||||
void FileOutputStream::write(unsigned int b)
|
||||
{
|
||||
byte value = (byte) b;
|
||||
uint8_t value = (uint8_t) b;
|
||||
|
||||
#if defined(_WIN32)
|
||||
BOOL result = WriteFile(
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
dis->readFully(data);
|
||||
}
|
||||
|
||||
byte getId() { return TAG_Byte_Array; }
|
||||
uint8_t getId() { return TAG_Byte_Array; }
|
||||
|
||||
wstring toString()
|
||||
{
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
class ByteTag : public Tag
|
||||
{
|
||||
public:
|
||||
byte data;
|
||||
uint8_t data;
|
||||
ByteTag(const wstring &name) : Tag(name) {}
|
||||
ByteTag(const wstring &name, byte data) : Tag(name) {this->data = data; }
|
||||
ByteTag(const wstring &name, uint8_t data) : Tag(name) {this->data = data; }
|
||||
|
||||
void write(DataOutput *dos) { dos->writeByte(data); }
|
||||
void load(DataInput *dis) { data = dis->readByte(); }
|
||||
|
||||
byte getId() { return TAG_Byte; }
|
||||
uint8_t getId() { return TAG_Byte; }
|
||||
wstring toString()
|
||||
{
|
||||
static wchar_t buf[32];
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
byte getId()
|
||||
uint8_t getId()
|
||||
{
|
||||
return TAG_Compound;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
tags[name] = tag->setName(wstring( name ));
|
||||
}
|
||||
|
||||
void putByte(const wchar_t * name, byte value)
|
||||
void putByte(const wchar_t * name, uint8_t value)
|
||||
{
|
||||
tags[name] = (new ByteTag(name,value));
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
|
||||
void putBoolean(const wchar_t * string, bool val)
|
||||
{
|
||||
putByte(string, val?static_cast<byte>(1):static_cast<byte>(0));
|
||||
putByte(string, val?static_cast<uint8_t>(1):static_cast<uint8_t>(0));
|
||||
}
|
||||
|
||||
Tag *get(const wchar_t *name)
|
||||
@@ -132,9 +132,9 @@ public:
|
||||
return tags.find(name) != tags.end();
|
||||
}
|
||||
|
||||
byte getByte(const wchar_t * name)
|
||||
uint8_t getByte(const wchar_t * name)
|
||||
{
|
||||
if (tags.find(name) == tags.end()) return (byte)0;
|
||||
if (tags.find(name) == tags.end()) return (uint8_t)0;
|
||||
return ((ByteTag *) tags[name])->data;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
|
||||
bool getBoolean(const wchar_t *string)
|
||||
{
|
||||
return getByte(string) != static_cast<byte>(0);
|
||||
return getByte(string) != static_cast<uint8_t>(0);
|
||||
}
|
||||
|
||||
void remove(const wstring &name)
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
void write(DataOutput *dos) { dos->writeDouble(data); }
|
||||
void load(DataInput *dis) { data = dis->readDouble(); }
|
||||
|
||||
byte getId() { return TAG_Double; }
|
||||
uint8_t getId() { return TAG_Double; }
|
||||
wstring toString()
|
||||
{
|
||||
static wchar_t buf[32];
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
void load(DataInput *dis) {};
|
||||
void write(DataOutput *dos) {};
|
||||
|
||||
byte getId() { return TAG_End; }
|
||||
uint8_t getId() { return TAG_End; }
|
||||
wstring toString() { return wstring( L"END" ); }
|
||||
|
||||
Tag *copy()
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
void write(DataOutput *dos) { dos->writeFloat(data); }
|
||||
void load(DataInput *dis) { data = dis->readFloat(); }
|
||||
|
||||
byte getId() { return TAG_Float; }
|
||||
uint8_t getId() { return TAG_Float; }
|
||||
wstring toString()
|
||||
{
|
||||
static wchar_t buf[32];
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
byte getId() { return TAG_Int_Array; }
|
||||
uint8_t getId() { return TAG_Int_Array; }
|
||||
|
||||
wstring toString()
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
void write(DataOutput *dos) { dos->writeInt(data); }
|
||||
void load(DataInput *dis) { data = dis->readInt(); }
|
||||
|
||||
byte getId() { return TAG_Int; }
|
||||
uint8_t getId() { return TAG_Int; }
|
||||
wstring toString()
|
||||
{
|
||||
static wchar_t buf[32];
|
||||
|
||||
@@ -6,7 +6,7 @@ template <class T> class ListTag : public Tag
|
||||
{
|
||||
private:
|
||||
vector<Tag *> list;
|
||||
byte type;
|
||||
uint8_t type;
|
||||
|
||||
public:
|
||||
ListTag() : Tag(L"") {}
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
void write(DataOutput *dos)
|
||||
{
|
||||
if (list.size() > 0) type = (list[0])->getId();
|
||||
else type = static_cast<byte>(1);
|
||||
else type = static_cast<uint8_t>(1);
|
||||
|
||||
dos->writeByte(type);
|
||||
dos->writeInt((int)list.size());
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
byte getId() { return TAG_List; }
|
||||
uint8_t getId() { return TAG_List; }
|
||||
|
||||
wstring toString()
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
void write(DataOutput *dos) { dos->writeLong(data); }
|
||||
void load(DataInput *dis) { data = dis->readLong(); }
|
||||
|
||||
byte getId() { return TAG_Long; }
|
||||
uint8_t getId() { return TAG_Long; }
|
||||
wstring toString()
|
||||
{
|
||||
static wchar_t buf[32];
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
void write(DataOutput *dos) { dos->writeShort(data); }
|
||||
void load(DataInput *dis) { data = dis->readShort(); }
|
||||
|
||||
byte getId() { return TAG_Short; }
|
||||
uint8_t getId() { return TAG_Short; }
|
||||
wstring toString()
|
||||
{
|
||||
static wchar_t buf[32];
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
data = dis->readUTF();
|
||||
}
|
||||
|
||||
byte getId() { return TAG_String; }
|
||||
uint8_t getId() { return TAG_String; }
|
||||
|
||||
wstring toString()
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ Tag *Tag::setName(const wstring& name)
|
||||
|
||||
Tag *Tag::readNamedTag(DataInput *dis)
|
||||
{
|
||||
byte type = dis->readByte();
|
||||
uint8_t type = dis->readByte();
|
||||
if ( static_cast<int>(type) == 0) return new EndTag();
|
||||
|
||||
// 4J Stu - readByte can return -1, so if it's that then also mark as the end tag
|
||||
@@ -96,7 +96,7 @@ Tag *Tag::readNamedTag(DataInput *dis)
|
||||
|
||||
Tag *tag = newTag(type, name);
|
||||
// short length = dis.readShort();
|
||||
// byte[] bytes = new byte[length];
|
||||
// byte[] bytes = new uint8_t[length];
|
||||
// dis.readFully(bytes);
|
||||
|
||||
tag->load(dis);
|
||||
@@ -116,7 +116,7 @@ void Tag::writeNamedTag(Tag *tag, DataOutput *dos)
|
||||
tag->write(dos);
|
||||
}
|
||||
|
||||
Tag *Tag::newTag(byte type, const wstring &name)
|
||||
Tag *Tag::newTag(uint8_t type, const wstring &name)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@@ -148,7 +148,7 @@ Tag *Tag::newTag(byte type, const wstring &name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const wchar_t *Tag::getTagName(byte type)
|
||||
const wchar_t *Tag::getTagName(uint8_t type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
||||
@@ -7,18 +7,18 @@ using namespace std;
|
||||
class Tag
|
||||
{
|
||||
public:
|
||||
static const byte TAG_End = static_cast<byte>(0);
|
||||
static const byte TAG_Byte = static_cast<byte>(1);
|
||||
static const byte TAG_Short = static_cast<byte>(2);
|
||||
static const byte TAG_Int = static_cast<byte>(3);
|
||||
static const byte TAG_Long = static_cast<byte>(4);
|
||||
static const byte TAG_Float = static_cast<byte>(5);
|
||||
static const byte TAG_Double = static_cast<byte>(6);
|
||||
static const byte TAG_Byte_Array = static_cast<byte>(7);
|
||||
static const byte TAG_String = static_cast<byte>(8);
|
||||
static const byte TAG_List = static_cast<byte>(9);
|
||||
static const byte TAG_Compound = static_cast<byte>(10);
|
||||
static const byte TAG_Int_Array = static_cast<byte>(11);
|
||||
static const uint8_t TAG_End = static_cast<uint8_t>(0);
|
||||
static const uint8_t TAG_Byte = static_cast<uint8_t>(1);
|
||||
static const uint8_t TAG_Short = static_cast<uint8_t>(2);
|
||||
static const uint8_t TAG_Int = static_cast<uint8_t>(3);
|
||||
static const uint8_t TAG_Long = static_cast<uint8_t>(4);
|
||||
static const uint8_t TAG_Float = static_cast<uint8_t>(5);
|
||||
static const uint8_t TAG_Double = static_cast<uint8_t>(6);
|
||||
static const uint8_t TAG_Byte_Array = static_cast<uint8_t>(7);
|
||||
static const uint8_t TAG_String = static_cast<uint8_t>(8);
|
||||
static const uint8_t TAG_List = static_cast<uint8_t>(9);
|
||||
static const uint8_t TAG_Compound = static_cast<uint8_t>(10);
|
||||
static const uint8_t TAG_Int_Array = static_cast<uint8_t>(11);
|
||||
|
||||
private:
|
||||
wstring name;
|
||||
@@ -30,15 +30,15 @@ public:
|
||||
virtual void write(DataOutput *dos) = 0;
|
||||
virtual void load(DataInput *dis) = 0;
|
||||
virtual wstring toString() = 0;
|
||||
virtual byte getId() = 0;
|
||||
virtual uint8_t getId() = 0;
|
||||
void print(ostream out);
|
||||
void print(char *prefix, wostream out);
|
||||
wstring getName();
|
||||
Tag *setName(const wstring& name);
|
||||
static Tag *readNamedTag(DataInput *dis);
|
||||
static void writeNamedTag(Tag *tag, DataOutput *dos);
|
||||
static Tag *newTag(byte type, const wstring &name);
|
||||
static const wchar_t *getTagName(byte type);
|
||||
static Tag *newTag(uint8_t type, const wstring &name);
|
||||
static const wchar_t *getTagName(uint8_t type);
|
||||
virtual ~Tag() {}
|
||||
virtual bool equals(Tag *obj); // 4J Brought forward from 1.2
|
||||
virtual Tag *copy() = 0; // 4J Brought foward from 1.2
|
||||
|
||||
@@ -79,7 +79,7 @@ void BufferedOutputStream::write(byteArray b)
|
||||
//b - the byte to be written.
|
||||
void BufferedOutputStream::write(unsigned int b)
|
||||
{
|
||||
buf[count++] = (byte) b;
|
||||
buf[count++] = (uint8_t) b;
|
||||
if( count == buf.length )
|
||||
{
|
||||
flush();
|
||||
|
||||
@@ -33,7 +33,7 @@ void ByteArrayOutputStream::write(unsigned int b)
|
||||
if( count + 1 >= buf.length )
|
||||
buf.resize( buf.length * 2 );
|
||||
|
||||
buf[count] = (byte) b;
|
||||
buf[count] = (uint8_t) b;
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
ByteBuffer::ByteBuffer( unsigned int capacity ) : Buffer( capacity )
|
||||
{
|
||||
hasBackingArray = false;
|
||||
buffer = new byte[capacity];
|
||||
memset( buffer,0,sizeof(byte)*capacity);
|
||||
buffer = new uint8_t[capacity];
|
||||
memset( buffer,0,sizeof(uint8_t)*capacity);
|
||||
byteOrder = BIGENDIAN;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ ByteBuffer *ByteBuffer::allocateDirect(int capacity)
|
||||
}
|
||||
|
||||
|
||||
ByteBuffer::ByteBuffer( unsigned int capacity, byte *backingArray ) : Buffer( capacity )
|
||||
ByteBuffer::ByteBuffer( unsigned int capacity, uint8_t *backingArray ) : Buffer( capacity )
|
||||
{
|
||||
hasBackingArray = true;
|
||||
buffer = backingArray;
|
||||
@@ -38,7 +38,7 @@ ByteBuffer::~ByteBuffer()
|
||||
}
|
||||
|
||||
//Wraps a byte array into a buffer.
|
||||
//The new buffer will be backed by the given byte array; that is, modifications to the buffer will cause the array
|
||||
//The new buffer will be backed by the given uint8_t array; that is, modifications to the buffer will cause the array
|
||||
//to be modified and vice versa. The new buffer's capacity and limit will be array.length, its position will be zero,
|
||||
//and its mark will be undefined. Its backing array will be the given array, and its array offset will be zero.
|
||||
//
|
||||
@@ -85,7 +85,7 @@ ByteBuffer *ByteBuffer::flip()
|
||||
}
|
||||
|
||||
// 4J Added so we can write this to a file
|
||||
byte *ByteBuffer::getBuffer()
|
||||
uint8_t *ByteBuffer::getBuffer()
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ int ByteBuffer::getSize()
|
||||
//The byte at the given index
|
||||
//Throws:
|
||||
//IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit
|
||||
byte ByteBuffer::get(int index)
|
||||
uint8_t ByteBuffer::get(int index)
|
||||
{
|
||||
assert( index < m_limit );
|
||||
assert( index >= 0 );
|
||||
@@ -253,7 +253,7 @@ void ByteBuffer::getShortArray(shortArray &s)
|
||||
//Throws:
|
||||
//IndexOutOfBoundsException - If index is negative or not smaller than the buffer's limit
|
||||
//ReadOnlyBufferException - If this buffer is read-only
|
||||
ByteBuffer *ByteBuffer::put(int index, byte b)
|
||||
ByteBuffer *ByteBuffer::put(int index, uint8_t b)
|
||||
{
|
||||
assert( index < m_limit );
|
||||
assert( index >= 0 );
|
||||
@@ -277,17 +277,17 @@ ByteBuffer *ByteBuffer::putInt(int value)
|
||||
|
||||
if( byteOrder == BIGENDIAN )
|
||||
{
|
||||
buffer[m_position] = static_cast<byte>((value >> 24) & 0xFF);
|
||||
buffer[m_position+1] = static_cast<byte>((value >> 16) & 0xFF);
|
||||
buffer[m_position+2] = static_cast<byte>((value >> 8) & 0xFF);
|
||||
buffer[m_position+3] = static_cast<byte>(value & 0xFF);
|
||||
buffer[m_position] = static_cast<uint8_t>((value >> 24) & 0xFF);
|
||||
buffer[m_position+1] = static_cast<uint8_t>((value >> 16) & 0xFF);
|
||||
buffer[m_position+2] = static_cast<uint8_t>((value >> 8) & 0xFF);
|
||||
buffer[m_position+3] = static_cast<uint8_t>(value & 0xFF);
|
||||
}
|
||||
else if( byteOrder == LITTLEENDIAN )
|
||||
{
|
||||
buffer[m_position] = static_cast<byte>(value & 0xFF);
|
||||
buffer[m_position+1] = static_cast<byte>((value >> 8) & 0xFF);
|
||||
buffer[m_position+2] = static_cast<byte>((value >> 16) & 0xFF);
|
||||
buffer[m_position+3] = static_cast<byte>((value >> 24) & 0xFF);
|
||||
buffer[m_position] = static_cast<uint8_t>(value & 0xFF);
|
||||
buffer[m_position+1] = static_cast<uint8_t>((value >> 8) & 0xFF);
|
||||
buffer[m_position+2] = static_cast<uint8_t>((value >> 16) & 0xFF);
|
||||
buffer[m_position+3] = static_cast<uint8_t>((value >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
m_position += 4;
|
||||
@@ -309,17 +309,17 @@ ByteBuffer *ByteBuffer::putInt(unsigned int index, int value)
|
||||
|
||||
if( byteOrder == BIGENDIAN )
|
||||
{
|
||||
buffer[index] = static_cast<byte>((value >> 24) & 0xFF);
|
||||
buffer[index+1] = static_cast<byte>((value >> 16) & 0xFF);
|
||||
buffer[index+2] = static_cast<byte>((value >> 8) & 0xFF);
|
||||
buffer[index+3] = static_cast<byte>(value & 0xFF);
|
||||
buffer[index] = static_cast<uint8_t>((value >> 24) & 0xFF);
|
||||
buffer[index+1] = static_cast<uint8_t>((value >> 16) & 0xFF);
|
||||
buffer[index+2] = static_cast<uint8_t>((value >> 8) & 0xFF);
|
||||
buffer[index+3] = static_cast<uint8_t>(value & 0xFF);
|
||||
}
|
||||
else if( byteOrder == LITTLEENDIAN )
|
||||
{
|
||||
buffer[index] = static_cast<byte>(value & 0xFF);
|
||||
buffer[index+1] = static_cast<byte>((value >> 8) & 0xFF);
|
||||
buffer[index+2] = static_cast<byte>((value >> 16) & 0xFF);
|
||||
buffer[index+3] = static_cast<byte>((value >> 24) & 0xFF);
|
||||
buffer[index] = static_cast<uint8_t>(value & 0xFF);
|
||||
buffer[index+1] = static_cast<uint8_t>((value >> 8) & 0xFF);
|
||||
buffer[index+2] = static_cast<uint8_t>((value >> 16) & 0xFF);
|
||||
buffer[index+3] = static_cast<uint8_t>((value >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -339,13 +339,13 @@ ByteBuffer *ByteBuffer::putShort(short value)
|
||||
|
||||
if( byteOrder == BIGENDIAN )
|
||||
{
|
||||
buffer[m_position] = static_cast<byte>((value >> 8) & 0xFF);
|
||||
buffer[m_position+1] = static_cast<byte>(value & 0xFF);
|
||||
buffer[m_position] = static_cast<uint8_t>((value >> 8) & 0xFF);
|
||||
buffer[m_position+1] = static_cast<uint8_t>(value & 0xFF);
|
||||
}
|
||||
else if( byteOrder == LITTLEENDIAN )
|
||||
{
|
||||
buffer[m_position] = static_cast<byte>(value & 0xFF);
|
||||
buffer[m_position+1] = static_cast<byte>((value >> 8) & 0xFF);
|
||||
buffer[m_position] = static_cast<uint8_t>(value & 0xFF);
|
||||
buffer[m_position+1] = static_cast<uint8_t>((value >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
m_position += 2;
|
||||
@@ -379,25 +379,25 @@ ByteBuffer *ByteBuffer::putLong(__int64 value)
|
||||
|
||||
if( byteOrder == BIGENDIAN )
|
||||
{
|
||||
buffer[m_position] = static_cast<byte>((value >> 56) & 0xFF);
|
||||
buffer[m_position+1] = static_cast<byte>((value >> 48) & 0xFF);
|
||||
buffer[m_position+2] = static_cast<byte>((value >> 40) & 0xFF);
|
||||
buffer[m_position+3] = static_cast<byte>((value >> 32) & 0xFF);
|
||||
buffer[m_position+4] = static_cast<byte>((value >> 24) & 0xFF);
|
||||
buffer[m_position+5] = static_cast<byte>((value >> 16) & 0xFF);
|
||||
buffer[m_position+6] = static_cast<byte>((value >> 8) & 0xFF);
|
||||
buffer[m_position+7] = static_cast<byte>(value & 0xFF);
|
||||
buffer[m_position] = static_cast<uint8_t>((value >> 56) & 0xFF);
|
||||
buffer[m_position+1] = static_cast<uint8_t>((value >> 48) & 0xFF);
|
||||
buffer[m_position+2] = static_cast<uint8_t>((value >> 40) & 0xFF);
|
||||
buffer[m_position+3] = static_cast<uint8_t>((value >> 32) & 0xFF);
|
||||
buffer[m_position+4] = static_cast<uint8_t>((value >> 24) & 0xFF);
|
||||
buffer[m_position+5] = static_cast<uint8_t>((value >> 16) & 0xFF);
|
||||
buffer[m_position+6] = static_cast<uint8_t>((value >> 8) & 0xFF);
|
||||
buffer[m_position+7] = static_cast<uint8_t>(value & 0xFF);
|
||||
}
|
||||
else if( byteOrder == LITTLEENDIAN )
|
||||
{
|
||||
buffer[m_position] = static_cast<byte>((value & 0xFF));
|
||||
buffer[m_position+1] = static_cast<byte>((value >> 8) & 0xFF);
|
||||
buffer[m_position+2] = static_cast<byte>((value >> 16) & 0xFF);
|
||||
buffer[m_position+3] = static_cast<byte>((value >> 24) & 0xFF);
|
||||
buffer[m_position+4] = static_cast<byte>((value >> 32) & 0xFF);
|
||||
buffer[m_position+5] = static_cast<byte>((value >> 40) & 0xFF);
|
||||
buffer[m_position+6] = static_cast<byte>((value >> 48) & 0xFF);
|
||||
buffer[m_position+7] = static_cast<byte>((value >> 56) & 0xFF);
|
||||
buffer[m_position] = static_cast<uint8_t>((value & 0xFF));
|
||||
buffer[m_position+1] = static_cast<uint8_t>((value >> 8) & 0xFF);
|
||||
buffer[m_position+2] = static_cast<uint8_t>((value >> 16) & 0xFF);
|
||||
buffer[m_position+3] = static_cast<uint8_t>((value >> 24) & 0xFF);
|
||||
buffer[m_position+4] = static_cast<uint8_t>((value >> 32) & 0xFF);
|
||||
buffer[m_position+5] = static_cast<uint8_t>((value >> 40) & 0xFF);
|
||||
buffer[m_position+6] = static_cast<uint8_t>((value >> 48) & 0xFF);
|
||||
buffer[m_position+7] = static_cast<uint8_t>((value >> 56) & 0xFF);
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -464,9 +464,9 @@ FloatBuffer *ByteBuffer::asFloatBuffer()
|
||||
#ifdef __PS3__
|
||||
// we're using the RSX now to upload textures to vram, so we need th main ram textures allocated from io space
|
||||
ByteBuffer_IO::ByteBuffer_IO( unsigned int capacity )
|
||||
: ByteBuffer(capacity, (byte*)RenderManager.allocIOMem(capacity, 64))
|
||||
: ByteBuffer(capacity, (uint8_t*)RenderManager.allocIOMem(capacity, 64))
|
||||
{
|
||||
memset( buffer,0,sizeof(byte)*capacity);
|
||||
memset( buffer,0,sizeof(uint8_t)*capacity);
|
||||
byteOrder = BIGENDIAN;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,29 +9,29 @@ class FloatBuffer;
|
||||
class ByteBuffer : public Buffer
|
||||
{
|
||||
protected:
|
||||
byte *buffer;
|
||||
uint8_t *buffer;
|
||||
ByteOrder byteOrder;
|
||||
|
||||
public:
|
||||
ByteBuffer(unsigned int capacity);
|
||||
static ByteBuffer *allocateDirect(int capacity);
|
||||
ByteBuffer( unsigned int capacity, byte *backingArray );
|
||||
ByteBuffer( unsigned int capacity, uint8_t *backingArray );
|
||||
virtual ~ByteBuffer();
|
||||
|
||||
static ByteBuffer *wrap(byteArray &b);
|
||||
static ByteBuffer *allocate(unsigned int capacity);
|
||||
void order(ByteOrder a);
|
||||
ByteBuffer *flip();
|
||||
byte *getBuffer();
|
||||
uint8_t *getBuffer();
|
||||
int getSize();
|
||||
int getInt();
|
||||
int getInt(unsigned int index);
|
||||
void get(byteArray) {} // 4J - TODO
|
||||
byte get(int index);
|
||||
uint8_t get(int index);
|
||||
__int64 getLong();
|
||||
short getShort();
|
||||
void getShortArray(shortArray &s);
|
||||
ByteBuffer *put(int index, byte b);
|
||||
ByteBuffer *put(int index, uint8_t b);
|
||||
ByteBuffer *putInt(int value);
|
||||
ByteBuffer *putInt(unsigned int index, int value);
|
||||
ByteBuffer *putShort(short value);
|
||||
|
||||
@@ -7,7 +7,7 @@ public:
|
||||
virtual int read(byteArray b) = 0;
|
||||
virtual int read(byteArray b, unsigned int offset, unsigned int length) = 0;
|
||||
virtual bool readBoolean() = 0;
|
||||
virtual byte readByte() = 0;
|
||||
virtual uint8_t readByte() = 0;
|
||||
virtual unsigned char readUnsignedByte() = 0;
|
||||
virtual bool readFully(byteArray a) = 0;
|
||||
virtual double readDouble() = 0;
|
||||
|
||||
@@ -60,7 +60,7 @@ int DataInputStream::read(byteArray b)
|
||||
//This method blocks until input data is available, end of file is detected, or an exception is thrown.
|
||||
//
|
||||
//If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte.
|
||||
//If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.
|
||||
//If no uint8_t is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.
|
||||
//
|
||||
//The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is,
|
||||
//at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1],
|
||||
@@ -115,14 +115,14 @@ bool DataInputStream::readBoolean()
|
||||
//This method is suitable for reading the byte written by the writeByte method of interface DataOutput.
|
||||
//Returns:
|
||||
//the 8-bit value read.
|
||||
byte DataInputStream::readByte()
|
||||
uint8_t DataInputStream::readByte()
|
||||
{
|
||||
if (stream == NULL)
|
||||
{
|
||||
app.DebugPrintf("DataInputStream::readByte() but underlying stream is NULL\n");
|
||||
return 0;
|
||||
}
|
||||
return (byte) stream->read();
|
||||
return (uint8_t) stream->read();
|
||||
}
|
||||
|
||||
unsigned char DataInputStream::readUnsignedByte()
|
||||
@@ -183,7 +183,7 @@ bool DataInputStream::readFully(byteArray b)
|
||||
}
|
||||
else
|
||||
{
|
||||
b[i] = static_cast<byte>(byteRead);
|
||||
b[i] = static_cast<uint8_t>(byteRead);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
virtual int read(byteArray b, unsigned int offset, unsigned int length);
|
||||
virtual void close();
|
||||
virtual bool readBoolean();
|
||||
virtual byte readByte();
|
||||
virtual uint8_t readByte();
|
||||
virtual unsigned char readUnsignedByte();
|
||||
virtual wchar_t readChar();
|
||||
virtual bool readFully(byteArray b);
|
||||
|
||||
@@ -6,7 +6,7 @@ public:
|
||||
virtual void write(unsigned int b) = 0;
|
||||
virtual void write(byteArray b) = 0;
|
||||
virtual void write(byteArray b, unsigned int offset, unsigned int length) = 0;
|
||||
virtual void writeByte(byte a) = 0;
|
||||
virtual void writeByte(uint8_t a) = 0;
|
||||
virtual void writeDouble(double a) = 0;
|
||||
virtual void writeFloat(float a) = 0;
|
||||
virtual void writeInt(int a) = 0;
|
||||
|
||||
@@ -66,7 +66,7 @@ void DataOutputStream::close()
|
||||
//Writes out a byte to the underlying output stream as a 1-byte value. If no exception is thrown, the counter written is incremented by 1.
|
||||
//Parameters:
|
||||
//v - a byte value to be written.
|
||||
void DataOutputStream::writeByte(byte a)
|
||||
void DataOutputStream::writeByte(uint8_t a)
|
||||
{
|
||||
stream->write( static_cast<unsigned int>(a) );
|
||||
}
|
||||
@@ -170,7 +170,7 @@ void DataOutputStream::writeChars(const wstring& str)
|
||||
}
|
||||
|
||||
//Writes a boolean to the underlying output stream as a 1-byte value.
|
||||
//The value true is written out as the value (byte)1; the value false is written out as the value (byte)0.
|
||||
//The value true is written out as the value (uint8_t)1; the value false is written out as the value (uint8_t)0.
|
||||
//If no exception is thrown, the counter written is incremented by 1.
|
||||
//Parameters:
|
||||
//v - a boolean value to be written.
|
||||
@@ -219,15 +219,15 @@ void DataOutputStream::writeUTF(const wstring& str)
|
||||
|
||||
byteArray bytearr(utflen+2);
|
||||
|
||||
bytearr[count++] = (byte) ((utflen >> 8) & 0xFF);
|
||||
bytearr[count++] = (byte) ((utflen >> 0) & 0xFF);
|
||||
bytearr[count++] = (uint8_t) ((utflen >> 8) & 0xFF);
|
||||
bytearr[count++] = (uint8_t) ((utflen >> 0) & 0xFF);
|
||||
|
||||
int i=0;
|
||||
for (i=0; i<strlen; i++)
|
||||
{
|
||||
c = str.at(i);
|
||||
if (!((c >= 0x0001) && (c <= 0x007F))) break;
|
||||
bytearr[count++] = (byte) c;
|
||||
bytearr[count++] = (uint8_t) c;
|
||||
}
|
||||
|
||||
for (;i < strlen; i++)
|
||||
@@ -235,19 +235,19 @@ void DataOutputStream::writeUTF(const wstring& str)
|
||||
c = str.at(i);
|
||||
if ((c >= 0x0001) && (c <= 0x007F))
|
||||
{
|
||||
bytearr[count++] = (byte) c;
|
||||
bytearr[count++] = (uint8_t) c;
|
||||
|
||||
}
|
||||
else if (c > 0x07FF)
|
||||
{
|
||||
bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
|
||||
bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
|
||||
bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
|
||||
bytearr[count++] = (uint8_t) (0xE0 | ((c >> 12) & 0x0F));
|
||||
bytearr[count++] = (uint8_t) (0x80 | ((c >> 6) & 0x3F));
|
||||
bytearr[count++] = (uint8_t) (0x80 | ((c >> 0) & 0x3F));
|
||||
}
|
||||
else
|
||||
{
|
||||
bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
|
||||
bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
|
||||
bytearr[count++] = (uint8_t) (0xC0 | ((c >> 6) & 0x1F));
|
||||
bytearr[count++] = (uint8_t) (0x80 | ((c >> 0) & 0x3F));
|
||||
}
|
||||
}
|
||||
write(bytearr, 0, utflen+2);
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
virtual void write(byteArray b);
|
||||
virtual void write(byteArray b, unsigned int offset, unsigned int length);
|
||||
virtual void close();
|
||||
virtual void writeByte(byte a);
|
||||
virtual void writeByte(uint8_t a);
|
||||
virtual void writeDouble(double a);
|
||||
virtual void writeFloat(float a);
|
||||
virtual void writeInt(int a);
|
||||
|
||||
Reference in New Issue
Block a user