Browse Source

Merge pull request #89 from branan/typedefs

Typedefs
Darryl Pogue 13 years ago
parent
commit
ab37a4a486
  1. 4
      Sources/Plasma/CoreLib/hsMemory.cpp
  2. 6
      Sources/Plasma/CoreLib/hsSTLStream.cpp
  3. 6
      Sources/Plasma/CoreLib/hsStream.cpp
  4. 4
      Sources/Plasma/CoreLib/hsStream.h
  5. 82
      Sources/Plasma/CoreLib/hsTypes.h
  6. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNt.cpp
  7. 2
      Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.h
  8. 10
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp
  9. 3
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h
  10. 10
      Sources/Plasma/PubUtilLib/plCompression/plZlibCompress.cpp
  11. 4
      Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp
  12. 2
      Sources/Plasma/PubUtilLib/plJPEG/plJPEG.cpp
  13. 6
      Sources/Tools/MaxComponent/plMultistageBehComponent.cpp

4
Sources/Plasma/CoreLib/hsMemory.cpp

@ -99,11 +99,11 @@ void HSMemory::Clear(void* m, UInt32 byteLen)
UInt8* memStop = mem + byteLen;
if (byteLen > 8)
{ while (UInt32(mem) & 3)
{ while (unsigned_ptr(mem) & 3)
*mem++ = 0;
UInt32* mem32 = (UInt32*)mem;
UInt32* mem32Stop = (UInt32*)(UInt32(memStop) & ~3);
UInt32* mem32Stop = (UInt32*)(unsigned_ptr(memStop) & ~3);
do {
*mem32++ = 0;
} while (mem32 < mem32Stop);

6
Sources/Plasma/CoreLib/hsSTLStream.cpp

@ -280,7 +280,7 @@ hsBool hsNamedPipeStream::ICheckOverlappedResult(BOOL result, UInt32 &numTransfe
{
if (WaitForSingleObject(fOverlap.hEvent, fTimeout) == WAIT_OBJECT_0)
{
BOOL oResult = GetOverlappedResult(fPipe, &fOverlap, &numTransferred, FALSE);
BOOL oResult = GetOverlappedResult(fPipe, &fOverlap, (LPDWORD)&numTransferred, FALSE);
if (oResult)
return true;
hsAssert(oResult, "GetOverlappedResult failed");
@ -300,7 +300,7 @@ hsBool hsNamedPipeStream::IRead(UInt32 byteCount, void *buffer, UInt32 &numRead)
if (fPipe != INVALID_HANDLE_VALUE && fReadMode)
{
BOOL result = ReadFile(fPipe, buffer, byteCount, &numRead, &fOverlap);
BOOL result = ReadFile(fPipe, buffer, byteCount, (LPDWORD)&numRead, &fOverlap);
if (ICheckOverlappedResult(result, numRead))
return true;
}
@ -318,7 +318,7 @@ hsBool hsNamedPipeStream::IWrite(UInt32 byteCount, const void *buffer, UInt32 &n
if (fPipe != INVALID_HANDLE_VALUE && !fReadMode)
{
BOOL result = WriteFile(fPipe, buffer, byteCount, &numWritten, &fOverlap);
BOOL result = WriteFile(fPipe, buffer, byteCount, (LPDWORD)&numWritten, &fOverlap);
if (ICheckOverlappedResult(result, numWritten))
return true;
}

6
Sources/Plasma/CoreLib/hsStream.cpp

@ -827,7 +827,7 @@ UInt32 hsFileStream::Read(UInt32 bytes, void* buffer)
#elif HS_BUILD_FOR_WIN32
UInt32 rBytes;
ReadFile((HANDLE)fRef, buffer, bytes, &rBytes, nil);
ReadFile((HANDLE)fRef, buffer, bytes, (LPDWORD)&rBytes, nil);
if(bytes == rBytes)
return bytes;
else
@ -867,7 +867,7 @@ UInt32 hsFileStream::Write(UInt32 bytes, const void* buffer)
return 0;
#elif HS_BUILD_FOR_WIN32
UInt32 wBytes;
WriteFile((HANDLE)fRef, buffer, bytes, &wBytes, nil);
WriteFile((HANDLE)fRef, buffer, bytes, (LPDWORD)&wBytes, nil);
if(bytes == wBytes)
return bytes;
else
@ -904,7 +904,7 @@ hsBool hsFileStream::AtEnd()
#elif HS_BUILD_FOR_WIN32
UInt32 bytes;
PeekNamedPipe((void*)fRef, nil, 0, nil, &bytes, nil);
PeekNamedPipe((void*)fRef, nil, 0, nil, (LPDWORD)&bytes, nil);
return bytes>0;
#else
hsAssert(0,"No hsStream::AtEnd() implemented for this stream class");

4
Sources/Plasma/CoreLib/hsStream.h

@ -200,8 +200,6 @@ public:
void ReadSwap(int count, Int16 values[]) { this->ReadSwap16(count, (UInt16*)values); }
void ReadSwap(Int32* value) { *value = (Int32)this->ReadSwap32(); }
void ReadSwap(int count, Int32 values[]) { this->ReadSwap32(count, (UInt32*)values); }
void ReadSwap(int* value) { *value = (Int32)this->ReadSwap32(); }
void ReadSwap(int count, int values[]) { this->ReadSwap32(count, (UInt32*)values); }
#ifdef STREAM_LOGGER
// Begin LogReadSwaps
virtual void LogReadSwap(Int8* value, const char* desc) { this->ReadSwap(value); }
@ -224,8 +222,6 @@ public:
void WriteSwap(int count, const Int16 values[]) { this->WriteSwap16(count, (UInt16*)values); }
void WriteSwap(Int32 value) { this->WriteSwap32((UInt32)value); }
void WriteSwap(int count, const Int32 values[]) { this->WriteSwap32(count, (UInt32*)values); }
void WriteSwap(int value) { this->WriteSwap32((UInt32)value); }
void WriteSwap(int count, const int values[]) { this->WriteSwap32(count, (UInt32*)values); }
/* Overloaded End */

82
Sources/Plasma/CoreLib/hsTypes.h

@ -46,8 +46,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
/************************** Other Includes *****************************/
#include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include <cstdio>
#if HS_CAN_USE_FLOAT
#include <math.h>
@ -64,17 +64,25 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
/************************** Basic Types *****************************/
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;
#ifdef _MSC_VER
typedef unsigned __int64 qword;
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
typedef unsigned long long qword;
#include <stdint.h>
#endif
typedef size_t unsigned_ptr;
typedef uint8_t byte;
typedef uint16_t word;
typedef uint32_t dword;
typedef uint64_t qword;
typedef uintptr_t unsigned_ptr;
typedef wchar_t wchar;
@ -84,51 +92,31 @@ typedef wchar_t wchar;
#define kPosInfinity32 (0x7fffffff)
#define kNegInfinity32 (0x80000000)
#if HS_BUILD_FOR_PS2
typedef int Int32;
#else
typedef long Int32;
#endif
typedef int8_t Int8;
typedef int16_t Int16;
typedef int32_t Int32;
typedef int64_t Int64;
typedef short Int16;
typedef signed char Int8;
typedef uint8_t UInt8;
typedef uint16_t UInt16;
typedef uint32_t UInt32;
typedef uint64_t UInt64;
#if !(HS_BUILD_FOR_MAC)
typedef unsigned char UInt8;
typedef unsigned short UInt16;
#if HS_BUILD_FOR_PS2
typedef unsigned int UInt32;
#else
typedef unsigned long UInt32;
#ifndef Byte
typedef uint8_t Byte;
#endif
#ifndef Byte
typedef UInt8 Byte;
#endif
#ifndef false
#define false 0
#endif
#ifndef true
#define true 1
#endif
#ifndef Boolean
#if HS_BUILD_FOR_UNIX
typedef char Boolean;
#else
typedef UInt8 Boolean;
#endif
#endif
#ifndef false
#define false 0
#endif
#if HS_BUILD_FOR_WIN32
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#else
typedef long long Int64;
typedef unsigned long long UInt64;
#ifndef true
#define true 1
#endif
#ifndef Boolean
typedef uint8_t Boolean;
#endif
typedef Int32 hsFixed;
typedef Int32 hsFract;

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNt.cpp

@ -251,7 +251,7 @@ static unsigned THREADCALL NtWorkerThreadProc (AsyncThread * thread) {
// process I/O operations
{
dword bytes;
DWORD bytes;
NtObject * ntObj;
Operation * op;
(void) GetQueuedCompletionStatus(

2
Sources/Plasma/NucleusLib/pnNetCommon/plGenericVar.h

@ -113,8 +113,6 @@ public:
operator bool() const { return IToBool(); }
operator const CharPtr() const { return IToString(); }
operator char() const { return IToChar(); }
operator unsigned int() const { return IToUInt(); }
operator int() const { return IToInt(); }
void SetType(Types t) { fType=t; }
UInt8 GetType( void ) const { return fType; }

10
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp

@ -1125,15 +1125,7 @@ void CSrvPackBuffer::AddString (const wchar str[]) {
}
//============================================================================
void CSrvPackBuffer::AddDWordArray (const dword * arr, unsigned count) {
// Don't let large counts cause pointer wrap
count &= 0x00ffffff;
AddData(arr, count * sizeof(arr[0]));
}
//============================================================================
void CSrvPackBuffer::AddDWordArray (const unsigned * arr, unsigned count) {
COMPILER_ASSERT(sizeof(unsigned) == sizeof(dword));
void CSrvPackBuffer::AddDWordArray (const UInt32 * arr, unsigned count) {
// Don't let large counts cause pointer wrap
count &= 0x00ffffff;
AddData(arr, count * sizeof(arr[0]));

3
Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h

@ -470,8 +470,7 @@ public:
void * Alloc (unsigned bytes);
void AddData (const void * ptr, unsigned bytes);
void AddString (const wchar str[]);
void AddDWordArray (const dword * arr, unsigned count);
void AddDWordArray (const unsigned * arr, unsigned count);
void AddDWordArray (const UInt32 * arr, unsigned count);
// add new "Add..." methods here as needed
unsigned Size ();

10
Sources/Plasma/PubUtilLib/plCompression/plZlibCompress.cpp

@ -46,14 +46,20 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
hsBool plZlibCompress::Uncompress(UInt8* bufOut, UInt32* bufLenOut, const UInt8* bufIn, UInt32 bufLenIn)
{
return (uncompress(bufOut, bufLenOut, bufIn, bufLenIn) == Z_OK);
unsigned long buflen_out;
bool result = (uncompress(bufOut, &buflen_out, bufIn, bufLenIn) == Z_OK);
*bufLenOut = buflen_out;
return result;
}
hsBool plZlibCompress::Compress(UInt8* bufOut, UInt32* bufLenOut, const UInt8* bufIn, UInt32 bufLenIn)
{
// according to compress doc, the bufOut buffer should be at least .1% larger than source buffer, plus 12 bytes.
hsAssert(*bufLenOut>=(int)(bufLenIn*1.1+12), "bufOut compress buffer is not large enough");
return (compress(bufOut, bufLenOut, bufIn, bufLenIn) == Z_OK);
unsigned long buflen_out;
bool result = (compress(bufOut, &buflen_out, bufIn, bufLenIn) == Z_OK);
*bufLenOut = buflen_out;
return result;
}
//

4
Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp

@ -88,7 +88,7 @@ plEncryptedStream::~plEncryptedStream()
//
void plEncryptedStream::IEncipher(UInt32* const v)
{
register unsigned long y=v[0], z=v[1], sum=0, delta=0x9E3779B9, n=32;
register UInt32 y=v[0], z=v[1], sum=0, delta=0x9E3779B9, n=32;
while (n-- > 0)
{
@ -102,7 +102,7 @@ void plEncryptedStream::IEncipher(UInt32* const v)
void plEncryptedStream::IDecipher(UInt32* const v)
{
register unsigned long y=v[0], z=v[1], sum=0xC6EF3720, delta=0x9E3779B9, n=32;
register UInt32 y=v[0], z=v[1], sum=0xC6EF3720, delta=0x9E3779B9, n=32;
// sum = delta<<5, in general sum = delta * n

2
Sources/Plasma/PubUtilLib/plJPEG/plJPEG.cpp

@ -299,7 +299,7 @@ hsBool plJPEG::IWrite( plMipmap *source, hsStream *outStream )
}
UInt8 *bufferAddr = jpgBuffer;
UInt32 bufferSize = jpgBufferSize;
unsigned long bufferSize = jpgBufferSize;
jpeg_mem_dest( &cinfo, &bufferAddr, &bufferSize );
cinfo.image_width = source->GetWidth();

6
Sources/Tools/MaxComponent/plMultistageBehComponent.cpp

@ -492,11 +492,11 @@ public:
virtual void Skip(UInt32 deltaByteCount) { hsAssert(0, "Not supported"); }
virtual void Rewind() { hsAssert(0, "Not supported"); }
virtual UInt32 GetEOF() { return fLoad->CurChunkLength(); }
virtual UInt32 GetEOF() { return (UInt32)fLoad->CurChunkLength(); }
virtual UInt32 Read(UInt32 byteCount, void * buffer)
{
UInt32 numRead = 0;
ULONG numRead = 0;
hsAssert(fLoad, "No Max ILoad!");
if (fLoad)
fLoad->Read(buffer, byteCount, &numRead);
@ -505,7 +505,7 @@ public:
}
virtual UInt32 Write(UInt32 byteCount, const void* buffer)
{
UInt32 numWritten;
ULONG numWritten;
hsAssert(fSave, "No Max ISave!");
if (fSave)
fSave->Write(buffer, byteCount, &numWritten);

Loading…
Cancel
Save