mirror of https://github.com/PCSX2/pcsx2.git
* Added subdivided content to the u128 type (changed it from a struct to a union, added _u32[4], _u16[8], etc).
* Added ToString methods to the u128 type. * Bugfixes for the FastFormat string utilities, namely when writing UTF8 content via the UTF16 formatter. * MSVC: Removed obsolete disabling of unsigned/signed mismatch warning (4018) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3703 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
393333456c
commit
1cac8d3948
|
@ -16,16 +16,23 @@
|
|||
#ifndef __PCSX2TYPES_H__
|
||||
#define __PCSX2TYPES_H__
|
||||
|
||||
/*
|
||||
* Based on PS2E Definitions by
|
||||
linuzappz@hotmail.com,
|
||||
* shadowpcsx2@yahoo.gr,
|
||||
* and florinsasu@hotmail.com
|
||||
*/
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Forward declarations
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Forward declarations for wxWidgets-supporting features.
|
||||
// If you aren't linking against wxWidgets libraries, then functions that
|
||||
// depend on these types will not be usable (they will yield linker errors).
|
||||
|
||||
#ifdef __cplusplus
|
||||
class wxString;
|
||||
class FastFormatAscii;
|
||||
class FastFormatUnicode;
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Basic Atomic Types
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
|
@ -111,19 +118,27 @@ typedef s32 sptr;
|
|||
// performing explicit conversion from 64 and 32 bit values are provided instead.
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
struct u128
|
||||
union u128
|
||||
{
|
||||
struct
|
||||
{
|
||||
u64 lo;
|
||||
u64 hi;
|
||||
};
|
||||
|
||||
// Explicit conversion from u64
|
||||
u64 _u64[2];
|
||||
u32 _u32[4];
|
||||
u16 _u16[8];
|
||||
u8 _u8[16];
|
||||
|
||||
// Explicit conversion from u64. Zero-extends the source through 128 bits.
|
||||
static u128 From64( u64 src )
|
||||
{
|
||||
u128 retval = { src, 0 };
|
||||
return retval;
|
||||
}
|
||||
|
||||
// Explicit conversion from u32
|
||||
// Explicit conversion from u32. Zero-extends the source through 128 bits.
|
||||
static u128 From32( u32 src )
|
||||
{
|
||||
u128 retval = { src, 0 };
|
||||
|
@ -143,6 +158,17 @@ struct u128
|
|||
{
|
||||
return (lo != right.lo) && (hi != right.hi);
|
||||
}
|
||||
|
||||
// In order for the following ToString() and WriteTo methods to be available, you must
|
||||
// be linking to both wxWidgets and the pxWidgets extension library. If you are not
|
||||
// using them, then you will need to provide your own implementations of these methods.
|
||||
wxString ToString() const;
|
||||
wxString ToString64() const;
|
||||
wxString ToString8() const;
|
||||
|
||||
void WriteTo( FastFormatAscii& dest ) const;
|
||||
void WriteTo8( FastFormatAscii& dest ) const;
|
||||
void WriteTo64( FastFormatAscii& dest ) const;
|
||||
};
|
||||
|
||||
struct s128
|
||||
|
@ -183,13 +209,21 @@ struct s128
|
|||
|
||||
typedef union _u128_t
|
||||
{
|
||||
struct
|
||||
{
|
||||
u64 lo;
|
||||
u64 hi;
|
||||
};
|
||||
|
||||
u64 _u64[2];
|
||||
u32 _u32[4];
|
||||
u16 _u16[8];
|
||||
u8 _u8[16];
|
||||
} u128;
|
||||
|
||||
typedef union _s128_t
|
||||
{
|
||||
s64 lo;
|
||||
u64 lo;
|
||||
s64 hi;
|
||||
} s128;
|
||||
|
||||
|
|
|
@ -127,11 +127,11 @@ public:
|
|||
FastFormatAscii& Write( const char* fmt, ... );
|
||||
FastFormatAscii& WriteV( const char* fmt, va_list argptr );
|
||||
|
||||
const char* GetResult() const;
|
||||
operator const char*() const;
|
||||
const char* c_str() const { return m_dest->GetPtr(); }
|
||||
operator const char*() const { return m_dest->GetPtr(); }
|
||||
|
||||
const wxString GetString() const;
|
||||
operator wxString() const;
|
||||
//operator wxString() const;
|
||||
};
|
||||
|
||||
class FastFormatUnicode
|
||||
|
@ -149,18 +149,9 @@ public:
|
|||
FastFormatUnicode& WriteV( const char* fmt, va_list argptr );
|
||||
FastFormatUnicode& WriteV( const wxChar* fmt, va_list argptr );
|
||||
|
||||
const wxChar* GetResult() const;
|
||||
const wxString GetString() const;
|
||||
|
||||
operator const wxChar*() const
|
||||
{
|
||||
return (const wxChar*)m_dest->GetPtr();
|
||||
}
|
||||
|
||||
operator wxString() const
|
||||
{
|
||||
return (const wxChar*)m_dest->GetPtr();
|
||||
}
|
||||
const wxChar* c_str() const { return (const wxChar*)m_dest->GetPtr(); }
|
||||
operator const wxChar*() const { return (const wxChar*)m_dest->GetPtr(); }
|
||||
operator wxString() const { return (const wxChar*)m_dest->GetPtr(); }
|
||||
};
|
||||
|
||||
extern bool pxParseAssignmentString( const wxString& src, wxString& ldest, wxString& rdest );
|
||||
|
|
|
@ -298,7 +298,7 @@ const IConsoleWriter ConsoleWriter_wxError =
|
|||
};
|
||||
|
||||
// =====================================================================================================
|
||||
// IConsoleWriter Implementations
|
||||
// IConsoleWriter (implementations)
|
||||
// =====================================================================================================
|
||||
// (all non-virtual members that do common work and then pass the result through DoWrite
|
||||
// or DoWriteLn)
|
||||
|
@ -569,14 +569,14 @@ const NullConsoleWriter NullCon = {};
|
|||
bool ConsoleLogSource::WriteV( ConsoleColors color, const char *fmt, va_list list ) const
|
||||
{
|
||||
ConsoleColorScope cs(color);
|
||||
DoWrite( pxsFmtV(fmt,list).GetResult() );
|
||||
DoWrite( pxsFmtV(fmt,list).c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConsoleLogSource::WriteV( ConsoleColors color, const wxChar *fmt, va_list list ) const
|
||||
{
|
||||
ConsoleColorScope cs(color);
|
||||
DoWrite( pxsFmtV(fmt,list) );
|
||||
DoWrite( pxsFmtV(fmt,list).c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,21 +49,20 @@ pxDoAssertFnType* pxDoAssert = pxAssertImpl_LogIt;
|
|||
// response times from the Output window...
|
||||
wxString DiagnosticOrigin::ToString( const wxChar* msg ) const
|
||||
{
|
||||
wxString message;
|
||||
message.reserve( 2048 );
|
||||
FastFormatUnicode message;
|
||||
|
||||
message.Printf( L"%s(%d) : assertion failed:\n", srcfile, line );
|
||||
message.Write( L"%s(%d) : assertion failed:\n", srcfile, line );
|
||||
|
||||
if( function != NULL )
|
||||
message += L" Function: " + fromUTF8(function) + L"\n";
|
||||
message.Write( " Function: %s\n", function );
|
||||
|
||||
message += L" Thread: " + Threading::pxGetCurrentThreadName() + L"\n";
|
||||
message.Write(L" Thread: %s\n", Threading::pxGetCurrentThreadName().c_str() );
|
||||
|
||||
if( condition != NULL )
|
||||
message += L" Condition: " + wxString(condition) + L"\n";
|
||||
message.Write(L" Condition: %s\n", condition);
|
||||
|
||||
if( msg != NULL )
|
||||
message += L" Message: " + wxString(msg) + L"\n";
|
||||
message.Write(L" Message: %s\n", msg);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class FastFormatBuffers
|
|||
protected:
|
||||
typedef SafeAlignedArray<CharType,16> BufferType;
|
||||
|
||||
static const uint BufferCount = 3;
|
||||
static const uint BufferCount = 4;
|
||||
|
||||
BufferType m_buffers[BufferCount];
|
||||
uint m_curslot;
|
||||
|
@ -63,8 +63,8 @@ public:
|
|||
{
|
||||
m_buffers[i].Name = wxsFormat(L"%s Formatting Buffer (slot%d)",
|
||||
(sizeof(CharType)==1) ? L"Ascii" : L"Unicode", i);
|
||||
m_buffers[i].MakeRoomFor(1024);
|
||||
m_buffers[i].ChunkSize = 4096;
|
||||
m_buffers[i].MakeRoomFor(512);
|
||||
m_buffers[i].ChunkSize = 2048;
|
||||
}
|
||||
|
||||
m_curslot = 0;
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
bool HasFreeBuffer() const
|
||||
{
|
||||
return m_curslot < BufferCount;
|
||||
return m_curslot < BufferCount-1;
|
||||
}
|
||||
|
||||
BufferType& GrabBuffer()
|
||||
|
@ -176,7 +176,7 @@ static __ri void format_that_unicode_mess( SafeArray<char>& buffer, uint writepo
|
|||
while( true )
|
||||
{
|
||||
int size = buffer.GetLength() / sizeof(wxChar);
|
||||
int len = wxVsnprintf((wxChar*)buffer.GetPtr(writepos), size-writepos, fmt, argptr);
|
||||
int len = wxVsnprintf((wxChar*)buffer.GetPtr(writepos*2), size-writepos, fmt, argptr);
|
||||
|
||||
// some implementations of vsnprintf() don't NUL terminate
|
||||
// the string if there is not enough space for it so
|
||||
|
@ -266,11 +266,6 @@ FastFormatUnicode& FastFormatUnicode::Write( const wxChar* fmt, ... )
|
|||
return *this;
|
||||
}
|
||||
|
||||
const wxChar* FastFormatUnicode::GetResult() const
|
||||
{
|
||||
return (wxChar*)m_dest->GetPtr();
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// FastFormatAscii (implementations)
|
||||
|
@ -294,10 +289,10 @@ const wxString FastFormatAscii::GetString() const
|
|||
return fromAscii(m_dest->GetPtr());
|
||||
}
|
||||
|
||||
FastFormatAscii::operator wxString() const
|
||||
/*FastFormatAscii::operator wxString() const
|
||||
{
|
||||
return fromAscii(m_dest->GetPtr());
|
||||
}
|
||||
}*/
|
||||
|
||||
FastFormatAscii& FastFormatAscii::WriteV( const char* fmt, va_list argptr )
|
||||
{
|
||||
|
@ -314,13 +309,3 @@ FastFormatAscii& FastFormatAscii::Write( const char* fmt, ... )
|
|||
return *this;
|
||||
}
|
||||
|
||||
const char* FastFormatAscii::GetResult() const
|
||||
{
|
||||
return m_dest->GetPtr();
|
||||
}
|
||||
|
||||
FastFormatAscii::operator const char*() const
|
||||
{
|
||||
return m_dest->GetPtr();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,42 @@ __fi wxString fromAscii( const char* src )
|
|||
return wxString::FromAscii( src );
|
||||
}
|
||||
|
||||
wxString u128::ToString() const
|
||||
{
|
||||
return pxsFmt( L"0x%08X.%08X.%08X.%08X", _u32[0], _u32[1], _u32[2], _u32[3] );
|
||||
}
|
||||
|
||||
wxString u128::ToString64() const
|
||||
{
|
||||
return pxsFmt( L"0x%08X%08X.%08X%08X", _u32[0], _u32[1], _u32[2], _u32[3] );
|
||||
}
|
||||
|
||||
wxString u128::ToString8() const
|
||||
{
|
||||
FastFormatUnicode result;
|
||||
result.Write( L"0x%02X.%02X", _u8[0], _u8[1] );
|
||||
for (uint i=2; i<16; i+=2)
|
||||
result.Write( L".%02X.%02X", _u8[i], _u8[i+1] );
|
||||
return result;
|
||||
}
|
||||
|
||||
void u128::WriteTo( FastFormatAscii& dest ) const
|
||||
{
|
||||
dest.Write( "0x%08X.%08X.%08X.%08X", _u32[0], _u32[1], _u32[2], _u32[3] );
|
||||
}
|
||||
|
||||
void u128::WriteTo64( FastFormatAscii& dest ) const
|
||||
{
|
||||
dest.Write( "0x%08X%08X.%08X%08X", _u32[0], _u32[1], _u32[2], _u32[3] );
|
||||
}
|
||||
|
||||
void u128::WriteTo8( FastFormatAscii& dest ) const
|
||||
{
|
||||
dest.Write( "0x%02X.%02X", _u8[0], _u8[1] );
|
||||
for (uint i=2; i<16; i+=2)
|
||||
dest.Write( ".%02X.%02X", _u8[i], _u8[i+1] );
|
||||
}
|
||||
|
||||
// Splits a string into parts and adds the parts into the given SafeList.
|
||||
// This list is not cleared, so concatenating many splits into a single large list is
|
||||
// the 'default' behavior, unless you manually clear the SafeList prior to subsequent calls.
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
#ifndef __CDVD_ISO_READER_H__
|
||||
#define __CDVD_ISO_READER_H__
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4018)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "IopCommon.h"
|
||||
|
|
|
@ -29,10 +29,6 @@
|
|||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable:4018) // disable signed/unsigned mismatch error
|
||||
#endif
|
||||
|
||||
#include "IopCommon.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -524,7 +524,7 @@ union tDMAC_ADDR
|
|||
|
||||
wxCharBuffer ToUTF8(bool sprIsValid=true) const
|
||||
{
|
||||
return FastFormatAscii().Write((sprIsValid && SPR) ? "0x%04X(SPR)" : "0x%08X", ADDR).GetResult();
|
||||
return FastFormatAscii().Write((sprIsValid && SPR) ? "0x%04X(SPR)" : "0x%08X", ADDR).c_str();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue