Merge pull request #1659 from PCSX2/greg/clang-format-common

reformat main common directory
This commit is contained in:
Gregory Hainaut 2016-11-14 11:37:53 +01:00 committed by GitHub
commit 259521ec3e
137 changed files with 15017 additions and 14373 deletions

View File

@ -71,12 +71,14 @@
#define KEYPRESS 1
#define KEYRELEASE 2
typedef struct {
typedef struct
{
int size;
s8 *data;
} freezeData;
typedef struct _keyEvent {
typedef struct _keyEvent
{
u32 key;
u32 evt;
} keyEvent;
@ -149,7 +151,8 @@ typedef char __keyEvent_Size__[(sizeof(keyEvent) == 8)?1:-1];
typedef int(CALLBACK *SIOchangeSlotCB)(int slot);
typedef struct _cdvdSubQ {
typedef struct _cdvdSubQ
{
u8 ctrl : 4; // control and mode bits
u8 mode : 4; // control and mode bits
u8 trackNum; // current track number (1 to 99)
@ -163,12 +166,14 @@ typedef struct _cdvdSubQ {
u8 discF; // current frame offset from first track (BCD encoded)
} cdvdSubQ;
typedef struct _cdvdTD { // NOT bcd coded
typedef struct _cdvdTD
{ // NOT bcd coded
u32 lsn;
u8 type;
} cdvdTD;
typedef struct _cdvdTN {
typedef struct _cdvdTN
{
u8 strack; //number of the first track (usually 1)
u8 etrack; //number of the last track
} cdvdTN;
@ -215,7 +220,8 @@ typedef int (*DEV9handler)(void);
typedef void (*USBcallback)(int cycles);
typedef int (*USBhandler)(void);
typedef struct _GSdriverInfo {
typedef struct _GSdriverInfo
{
char name[8];
void *common;
} GSdriverInfo;

View File

@ -55,8 +55,7 @@ static void __forceinline PluginNullConfigure(std::wstring desc, s32 &log);
static void __forceinline PluginNullAbout(const wchar_t *aboutText);
#endif
enum FileMode
{
enum FileMode {
READ_FILE = 0,
WRITE_FILE
};
@ -70,8 +69,7 @@ struct PluginLog
{
LogFile = fopen(logname.c_str(), "w");
if (LogFile)
{
if (LogFile) {
setvbuf(LogFile, NULL, _IONBF, 0);
return true;
}
@ -90,11 +88,14 @@ struct PluginLog
{
va_list list;
if (LogFile == NULL) return;
if (LogFile == NULL)
return;
va_start(list, fmt);
if (WriteToFile) vfprintf(LogFile, fmt, list);
if (WriteToConsole) vfprintf(stdout, fmt, list);
if (WriteToFile)
vfprintf(LogFile, fmt, list);
if (WriteToConsole)
vfprintf(stdout, fmt, list);
va_end(list);
}
@ -102,15 +103,20 @@ struct PluginLog
{
va_list list;
if (LogFile == NULL) return;
if (LogFile == NULL)
return;
va_start(list, fmt);
if (WriteToFile) vfprintf(LogFile, fmt, list);
if (WriteToConsole) vfprintf(stdout, fmt, list);
if (WriteToFile)
vfprintf(LogFile, fmt, list);
if (WriteToConsole)
vfprintf(stdout, fmt, list);
va_end(list);
if (WriteToFile) fprintf(LogFile, "\n");
if (WriteToConsole) fprintf(stdout, "\n");
if (WriteToFile)
fprintf(LogFile, "\n");
if (WriteToConsole)
fprintf(stdout, "\n");
}
#if !defined(_MSC_VER) || !defined(UNICODE)
@ -119,7 +125,8 @@ struct PluginLog
va_list list;
char buf[256];
if (LogFile == NULL) return;
if (LogFile == NULL)
return;
va_start(list, fmt);
vsprintf(buf, fmt, list);
@ -133,7 +140,8 @@ struct PluginLog
va_list list;
wchar_t buf[256];
if (LogFile == NULL) return;
if (LogFile == NULL)
return;
va_start(list, fmt);
vswprintf(buf, 256, fmt, list);
@ -151,16 +159,14 @@ struct PluginConf
bool Open(std::string name, FileMode mode = READ_FILE)
{
if (mode == READ_FILE)
{
if (mode == READ_FILE) {
ConfFile = fopen(name.c_str(), "r");
}
else
{
} else {
ConfFile = fopen(name.c_str(), "w");
}
if (ConfFile == NULL) return false;
if (ConfFile == NULL)
return false;
return true;
}
@ -189,7 +195,8 @@ struct PluginConf
{
std::string buf = item + " = %d\n";
if (ConfFile) fprintf(ConfFile, buf.c_str(), value);
if (ConfFile)
fprintf(ConfFile, buf.c_str(), value);
}
};
@ -204,7 +211,8 @@ static void SysMessage(const char *fmt, ...)
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
if (msg[strlen(msg) - 1] == '\n')
msg[strlen(msg) - 1] = 0;
GtkWidget *dialog;
dialog = gtk_message_dialog_new(NULL,
@ -265,7 +273,8 @@ static void SysMessage(const char *fmt, ...)
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
if (msg[strlen(msg) - 1] == '\n')
msg[strlen(msg) - 1] = 0;
// TODO OSX can we use WX MessageBox here or should Cocoa MessageBox used?
}

View File

@ -38,19 +38,24 @@
#define EXPORT_C(type) extern "C" __attribute__((externally_visible, visibility("default"))) type
#endif
EXPORT_C(u32) PS2EgetLibType(void);
EXPORT_C(u32) PS2EgetLibVersion2(u32 type);
EXPORT_C(char*) PS2EgetLibName(void);
EXPORT_C(u32)
PS2EgetLibType(void);
EXPORT_C(u32)
PS2EgetLibVersion2(u32 type);
EXPORT_C(char *)
PS2EgetLibName(void);
// Extended functions.
// allows the plugin to see the whole configuration when started up.
// Intended for them to get the ini and plugin paths, but could allow for other things as well.
EXPORT_C_(void) PS2EpassConfig(PcsxConfig Config);
EXPORT_C_(void)
PS2EpassConfig(PcsxConfig Config);
// Alternately, this function serves the same purpose, but would work for emulators outside
// of pcsx2.
EXPORT_C_(void) PS2EpassIniPath(const char *path);
EXPORT_C_(void)
PS2EpassIniPath(const char *path);
// PS2EgetLibType returns (may be OR'd)
enum {
@ -83,13 +88,15 @@ FREEZE_SAVE = 1,
FREEZE_SIZE = 2
} FreezeModes;
typedef struct _GSdriverInfo {
typedef struct _GSdriverInfo
{
char name[8];
void *common;
} GSdriverInfo;
#ifdef _MSC_VER
typedef struct _winInfo { // unsupported values must be set to zero
typedef struct _winInfo
{ // unsupported values must be set to zero
HWND hWnd;
HMENU hMenu;
HWND hStatusWnd;

View File

@ -174,8 +174,7 @@ extern "C" {
// Plugin Type / Version Enumerations
// ------------------------------------------------------------------------------------
enum PS2E_ComponentTypes
{
enum PS2E_ComponentTypes {
PS2E_TYPE_GS = 0,
PS2E_TYPE_PAD,
PS2E_TYPE_SPU2,
@ -187,8 +186,7 @@ enum PS2E_ComponentTypes
PS2E_TYPE_Mcd,
};
enum PluginLibVersion
{
enum PluginLibVersion {
PS2E_VER_GS = 0x1000,
PS2E_VER_PAD = 0x1000,
PS2E_VER_SPU2 = 0x1000,
@ -199,8 +197,7 @@ enum PluginLibVersion
PS2E_VER_SIO = 0x1000
};
enum OSDIconTypes
{
enum OSDIconTypes {
OSD_Icon_None = 0,
OSD_Icon_Error,
OSD_Icon_Notice, // An exclamation point maybe?
@ -215,8 +212,7 @@ enum OSDIconTypes
OSD_Icon_ReserveEnd = 0x1000
};
enum PS2E_MenuItemStyle
{
enum PS2E_MenuItemStyle {
MenuType_Normal = 0,
MenuType_Checked,
MenuType_Radio,
@ -386,7 +382,8 @@ typedef struct _PS2E_MenuItemAPI
// Returns:
// TRUE if the image was loaded successfully, or FALSE if the image was not found,
// could not be opened, or the image data is invalid (not a PNG, or data corrupted).
BOOL (PS2E_CALLBACK* MenuItem_SetImagePng_FromFile)( PS2E_MenuItemHandle mitem, const char* filename );
BOOL(PS2E_CALLBACK *MenuItem_SetImagePng_FromFile)
(PS2E_MenuItemHandle mitem, const char *filename);
// Gives the menu item an accompanying image (orientation of the image may depend on
// the operating system platform). Image is loaded from memory using a memory stream
@ -395,7 +392,8 @@ typedef struct _PS2E_MenuItemAPI
// Returns:
// TRUE if the image was loaded successfully, or FALSE if the image data is invalid
// (not a PNG, or data corrupted).
BOOL (PS2E_CALLBACK* MenuItem_SetImagePng_FromMemory)( PS2E_MenuItemHandle mitem, const u8* data );
BOOL(PS2E_CALLBACK *MenuItem_SetImagePng_FromMemory)
(PS2E_MenuItemHandle mitem, const u8 *data);
// Assigns the menu item's style.
void(PS2E_CALLBACK *MenuItem_SetStyle)(PS2E_MenuItemHandle mitem, PS2E_MenuItemStyle style);
@ -419,7 +417,8 @@ typedef struct _PS2E_MenuItemAPI
void(PS2E_CALLBACK *MenuItem_Enable)(PS2E_MenuItemHandle mitem, BOOL enable);
// Returns the current enable status of the specified menu item.
BOOL (PS2E_CALLBACK* MenuItem_IsEnabled)( PS2E_MenuItemHandle mitem );
BOOL(PS2E_CALLBACK *MenuItem_IsEnabled)
(PS2E_MenuItemHandle mitem);
void *reserved[4];
@ -526,7 +525,8 @@ typedef struct _PS2E_EmulatorInfo
// Returns:
// 0 - Value was retrieved successfully.
// 1 - Unknown value. Contents of dest are unchanged.
BOOL (PS2E_CALLBACK* GetInt)( const char* name, int* dest );
BOOL(PS2E_CALLBACK *GetInt)
(const char *name, int *dest);
// GetBoolean
// Assigns *dest either 1 (true) or 0 (false). Note to Emulators: Returning any non-
@ -536,7 +536,8 @@ typedef struct _PS2E_EmulatorInfo
// Returns:
// 0 - Value was retrieved successfully.
// 1 - Unknown value. Contents of dest are unchanged.
BOOL (PS2E_CALLBACK* GetBoolean)( const char* name, BOOL* result );
BOOL(PS2E_CALLBACK *GetBoolean)
(const char *name, BOOL *result);
// GetString
// Copies an ASCII-Z string into the dest pointer, to max length allowed. The result
@ -546,7 +547,8 @@ typedef struct _PS2E_EmulatorInfo
// Returns:
// 0 - Value was retrieved successfully.
// 1 - Unknown value. Contents of dest are unchanged.
BOOL (PS2E_CALLBACK* GetString)( const char* name, char* dest, int maxlen );
BOOL(PS2E_CALLBACK *GetString)
(const char *name, char *dest, int maxlen);
// GetStringAlloc
// Provides an alternative to GetString, that can retrieve strings of arbitrary length.
@ -824,7 +826,8 @@ typedef struct _PS2E_LibraryAPI
// have provisions in its interface to allow for the forced disabling of extended CPU cap-
// abilities, for testing purposes.
//
BOOL (PS2E_CALLBACK* Test)( u32 component, const PS2E_EmulatorInfo* xinfo );
BOOL(PS2E_CALLBACK *Test)
(u32 component, const PS2E_EmulatorInfo *xinfo);
// NewComponentInstance
// The emulator calls this function to fetch the API for the requested component.
@ -851,7 +854,8 @@ typedef struct _PS2E_LibraryAPI
// Plugins may optionally prepare more detailed information on why the plugin failed
// it's availability test which the emu can request via GetLastError.
//
PS2E_THISPTR (PS2E_CALLBACK* NewComponentInstance)( u32 component );
PS2E_THISPTR(PS2E_CALLBACK *NewComponentInstance)
(u32 component);
// DeleteComponentInstance
// Called by the emulator when the plugin component is to be shutdown. The component API
@ -920,7 +924,8 @@ typedef struct _PS2E_ComponentAPI_GS
//
// Returns TRUE if the snapshot succeeded, or FALSE if it failed (contents of dest
// are considered indeterminate and will be ignored by the emu).
BOOL (PS2E_CALLBACK* GsTakeSnapshot)( PS2E_THISPTR thisptr, PS2E_Image* dest );
BOOL(PS2E_CALLBACK *GsTakeSnapshot)
(PS2E_THISPTR thisptr, PS2E_Image *dest);
// OSD_QueueMessage
// Queues a message to the GS for display to the user. The GS can print the message
@ -958,7 +963,8 @@ typedef struct _PS2E_ComponentAPI_GS
// (if any critical errors accumulated during GStransferTags or GStransferImage, they
// should also be handled here by returning FALSE)
//
BOOL (PS2E_CALLBACK* GsVsync)(int field);
BOOL(PS2E_CALLBACK *GsVsync)
(int field);
// GSwriteRegs
// Sends a GIFtag and associated register data. This is the main transfer method for all
@ -1047,7 +1053,8 @@ typedef struct _PS2E_ComponentAPI_Mcd
// Returns:
// False if the card is not available, or True if it is available.
//
BOOL (PS2E_CALLBACK* McdIsPresent)( PS2E_THISPTR thisptr, uint port, uint slot );
BOOL(PS2E_CALLBACK *McdIsPresent)
(PS2E_THISPTR thisptr, uint port, uint slot);
// McdGetSectorSize (can be NULL)
// Requests memorycard formatting information from the Mcd provider. See the description of
@ -1077,7 +1084,8 @@ typedef struct _PS2E_ComponentAPI_Mcd
// False on failure, and True on success. Emulator may use GetLastError to retrieve additional
// information for logging or displaying to the user.
//
BOOL (PS2E_CALLBACK* McdRead)( PS2E_THISPTR thisptr, uint port, uint slot, u8 *dest, u32 adr, int size );
BOOL(PS2E_CALLBACK *McdRead)
(PS2E_THISPTR thisptr, uint port, uint slot, u8 *dest, u32 adr, int size);
// McdSave
// Saves the provided block of data to the memorycard at the specified seek address.
@ -1088,7 +1096,8 @@ typedef struct _PS2E_ComponentAPI_Mcd
// False on failure, and True on success. Emulator may use GetLastError to retrieve additional
// information for logging or displaying to the user.
//
BOOL (PS2E_CALLBACK* McdSave)( PS2E_THISPTR thisptr, uint port, uint slot, const u8 *src, u32 adr, int size );
BOOL(PS2E_CALLBACK *McdSave)
(PS2E_THISPTR thisptr, uint port, uint slot, const u8 *src, u32 adr, int size);
// McdEraseBlock
// Saves "cleared" data to the memorycard at the specified seek address. Cleared data
@ -1100,7 +1109,8 @@ typedef struct _PS2E_ComponentAPI_Mcd
// False on failure, and True on success. Emulator may use GetLastError to retrieve additional
// information for logging or displaying to the user.
//
BOOL (PS2E_CALLBACK* McdEraseBlock)( PS2E_THISPTR thisptr, uint port, uint slot, u32 adr );
BOOL(PS2E_CALLBACK *McdEraseBlock)
(PS2E_THISPTR thisptr, uint port, uint slot, u32 adr);
u64(PS2E_CALLBACK *McdGetCRC)(PS2E_THISPTR thisptr, uint port, uint slot);
@ -1120,14 +1130,12 @@ typedef struct _PS2E_ComponentAPI_Mcd
// KeyEvent type enumerations
// ------------------------------------------------------------------------------------
enum PS2E_KeyEventTypes
{
enum PS2E_KeyEventTypes {
PS2E_KEY_UP = 0,
PS2E_KEY_DOWN
};
enum PS2E_KeyModifiers
{
enum PS2E_KeyModifiers {
PS2E_SHIFT = 1,
PS2E_CONTROL = 2,
PS2E_ALT = 4
@ -1176,7 +1184,8 @@ typedef struct _PS2E_ComponentAPI_Pad
// Returns:
// False if the card/pad is not available, or True if it is available.
//
BOOL (PS2E_CALLBACK* PadIsPresent)( PS2E_THISPTR thisptr, uint port, uint slot );
BOOL(PS2E_CALLBACK *PadIsPresent)
(PS2E_THISPTR thisptr, uint port, uint slot);
// PadStartPoll
// Called by the emulator to start polling the specified pad.

View File

@ -37,4 +37,3 @@ public:
wxStandardPaths &GetStandardPaths();
#endif
};

View File

@ -155,8 +155,12 @@ extern pxDoAssertFnType* pxDoAssert;
#define pxAssumeMsg(cond, msg) (__assume(cond))
#define pxAssumeDev(cond, msg) (__assume(cond))
# define pxFail(msg) do{} while(0)
# define pxFailDev(msg) do{} while(0)
#define pxFail(msg) \
do { \
} while (0)
#define pxFailDev(msg) \
do { \
} while (0)
#endif
@ -199,8 +203,7 @@ extern void pxOnAssert( const DiagnosticOrigin& origin, const FastFormatUnicode&
//
#ifndef jNO_DEFAULT
#define jNO_DEFAULT \
default: \
{ \
default: { \
pxAssumeDev(0, "Incorrect usage of jNO_DEFAULT detected (default case is not unreachable!)"); \
break; \
}

View File

@ -17,8 +17,7 @@
#include "StringHelpers.h"
enum ConsoleColors
{
enum ConsoleColors {
Color_Current = -1,
Color_Default = 0,

View File

@ -62,23 +62,47 @@
// EnumToString(value);
//
#define ImplementEnumOperators(enumName) \
static __fi enumName& operator++ ( enumName& src ) { src = (enumName)((int)src+1); return src; } \
static __fi enumName& operator-- ( enumName& src ) { src = (enumName)((int)src-1); return src; } \
static __fi enumName operator++ ( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src+1); return orig; } \
static __fi enumName operator-- ( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src-1); return orig; } \
static __fi enumName &operator++(enumName &src) \
{ \
src = (enumName)((int)src + 1); \
return src; \
} \
static __fi enumName &operator--(enumName &src) \
{ \
src = (enumName)((int)src - 1); \
return src; \
} \
static __fi enumName operator++(enumName &src, int) \
{ \
enumName orig = src; \
src = (enumName)((int)src + 1); \
return orig; \
} \
static __fi enumName operator--(enumName &src, int) \
{ \
enumName orig = src; \
src = (enumName)((int)src - 1); \
return orig; \
} \
\
static __fi bool operator<(const enumName &left, const pxEnumEnd_t &) { return (int)left < enumName##_COUNT; } \
static __fi bool operator!=(const enumName &left, const pxEnumEnd_t &) { return (int)left != enumName##_COUNT; } \
static __fi bool operator==(const enumName &left, const pxEnumEnd_t &) { return (int)left == enumName##_COUNT; } \
\
static __fi bool EnumIsValid( enumName id ) { \
return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); } \
static __fi void EnumAssert( enumName id ) { \
pxAssert( EnumIsValid(id) ); } \
static __fi bool EnumIsValid(enumName id) \
{ \
return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); \
} \
static __fi void EnumAssert(enumName id) \
{ \
pxAssert(EnumIsValid(id)); \
} \
\
extern const wxChar *EnumToString(enumName id)
class pxEnumEnd_t { };
class pxEnumEnd_t
{
};
static const pxEnumEnd_t pxEnumEnd = {};
// --------------------------------------------------------------------------------------

View File

@ -52,8 +52,7 @@ protected:
//
void _loadImage()
{
if( !m_Image.Ok() )
{
if (!m_Image.Ok()) {
wxMemoryInputStream joe(ImageType::Data, ImageType::Length);
m_Image.LoadFile(joe, ImageType::GetFormat());
@ -63,8 +62,8 @@ protected:
}
public:
EmbeddedImage() :
m_Image()
EmbeddedImage()
: m_Image()
, m_ResampleTo(wxDefaultSize)
{
}
@ -78,8 +77,8 @@ public:
// sampling images (basically resembles a pixel resize). ResampleBox produces much cleaner
// results.
//
EmbeddedImage( int newWidth, int newHeight ) :
m_Image()
EmbeddedImage(int newWidth, int newHeight)
: m_Image()
, m_ResampleTo(newWidth, newHeight)
{
}
@ -119,4 +118,3 @@ public:
return m_Image;
}
};

View File

@ -57,13 +57,15 @@ public:
void Add(ListenerType *listener)
{
if( listener == NULL ) return;
if (listener == NULL)
return;
Add(*listener);
}
void Remove(ListenerType *listener)
{
if( listener == NULL ) return;
if (listener == NULL)
return;
Remove(*listener);
}

View File

@ -25,12 +25,11 @@ typename EventSource<ListenerType>::ListenerIterator EventSource<ListenerType>::
ScopedLock locker(m_listeners_lock);
// Check for duplicates before adding the event.
if( IsDebugBuild )
{
if (IsDebugBuild) {
ListenerIterator iter = m_listeners.begin();
while( iter != m_listeners.end() )
{
if( (*iter) == &listener ) return iter;
while (iter != m_listeners.end()) {
if ((*iter) == &listener)
return iter;
++iter;
}
}
@ -65,24 +64,17 @@ typename EventSource<ListenerType>::ListenerIterator EventSource<ListenerType>::
template <typename ListenerType>
__fi void EventSource<ListenerType>::_DispatchRaw(ListenerIterator iter, const ListenerIterator &iend, const EvtParams &evtparams)
{
while( iter != iend )
{
while (iter != iend) {
try {
(*iter)->DispatchEvent(evtparams);
}
catch( Exception::RuntimeError& ex )
{
} catch (Exception::RuntimeError &ex) {
if (IsDevBuild) {
pxFailDev(L"Ignoring runtime error thrown from event listener (event listeners should not throw exceptions!): " + ex.FormatDiagnosticMessage());
}
else {
} else {
Console.Error(L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage());
}
}
catch( BaseException& ex )
{
if( IsDevBuild )
{
} catch (BaseException &ex) {
if (IsDevBuild) {
ex.DiagMsg() = L"Non-runtime BaseException thrown from event listener .. " + ex.DiagMsg();
throw;
}
@ -95,12 +87,12 @@ __fi void EventSource<ListenerType>::_DispatchRaw( ListenerIterator iter, const
template <typename ListenerType>
void EventSource<ListenerType>::Dispatch(const EvtParams &evtparams)
{
if( !m_cache_valid )
{
if (!m_cache_valid) {
m_cache_copy = m_listeners;
m_cache_valid = true;
}
if( m_cache_copy.empty() ) return;
if (m_cache_copy.empty())
return;
_DispatchRaw(m_cache_copy.begin(), m_cache_copy.end(), evtparams);
}

View File

@ -49,7 +49,8 @@ void pxTrap();
fprintf(stderr, "ERROR: (out of memory?)\n"); \
} \
} \
catch(...) { \
catch (...) \
{ \
/* Unreachable code */ \
}
@ -154,6 +155,7 @@ namespace Exception
#define DEFINE_EXCEPTION_COPYTORS(classname, parent) \
private: \
typedef parent _parent; \
\
public: \
virtual ~classname() throw() {} \
virtual void Rethrow() const { throw * this; } \
@ -161,9 +163,21 @@ public: \
#define DEFINE_EXCEPTION_MESSAGES(classname) \
public: \
classname& SetBothMsgs( const wxChar* msg_diag ) { BaseException::SetBothMsgs(msg_diag); return *this; } \
classname& SetDiagMsg( const wxString& msg_diag ) { m_message_diag = msg_diag; return *this; } \
classname& SetUserMsg( const wxString& msg_user ) { m_message_user = msg_user; return *this; }
classname &SetBothMsgs(const wxChar *msg_diag) \
{ \
BaseException::SetBothMsgs(msg_diag); \
return *this; \
} \
classname &SetDiagMsg(const wxString &msg_diag) \
{ \
m_message_diag = msg_diag; \
return *this; \
} \
classname &SetUserMsg(const wxString &msg_user) \
{ \
m_message_user = msg_user; \
return *this; \
}
#define DEFINE_RUNTIME_EXCEPTION(classname, parent, message) \
DEFINE_EXCEPTION_COPYTORS(classname, parent) \
@ -271,12 +285,21 @@ public: \
// ---------------------------------------------------------------------------------------
#define DEFINE_STREAM_EXCEPTION_ACCESSORS(classname) \
virtual classname& SetStreamName( const wxString& name ) { StreamName = name; return *this; } \
virtual classname& SetStreamName( const char* name ) { StreamName = fromUTF8(name); return *this; }
virtual classname &SetStreamName(const wxString &name) \
{ \
StreamName = name; \
return *this; \
} \
virtual classname &SetStreamName(const char *name) \
{ \
StreamName = fromUTF8(name); \
return *this; \
}
#define DEFINE_STREAM_EXCEPTION(classname, parent) \
DEFINE_RUNTIME_EXCEPTION(classname, parent, wxEmptyString) \
classname( const wxString& filename ) { \
classname(const wxString &filename) \
{ \
StreamName = filename; \
} \
DEFINE_STREAM_EXCEPTION_ACCESSORS(classname)

View File

@ -122,8 +122,16 @@ bool FixedInt<Precision>::OverflowCheck( double signedval )
return (signedval >= (INT_MAX / Precision));
}
template< int Precision > int FixedInt<Precision>::GetWhole() const { return Raw / Precision; }
template< int Precision > int FixedInt<Precision>::GetFraction() const { return Raw % Precision; }
template <int Precision>
int FixedInt<Precision>::GetWhole() const
{
return Raw / Precision;
}
template <int Precision>
int FixedInt<Precision>::GetFraction() const
{
return Raw % Precision;
}
template <int Precision>
FixedInt<Precision> &FixedInt<Precision>::SetRaw(s32 rawsrc)
@ -163,7 +171,8 @@ wxString FixedInt<Precision>::ToString() const
template <int Precision>
wxString FixedInt<Precision>::ToString(int fracDigits) const
{
if( fracDigits == 0 ) return wxsFormat( L"%d", GetWhole() );
if (fracDigits == 0)
return wxsFormat(L"%d", GetWhole());
pxAssert(fracDigits <= 7); // higher numbers would just cause overflows and bad mojo.
int mulby = (int)pow(10.0, fracDigits);
@ -209,12 +218,12 @@ bool FixedInt<Precision>::TryFromString( FixedInt<Precision>& dest, const wxStri
if (!afterFirst.IsEmpty())
success = success && afterFirst.ToLong(&frac);
if( !success ) return false;
if (!success)
return false;
dest.SetWhole(whole);
if( afterFirst.Length() != 0 && frac != 0 )
{
if (afterFirst.Length() != 0 && frac != 0) {
int fracPower = (int)pow(10.0, (int)afterFirst.Length());
dest.SetFraction((frac * Precision) / fracPower);
}
@ -225,7 +234,8 @@ template< int Precision >
FixedInt<Precision> FixedInt<Precision>::FromString(const wxString &parseFrom, const FixedInt<Precision> &defval)
{
FixedInt<Precision> dest;
if( !TryFromString( dest, parseFrom ) ) return defval;
if (!TryFromString(dest, parseFrom))
return defval;
return dest;
}
@ -234,7 +244,8 @@ template< int Precision >
FixedInt<Precision> FixedInt<Precision>::FromString(const wxString parseFrom)
{
FixedInt<Precision> dest;
if( !TryFromString( dest, parseFrom ) ) throw Exception::ParseError()
if (!TryFromString(dest, parseFrom))
throw Exception::ParseError()
.SetDiagMsg(wxsFormat(L"Parse error on FixedInt<%d>::FromString", Precision));
return dest;

View File

@ -22,11 +22,17 @@
// Macro used for removing some of the redtape involved in defining bitfield/union helpers.
//
#define BITFIELD32() \
union { \
union \
{ \
u32 bitset; \
struct {
struct \
{
#define BITFIELD_END }; };
#define BITFIELD_END \
} \
; \
} \
;
// ----------------------------------------------------------------------------------------
@ -44,11 +50,16 @@ class RecursionGuard
public:
int &Counter;
RecursionGuard( int& counter ) : Counter( counter )
{ ++Counter; }
RecursionGuard(int &counter)
: Counter(counter)
{
++Counter;
}
virtual ~RecursionGuard() throw()
{ --Counter; }
{
--Counter;
}
bool IsReentrant() const { return Counter > 1; }
};

View File

@ -15,7 +15,8 @@
#pragma once
namespace HashTools {
namespace HashTools
{
/// <summary>
/// Type that represents a hashcode; returned by all hash functions.
@ -27,6 +28,4 @@ namespace HashTools {
typedef u32 hash_key_t;
hash_key_t Hash(const char *data, int len);
}

View File

@ -43,7 +43,11 @@ public:
void SetPath(const wxString &path);
void Flush();
wxConfigBase& GetConfig() { pxAssert( m_Config ); return *m_Config; }
wxConfigBase &GetConfig()
{
pxAssert(m_Config);
return *m_Config;
}
bool IsOk() const { return m_Config != NULL; }
virtual bool IsLoading() const = 0;

View File

@ -20,7 +20,8 @@
#include "Pcsx2Defs.h"
// On GCC >= 4.7, this is equivalent to __builtin_clrsb(n);
inline u32 count_leading_sign_bits(s32 n) {
inline u32 count_leading_sign_bits(s32 n)
{
// If the sign bit is 1, we invert the bits to 0 for count-leading-zero.
if (n < 0)
n = ~n;
@ -38,4 +39,3 @@ inline u32 count_leading_sign_bits(s32 n) {
return __builtin_clz(n);
#endif
}

View File

@ -17,7 +17,9 @@
#include <xmmintrin.h>
#define StoreDestIdx(idx) case idx: _mm_store_ps(&destxmm[idx-1][0], srcreg)
#define StoreDestIdx(idx) \
case idx: \
_mm_store_ps(&destxmm[idx - 1][0], srcreg)
template <u8 data>
__noinline void memset_sse_a(void *dest, const size_t size)
@ -28,18 +30,15 @@ __noinline void memset_sse_a( void* dest, const size_t size )
__m128 srcreg;
if (data != 0)
{
if (data != 0) {
static __aligned16 const u8 loadval[8] = {data, data, data, data, data, data, data, data};
srcreg = _mm_loadh_pi(_mm_load_ps((float *)loadval), (__m64 *)loadval);
}
else
} else
srcreg = _mm_setzero_ps();
float(*destxmm)[4] = (float(*)[4])dest;
switch( MZFqwc & 0x07 )
{
switch (MZFqwc & 0x07) {
StoreDestIdx(0x07);
StoreDestIdx(0x06);
StoreDestIdx(0x05);
@ -50,8 +49,7 @@ __noinline void memset_sse_a( void* dest, const size_t size )
}
destxmm += (MZFqwc & 0x07);
for( uint i=0; i<MZFqwc / 8; ++i, destxmm+=8 )
{
for (uint i = 0; i < MZFqwc / 8; ++i, destxmm += 8) {
_mm_store_ps(&destxmm[0][0], srcreg);
_mm_store_ps(&destxmm[1][0], srcreg);
_mm_store_ps(&destxmm[2][0], srcreg);

View File

@ -94,7 +94,6 @@ protected:
{
Owner->OnPageFaultEvent(info, handled);
}
};
// --------------------------------------------------------------------------------------
@ -109,7 +108,10 @@ protected:
bool m_handled;
public:
SrcType_PageFault() : m_handled(false) {}
SrcType_PageFault()
: m_handled(false)
{
}
virtual ~SrcType_PageFault() throw() {}
bool WasHandled() const { return m_handled; }
@ -254,7 +256,6 @@ public:
}
protected:
// This function is called from OnPageFaultEvent after the address has been translated
// and confirmed to apply to this reserved area in question. OnPageFaultEvent contains
// a try/catch exception handler, which ensures "reasonable" error response behavior if
@ -282,7 +283,8 @@ struct _EXCEPTION_POINTERS;
extern int SysPageFaultExceptionFilter(struct _EXCEPTION_POINTERS *eps);
#define PCSX2_PAGEFAULT_PROTECT __try
# define PCSX2_PAGEFAULT_EXCEPT __except(SysPageFaultExceptionFilter(GetExceptionInformation())) {}
#define PCSX2_PAGEFAULT_EXCEPT \
__except (SysPageFaultExceptionFilter(GetExceptionInformation())) {}
#else
#error PCSX2 - Unsupported operating system platform.
@ -294,4 +296,3 @@ extern void _platform_InstallSignalHandler();
#include "Threading.h"
extern SrcType_PageFault *Source_PageFault;
extern Threading::Mutex PageFault_Mutex;

View File

@ -31,8 +31,14 @@ public:
Assign(src.GetPath(), wxEmptyString);
}
wxDirName() : wxFileName() {}
wxDirName( const wxDirName& src ) : wxFileName( src ) { }
wxDirName()
: wxFileName()
{
}
wxDirName(const wxDirName &src)
: wxFileName(src)
{
}
explicit wxDirName(const char *src) { Assign(fromUTF8(src)); }
explicit wxDirName(const wxString &src) { Assign(src); }
@ -80,8 +86,7 @@ public:
wxFileName f(file);
while( 1 )
{
while (1) {
if (this->SameAs(wxDirName(f.GetPath())))
return true;
@ -114,15 +119,14 @@ public:
if (base.IsRelative() || subject.IsRelative())
return subject.GetFullPath();
wxString bv( base.GetVolume() ); bv.MakeUpper();
wxString sv( subject.GetVolume() ); sv.MakeUpper();
wxString bv(base.GetVolume());
bv.MakeUpper();
wxString sv(subject.GetVolume());
sv.MakeUpper();
if( base.IsContains( subject ) )
{
if (base.IsContains(subject)) {
subject.MakeRelativeTo(base.GetFullPath());
}
else if( base.HasVolume() && subject.HasVolume() && bv == sv )
{
} else if (base.HasVolume() && subject.HasVolume() && bv == sv) {
wxString unusedVolume;
wxString pathSansVolume;
subject.SplitVolume(subject.GetFullPath(), &unusedVolume, &pathSansVolume);
@ -163,9 +167,21 @@ public:
// ------------------------------------------------------------------------
wxDirName& operator=(const wxDirName& dirname) { Assign( dirname ); return *this; }
wxDirName& operator=(const wxString& dirname) { Assign( dirname ); return *this; }
wxDirName& operator=(const char* dirname) { Assign( fromUTF8(dirname) ); return *this; }
wxDirName &operator=(const wxDirName &dirname)
{
Assign(dirname);
return *this;
}
wxDirName &operator=(const wxString &dirname)
{
Assign(dirname);
return *this;
}
wxDirName &operator=(const char *dirname)
{
Assign(fromUTF8(dirname));
return *this;
}
wxFileName operator+(const wxFileName &right) const { return Combine(right); }
wxDirName operator+(const wxDirName &right) const { return Combine(right); }

View File

@ -15,7 +15,8 @@
#pragma once
namespace Perf {
namespace Perf
{
struct Info
{
@ -37,14 +38,12 @@ namespace Perf {
char m_prefix[20];
public:
InfoVector(const char *prefix);
void print(FILE *fp);
void map(uptr x86, u32 size, const char *symbol);
void map(uptr x86, u32 size, u32 pc);
void reset();
};
void dump();

View File

@ -131,7 +131,8 @@ namespace Threading
void AddListener(EventListener_Thread &evt);
void AddListener(EventListener_Thread *evt)
{
if( evt == NULL ) return;
if (evt == NULL)
return;
AddListener(*evt);
}
@ -250,8 +251,8 @@ namespace Threading
public:
virtual ~BaseTaskThread() throw() {}
BaseTaskThread() :
m_Done( false )
BaseTaskThread()
: m_Done(false)
, m_TaskPending(false)
, m_post_TaskComplete()
{

View File

@ -205,12 +205,11 @@ public:
virtual ~SafeAlignedArray() throw();
explicit SafeAlignedArray( const wxChar* name=L"Unnamed" ) :
SafeArray<T>::SafeArray( name )
explicit SafeAlignedArray(const wxChar *name = L"Unnamed")
: SafeArray<T>::SafeArray(name)
{
}
explicit SafeAlignedArray(int initialSize, const wxChar *name = L"Unnamed");
virtual SafeAlignedArray<T, Alignment> *Clone() const;
};

View File

@ -39,17 +39,16 @@ T* SafeArray<T>::_virtual_realloc( int newsize )
{
T *retval = (T *)((m_ptr == NULL) ?
malloc(newsize * sizeof(T)) :
realloc( m_ptr, newsize * sizeof(T) )
);
realloc(m_ptr, newsize * sizeof(T)));
if( IsDebugBuild && (retval != NULL))
{
if (IsDebugBuild && (retval != NULL)) {
// Zero everything out to 0xbaadf00d, so that its obviously uncleared
// to a debuggee
u32 *fill = (u32 *)&retval[m_size];
const u32 *end = (u32 *)((((uptr)&retval[newsize - 1]) - 3) & ~0x3);
for( ; fill<end; ++fill ) *fill = 0xbaadf00d;
for (; fill < end; ++fill)
*fill = 0xbaadf00d;
}
return retval;
@ -103,7 +102,8 @@ T* SafeArray<T>::_getPtr( uint i ) const
template <typename T>
void SafeArray<T>::ExactAlloc(int newsize)
{
if( newsize == m_size ) return;
if (newsize == m_size)
return;
m_ptr = _virtual_realloc(newsize);
if (m_ptr == NULL)
@ -131,8 +131,7 @@ T* SafeAlignedArray<T,Alignment>::_virtual_realloc( int newsize )
{
return (T *)((this->m_ptr == NULL) ?
_aligned_malloc(newsize * sizeof(T), Alignment) :
pcsx2_aligned_realloc( this->m_ptr, newsize * sizeof(T), Alignment, this->m_size * sizeof(T) )
);
pcsx2_aligned_realloc(this->m_ptr, newsize * sizeof(T), Alignment, this->m_size * sizeof(T)));
}
// Appends "(align: xx)" to the name of the allocation in devel builds.
@ -146,12 +145,11 @@ SafeAlignedArray<T,Alignment>::~SafeAlignedArray() throw()
}
template <typename T, uint Alignment>
SafeAlignedArray<T,Alignment>::SafeAlignedArray( int initialSize, const wxChar* name ) :
SafeArray<T>::SafeArray(
SafeAlignedArray<T, Alignment>::SafeAlignedArray(int initialSize, const wxChar *name)
: SafeArray<T>::SafeArray(
name,
(T *)_aligned_malloc(initialSize * sizeof(T), Alignment),
initialSize
)
initialSize)
{
}
@ -202,11 +200,9 @@ SafeList<T>::SafeList( int initialSize, const wxChar* name )
throw Exception::OutOfMemory(Name)
.SetDiagMsg(wxsFormat(L"called from 'SafeList::ctor' [length=%d]", m_length));
for( int i=0; i<m_allocsize; ++i )
{
for (int i = 0; i < m_allocsize; ++i) {
new (&m_ptr[i]) T();
}
}
template <typename T>
@ -221,16 +217,14 @@ T* SafeList<T>::_getPtr( uint i ) const
template <typename T>
void SafeList<T>::MakeRoomFor(int blockSize)
{
if( blockSize > m_allocsize )
{
if (blockSize > m_allocsize) {
const int newalloc = blockSize + ChunkSize;
m_ptr = _virtual_realloc(newalloc);
if (m_ptr == NULL)
throw Exception::OutOfMemory(Name)
.SetDiagMsg(wxsFormat(L"Called from 'SafeList::MakeRoomFor' [oldlen=%d] [newlen=%d]", m_length, blockSize));
for( ; m_allocsize<newalloc; ++m_allocsize )
{
for (; m_allocsize < newalloc; ++m_allocsize) {
new (&m_ptr[m_allocsize]) T();
}
}

View File

@ -133,7 +133,8 @@ public:
// Makes enough room for the requested size. Existing data in the array is retained.
void MakeRoomFor(uint size)
{
if (size <= m_size) return;
if (size <= m_size)
return;
Resize(size);
}
@ -177,7 +178,8 @@ class ScopedAlloc : public BaseScopedAlloc<T>
typedef BaseScopedAlloc<T> _parent;
public:
ScopedAlloc( size_t size=0 ) : _parent()
ScopedAlloc(size_t size = 0)
: _parent()
{
Alloc(size);
}
@ -191,7 +193,8 @@ public:
{
safe_free(this->m_buffer);
this->m_size = newsize;
if (!this->m_size) return;
if (!this->m_size)
return;
this->m_buffer = (T *)malloc(this->m_size * sizeof(T));
if (!this->m_buffer)
@ -225,7 +228,8 @@ class ScopedAlignedAlloc : public BaseScopedAlloc<T>
typedef BaseScopedAlloc<T> _parent;
public:
ScopedAlignedAlloc( size_t size=0 ) : _parent()
ScopedAlignedAlloc(size_t size = 0)
: _parent()
{
Alloc(size);
}
@ -239,7 +243,8 @@ public:
{
safe_aligned_free(this->m_buffer);
this->m_size = newsize;
if (!this->m_size) return;
if (!this->m_size)
return;
this->m_buffer = (T *)_aligned_malloc(this->m_size * sizeof(T), align);
if (!this->m_buffer)

View File

@ -44,7 +44,8 @@ public:
ScopedPtrMT &Reassign(T *ptr = nullptr)
{
T *doh = m_ptr.exchange(ptr);
if ( ptr != doh ) delete doh;
if (ptr != doh)
delete doh;
return *this;
}

View File

@ -44,13 +44,16 @@ public:
ConsoleLogSource_Threading();
bool Write( const wxString& thrname, const wxChar* msg ) {
bool Write(const wxString &thrname, const wxChar *msg)
{
return _parent::Write(wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg);
}
bool Warn( const wxString& thrname, const wxChar* msg ) {
bool Warn(const wxString &thrname, const wxChar *msg)
{
return _parent::Warn(wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg);
}
bool Error( const wxString& thrname, const wxChar* msg ) {
bool Error(const wxString &thrname, const wxChar *msg)
{
return _parent::Error(wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg);
}
};
@ -101,7 +104,8 @@ namespace Exception
Threading::pxThread *m_thread;
protected:
BaseThreadError() {
BaseThreadError()
{
m_thread = NULL;
}
@ -210,7 +214,10 @@ namespace Threading
// Can be done with a TryAcquire/Release but it is likely better to do it outside of the object
bool IsLocked()
{ pxAssertMsg(0, "IsLocked isn't supported for NonblockingMutex"); return false; }
{
pxAssertMsg(0, "IsLocked isn't supported for NonblockingMutex");
return false;
}
void Release()
{
@ -336,7 +343,10 @@ namespace Threading
class ScopedTryLock : public ScopedLock
{
public:
ScopedTryLock( const Mutex& locker ) : ScopedLock( locker, true ) { }
ScopedTryLock(const Mutex &locker)
: ScopedLock(locker, true)
{
}
virtual ~ScopedTryLock() throw() {}
bool Failed() const { return !m_IsLocked; }
};
@ -355,8 +365,8 @@ namespace Threading
bool m_IsLocked;
public:
ScopedNonblockingLock( NonblockingMutex& locker ) :
m_lock( locker )
ScopedNonblockingLock(NonblockingMutex &locker)
: m_lock(locker)
, m_IsLocked(m_lock.TryAcquire())
{
}
@ -377,26 +387,30 @@ namespace Threading
// Note that the isLockedBool should only be used as an indicator for the locked status,
// and not actually depended on for thread synchronization...
struct ScopedLockBool {
struct ScopedLockBool
{
ScopedLock m_lock;
std::atomic<bool> &m_bool;
ScopedLockBool(Mutex &mutexToLock, std::atomic<bool> &isLockedBool)
: m_lock(mutexToLock),
m_bool(isLockedBool) {
: m_lock(mutexToLock)
, m_bool(isLockedBool)
{
m_bool.store(m_lock.IsLocked(), std::memory_order_relaxed);
}
virtual ~ScopedLockBool() throw() {
virtual ~ScopedLockBool() throw()
{
m_bool.store(false, std::memory_order_relaxed);
}
void Acquire() {
void Acquire()
{
m_lock.Acquire();
m_bool.store(m_lock.IsLocked(), std::memory_order_relaxed);
}
void Release() {
void Release()
{
m_bool.store(false, std::memory_order_relaxed);
m_lock.Release();
}
};
}

View File

@ -49,5 +49,4 @@ namespace Threading
void OnTaskComplete(wxCommandEvent &evt);
//void OnTimer( wxTimerEvent& evt );
};
}

View File

@ -63,8 +63,7 @@ public:
void Dispose()
{
if (!m_IsDisposed)
{
if (!m_IsDisposed) {
m_IsDisposed = true;
KillKey();
}
@ -81,7 +80,8 @@ protected:
static void _aligned_delete_and_free(void *ptr)
{
if (!ptr) return;
if (!ptr)
return;
((T *)ptr)->~T();
_aligned_free(ptr);
}
@ -98,7 +98,9 @@ protected:
public:
TlsVariable() {}
TlsVariable(const T &initval)
: m_initval(initval) { }
: m_initval(initval)
{
}
// This is needed; The C++ standard likes making life suck for programmers.
using BaseTlsVariable<T>::GetRef;
@ -152,7 +154,8 @@ Threading::BaseTlsVariable<T>::BaseTlsVariable()
template <typename T>
void Threading::BaseTlsVariable<T>::KillKey()
{
if (!m_thread_key) return;
if (!m_thread_key)
return;
// Delete the handle for the current thread (which should always be the main/UI thread!)
// This is needed because pthreads does *not* clean up the dangling objects when you delete
@ -169,8 +172,7 @@ template< typename T >
T *Threading::BaseTlsVariable<T>::GetPtr() const
{
T *result = (T *)pthread_getspecific(m_thread_key);
if( result == NULL )
{
if (result == NULL) {
pthread_setspecific(m_thread_key, result = (T *)_aligned_malloc(sizeof(T), 16));
CreateInstance(result);
if (result == NULL)
@ -182,8 +184,7 @@ T* Threading::BaseTlsVariable<T>::GetPtr() const
template <typename T>
void Threading::BaseTlsVariable<T>::CreateKey()
{
if( 0 != pthread_key_create(&m_thread_key, BaseTlsVariable<T>::_aligned_delete_and_free) )
{
if (0 != pthread_key_create(&m_thread_key, BaseTlsVariable<T>::_aligned_delete_and_free)) {
pxFailRel("Thread Local Storage Error: key creation failed. This will most likely lead to a rapid application crash.");
}
}

View File

@ -77,7 +77,11 @@ public:
bool Enabled;
protected:
BaseTraceLogSource() : m_Descriptor(NULL), Enabled(false) {}
BaseTraceLogSource()
: m_Descriptor(NULL)
, Enabled(false)
{
}
public:
TraceLog_ImplementBaseAPI(BaseTraceLogSource)
@ -107,7 +111,6 @@ public:
}
virtual bool HasDescription() const { return m_Descriptor->Description != NULL; }
};
// --------------------------------------------------------------------------------------
@ -159,7 +162,10 @@ public:
ConsoleColors DefaultColor;
protected:
ConsoleLogSource() : DefaultColor(Color_Gray) {}
ConsoleLogSource()
: DefaultColor(Color_Gray)
{
}
public:
ConsoleLog_ImplementBaseAPI(ConsoleLogSource)
@ -280,4 +286,3 @@ public:
Console.DoWriteLn(msg);
}
};

View File

@ -36,6 +36,7 @@ protected:
int m_subPadding;
wxSizerItem *m_sizerItem_subtext;
public:
pxCheckBox(wxWindow *parent, const wxString &label, const wxString &subtext = wxEmptyString, int flags = wxCHK_2STATE);
pxCheckBox(wxWindow *parent, const wxString &label, int flags);
@ -50,12 +51,36 @@ public:
pxCheckBox &SetIndeterminate();
pxCheckBox &SetState(wxCheckBoxState state);
wxCheckBoxState GetState() const { pxAssert( m_checkbox != NULL ); return m_checkbox->Get3StateValue(); }
bool GetValue() const { pxAssert( m_checkbox != NULL ); return m_checkbox->GetValue(); }
bool IsChecked() const { pxAssert( m_checkbox != NULL ); return m_checkbox->IsChecked(); }
bool IsIndeterminate() const { pxAssert( m_checkbox != NULL ); return m_checkbox->Get3StateValue() == wxCHK_UNDETERMINED; }
operator wxCheckBox&() { pxAssert( m_checkbox != NULL ); return *m_checkbox; }
operator const wxCheckBox&() const { pxAssert( m_checkbox != NULL ); return *m_checkbox; }
wxCheckBoxState GetState() const
{
pxAssert(m_checkbox != NULL);
return m_checkbox->Get3StateValue();
}
bool GetValue() const
{
pxAssert(m_checkbox != NULL);
return m_checkbox->GetValue();
}
bool IsChecked() const
{
pxAssert(m_checkbox != NULL);
return m_checkbox->IsChecked();
}
bool IsIndeterminate() const
{
pxAssert(m_checkbox != NULL);
return m_checkbox->Get3StateValue() == wxCHK_UNDETERMINED;
}
operator wxCheckBox &()
{
pxAssert(m_checkbox != NULL);
return *m_checkbox;
}
operator const wxCheckBox &() const
{
pxAssert(m_checkbox != NULL);
return *m_checkbox;
}
wxCheckBox *GetWxPtr() { return m_checkbox; }
const wxCheckBox *GetWxPtr() const { return m_checkbox; }
@ -75,4 +100,3 @@ inline void operator+=( wxSizer& target, const pxWindowAndFlags<pxCheckBox>& src
{
target.Add(src.window, src.flags);
}

View File

@ -73,11 +73,13 @@ class pxSimpleEvent : public wxEvent
public:
explicit pxSimpleEvent(int evtid = 0)
: wxEvent(0, evtid)
{ }
{
}
pxSimpleEvent(wxWindowID winId, int evtid)
: wxEvent(winId, evtid)
{ }
{
}
virtual wxEvent *Clone() const { return new pxSimpleEvent(*this); }
};
@ -241,18 +243,62 @@ protected:
public:
MsgButtons() { bitset = 0; }
MsgButtons& OK() { m_OK = true; return *this; }
MsgButtons& Cancel() { m_Cancel = true; return *this; }
MsgButtons& Apply() { m_Apply = true; return *this; }
MsgButtons& Yes() { m_Yes = true; return *this; }
MsgButtons& No() { m_No = true; return *this; }
MsgButtons& ToAll() { m_AllowToAll = true; return *this; }
MsgButtons &OK()
{
m_OK = true;
return *this;
}
MsgButtons &Cancel()
{
m_Cancel = true;
return *this;
}
MsgButtons &Apply()
{
m_Apply = true;
return *this;
}
MsgButtons &Yes()
{
m_Yes = true;
return *this;
}
MsgButtons &No()
{
m_No = true;
return *this;
}
MsgButtons &ToAll()
{
m_AllowToAll = true;
return *this;
}
MsgButtons& Abort() { m_Abort = true; return *this; }
MsgButtons& Retry() { m_Retry = true; return *this; }
MsgButtons& Ignore() { m_Ignore = true; return *this; }
MsgButtons& Reset() { m_Reset = true; return *this; }
MsgButtons& Close() { m_Close = true; return *this; }
MsgButtons &Abort()
{
m_Abort = true;
return *this;
}
MsgButtons &Retry()
{
m_Retry = true;
return *this;
}
MsgButtons &Ignore()
{
m_Ignore = true;
return *this;
}
MsgButtons &Reset()
{
m_Reset = true;
return *this;
}
MsgButtons &Close()
{
m_Close = true;
return *this;
}
// label - native language label displayed to user
// id - raw ASCII identifier used in the config file (do not translate, hence char*)
@ -263,8 +309,16 @@ public:
return *this;
}
MsgButtons& OKCancel() { m_OK = m_Cancel = true; return *this; }
MsgButtons& YesNo() { m_Yes = m_No = true; return *this; }
MsgButtons &OKCancel()
{
m_OK = m_Cancel = true;
return *this;
}
MsgButtons &YesNo()
{
m_Yes = m_No = true;
return *this;
}
bool HasOK() const { return m_OK; }
bool HasCancel() const { return m_Cancel; }

View File

@ -122,4 +122,3 @@ inline void operator+=( wxSizer& target, const pxWindowAndFlags<pxStaticText>& s
{
target.Add(src.window, src.flags);
}

View File

@ -85,14 +85,16 @@ public:
void DeleteObject(BaseDeletableObject &obj);
void DeleteObject(BaseDeletableObject *obj)
{
if( obj == NULL ) return;
if (obj == NULL)
return;
DeleteObject(*obj);
}
void DeleteThread(Threading::pxThread &obj);
void DeleteThread(Threading::pxThread *obj)
{
if( obj == NULL ) return;
if (obj == NULL)
return;
DeleteThread(*obj);
}
@ -134,7 +136,6 @@ protected:
void OnDeleteThread(wxCommandEvent &evt);
void OnSynchronousCommand(pxSynchronousCommandEvent &evt);
void OnInvokeAction(pxActionEvent &evt);
};
namespace Msgbox

View File

@ -69,4 +69,3 @@ extern bool pxReadLine( wxInputStream& input, std::string& dest );
extern void pxWriteLine(wxOutputStream &output);
extern void pxWriteLine(wxOutputStream &output, const wxString &text);
extern void pxWriteMultiline(wxOutputStream &output, const wxString &src);

View File

@ -61,8 +61,7 @@ namespace pxSizerFlags
//
struct pxAlignmentType
{
enum
{
enum {
Centre,
Center = Centre,
Middle,
@ -104,8 +103,7 @@ struct pxAlignmentType
struct pxStretchType
{
enum
{
enum {
Shrink,
Expand,
Shaped,
@ -246,21 +244,24 @@ extern void operator+=( wxWindow& target, const pxStretchSpacer& spacer );
template <typename WinType>
void operator+=(wxWindow &target, WinType *src)
{
if( !pxAssert( target.GetSizer() != NULL ) ) return;
if (!pxAssert(target.GetSizer() != NULL))
return;
*target.GetSizer() += src;
}
template <typename WinType>
void operator+=(wxWindow &target, WinType &src)
{
if( !pxAssert( target.GetSizer() != NULL ) ) return;
if (!pxAssert(target.GetSizer() != NULL))
return;
*target.GetSizer() += src;
}
template <typename WinType>
void operator+=(wxWindow &target, const pxWindowAndFlags<WinType> &src)
{
if( !pxAssert( target.GetSizer() != NULL ) ) return;
if (!pxAssert(target.GetSizer() != NULL))
return;
*target.GetSizer() += src;
}
@ -358,13 +359,15 @@ public:
pxDialogCreationFlags &SetMinWidth(int width)
{
if( width > MinimumSize.x ) MinimumSize.SetWidth( width );
if (width > MinimumSize.x)
MinimumSize.SetWidth(width);
return *this;
}
pxDialogCreationFlags &SetMinHeight(int height)
{
if( height > MinimumSize.y ) MinimumSize.SetHeight( height );
if (height > MinimumSize.y)
MinimumSize.SetHeight(height);
return *this;
}
@ -474,12 +477,18 @@ public:
int GetWxWindowFlags() const
{
int retval = 0;
if( isResizable ) retval |= wxRESIZE_BORDER;
if( hasCaption ) retval |= wxCAPTION;
if( hasMaximizeBox ) retval |= wxMAXIMIZE_BOX;
if( hasMinimizeBox ) retval |= wxMINIMIZE_BOX;
if( hasSystemMenu ) retval |= wxSYSTEM_MENU;
if( hasCloseBox ) retval |= wxCLOSE_BOX;
if (isResizable)
retval |= wxRESIZE_BORDER;
if (hasCaption)
retval |= wxCAPTION;
if (hasMaximizeBox)
retval |= wxMAXIMIZE_BOX;
if (hasMinimizeBox)
retval |= wxMINIMIZE_BOX;
if (hasSystemMenu)
retval |= wxSYSTEM_MENU;
if (hasCloseBox)
retval |= wxCLOSE_BOX;
return retval;
}
@ -640,7 +649,8 @@ protected:
public:
pxTextWrapper(const wxString &wrapPrefix = wxEmptyString)
: pxTextWrapperBase(wrapPrefix)
{ }
{
}
virtual ~pxTextWrapper() throw() {}
@ -739,8 +749,7 @@ public:
const wxCursor &GetArrowWait();
};
enum BusyCursorType
{
enum BusyCursorType {
Cursor_NotBusy,
Cursor_KindaBusy,
Cursor_ReallyBusy,

View File

@ -35,34 +35,55 @@
// Basic functions.
EXPORT_C_(s32) CDVDinit();
EXPORT_C_(s32) CDVDopen(void *pDisplay, const char* pTitleFilename);
EXPORT_C_(void) CDVDclose();
EXPORT_C_(void) CDVDshutdown();
EXPORT_C_(s32) CDVDreadTrack(u32 lsn, int mode);
EXPORT_C_(s32)
CDVDinit();
EXPORT_C_(s32)
CDVDopen(void *pDisplay, const char *pTitleFilename);
EXPORT_C_(void)
CDVDclose();
EXPORT_C_(void)
CDVDshutdown();
EXPORT_C_(s32)
CDVDreadTrack(u32 lsn, int mode);
// return can be NULL (for async modes)
EXPORT_C_(u8*) CDVDgetBuffer();
EXPORT_C_(u8 *)
CDVDgetBuffer();
EXPORT_C_(s32) CDVDreadSubQ(u32 lsn, cdvdSubQ* subq);//read subq from disc (only cds have subq data)
EXPORT_C_(s32) CDVDgetTN(cdvdTN *Buffer); //disk information
EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
EXPORT_C_(s32) CDVDgetTOC(void* toc); //gets ps2 style toc from disc
EXPORT_C_(s32) CDVDgetDiskType(); //CDVD_TYPE_xxxx
EXPORT_C_(s32) CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
EXPORT_C_(s32) CDVDctrlTrayOpen(); //open disc tray
EXPORT_C_(s32) CDVDctrlTrayClose(); //close disc tray
EXPORT_C_(s32)
CDVDreadSubQ(u32 lsn, cdvdSubQ *subq); //read subq from disc (only cds have subq data)
EXPORT_C_(s32)
CDVDgetTN(cdvdTN *Buffer); //disk information
EXPORT_C_(s32)
CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
EXPORT_C_(s32)
CDVDgetTOC(void *toc); //gets ps2 style toc from disc
EXPORT_C_(s32)
CDVDgetDiskType(); //CDVD_TYPE_xxxx
EXPORT_C_(s32)
CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
EXPORT_C_(s32)
CDVDctrlTrayOpen(); //open disc tray
EXPORT_C_(s32)
CDVDctrlTrayClose(); //close disc tray
// Extended functions
EXPORT_C_(void) CDVDkeyEvent(keyEvent *ev);
EXPORT_C_(void) CDVDconfigure();
EXPORT_C_(s32) CDVDfreeze(u8 mode, freezeData *data);
EXPORT_C_(void) CDVDabout();
EXPORT_C_(s32) CDVDtest();
EXPORT_C_(void) CDVDnewDiskCB(void (*callback)());
EXPORT_C_(void)
CDVDkeyEvent(keyEvent *ev);
EXPORT_C_(void)
CDVDconfigure();
EXPORT_C_(s32)
CDVDfreeze(u8 mode, freezeData *data);
EXPORT_C_(void)
CDVDabout();
EXPORT_C_(s32)
CDVDtest();
EXPORT_C_(void)
CDVDnewDiskCB(void (*callback)());
typedef struct _cdvdSubQ {
typedef struct _cdvdSubQ
{
u8 ctrl : 4; // control and mode bits
u8 mode : 4; // control and mode bits
u8 trackNum; // current track number (1 to 99)
@ -76,12 +97,14 @@ typedef struct _cdvdSubQ {
u8 discF; // current frame offset from first track (BCD encoded)
} cdvdSubQ;
typedef struct _cdvdTD { // NOT bcd coded
typedef struct _cdvdTD
{ // NOT bcd coded
u32 lsn;
u8 type;
} cdvdTD;
typedef struct _cdvdTN {
typedef struct _cdvdTN
{
u8 strack; //number of the first track (usually 1)
u8 etrack; //number of the last track
} cdvdTN;

View File

@ -37,32 +37,51 @@ typedef int (*DEV9handler)(void);
// Basic functions.
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
EXPORT_C_(s32) DEV9init();
EXPORT_C_(s32)
DEV9init();
// pDisplay normally is passed a handle to the GS plugins window.
EXPORT_C_(s32) DEV9open(void *pDisplay);
EXPORT_C_(void) DEV9close();
EXPORT_C_(void) DEV9shutdown();
EXPORT_C_(u8) DEV9read8(u32 addr);
EXPORT_C_(u16) DEV9read16(u32 addr);
EXPORT_C_(u32) DEV9read32(u32 addr);
EXPORT_C_(void) DEV9write8(u32 addr, u8 value);
EXPORT_C_(void) DEV9write16(u32 addr, u16 value);
EXPORT_C_(void) DEV9write32(u32 addr, u32 value);
EXPORT_C_(void) DEV9readDMA8Mem(u32 *pMem, int size);
EXPORT_C_(void) DEV9writeDMA8Mem(u32 *pMem, int size);
EXPORT_C_(s32)
DEV9open(void *pDisplay);
EXPORT_C_(void)
DEV9close();
EXPORT_C_(void)
DEV9shutdown();
EXPORT_C_(u8)
DEV9read8(u32 addr);
EXPORT_C_(u16)
DEV9read16(u32 addr);
EXPORT_C_(u32)
DEV9read32(u32 addr);
EXPORT_C_(void)
DEV9write8(u32 addr, u8 value);
EXPORT_C_(void)
DEV9write16(u32 addr, u16 value);
EXPORT_C_(void)
DEV9write32(u32 addr, u32 value);
EXPORT_C_(void)
DEV9readDMA8Mem(u32 *pMem, int size);
EXPORT_C_(void)
DEV9writeDMA8Mem(u32 *pMem, int size);
// cycles = IOP cycles before calling callback,
// if callback returns 1 the irq is triggered, else not
EXPORT_C_(void) DEV9irqCallback(DEV9callback callback);
EXPORT_C_(DEV9handler) DEV9irqHandler(void);
EXPORT_C_(void)
DEV9irqCallback(DEV9callback callback);
EXPORT_C_(DEV9handler)
DEV9irqHandler(void);
// Extended functions
EXPORT_C_(void) DEV9keyEvent(keyEvent *ev);
EXPORT_C_(s32) DEV9freeze(u8 mode, freezeData *data);
EXPORT_C_(void) DEV9configure();
EXPORT_C_(void) DEV9about();
EXPORT_C_(s32) DEV9test();
EXPORT_C_(void)
DEV9keyEvent(keyEvent *ev);
EXPORT_C_(s32)
DEV9freeze(u8 mode, freezeData *data);
EXPORT_C_(void)
DEV9configure();
EXPORT_C_(void)
DEV9about();
EXPORT_C_(s32)
DEV9test();
#endif // __DEV9API_H__

View File

@ -37,22 +37,34 @@
// NOTE: The read/write functions CANNOT use XMM/MMX regs
// If you want to use them, need to save and restore current ones
EXPORT_C_(s32) FWinit();
EXPORT_C_(s32)
FWinit();
// pDisplay normally is passed a handle to the GS plugins window.
EXPORT_C_(s32) FWopen(void *pDisplay);
EXPORT_C_(void) FWclose();
EXPORT_C_(void) FWshutdown();
EXPORT_C_(u32) FWread32(u32 addr);
EXPORT_C_(void) FWwrite32(u32 addr, u32 value);
EXPORT_C_(void) FWirqCallback(void (*callback)());
EXPORT_C_(s32)
FWopen(void *pDisplay);
EXPORT_C_(void)
FWclose();
EXPORT_C_(void)
FWshutdown();
EXPORT_C_(u32)
FWread32(u32 addr);
EXPORT_C_(void)
FWwrite32(u32 addr, u32 value);
EXPORT_C_(void)
FWirqCallback(void (*callback)());
// Extended functions
EXPORT_C_(void) FWkeyEvent(keyEvent *ev);
EXPORT_C_(s32) FWfreeze(u8 mode, freezeData *data);
EXPORT_C_(void) FWconfigure();
EXPORT_C_(void) FWabout();
EXPORT_C_(s32) FWtest();
EXPORT_C_(void)
FWkeyEvent(keyEvent *ev);
EXPORT_C_(s32)
FWfreeze(u8 mode, freezeData *data);
EXPORT_C_(void)
FWconfigure();
EXPORT_C_(void)
FWabout();
EXPORT_C_(s32)
FWtest();
#endif
#endif // __USBAPI_H__

View File

@ -31,55 +31,86 @@
#include "Pcsx2Api.h"
typedef struct _GSdriverInfo {
typedef struct _GSdriverInfo
{
char name[8];
void *common;
} GSdriverInfo;
// Basic functions.
EXPORT_C_(s32) GSinit();
EXPORT_C_(s32)
GSinit();
// pDisplay normally is passed a handle to the GS plugins window.
EXPORT_C_(s32) GSopen(void *pDisplay, char *Title, bool multithread);
EXPORT_C_(void) GSclose();
EXPORT_C_(void) GSshutdown();
EXPORT_C_(void) GSvsync(int field);
EXPORT_C_(void) GSgifTransfer1(u32 *pMem, u32 addr);
EXPORT_C_(void) GSgifTransfer2(u32 *pMem, u32 size);
EXPORT_C_(void) GSgifTransfer3(u32 *pMem, u32 size);
EXPORT_C_(void) GSgetLastTag(u64* ptag); // returns the last tag processed (64 bits)
EXPORT_C_(void) GSgifSoftReset(u32 mask);
EXPORT_C_(void) GSreadFIFO(u64 *mem);
EXPORT_C_(void) GSreadFIFO2(u64 *mem, int qwc);
EXPORT_C_(s32)
GSopen(void *pDisplay, char *Title, bool multithread);
EXPORT_C_(void)
GSclose();
EXPORT_C_(void)
GSshutdown();
EXPORT_C_(void)
GSvsync(int field);
EXPORT_C_(void)
GSgifTransfer1(u32 *pMem, u32 addr);
EXPORT_C_(void)
GSgifTransfer2(u32 *pMem, u32 size);
EXPORT_C_(void)
GSgifTransfer3(u32 *pMem, u32 size);
EXPORT_C_(void)
GSgetLastTag(u64 *ptag); // returns the last tag processed (64 bits)
EXPORT_C_(void)
GSgifSoftReset(u32 mask);
EXPORT_C_(void)
GSreadFIFO(u64 *mem);
EXPORT_C_(void)
GSreadFIFO2(u64 *mem, int qwc);
// Extended functions
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
EXPORT_C_(void) GSkeyEvent(keyEvent *ev);
EXPORT_C_(void) GSchangeSaveState(s32 state, const char* filename);
EXPORT_C_(void) GSmakeSnapshot(char *path);
EXPORT_C_(void) GSmakeSnapshot2(char *pathname, int* snapdone, int savejpg);
EXPORT_C_(void) GSirqCallback(void (*callback)());
EXPORT_C_(void) CALLBACK GSprintf(s32 timeout, char *fmt, ...);
EXPORT_C_(void) GSsetBaseMem(void*);
EXPORT_C_(void) GSsetGameCRC(s32 crc, s32 gameoptions);
EXPORT_C_(void)
GSkeyEvent(keyEvent *ev);
EXPORT_C_(void)
GSchangeSaveState(s32 state, const char *filename);
EXPORT_C_(void)
GSmakeSnapshot(char *path);
EXPORT_C_(void)
GSmakeSnapshot2(char *pathname, int *snapdone, int savejpg);
EXPORT_C_(void)
GSirqCallback(void (*callback)());
EXPORT_C_(void)
CALLBACK GSprintf(s32 timeout, char *fmt, ...);
EXPORT_C_(void)
GSsetBaseMem(void *);
EXPORT_C_(void)
GSsetGameCRC(s32 crc, s32 gameoptions);
// controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done
EXPORT_C_(void) GSsetFrameSkip(int frameskip);
EXPORT_C_(void)
GSsetFrameSkip(int frameskip);
// if start is true, starts recording spu2 data, else stops
// returns true if successful
// for now, pData is not used
EXPORT_C_(bool) GSsetupRecording(bool start);
EXPORT_C_(bool)
GSsetupRecording(bool start);
EXPORT_C_(void) GSreset();
EXPORT_C_(void) GSwriteCSR(u32 value);
EXPORT_C_(void ) GSgetDriverInfo(GSdriverInfo *info);
EXPORT_C_(void)
GSreset();
EXPORT_C_(void)
GSwriteCSR(u32 value);
EXPORT_C_(void)
GSgetDriverInfo(GSdriverInfo *info);
#ifdef _WIN32
EXPORT_C_(s32) CALLBACK GSsetWindowInfo(winInfo *info);
EXPORT_C_(s32)
CALLBACK GSsetWindowInfo(winInfo *info);
#endif
EXPORT_C_(s32) GSfreeze(u8 mode, freezeData *data);
EXPORT_C_(void) GSconfigure();
EXPORT_C_(void) GSabout();
EXPORT_C_(s32) GStest();
EXPORT_C_(s32)
GSfreeze(u8 mode, freezeData *data);
EXPORT_C_(void)
GSconfigure();
EXPORT_C_(void)
GSabout();
EXPORT_C_(s32)
GStest();
#endif // __GSAPI_H__

View File

@ -35,19 +35,27 @@
/* So obsolete that everyone uses it. */
// Basic functions.
EXPORT_C_(s32) PADinit(u32 flags);
EXPORT_C_(s32)
PADinit(u32 flags);
// pDisplay normally is passed a handle to the GS plugins window.
EXPORT_C_(s32) PADopen(void *pDisplay);
EXPORT_C_(void) PADclose();
EXPORT_C_(void) PADshutdown();
EXPORT_C_(s32)
PADopen(void *pDisplay);
EXPORT_C_(void)
PADclose();
EXPORT_C_(void)
PADshutdown();
// PADkeyEvent is called every vsync (return NULL if no event)
EXPORT_C_(keyEvent*) PADkeyEvent();
EXPORT_C_(u8) PADstartPoll(u8 pad);
EXPORT_C_(u8) PADpoll(u8 value);
EXPORT_C_(keyEvent *)
PADkeyEvent();
EXPORT_C_(u8)
PADstartPoll(u8 pad);
EXPORT_C_(u8)
PADpoll(u8 value);
// returns: 1 if supported pad1
// 2 if supported pad2
// 3 if both are supported
EXPORT_C_(u8) PADquery();
EXPORT_C_(u8)
PADquery();
// call to give a hint to the PAD plugin to query for the keyboard state. A
// good plugin will query the OS for keyboard state ONLY in this function.
@ -56,25 +64,33 @@ EXPORT_C_(u8) PADquery();
// the window (and input). Note that PADupdate can be called from a different
// thread than the other functions, so mutex or other multithreading primitives
// have to be added to maintain data integrity.
EXPORT_C_(void) PADupdate(u8 pad);
EXPORT_C_(void)
PADupdate(u8 pad);
// Extended functions
EXPORT_C_(void) PADgsDriverInfo(GSdriverInfo *info);
EXPORT_C_(s32) PADfreeze(u8 mode, freezeData *data);
EXPORT_C_(void)
PADgsDriverInfo(GSdriverInfo *info);
EXPORT_C_(s32)
PADfreeze(u8 mode, freezeData *data);
// Returns 1 if the pad plugin wants a multitap on the specified port.
// 0 otherwise.
EXPORT_C_(s32) PADqueryMtap(u8 port);
EXPORT_C_(s32)
PADqueryMtap(u8 port);
// Sets the active pad slot for the specified port.
// Both numbers are 1-based indices. Should return 0 if there's no
// pad on the specified slot. Even if PADqueryMtap(port) returns 0,
// should handle this properly for slot != 1, so emulator can allow
// Multitap to be enabled/disabled elsewhere.
EXPORT_C_(s32) PADsetSlot(u8 port, u8 slot);
EXPORT_C_(s32)
PADsetSlot(u8 port, u8 slot);
EXPORT_C_(void) PADconfigure();
EXPORT_C_(void) PADabout();
EXPORT_C_(s32) PADtest();
EXPORT_C_(void)
PADconfigure();
EXPORT_C_(void)
PADabout();
EXPORT_C_(s32)
PADtest();
#endif // __PADAPI_H__

View File

@ -45,36 +45,48 @@ typedef int (CALLBACK * SIOchangeSlotCB)(int port, int slot);
// Types is an or-ed combination of SioTypes to initialize. It'd probably be simplest
// just to make each SIO plugin support only one type, for simplicity.
// SIOchangeSlotCB should *only* be called by MTAP plugins.
EXPORT_C_(s32) SIOinit(int types, SIOchangeSlotCB f);
EXPORT_C_(s32)
SIOinit(int types, SIOchangeSlotCB f);
// Single plugin can only be PAD, MTAP, RM, or MC. Only load one plugin of each type,
// but not both a PAD and MTAP. Simplifies plugin selection and interface, as well
// as API.
// pDisplay normally is passed a handle to the GS plugins window.
EXPORT_C_(s32) SIOopen(void *pDisplay);
EXPORT_C_(void) SIOclose();
EXPORT_C_(void) SIOshutdown();
EXPORT_C_(s32)
SIOopen(void *pDisplay);
EXPORT_C_(void)
SIOclose();
EXPORT_C_(void)
SIOshutdown();
// Returns 0 if device doesn't exist. Means old pad plugins can just say nothing
// connected to other slots, and SIOpoll won't be called on those slots, ideally.
EXPORT_C_(s32) SIOstartPoll(u8 deviceType, u32 port, u32 slot, u8 *returnValue);
EXPORT_C_(s32)
SIOstartPoll(u8 deviceType, u32 port, u32 slot, u8 *returnValue);
// Returns 0 on the last output byte.
EXPORT_C_(s32) SIOpoll(u8 value, u8 *returnValue);
EXPORT_C_(s32)
SIOpoll(u8 value, u8 *returnValue);
// returns: SIO_TYPE_{PAD,MTAP,RM,MC}
EXPORT_C_(u32) SIOquery();
EXPORT_C_(u32)
SIOquery();
// extended funcs
EXPORT_C_(void) SIOconfigure();
EXPORT_C_(keyEvent*) CALLBACK SIOkeyEvent();
EXPORT_C_(void)
SIOconfigure();
EXPORT_C_(keyEvent *)
CALLBACK SIOkeyEvent();
// Save one type at a time. If a plugin supports all 4 types,
// should expect 4 calls. Increases savestate compatibility.
EXPORT_C_(s32) SIOfreeze(u8 mode, freezeData *data, int type);
EXPORT_C_(void) SIOabout();
EXPORT_C_(s32) SIOtest();
EXPORT_C_(s32)
SIOfreeze(u8 mode, freezeData *data, int type);
EXPORT_C_(void)
SIOabout();
EXPORT_C_(s32)
SIOtest();
enum {
SIO_TYPE_PAD = 0x00000001,

View File

@ -31,47 +31,74 @@
#include "Pcsx2Api.h"
EXPORT_C_(s32) SPU2init();
EXPORT_C_(s32)
SPU2init();
// pDisplay normally is passed a handle to the GS plugins window.
EXPORT_C_(s32) SPU2open(void *pDisplay);
EXPORT_C_(void) SPU2close();
EXPORT_C_(void) SPU2shutdown();
EXPORT_C_(void) SPU2write(u32 mem, u16 value);
EXPORT_C_(u16) SPU2read(u32 mem);
EXPORT_C_(s32)
SPU2open(void *pDisplay);
EXPORT_C_(void)
SPU2close();
EXPORT_C_(void)
SPU2shutdown();
EXPORT_C_(void)
SPU2write(u32 mem, u16 value);
EXPORT_C_(u16)
SPU2read(u32 mem);
// The following calls are depreciated.
EXPORT_C_(void) SPU2readDMA4Mem(u16 *pMem, u32 size);
EXPORT_C_(void) SPU2readDMA7Mem(u16 *pMem, u32 size);
EXPORT_C_(void) SPU2writeDMA4Mem(u16 *pMem, u32 size);
EXPORT_C_(void) SPU2writeDMA7Mem(u16 *pMem, u32 size);
EXPORT_C_(void) SPU2interruptDMA4();
EXPORT_C_(void) SPU2interruptDMA7();
EXPORT_C_(void)
SPU2readDMA4Mem(u16 *pMem, u32 size);
EXPORT_C_(void)
SPU2readDMA7Mem(u16 *pMem, u32 size);
EXPORT_C_(void)
SPU2writeDMA4Mem(u16 *pMem, u32 size);
EXPORT_C_(void)
SPU2writeDMA7Mem(u16 *pMem, u32 size);
EXPORT_C_(void)
SPU2interruptDMA4();
EXPORT_C_(void)
SPU2interruptDMA7();
// These calls replace the calls above.
EXPORT_C_(void) SPU2readDMAMem(u16 *pMem, u32 size, u8 core);
EXPORT_C_(void) SPU2writeDMAMem(u16 *pMem, u32 size, u8 core);
EXPORT_C_(void) SPU2interruptDMA(u8 core);
EXPORT_C_(void)
SPU2readDMAMem(u16 *pMem, u32 size, u8 core);
EXPORT_C_(void)
SPU2writeDMAMem(u16 *pMem, u32 size, u8 core);
EXPORT_C_(void)
SPU2interruptDMA(u8 core);
// all addresses passed by dma will be pointers to the array starting at baseaddr
// This function is necessary to successfully save and reload the spu2 state
EXPORT_C_(void) SPU2setDMABaseAddr(uptr baseaddr);
EXPORT_C_(void)
SPU2setDMABaseAddr(uptr baseaddr);
EXPORT_C_(u32) SPU2ReadMemAddr(u8 core);
EXPORT_C_(void) SPU2WriteMemAddr(u8 core,u32 value);
EXPORT_C_(void) SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
EXPORT_C_(u32)
SPU2ReadMemAddr(u8 core);
EXPORT_C_(void)
SPU2WriteMemAddr(u8 core, u32 value);
EXPORT_C_(void)
SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)());
// extended funcs
// if start is true, starts recording spu2 data, else stops
// returns true if successful
EXPORT_C_(bool) SPU2setupRecording(bool start);
EXPORT_C_(bool)
SPU2setupRecording(bool start);
EXPORT_C_(void) SPU2keyEvent(keyEvent *ev);
EXPORT_C_(void) SPU2setClockPtr(u32* ptr);
EXPORT_C_(void) SPU2async(u32 cycles);
EXPORT_C_(s32) SPU2freeze(u8 mode, freezeData *data);
EXPORT_C_(void) SPU2configure();
EXPORT_C_(void) SPU2about();
EXPORT_C_(s32) SPU2test();
EXPORT_C_(void)
SPU2keyEvent(keyEvent *ev);
EXPORT_C_(void)
SPU2setClockPtr(u32 *ptr);
EXPORT_C_(void)
SPU2async(u32 cycles);
EXPORT_C_(s32)
SPU2freeze(u8 mode, freezeData *data);
EXPORT_C_(void)
SPU2configure();
EXPORT_C_(void)
SPU2about();
EXPORT_C_(s32)
SPU2test();
#endif

View File

@ -35,31 +35,50 @@ typedef void (*USBcallback)(int cycles);
typedef int (*USBhandler)(void);
// Basic functions.
EXPORT_C_(s32) USBinit();
EXPORT_C_(s32)
USBinit();
// pDisplay normally is passed a handle to the GS plugins window.
EXPORT_C_(s32) USBopen(void *pDisplay);
EXPORT_C_(void) USBclose();
EXPORT_C_(void) USBshutdown();
EXPORT_C_(u8) USBread8(u32 addr);
EXPORT_C_(u16) USBread16(u32 addr);
EXPORT_C_(u32) USBread32(u32 addr);
EXPORT_C_(void) USBwrite8(u32 addr, u8 value);
EXPORT_C_(void) USBwrite16(u32 addr, u16 value);
EXPORT_C_(void) USBwrite32(u32 addr, u32 value);
EXPORT_C_(void) USBasync(u32 cycles);
EXPORT_C_(s32)
USBopen(void *pDisplay);
EXPORT_C_(void)
USBclose();
EXPORT_C_(void)
USBshutdown();
EXPORT_C_(u8)
USBread8(u32 addr);
EXPORT_C_(u16)
USBread16(u32 addr);
EXPORT_C_(u32)
USBread32(u32 addr);
EXPORT_C_(void)
USBwrite8(u32 addr, u8 value);
EXPORT_C_(void)
USBwrite16(u32 addr, u16 value);
EXPORT_C_(void)
USBwrite32(u32 addr, u32 value);
EXPORT_C_(void)
USBasync(u32 cycles);
// cycles = IOP cycles before calling callback,
// if callback returns 1 the irq is triggered, else not
EXPORT_C_(void) USBirqCallback(USBcallback callback);
EXPORT_C_(USBhandler) USBirqHandler(void);
EXPORT_C_(void) USBsetRAM(void *mem);
EXPORT_C_(void)
USBirqCallback(USBcallback callback);
EXPORT_C_(USBhandler)
USBirqHandler(void);
EXPORT_C_(void)
USBsetRAM(void *mem);
// Extended functions
EXPORT_C_(void) USBkeyEvent(keyEvent *ev);
EXPORT_C_(s32) USBfreeze(u8 mode, freezeData *data);
EXPORT_C_(void) USBconfigure();
EXPORT_C_(void) USBabout();
EXPORT_C_(s32) USBtest();
EXPORT_C_(void)
USBkeyEvent(keyEvent *ev);
EXPORT_C_(s32)
USBfreeze(u8 mode, freezeData *data);
EXPORT_C_(void)
USBconfigure();
EXPORT_C_(void)
USBabout();
EXPORT_C_(s32)
USBtest();
#endif // __USBAPI_H__

View File

@ -17,7 +17,8 @@
// Implement BMI1/BMI2 instruction set
namespace x86Emitter {
namespace x86Emitter
{
struct xImplBMI_RVM
{
@ -57,5 +58,4 @@ namespace x86Emitter {
void operator()( const xRegisterInt& to, const xIndirectVoid& from, u8 imm) const;
#endif
};
}

View File

@ -15,7 +15,8 @@
#pragma once
namespace x86Emitter {
namespace x86Emitter
{
// Implementations here cover SHLD and SHRD.

View File

@ -15,10 +15,10 @@
#pragma once
namespace x86Emitter {
enum G1Type
namespace x86Emitter
{
enum G1Type {
G1Type_ADD = 0,
G1Type_OR,
G1Type_ADC,
@ -140,4 +140,3 @@ struct xImpl_G1Compare
};
} // End namespace x86Emitter

View File

@ -15,10 +15,10 @@
#pragma once
namespace x86Emitter {
enum G2Type
namespace x86Emitter
{
enum G2Type {
G2Type_ROL = 0,
G2Type_ROR,
G2Type_RCL,

View File

@ -15,10 +15,10 @@
#pragma once
namespace x86Emitter {
enum G3Type
namespace x86Emitter
{
enum G3Type {
G3Type_NOT = 2,
G3Type_NEG = 3,
G3Type_MUL = 4,
@ -105,5 +105,4 @@ struct xImpl_iMul
const xImplSimd_DestRegSSE SS;
const xImplSimd_DestRegSSE SD;
};
}

View File

@ -15,7 +15,8 @@
#pragma once
namespace x86Emitter {
namespace x86Emitter
{
// helpermess is currently broken >_<

View File

@ -18,7 +18,8 @@
// Implementations found here: Increment and Decrement Instructions!
// (They're soooo lonely... but I dunno where else to stick this class!)
namespace x86Emitter {
namespace x86Emitter
{
// --------------------------------------------------------------------------------------
// xImpl_IncDec

View File

@ -17,7 +17,8 @@
// Implementations found here: CALL and JMP! (unconditional only)
namespace x86Emitter {
namespace x86Emitter
{
extern void xJccKnownTarget(JccComparisonType comparison, const void *target, bool slideForward);
@ -35,8 +36,7 @@ struct xImpl_JmpCall
{
if (isJmp)
xJccKnownTarget(Jcc_Unconditional, (void *)(uptr)func, false); // double cast to/from (uptr) needed to appease GCC
else
{
else {
// calls are relative to the instruction after this one, and length is
// always 5 bytes (16 bit calls are bad mojo, so no bother to do special logic).
@ -109,8 +109,8 @@ struct xImpl_FastCall
#endif
}
template< typename T > __fi
void operator()( T* func, u32 a1, const xRegisterLong& a2) const
template <typename T>
__fi void operator()(T *func, u32 a1, const xRegisterLong &a2) const
{
void *f = (void *)func;
@ -121,8 +121,8 @@ struct xImpl_FastCall
#endif
}
template< typename T > __fi
void operator()( T* func, const xIndirectVoid& a1) const
template <typename T>
__fi void operator()(T *func, const xIndirectVoid &a1) const
{
void *f = (void *)func;
@ -133,8 +133,8 @@ struct xImpl_FastCall
#endif
}
template< typename T > __fi
void operator()( T* func, u32 a1, u32 a2) const
template <typename T>
__fi void operator()(T *func, u32 a1, u32 a2) const
{
void *f = (void *)func;
@ -145,8 +145,8 @@ struct xImpl_FastCall
#endif
}
template< typename T > __fi
void operator()( T* func, u32 a1) const
template <typename T>
__fi void operator()(T *func, u32 a1) const
{
void *f = (void *)func;
@ -184,4 +184,3 @@ struct xImpl_FastCall
};
} // End namespace x86Emitter

View File

@ -18,7 +18,8 @@
// Header: ix86_impl_movs.h -- covers mov, cmov, movsx/movzx, and SETcc (which shares
// with cmov many similarities).
namespace x86Emitter {
namespace x86Emitter
{
// --------------------------------------------------------------------------------------
// MovImplAll

View File

@ -15,7 +15,8 @@
#pragma once
namespace x86Emitter {
namespace x86Emitter
{
// --------------------------------------------------------------------------------------
// _SimdShiftHelper
@ -178,7 +179,6 @@ struct xImplSimd_PSign
// is unchanged. If a data element in src is zero, the corresponding data element in
// dest is set to zero.
const xImplSimd_DestRegEither D;
};
//////////////////////////////////////////////////////////////////////////////////////////
@ -314,4 +314,3 @@ struct xImplSimd_Round
};
} // End namespace x86Emitter

View File

@ -15,7 +15,8 @@
#pragma once
namespace x86Emitter {
namespace x86Emitter
{
struct xImplSimd_MinMax
{
@ -120,4 +121,3 @@ struct xImplSimd_PMinMax
};
} // end namespace x86Emitter

View File

@ -15,7 +15,8 @@
#pragma once
namespace x86Emitter {
namespace x86Emitter
{
// =====================================================================================================
// xImpl_SIMD Types (template free!)
@ -70,4 +71,3 @@ struct xImplSimd_DestRegEither
};
} // end namespace x86Emitter

View File

@ -15,7 +15,8 @@
#pragma once
namespace x86Emitter {
namespace x86Emitter
{
// --------------------------------------------------------------------------------------
// xImplSimd_MovHL
@ -169,6 +170,4 @@ struct xImplSimd_PMove
void DQ(const xRegisterSSE &to, const xRegisterSSE &from) const;
void DQ(const xRegisterSSE &to, const xIndirect64 &from) const;
};
}

View File

@ -15,7 +15,8 @@
#pragma once
namespace x86Emitter {
namespace x86Emitter
{
// --------------------------------------------------------------------------------------
// xImplSimd_Shuffle
@ -237,5 +238,4 @@ struct SimdImpl_PExtract
// used to extract any single packed dword value from src into an x86 32 bit register.
const xImplSimd_InsertExtractHelper D;
};
}

View File

@ -17,7 +17,8 @@
// Implementations found here: TEST + BTS/BT/BTC/BTR + BSF/BSR! (for lack of better location)
namespace x86Emitter {
namespace x86Emitter
{
// --------------------------------------------------------------------------------------
// xImpl_Test
@ -30,8 +31,7 @@ struct xImpl_Test
void operator()(const xRegisterInt &to, int imm) const;
};
enum G8Type
{
enum G8Type {
G8Type_BT = 4,
G8Type_BTS,
G8Type_BTR,
@ -72,4 +72,3 @@ struct xImpl_Group8
};
} // End namespace x86Emitter

View File

@ -18,7 +18,8 @@
// This header file is intended to be the future home of xchg, cmpxchg, xadd, and
// other threading-related exchange instructions.
namespace x86Emitter {
namespace x86Emitter
{
} // End namespace x86Emitter

View File

@ -96,8 +96,7 @@ namespace x86Emitter
extern const xImpl_FastCall xFastCall;
// ------------------------------------------------------------------------
extern const xImpl_CMov
xCMOVA, xCMOVAE,
extern const xImpl_CMov xCMOVA, xCMOVAE,
xCMOVB, xCMOVBE,
xCMOVG, xCMOVGE,
xCMOVL, xCMOVLE,
@ -111,8 +110,7 @@ namespace x86Emitter
xCMOVPE, xCMOVPO;
// ------------------------------------------------------------------------
extern const xImpl_Set
xSETA, xSETAE,
extern const xImpl_Set xSETA, xSETAE,
xSETB, xSETBE,
xSETG, xSETGE,
xSETL, xSETLE,
@ -211,30 +209,110 @@ namespace x86Emitter
// the target (efficient!)
//
template< typename T > __fi void xJE( T* func ) { xJcc( Jcc_Equal, (void*)(uptr)func ); }
template< typename T > __fi void xJZ( T* func ) { xJcc( Jcc_Zero, (void*)(uptr)func ); }
template< typename T > __fi void xJNE( T* func ) { xJcc( Jcc_NotEqual, (void*)(uptr)func ); }
template< typename T > __fi void xJNZ( T* func ) { xJcc( Jcc_NotZero, (void*)(uptr)func ); }
template <typename T>
__fi void xJE(T *func)
{
xJcc(Jcc_Equal, (void *)(uptr)func);
}
template <typename T>
__fi void xJZ(T *func)
{
xJcc(Jcc_Zero, (void *)(uptr)func);
}
template <typename T>
__fi void xJNE(T *func)
{
xJcc(Jcc_NotEqual, (void *)(uptr)func);
}
template <typename T>
__fi void xJNZ(T *func)
{
xJcc(Jcc_NotZero, (void *)(uptr)func);
}
template< typename T > __fi void xJO( T* func ) { xJcc( Jcc_Overflow, (void*)(uptr)func ); }
template< typename T > __fi void xJNO( T* func ) { xJcc( Jcc_NotOverflow, (void*)(uptr)func ); }
template< typename T > __fi void xJC( T* func ) { xJcc( Jcc_Carry, (void*)(uptr)func ); }
template< typename T > __fi void xJNC( T* func ) { xJcc( Jcc_NotCarry, (void*)(uptr)func ); }
template< typename T > __fi void xJS( T* func ) { xJcc( Jcc_Signed, (void*)(uptr)func ); }
template< typename T > __fi void xJNS( T* func ) { xJcc( Jcc_Unsigned, (void*)(uptr)func ); }
template <typename T>
__fi void xJO(T *func)
{
xJcc(Jcc_Overflow, (void *)(uptr)func);
}
template <typename T>
__fi void xJNO(T *func)
{
xJcc(Jcc_NotOverflow, (void *)(uptr)func);
}
template <typename T>
__fi void xJC(T *func)
{
xJcc(Jcc_Carry, (void *)(uptr)func);
}
template <typename T>
__fi void xJNC(T *func)
{
xJcc(Jcc_NotCarry, (void *)(uptr)func);
}
template <typename T>
__fi void xJS(T *func)
{
xJcc(Jcc_Signed, (void *)(uptr)func);
}
template <typename T>
__fi void xJNS(T *func)
{
xJcc(Jcc_Unsigned, (void *)(uptr)func);
}
template< typename T > __fi void xJPE( T* func ) { xJcc( Jcc_ParityEven, (void*)(uptr)func ); }
template< typename T > __fi void xJPO( T* func ) { xJcc( Jcc_ParityOdd, (void*)(uptr)func ); }
template <typename T>
__fi void xJPE(T *func)
{
xJcc(Jcc_ParityEven, (void *)(uptr)func);
}
template <typename T>
__fi void xJPO(T *func)
{
xJcc(Jcc_ParityOdd, (void *)(uptr)func);
}
template< typename T > __fi void xJL( T* func ) { xJcc( Jcc_Less, (void*)(uptr)func ); }
template< typename T > __fi void xJLE( T* func ) { xJcc( Jcc_LessOrEqual, (void*)(uptr)func ); }
template< typename T > __fi void xJG( T* func ) { xJcc( Jcc_Greater, (void*)(uptr)func ); }
template< typename T > __fi void xJGE( T* func ) { xJcc( Jcc_GreaterOrEqual, (void*)(uptr)func ); }
template <typename T>
__fi void xJL(T *func)
{
xJcc(Jcc_Less, (void *)(uptr)func);
}
template <typename T>
__fi void xJLE(T *func)
{
xJcc(Jcc_LessOrEqual, (void *)(uptr)func);
}
template <typename T>
__fi void xJG(T *func)
{
xJcc(Jcc_Greater, (void *)(uptr)func);
}
template <typename T>
__fi void xJGE(T *func)
{
xJcc(Jcc_GreaterOrEqual, (void *)(uptr)func);
}
template< typename T > __fi void xJB( T* func ) { xJcc( Jcc_Below, (void*)(uptr)func ); }
template< typename T > __fi void xJBE( T* func ) { xJcc( Jcc_BelowOrEqual, (void*)(uptr)func ); }
template< typename T > __fi void xJA( T* func ) { xJcc( Jcc_Above, (void*)(uptr)func ); }
template< typename T > __fi void xJAE( T* func ) { xJcc( Jcc_AboveOrEqual, (void*)(uptr)func ); }
template <typename T>
__fi void xJB(T *func)
{
xJcc(Jcc_Below, (void *)(uptr)func);
}
template <typename T>
__fi void xJBE(T *func)
{
xJcc(Jcc_BelowOrEqual, (void *)(uptr)func);
}
template <typename T>
__fi void xJA(T *func)
{
xJcc(Jcc_Above, (void *)(uptr)func);
}
template <typename T>
__fi void xJAE(T *func)
{
xJcc(Jcc_AboveOrEqual, (void *)(uptr)func);
}
// ------------------------------------------------------------------------
// Forward Jump Helpers (act as labels!)
@ -244,7 +322,10 @@ namespace x86Emitter
class xForward##label : public xForwardJump<OperandType> \
{ \
public: \
xForward##label() : xForwardJump<OperandType>( cond ) {} \
xForward##label() \
: xForwardJump<OperandType>(cond) \
{ \
} \
};
// ------------------------------------------------------------------------
@ -498,6 +579,4 @@ namespace x86Emitter
extern const SimdImpl_Pack xPACK;
extern const xImplSimd_PInsert xPINSR;
extern const SimdImpl_PExtract xPEXTR;
}

View File

@ -19,7 +19,8 @@
#include "instructions.h"
namespace x86Emitter {
namespace x86Emitter
{
#define OpWriteSSE(pre, op) xOpWrite0F(pre, op, to, from)
@ -40,17 +41,18 @@ namespace x86Emitter {
extern void _xMovRtoR(const xRegisterInt &to, const xRegisterInt &from);
template< typename T > inline
void xWrite( T val )
template <typename T>
inline void xWrite(T val)
{
*(T *)x86Ptr = val;
x86Ptr += sizeof(T);
}
template< typename T1, typename T2 > __emitinline
void xOpWrite( u8 prefix, u8 opcode, const T1& param1, const T2& param2 )
template <typename T1, typename T2>
__emitinline void xOpWrite(u8 prefix, u8 opcode, const T1 &param1, const T2 &param2)
{
if( prefix != 0 ) xWrite8( prefix );
if (prefix != 0)
xWrite8(prefix);
EmitRex(param1, param2);
xWrite8(opcode);
@ -58,10 +60,11 @@ namespace x86Emitter {
EmitSibMagic(param1, param2);
}
template< typename T1, typename T2 > __emitinline
void xOpAccWrite( u8 prefix, u8 opcode, const T1& param1, const T2& param2 )
template <typename T1, typename T2>
__emitinline void xOpAccWrite(u8 prefix, u8 opcode, const T1 &param1, const T2 &param2)
{
if( prefix != 0 ) xWrite8( prefix );
if (prefix != 0)
xWrite8(prefix);
EmitRex(param1, param2);
xWrite8(opcode);
@ -78,10 +81,11 @@ namespace x86Emitter {
// Prefixes are typically 0x66, 0xf2, or 0xf3. OpcodePrefixes are either 0x38 or
// 0x3a [and other value will result in assertion failue].
//
template< typename T1, typename T2 > __emitinline
void xOpWrite0F( u8 prefix, u16 opcode, const T1& param1, const T2& param2 )
template <typename T1, typename T2>
__emitinline void xOpWrite0F(u8 prefix, u16 opcode, const T1 &param1, const T2 &param2)
{
if( prefix != 0 ) xWrite8( prefix );
if (prefix != 0)
xWrite8(prefix);
EmitRex(param1, param2);
SimdPrefix(0, opcode);
@ -89,22 +93,28 @@ namespace x86Emitter {
EmitSibMagic(param1, param2);
}
template< typename T1, typename T2 > __emitinline
void xOpWrite0F( u8 prefix, u16 opcode, const T1& param1, const T2& param2, u8 imm8 )
template <typename T1, typename T2>
__emitinline void xOpWrite0F(u8 prefix, u16 opcode, const T1 &param1, const T2 &param2, u8 imm8)
{
xOpWrite0F(prefix, opcode, param1, param2);
xWrite8(imm8);
}
template< typename T1, typename T2 > __emitinline
void xOpWrite0F( u16 opcode, const T1& param1, const T2& param2 ) { xOpWrite0F( 0, opcode, param1, param2 ); }
template <typename T1, typename T2>
__emitinline void xOpWrite0F(u16 opcode, const T1 &param1, const T2 &param2)
{
xOpWrite0F(0, opcode, param1, param2);
}
template< typename T1, typename T2 > __emitinline
void xOpWrite0F( u16 opcode, const T1& param1, const T2& param2, u8 imm8 ) { xOpWrite0F( 0, opcode, param1, param2, imm8 ); }
template <typename T1, typename T2>
__emitinline void xOpWrite0F(u16 opcode, const T1 &param1, const T2 &param2, u8 imm8)
{
xOpWrite0F(0, opcode, param1, param2, imm8);
}
// VEX 2 Bytes Prefix
template< typename T1, typename T2, typename T3 > __emitinline
void xOpWriteC5( u8 prefix, u8 opcode, const T1& param1, const T2& param2, const T3& param3 )
template <typename T1, typename T2, typename T3>
__emitinline void xOpWriteC5(u8 prefix, u8 opcode, const T1 &param1, const T2 &param2, const T3 &param3)
{
pxAssert(prefix == 0 || prefix == 0x66 || prefix == 0xF3 || prefix == 0xF2);
@ -131,8 +141,8 @@ namespace x86Emitter {
}
// VEX 3 Bytes Prefix
template< typename T1, typename T2, typename T3 > __emitinline
void xOpWriteC4( u8 prefix, u8 mb_prefix, u8 opcode, const T1& param1, const T2& param2, const T3& param3, int w = -1 )
template <typename T1, typename T2, typename T3>
__emitinline void xOpWriteC4(u8 prefix, u8 mb_prefix, u8 opcode, const T1 &param1, const T2 &param2, const T3 &param3, int w = -1)
{
pxAssert(prefix == 0 || prefix == 0x66 || prefix == 0xF3 || prefix == 0xF2);
pxAssert(mb_prefix == 0x0F || mb_prefix == 0x38 || mb_prefix == 0x3A);
@ -169,6 +179,4 @@ namespace x86Emitter {
xWrite8(opcode);
EmitSibMagic(param1, param3);
}
}

View File

@ -38,4 +38,3 @@ extern void SibSB( uint ss, uint index, uint base );
extern void SET8R(int cc, int to);
extern u8 *J8Rel(int cc, int to);
extern u32 *J32Rel(int cc, u32 to);

View File

@ -17,8 +17,7 @@
#include "x86emitter.h"
enum x86VendorType
{
enum x86VendorType {
x86Vendor_Intel = 0,
x86Vendor_AMD = 1,
x86Vendor_Unknown = 2
@ -53,8 +52,10 @@ public:
// x86 CPU Capabilities Section (all boolean flags!)
// ----------------------------------------------------------------------------
union {
struct {
union
{
struct
{
u32 hasFloatingPointUnit : 1;
u32 hasVirtual8086ModeEnhancements : 1;
u32 hasDebuggingExtensions : 1;
@ -123,8 +124,7 @@ protected:
void CountLogicalCores();
};
enum SSE_RoundMode
{
enum SSE_RoundMode {
SSE_RoundMode_FIRST = 0,
SSEround_Nearest = 0,
SSEround_NegInf,
@ -199,4 +199,3 @@ extern SSE_MXCSR MXCSR_Mask;
extern __aligned16 x86capabilities x86caps;

View File

@ -39,18 +39,22 @@
#include <cpuid.h>
static __inline__ __attribute__((always_inline)) void cpuidex(int CPUInfo[], const int InfoType, const int count) {
static __inline__ __attribute__((always_inline)) void cpuidex(int CPUInfo[], const int InfoType, const int count)
{
__cpuid_count(InfoType, count, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
}
static __inline__ __attribute__((always_inline)) void cpuid(int CPUInfo[], const int InfoType) {
static __inline__ __attribute__((always_inline)) void cpuid(int CPUInfo[], const int InfoType)
{
__cpuid(InfoType, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
}
static __inline__ __attribute__((always_inline)) unsigned long long _xgetbv(unsigned int index)
{
unsigned int eax, edx;
__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
__asm__ __volatile__("xgetbv"
: "=a"(eax), "=d"(edx)
: "c"(index));
return ((unsigned long long)edx << 32) | eax;
}

View File

@ -24,8 +24,7 @@ static const uint iREGCNT_XMM = 8;
static const uint iREGCNT_GPR = 8;
#endif
enum XMMSSEType
{
enum XMMSSEType {
XMMT_INT = 0, // integer (sse2 only)
XMMT_FPS = 1, // floating point
//XMMT_FPD = 3, // double
@ -79,9 +78,13 @@ extern const char* xGetRegName( int regid, int operandSize );
//------------------------------------------------------------------
// templated version of is_s8 is required, so that u16's get correct sign extension treatment.
template <typename T>
static __fi bool is_s8( T imm ) { return (s8)imm == (s32)imm; }
static __fi bool is_s8(T imm)
{
return (s8)imm == (s32)imm;
}
template< typename T > void xWrite( T val );
template <typename T>
void xWrite(T val);
// --------------------------------------------------------------------------------------
// ALWAYS_USE_MOVAPS [define] / AlwaysUseMovaps [const]
@ -124,8 +127,7 @@ template< typename T > void xWrite( T val );
#endif
// ModRM 'mod' field enumeration. Provided mostly for reference:
enum ModRm_ModField
{
enum ModRm_ModField {
Mod_NoDisp = 0, // effective address operation with no displacement, in the form of [reg] (or uses special Disp32-only encoding in the case of [ebp] form)
Mod_Disp8, // effective address operation with 8 bit displacement, in the form of [reg+disp8]
Mod_Disp32, // effective address operation with 32 bit displacement, in the form of [reg+disp32],
@ -135,8 +137,7 @@ template< typename T > void xWrite( T val );
// ----------------------------------------------------------------------------
// JccComparisonType - enumerated possibilities for inspired code branching!
//
enum JccComparisonType
{
enum JccComparisonType {
Jcc_Unknown = -2,
Jcc_Unconditional = -1,
Jcc_Overflow = 0x0,
@ -167,8 +168,7 @@ template< typename T > void xWrite( T val );
// ----------------------------------------------------------------------------
// SSE2_ComparisonType - enumerated possibilities for SIMD data comparison!
//
enum SSE2_ComparisonType
{
enum SSE2_ComparisonType {
SSE2_Equal = 0,
SSE2_Less,
SSE2_LessOrEqual,
@ -204,16 +204,27 @@ template< typename T > void xWrite( T val );
bool Is8BitOp() const { return GetOperandSize() == 1; }
u8 GetPrefix16() const { return GetOperandSize() == 2 ? 0x66 : 0; }
void prefix16() const { if( GetOperandSize() == 2 ) xWrite8( 0x66 ); }
void prefix16() const
{
if (GetOperandSize() == 2)
xWrite8(0x66);
}
void xWriteImm(int imm) const
{
switch( GetOperandSize() )
{
case 1: xWrite8( imm ); break;
case 2: xWrite16( imm ); break;
case 4: xWrite32( imm ); break;
case 8: xWrite64( imm ); break;
switch (GetOperandSize()) {
case 1:
xWrite8(imm);
break;
case 2:
xWrite16(imm);
break;
case 4:
xWrite32(imm);
break;
case 8:
xWrite64(imm);
break;
jNO_DEFAULT
}
@ -267,9 +278,15 @@ template< typename T > void xWrite( T val );
// IsWide: return true if the register is 64 bits (requires a wide op on the rex prefix)
#ifdef __x86_64__
bool IsWide() const { return GetOperandSize() == 8; }
bool IsWide() const
{
return GetOperandSize() == 8;
}
#else
bool IsWide() const { return false; } // no 64 bits GPR
bool IsWide() const
{
return false;
} // no 64 bits GPR
#endif
// return true if the register is a valid YMM register
bool IsWideSIMD() const { return GetOperandSize() == 32; }
@ -289,8 +306,14 @@ template< typename T > void xWrite( T val );
public:
xRegisterInt() {}
explicit xRegisterInt( const xRegisterBase& src ) : _parent( src ) {}
explicit xRegisterInt( int regId ) : _parent( regId ) { }
explicit xRegisterInt(const xRegisterBase &src)
: _parent(src)
{
}
explicit xRegisterInt(int regId)
: _parent(regId)
{
}
bool operator==(const xRegisterInt &src) const { return Id == src.Id && (GetOperandSize() == src.GetOperandSize()); }
bool operator!=(const xRegisterInt &src) const { return !operator==(src); }
@ -304,8 +327,14 @@ template< typename T > void xWrite( T val );
typedef xRegisterInt _parent;
public:
xRegister8(): _parent() {}
explicit xRegister8( int regId ) : _parent( regId ) {}
xRegister8()
: _parent()
{
}
explicit xRegister8(int regId)
: _parent(regId)
{
}
virtual uint GetOperandSize() const { return 1; }
@ -318,8 +347,14 @@ template< typename T > void xWrite( T val );
typedef xRegisterInt _parent;
public:
xRegister16(): _parent() {}
explicit xRegister16( int regId ) : _parent( regId ) {}
xRegister16()
: _parent()
{
}
explicit xRegister16(int regId)
: _parent(regId)
{
}
virtual uint GetOperandSize() const { return 2; }
@ -332,8 +367,14 @@ template< typename T > void xWrite( T val );
typedef xRegisterInt _parent;
public:
xRegister32(): _parent() {}
explicit xRegister32( int regId ) : _parent( regId ) {}
xRegister32()
: _parent()
{
}
explicit xRegister32(int regId)
: _parent(regId)
{
}
virtual uint GetOperandSize() const { return 4; }
@ -346,8 +387,14 @@ template< typename T > void xWrite( T val );
typedef xRegisterInt _parent;
public:
xRegister64(): _parent() {}
explicit xRegister64( int regId ) : _parent( regId ) {}
xRegister64()
: _parent()
{
}
explicit xRegister64(int regId)
: _parent(regId)
{
}
virtual uint GetOperandSize() const { return 8; }
@ -366,8 +413,14 @@ template< typename T > void xWrite( T val );
typedef xRegisterBase _parent;
public:
xRegisterSSE(): _parent() {}
explicit xRegisterSSE( int regId ) : _parent( regId ) {}
xRegisterSSE()
: _parent()
{
}
explicit xRegisterSSE(int regId)
: _parent(regId)
{
}
virtual uint GetOperandSize() const { return 16; }
@ -394,7 +447,10 @@ template< typename T > void xWrite( T val );
class xRegisterCL : public xRegister8
{
public:
xRegisterCL(): xRegister8( 1 ) {}
xRegisterCL()
: xRegister8(1)
{
}
};
// --------------------------------------------------------------------------------------
@ -417,11 +473,26 @@ template< typename T > void xWrite( T val );
class xAddressReg : public xRegisterLong
{
public:
xAddressReg(): xRegisterLong() {}
xAddressReg( const xAddressReg& src ) : xRegisterLong( src.Id ) {}
xAddressReg( const xRegister32& src ) : xRegisterLong( src.Id ) {}
xAddressReg( const xRegister64& src ) : xRegisterLong( src.Id ) {}
explicit xAddressReg( int regId ) : xRegisterLong( regId ) {}
xAddressReg()
: xRegisterLong()
{
}
xAddressReg(const xAddressReg &src)
: xRegisterLong(src.Id)
{
}
xAddressReg(const xRegister32 &src)
: xRegisterLong(src.Id)
{
}
xAddressReg(const xRegister64 &src)
: xRegisterLong(src.Id)
{
}
explicit xAddressReg(int regId)
: xRegisterLong(regId)
{
}
// Returns true if the register is the stack pointer: ESP.
bool IsStackPointer() const { return Id == 4; }
@ -433,7 +504,6 @@ template< typename T > void xWrite( T val );
xAddressVoid operator-(const void *right) const;
xAddressVoid operator*(int factor) const;
xAddressVoid operator<<(u32 shift) const;
};
// --------------------------------------------------------------------------------------
@ -469,8 +539,14 @@ template< typename T > void xWrite( T val );
const xRegisterInt &m_convtype;
public:
xRegister16or32( const xRegister32& src ) : m_convtype( src ) {}
xRegister16or32( const xRegister16& src ) : m_convtype( src ) {}
xRegister16or32(const xRegister32 &src)
: m_convtype(src)
{
}
xRegister16or32(const xRegister16 &src)
: m_convtype(src)
{
}
operator const xRegisterBase &() const { return m_convtype; }
@ -486,9 +562,18 @@ template< typename T > void xWrite( T val );
const xRegisterInt &m_convtype;
public:
xRegister16or32or64( const xRegister64& src ) : m_convtype( src ) {}
xRegister16or32or64( const xRegister32& src ) : m_convtype( src ) {}
xRegister16or32or64( const xRegister16& src ) : m_convtype( src ) {}
xRegister16or32or64(const xRegister64 &src)
: m_convtype(src)
{
}
xRegister16or32or64(const xRegister32 &src)
: m_convtype(src)
{
}
xRegister16or32or64(const xRegister16 &src)
: m_convtype(src)
{
}
operator const xRegisterBase &() const { return m_convtype; }
@ -504,8 +589,14 @@ template< typename T > void xWrite( T val );
const xRegisterInt &m_convtype;
public:
xRegister32or64( const xRegister64& src ) : m_convtype( src ) {}
xRegister32or64( const xRegister32& src ) : m_convtype( src ) {}
xRegister32or64(const xRegister64 &src)
: m_convtype(src)
{
}
xRegister32or64(const xRegister32 &src)
: m_convtype(src)
{
}
operator const xRegisterBase &() const { return m_convtype; }
@ -517,6 +608,8 @@ template< typename T > void xWrite( T val );
extern const xRegisterEmpty xEmptyReg;
// clang-format off
extern const xRegisterSSE
xmm0, xmm1, xmm2, xmm3,
xmm4, xmm5, xmm6, xmm7,
@ -541,6 +634,8 @@ template< typename T > void xWrite( T val );
al, dl, bl,
ah, ch, dh, bh;
// clang-format on
extern const xRegisterCL cl; // I'm special!
const xRegisterSSE &xRegisterSSE::GetInstance(uint id)
@ -550,8 +645,7 @@ template< typename T > void xWrite( T val );
&xmm0, &xmm1, &xmm2, &xmm3,
&xmm4, &xmm5, &xmm6, &xmm7,
&xmm8, &xmm9, &xmm10, &xmm11,
&xmm12, &xmm13, &xmm14, &xmm15
};
&xmm12, &xmm13, &xmm14, &xmm15};
pxAssert(id < iREGCNT_XMM);
return *m_tbl_xmmRegs[id];
@ -608,16 +702,22 @@ template< typename T > void xWrite( T val );
public:
xAddressInfo(const xAddressReg &base, const xAddressReg &index, int factor = 1, s32 displacement = 0)
: _parent( base, index, factor, displacement ) {}
: _parent(base, index, factor, displacement)
{
}
/*xAddressInfo( const xAddressVoid& src )
: _parent( src ) {}*/
explicit xAddressInfo(const xAddressReg &index, int displacement = 0)
: _parent( index, displacement ) {}
: _parent(index, displacement)
{
}
explicit xAddressInfo(s32 displacement = 0)
: _parent( displacement ) {}
: _parent(displacement)
{
}
static xAddressInfo<BaseType> FromIndexReg(const xAddressReg &index, int scale = 0, s32 displacement = 0);
@ -633,8 +733,16 @@ template< typename T > void xWrite( T val );
return *this;
}
xAddressInfo<BaseType>& Add( const xAddressReg& src ) { _parent::Add(src); return *this; }
xAddressInfo<BaseType>& Add( const xAddressInfo<BaseType>& src ) { _parent::Add(src); return *this; }
xAddressInfo<BaseType> &Add(const xAddressReg &src)
{
_parent::Add(src);
return *this;
}
xAddressInfo<BaseType> &Add(const xAddressInfo<BaseType> &src)
{
_parent::Add(src);
return *this;
}
__fi xAddressInfo<BaseType> operator+(const xAddressReg &right) const { return xAddressInfo(*this).Add(right); }
__fi xAddressInfo<BaseType> operator+(const xAddressInfo<BaseType> &right) const { return xAddressInfo(*this).Add(right); }
@ -692,7 +800,8 @@ template< typename T > void xWrite( T val );
int m_imm;
public:
xImmReg() : m_reg()
xImmReg()
: m_reg()
{
m_imm = 0;
}
@ -760,10 +869,18 @@ template< typename T > void xWrite( T val );
typedef xIndirectVoid _parent;
public:
explicit xIndirect( s32 disp ) : _parent( disp ) {}
explicit xIndirect( const xAddressInfo<OperandType>& src ) : _parent( src ) {}
explicit xIndirect(s32 disp)
: _parent(disp)
{
}
explicit xIndirect(const xAddressInfo<OperandType> &src)
: _parent(src)
{
}
xIndirect(xAddressReg base, xAddressReg index, int scale = 0, s32 displacement = 0)
: _parent( base, index, scale, displacement ) {}
: _parent(base, index, scale, displacement)
{
}
virtual uint GetOperandSize() const { return sizeof(OperandType); }
@ -778,8 +895,7 @@ template< typename T > void xWrite( T val );
bool operator==(const xIndirect<OperandType> &src) const
{
return
( Base == src.Base ) && ( Index == src.Index ) &&
return (Base == src.Base) && (Index == src.Index) &&
(Scale == src.Scale) && (Displacement == src.Displacement);
}
@ -809,19 +925,40 @@ template< typename T > void xWrite( T val );
uint m_OpSize;
public:
xIndirect64orLess( const xIndirect8& src ) : _parent( src ) { m_OpSize = src.GetOperandSize(); }
xIndirect64orLess( const xIndirect16& src ) : _parent( src ) { m_OpSize = src.GetOperandSize(); }
xIndirect64orLess( const xIndirect32& src ) : _parent( src ) { m_OpSize = src.GetOperandSize(); }
xIndirect64orLess( const xIndirect64& src ) : _parent( src ) { m_OpSize = src.GetOperandSize(); }
xIndirect64orLess(const xIndirect8 &src)
: _parent(src)
{
m_OpSize = src.GetOperandSize();
}
xIndirect64orLess(const xIndirect16 &src)
: _parent(src)
{
m_OpSize = src.GetOperandSize();
}
xIndirect64orLess(const xIndirect32 &src)
: _parent(src)
{
m_OpSize = src.GetOperandSize();
}
xIndirect64orLess(const xIndirect64 &src)
: _parent(src)
{
m_OpSize = src.GetOperandSize();
}
uint GetOperandSize() const { return m_OpSize; }
protected:
//xIndirect64orLess( const xAddressVoid& src ) : _parent( src ) {}
explicit xIndirect64orLess( s32 disp ) : _parent( disp ) {}
xIndirect64orLess( xAddressReg base, xAddressReg index, int scale=0, s32 displacement=0 ) :
_parent( base, index, scale, displacement ) {}
explicit xIndirect64orLess(s32 disp)
: _parent(disp)
{
}
xIndirect64orLess(xAddressReg base, xAddressReg index, int scale = 0, s32 displacement = 0)
: _parent(base, index, scale, displacement)
{
}
};
// --------------------------------------------------------------------------------------
@ -1008,7 +1145,10 @@ template< typename T > void xWrite( T val );
// The jump instruction is emitted at the point of object construction. The conditional
// type must be valid (Jcc_Unknown generates an assertion).
xForwardJump( JccComparisonType cctype = Jcc_Unconditional ) : xForwardJumpBase( OperandSize, cctype ) { }
xForwardJump(JccComparisonType cctype = Jcc_Unconditional)
: xForwardJumpBase(OperandSize, cctype)
{
}
// Sets the jump target by writing back the current x86Ptr to the jump instruction.
// This method can be called multiple times, re-writing the jump instruction's target

View File

@ -43,8 +43,7 @@ void CheckedStaticBox::SetValue( bool val )
{
wxWindowList &list = GetChildren();
for( wxWindowList::iterator iter = list.begin(); iter != list.end(); ++iter)
{
for (wxWindowList::iterator iter = list.begin(); iter != list.end(); ++iter) {
wxWindow *current = *iter;
if (current != &ThisToggle)
current->Enable(val);
@ -61,13 +60,13 @@ bool CheckedStaticBox::GetValue() const
// the enable request are true. If not, disable them!
bool CheckedStaticBox::Enable(bool enable)
{
if (!_parent::Enable(enable)) return false;
if (!_parent::Enable(enable))
return false;
bool val = enable && ThisToggle.GetValue();
wxWindowList &list = GetChildren();
for( wxWindowList::iterator iter = list.begin(); iter != list.end(); ++iter)
{
for (wxWindowList::iterator iter = list.begin(); iter != list.end(); ++iter) {
wxWindow *current = *iter;
if (current != &ThisToggle)
current->Enable(val);

View File

@ -50,8 +50,7 @@ void Console_SetActiveHandler( const IConsoleWriter& writer, FILE* flushfp )
(writer.WriteRaw != NULL) && (writer.DoWriteLn != NULL) &&
(writer.Newline != NULL) && (writer.SetTitle != NULL) &&
(writer.DoSetColor != NULL),
"Invalid IConsoleWriter object! All function pointer interfaces must be implemented."
);
"Invalid IConsoleWriter object! All function pointer interfaces must be implemented.");
Console = writer;
DevConWriter = writer;
@ -67,7 +66,8 @@ void MSW_OutputDebugString( const wxString& text )
{
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
static bool hasDebugger = wxIsDebuggerRunning();
if( hasDebugger ) OutputDebugString( text );
if (hasDebugger)
OutputDebugString(text);
#else
fputs(text.utf8_str(), stdout_fp);
fflush(stdout_fp);
@ -105,41 +105,56 @@ const IConsoleWriter ConsoleWriter_Null =
#if defined(__unix__)
static __fi const char *GetLinuxConsoleColor(ConsoleColors color)
{
switch(color)
{
switch (color) {
case Color_Black:
case Color_StrongBlack: return "\033[30m\033[1m";
case Color_StrongBlack:
return "\033[30m\033[1m";
case Color_Red: return "\033[31m";
case Color_StrongRed: return "\033[31m\033[1m";
case Color_Red:
return "\033[31m";
case Color_StrongRed:
return "\033[31m\033[1m";
case Color_Green: return "\033[32m";
case Color_StrongGreen: return "\033[32m\033[1m";
case Color_Green:
return "\033[32m";
case Color_StrongGreen:
return "\033[32m\033[1m";
case Color_Yellow: return "\033[33m";
case Color_StrongYellow: return "\033[33m\033[1m";
case Color_Yellow:
return "\033[33m";
case Color_StrongYellow:
return "\033[33m\033[1m";
case Color_Blue: return "\033[34m";
case Color_StrongBlue: return "\033[34m\033[1m";
case Color_Blue:
return "\033[34m";
case Color_StrongBlue:
return "\033[34m\033[1m";
// No orange, so use magenta.
case Color_Orange:
case Color_Magenta: return "\033[35m";
case Color_Magenta:
return "\033[35m";
case Color_StrongOrange:
case Color_StrongMagenta: return "\033[35m\033[1m";
case Color_StrongMagenta:
return "\033[35m\033[1m";
case Color_Cyan: return "\033[36m";
case Color_StrongCyan: return "\033[36m\033[1m";
case Color_Cyan:
return "\033[36m";
case Color_StrongCyan:
return "\033[36m\033[1m";
// Use 'white' instead of grey.
case Color_Gray:
case Color_White: return "\033[37m";
case Color_White:
return "\033[37m";
case Color_StrongGray:
case Color_StrongWhite: return "\033[37m\033[1m";
case Color_StrongWhite:
return "\033[37m\033[1m";
// On some other value being passed, clear any formatting.
case Color_Default:
default: return "\033[0m";
default:
return "\033[0m";
}
}
#endif
@ -230,7 +245,8 @@ const IConsoleWriter ConsoleWriter_Assert =
wxString IConsoleWriter::_addIndentation(const wxString &src, int glob_indent = 0) const
{
const int indent = glob_indent + _imm_indentation;
if( indent == 0 ) return src;
if (indent == 0)
return src;
wxString result(src);
const wxString indentStr(L'\t', indent);
@ -261,7 +277,8 @@ IConsoleWriter IConsoleWriter::Indent( int tabcount ) const
const IConsoleWriter &IConsoleWriter::SetColor(ConsoleColors color) const
{
// Ignore current color requests since, well, the current color is already set. ;)
if( color == Color_Current ) return *this;
if (color == Color_Current)
return *this;
pxAssertMsg((color > Color_Current) && (color < ConsoleColors_Count), "Invalid ConsoleColor specified.");
@ -456,8 +473,7 @@ ConsoleColorScope::~ConsoleColorScope() throw()
void ConsoleColorScope::EnterScope()
{
if (!m_IsScoped)
{
if (!m_IsScoped) {
m_old_color = Console.GetColor();
Console.SetColor(m_newcolor);
m_IsScoped = true;

View File

@ -157,12 +157,10 @@ void Threading::Semaphore::Wait()
#if wxUSE_GUI
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
WaitWithoutYield();
}
else if(_WaitGui_RecursionGuard( L"Semaphore::Wait" )) {
} else if (_WaitGui_RecursionGuard(L"Semaphore::Wait")) {
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
WaitWithoutYield();
}
else {
} else {
while (!WaitWithoutYield(def_yieldgui_interval)) {
YieldToMain();
}
@ -186,17 +184,16 @@ bool Threading::Semaphore::Wait(const wxTimeSpan& timeout)
#if wxUSE_GUI
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
return WaitWithoutYield(timeout);
}
else if (_WaitGui_RecursionGuard( L"Semaphore::TimedWait")) {
} else if (_WaitGui_RecursionGuard(L"Semaphore::TimedWait")) {
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
return WaitWithoutYield(timeout);
}
else {
} else {
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
wxTimeSpan countdown((timeout));
do {
if (WaitWithoutYield(def_yieldgui_interval)) break;
if (WaitWithoutYield(def_yieldgui_interval))
break;
YieldToMain();
countdown -= def_yieldgui_interval;
} while (countdown.GetMilliseconds() > 0);

View File

@ -66,7 +66,8 @@ u64 Threading::GetThreadTicksPerSecond()
// gets the CPU time used by the current thread (both system and user), in
// microseconds, returns 0 on failure
static u64 getthreadtime(thread_port_t thread) {
static u64 getthreadtime(thread_port_t thread)
{
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
thread_basic_info_data_t info;

View File

@ -113,7 +113,9 @@ DEVASSERT_INLINE void pxOnAssert( const DiagnosticOrigin& origin, const wxChar*
// we get meaningless assertions while unwinding stack traces after exceptions have occurred.
RecursionGuard guard(s_assert_guard);
if (guard.Counter > 2) { return pxTrap(); }
if (guard.Counter > 2) {
return pxTrap();
}
// wxWidgets doesn't come with debug builds on some Linux distros, and other distros make
// it difficult to use the debug build (compilation failures). To handle these I've had to
@ -122,17 +124,16 @@ DEVASSERT_INLINE void pxOnAssert( const DiagnosticOrigin& origin, const wxChar*
bool trapit;
if( pxDoAssert == NULL )
{
if (pxDoAssert == NULL) {
// Note: Format uses MSVC's syntax for output window hotlinking.
trapit = pxAssertImpl_LogIt(origin, msg);
}
else
{
} else {
trapit = pxDoAssert(origin, msg);
}
if( trapit ) { pxTrap(); }
if (trapit) {
pxTrap();
}
}
__fi void pxOnAssert(const DiagnosticOrigin &origin, const char *msg)
@ -193,8 +194,7 @@ Exception::RuntimeError::RuntimeError( const std::runtime_error& ex, const wxStr
SetDiagMsg(pxsFmt(L"STL Runtime Error%s: %s",
(prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()),
WX_STR(fromUTF8( ex.what() ))
) );
WX_STR(fromUTF8(ex.what()))));
}
Exception::RuntimeError::RuntimeError(const std::exception &ex, const wxString &prefix)
@ -203,8 +203,7 @@ Exception::RuntimeError::RuntimeError( const std::exception& ex, const wxString&
SetDiagMsg(pxsFmt(L"STL Exception%s: %s",
(prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()),
WX_STR(fromUTF8( ex.what() ))
) );
WX_STR(fromUTF8(ex.what()))));
}
// --------------------------------------------------------------------------------------
@ -266,9 +265,7 @@ wxString Exception::VirtualMemoryMapConflict::FormatDisplayMessage() const
{
FastFormatUnicode retmsg;
retmsg.Write(L"%s",
pxE( L"There is not enough virtual memory available, or necessary virtual memory mappings have already been reserved by other processes, services, or DLLs."
)
);
pxE(L"There is not enough virtual memory available, or necessary virtual memory mappings have already been reserved by other processes, services, or DLLs."));
if (!m_message_diag.IsEmpty())
retmsg.Write(L"\n\n%s", WX_STR(m_message_diag));
@ -419,8 +416,7 @@ BaseException* Exception::FromErrno( const wxString& streamname, int errcode )
{
pxAssumeDev(errcode != 0, "Invalid NULL error code? (errno)");
switch( errcode )
{
switch (errcode) {
case EINVAL:
pxFailDev(L"Invalid argument");
return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Invalid argument? (likely caused by an unforgivable programmer error!)");

View File

@ -37,11 +37,11 @@ static
#ifndef __linux__
__ri
#endif
void format_that_ascii_mess( CharBufferType& buffer, uint writepos, const char* fmt, va_list argptr )
void
format_that_ascii_mess(CharBufferType &buffer, uint writepos, const char *fmt, va_list argptr)
{
va_list args;
while( true )
{
while (true) {
int size = buffer.GetLength();
va_copy(args, argptr);
@ -53,7 +53,8 @@ void format_that_ascii_mess( CharBufferType& buffer, uint writepos, const char*
// always do it manually
buffer[size - 1] = '\0';
if (size >= MaxFormattedStringLength) break;
if (size >= MaxFormattedStringLength)
break;
// vsnprintf() may return either -1 (traditional Unix behavior) or the
// total number of characters which would have been written if the
@ -63,7 +64,8 @@ void format_that_ascii_mess( CharBufferType& buffer, uint writepos, const char*
len = size + (size / 4);
len += writepos;
if (len < size) break;
if (len < size)
break;
buffer.Resize(len + 128);
};
@ -76,11 +78,11 @@ static
#ifndef __linux__
__ri
#endif
uint format_that_unicode_mess( CharBufferType& buffer, uint writepos, const wxChar* fmt, va_list argptr)
uint
format_that_unicode_mess(CharBufferType &buffer, uint writepos, const wxChar *fmt, va_list argptr)
{
va_list args;
while( true )
{
while (true) {
int size = buffer.GetLength() / sizeof(wxChar);
va_copy(args, argptr);
@ -92,7 +94,8 @@ uint format_that_unicode_mess( CharBufferType& buffer, uint writepos, const wxCh
// always do it manually
((wxChar *)buffer.GetPtr())[size - 1] = L'\0';
if( size >= MaxFormattedStringLength ) return size-1;
if (size >= MaxFormattedStringLength)
return size - 1;
// vsnprintf() may return either -1 (traditional Unix behavior) or the
// total number of characters which would have been written if the
@ -102,7 +105,8 @@ uint format_that_unicode_mess( CharBufferType& buffer, uint writepos, const wxCh
len = size + (size / 4);
len += writepos;
if (len < size) return len;
if (len < size)
return len;
buffer.Resize((len + 128) * sizeof(wxChar));
};

View File

@ -16,7 +16,8 @@
#include "PrecompiledHeader.h"
#include "HashMap.h"
namespace HashTools {
namespace HashTools
{
#define get16bits(d) (*((const u16 *)(d)))
@ -57,14 +58,14 @@ u32 Hash(const s8 * data, int len)
u32 hash = len;
int rem;
if (len <= 0 || data == NULL) return 0;
if (len <= 0 || data == NULL)
return 0;
rem = len & 3;
len >>= 2;
/* Main loop */
for (;len > 0; --len)
{
for (; len > 0; --len) {
hash += get16bits(data);
u32 tmp = (get16bits(data + 2) << 11) ^ hash;
hash = (hash << 16) ^ tmp;
@ -73,18 +74,20 @@ u32 Hash(const s8 * data, int len)
}
/* Handle end cases */
switch (rem)
{
case 3: hash += get16bits (data);
switch (rem) {
case 3:
hash += get16bits(data);
hash ^= hash << 16;
hash ^= data[sizeof(u16)] << 18;
hash += hash >> 11;
break;
case 2: hash += get16bits (data);
case 2:
hash += get16bits(data);
hash ^= hash << 11;
hash += hash >> 17;
break;
case 1: hash += *data;
case 1:
hash += *data;
hash ^= hash << 10;
hash += hash >> 1;
}

View File

@ -35,8 +35,7 @@ void SetFullBaseDir( wxDirName appRoot )
static int _calcEnumLength(const wxChar *const *enumArray)
{
int cnt = 0;
while( *enumArray != NULL )
{
while (*enumArray != NULL) {
enumArray++;
cnt++;
}
@ -81,22 +80,33 @@ IniInterface::~IniInterface()
void IniInterface::SetPath(const wxString &path)
{
if( m_Config ) m_Config->SetPath( path );
if (m_Config)
m_Config->SetPath(path);
}
void IniInterface::Flush()
{
if( m_Config ) m_Config->Flush();
if (m_Config)
m_Config->Flush();
}
// --------------------------------------------------------------------------------------
// IniLoader (implementations)
// --------------------------------------------------------------------------------------
IniLoader::IniLoader( wxConfigBase& config ) : IniInterface( config ) { }
IniLoader::IniLoader( wxConfigBase* config ) : IniInterface( config ) { }
IniLoader::IniLoader(wxConfigBase &config)
: IniInterface(config)
{
}
IniLoader::IniLoader(wxConfigBase *config)
: IniInterface(config)
{
}
IniLoader::IniLoader() : IniInterface() {}
IniLoader::IniLoader()
: IniInterface()
{
}
IniLoader::~IniLoader() throw() {}
@ -112,12 +122,12 @@ void IniLoader::Entry( const wxString& var, wxString& value, const wxString defv
void IniLoader::Entry(const wxString &var, wxDirName &value, const wxDirName defvalue, bool isAllowRelative)
{
wxString dest;
if( m_Config ) m_Config->Read( var, &dest, wxEmptyString );
if (m_Config)
m_Config->Read(var, &dest, wxEmptyString);
if (dest.IsEmpty())
value = defvalue;
else
{
else {
value = dest;
if (isAllowRelative)
value = g_fullBaseDirName + value;
@ -130,7 +140,8 @@ void IniLoader::Entry( const wxString& var, wxDirName& value, const wxDirName de
void IniLoader::Entry(const wxString &var, wxFileName &value, const wxFileName defvalue, bool isAllowRelative)
{
wxString dest(defvalue.GetFullPath());
if( m_Config ) m_Config->Read( var, &dest, defvalue.GetFullPath() );
if (m_Config)
m_Config->Read(var, &dest, defvalue.GetFullPath());
value = dest;
if (isAllowRelative)
value = g_fullBaseDirName + value;
@ -162,7 +173,8 @@ void IniLoader::Entry( const wxString& var, bool& value, const bool defvalue )
{
// TODO : Stricter value checking on enabled/disabled?
wxString dest(defvalue ? L"enabled" : L"disabled");
if( m_Config ) m_Config->Read( var, &dest, dest );
if (m_Config)
m_Config->Read(var, &dest, dest);
value = (dest == L"enabled") || (dest == L"1");
}
@ -187,33 +199,34 @@ void IniLoader::Entry( const wxString& var, Fixed100& value, const Fixed100 defv
// has way too much rounding error so we really need to do things out manually.. >_<
wxString readval(value.ToString());
if( m_Config ) m_Config->Read( var, &readval );
if (m_Config)
m_Config->Read(var, &readval);
value = Fixed100::FromString(readval, value);
}
void IniLoader::Entry(const wxString &var, wxPoint &value, const wxPoint defvalue)
{
if( !m_Config )
{
value = defvalue; return;
if (!m_Config) {
value = defvalue;
return;
}
TryParse(value, m_Config->Read(var, ToString(defvalue)), defvalue);
}
void IniLoader::Entry(const wxString &var, wxSize &value, const wxSize defvalue)
{
if( !m_Config )
{
value = defvalue; return;
if (!m_Config) {
value = defvalue;
return;
}
TryParse(value, m_Config->Read(var, ToString(defvalue)), defvalue);
}
void IniLoader::Entry(const wxString &var, wxRect &value, const wxRect defvalue)
{
if( !m_Config )
{
value = defvalue; return;
if (!m_Config) {
value = defvalue;
return;
}
TryParse(value, m_Config->Read(var, ToString(defvalue)), defvalue);
}
@ -223,16 +236,14 @@ void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const
// Confirm default value sanity...
const int cnt = _calcEnumLength(enumArray);
if( !IndexBoundsCheck( L"IniLoader EnumDefaultValue", defvalue, cnt ) )
{
if (!IndexBoundsCheck(L"IniLoader EnumDefaultValue", defvalue, cnt)) {
Console.Error("(LoadSettings) Default enumeration index is out of bounds. Truncating.");
defvalue = cnt - 1;
}
// Sanity confirmed, proceed with craziness!
if( !m_Config )
{
if (!m_Config) {
value = defvalue;
return;
}
@ -241,16 +252,14 @@ void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const
m_Config->Read(var, &retval, enumArray[defvalue]);
int i = 0;
while( enumArray[i] != NULL && ( retval != enumArray[i] ) ) i++;
while (enumArray[i] != NULL && (retval != enumArray[i]))
i++;
if( enumArray[i] == NULL )
{
if (enumArray[i] == NULL) {
Console.Warning(L"(LoadSettings) Warning: Unrecognized value '%s' on key '%s'\n\tUsing the default setting of '%s'.",
WX_STR(retval), WX_STR(var), enumArray[defvalue]
);
WX_STR(retval), WX_STR(var), enumArray[defvalue]);
value = defvalue;
}
else
} else
value = i;
}
@ -258,22 +267,33 @@ void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const
// IniSaver (implementations)
// --------------------------------------------------------------------------------------
IniSaver::IniSaver( wxConfigBase& config ) : IniInterface( config ) { }
IniSaver::IniSaver( wxConfigBase* config ) : IniInterface( config ) { }
IniSaver::IniSaver(wxConfigBase &config)
: IniInterface(config)
{
}
IniSaver::IniSaver(wxConfigBase *config)
: IniInterface(config)
{
}
IniSaver::IniSaver() : IniInterface() {}
IniSaver::IniSaver()
: IniInterface()
{
}
IniSaver::~IniSaver() {}
void IniSaver::Entry(const wxString &var, wxString &value, const wxString defvalue)
{
if( !m_Config ) return;
if (!m_Config)
return;
m_Config->Write(var, value);
}
void IniSaver::Entry(const wxString &var, wxDirName &value, const wxDirName defvalue, bool isAllowRelative)
{
if( !m_Config ) return;
if (!m_Config)
return;
wxDirName res(value);
if (res.IsAbsolute())
@ -291,7 +311,8 @@ void IniSaver::Entry( const wxString& var, wxDirName& value, const wxDirName def
void IniSaver::Entry(const wxString &var, wxFileName &value, const wxFileName defvalue, bool isAllowRelative)
{
if( !m_Config ) return;
if (!m_Config)
return;
wxFileName res(value);
if (res.IsAbsolute())
@ -305,37 +326,43 @@ void IniSaver::Entry( const wxString& var, wxFileName& value, const wxFileName d
void IniSaver::Entry(const wxString &var, int &value, const int defvalue)
{
if( !m_Config ) return;
if (!m_Config)
return;
m_Config->Write(var, value);
}
void IniSaver::Entry(const wxString &var, uint &value, const uint defvalue)
{
if( !m_Config ) return;
if (!m_Config)
return;
m_Config->Write(var, (int)value);
}
void IniSaver::Entry(const wxString &var, bool &value, const bool defvalue)
{
if( !m_Config ) return;
if (!m_Config)
return;
m_Config->Write(var, value ? L"enabled" : L"disabled");
}
bool IniSaver::EntryBitBool(const wxString &var, bool value, const bool defvalue)
{
if( m_Config ) m_Config->Write( var, value ? L"enabled" : L"disabled" );
if (m_Config)
m_Config->Write(var, value ? L"enabled" : L"disabled");
return value;
}
int IniSaver::EntryBitfield(const wxString &var, int value, const int defvalue)
{
if( m_Config ) m_Config->Write( var, value );
if (m_Config)
m_Config->Write(var, value);
return value;
}
void IniSaver::Entry(const wxString &var, Fixed100 &value, const Fixed100 defvalue)
{
if( !m_Config ) return;
if (!m_Config)
return;
// Note: the "easy" way would be to convert to double and load/save that, but floating point
// has way too much rounding error so we really need to do things out manually, using strings.
@ -345,19 +372,22 @@ void IniSaver::Entry( const wxString& var, Fixed100& value, const Fixed100 defva
void IniSaver::Entry(const wxString &var, wxPoint &value, const wxPoint defvalue)
{
if( !m_Config ) return;
if (!m_Config)
return;
m_Config->Write(var, ToString(value));
}
void IniSaver::Entry(const wxString &var, wxSize &value, const wxSize defvalue)
{
if( !m_Config ) return;
if (!m_Config)
return;
m_Config->Write(var, ToString(value));
}
void IniSaver::Entry(const wxString &var, wxRect &value, const wxRect defvalue)
{
if( !m_Config ) return;
if (!m_Config)
return;
m_Config->Write(var, ToString(value));
}
@ -367,22 +397,20 @@ void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const*
// Confirm default value sanity...
if( !IndexBoundsCheck( L"IniSaver EnumDefaultValue", defvalue, cnt ) )
{
if (!IndexBoundsCheck(L"IniSaver EnumDefaultValue", defvalue, cnt)) {
Console.Error("(SaveSettings) Default enumeration index is out of bounds. Truncating.");
defvalue = cnt - 1;
}
if( !m_Config ) return;
if (!m_Config)
return;
if( value >= cnt )
{
if (value >= cnt) {
Console.Warning(L"(SaveSettings) An illegal enumerated index was detected when saving '%s'", WX_STR(var));
Console.Indent().Warning(
L"Illegal Value: %d\n"
L"Using Default: %d (%s)\n",
value, defvalue, enumArray[defvalue]
);
value, defvalue, enumArray[defvalue]);
// Cause a debug assertion, since this is a fully recoverable error.
pxAssert(value < cnt);
@ -392,4 +420,3 @@ void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const*
m_Config->Write(var, enumArray[value]);
}

View File

@ -63,10 +63,10 @@ static void SysPageFaultSignalFilter( int signal, siginfo_t *siginfo, void * )
// resumes execution right where we left off (re-executes instruction that
// caused the SIGSEGV).
if (Source_PageFault->WasHandled()) return;
if (Source_PageFault->WasHandled())
return;
if (!wxThread::IsMain())
{
if (!wxThread::IsMain()) {
pxFailRel(pxsFmt("Unhandled page fault @ 0x%08x", siginfo->si_addr));
}
@ -74,7 +74,8 @@ static void SysPageFaultSignalFilter( int signal, siginfo_t *siginfo, void * )
// Instigate a trap if we're in a debugger, and if not then do a SIGKILL.
pxTrap();
if (!IsDebugBuild) raise( SIGKILL );
if (!IsDebugBuild)
raise(SIGKILL);
}
void _platform_InstallSignalHandler()
@ -93,14 +94,12 @@ static __ri void PageSizeAssertionTest( size_t size )
pxAssertMsg((__pagesize == getpagesize()), pxsFmt(
"Internal system error: Operating system pagesize does not match compiled pagesize.\n\t"
L"\tOS Page Size: 0x%x (%d), Compiled Page Size: 0x%x (%u)",
getpagesize(), getpagesize(), __pagesize, __pagesize )
);
getpagesize(), getpagesize(), __pagesize, __pagesize));
pxAssertDev((size & (__pagesize - 1)) == 0, pxsFmt(
L"Memory block size must be a multiple of the target platform's page size.\n"
L"\tPage Size: 0x%x (%u), Block Size: 0x%x (%u)",
__pagesize, __pagesize, size, size )
);
__pagesize, __pagesize, size, size));
}
// returns FALSE if the mprotect call fails with an ENOMEM.
@ -112,26 +111,27 @@ static bool _memprotect( void* baseaddr, size_t size, const PageProtectionMode&
uint lnxmode = 0;
if (mode.CanWrite()) lnxmode |= PROT_WRITE;
if (mode.CanRead()) lnxmode |= PROT_READ;
if (mode.CanExecute()) lnxmode |= PROT_EXEC | PROT_READ;
if (mode.CanWrite())
lnxmode |= PROT_WRITE;
if (mode.CanRead())
lnxmode |= PROT_READ;
if (mode.CanExecute())
lnxmode |= PROT_EXEC | PROT_READ;
const int result = mprotect(baseaddr, size, lnxmode);
if (result == 0) return true;
if (result == 0)
return true;
switch(errno)
{
switch (errno) {
case EINVAL:
pxFailDev(pxsFmt(L"mprotect returned EINVAL @ 0x%08X -> 0x%08X (mode=%s)",
baseaddr, (uptr)baseaddr+size, WX_STR(mode.ToString()))
);
baseaddr, (uptr)baseaddr + size, WX_STR(mode.ToString())));
break;
case EACCES:
pxFailDev(pxsFmt(L"mprotect returned EACCES @ 0x%08X -> 0x%08X (mode=%s)",
baseaddr, (uptr)baseaddr+size, WX_STR(mode.ToString()))
);
baseaddr, (uptr)baseaddr + size, WX_STR(mode.ToString())));
break;
case ENOMEM:
@ -159,11 +159,14 @@ bool HostSys::MmapCommitPtr(void* base, size_t size, const PageProtectionMode& m
// as PROT_NONE, then just ignore this call (memory will be committed automatically
// later when the user changes permissions to something useful via calls to MemProtect).
if (mode.IsNone()) return false;
if (mode.IsNone())
return false;
if (_memprotect( base, size, mode )) return true;
if (_memprotect(base, size, mode))
return true;
if (!pxDoOutOfMemory) return false;
if (!pxDoOutOfMemory)
return false;
pxDoOutOfMemory(size);
return _memprotect(base, size, mode);
}
@ -184,8 +187,8 @@ void HostSys::MmapResetPtr(void* base, size_t size)
pxAssertRel((uptr)result == (uptr)base, pxsFmt(
"Virtual memory decommit failed: memory at 0x%08X -> 0x%08X could not be remapped. "
"This is likely caused by multi-thread memory contention.", base, (uptr)base+size
));
"This is likely caused by multi-thread memory contention.",
base, (uptr)base + size));
}
void *HostSys::MmapReserve(uptr base, size_t size)
@ -214,18 +217,16 @@ void* HostSys::Mmap(uptr base, size_t size)
void HostSys::Munmap(uptr base, size_t size)
{
if (!base) return;
if (!base)
return;
munmap((void *)base, size);
}
void HostSys::MemProtect(void *baseaddr, size_t size, const PageProtectionMode &mode)
{
if (!_memprotect(baseaddr, size, mode))
{
if (!_memprotect(baseaddr, size, mode)) {
throw Exception::OutOfMemory(L"MemProtect")
.SetDiagMsg(pxsFmt(L"mprotect failed @ 0x%08X -> 0x%08X (mode=%s)",
baseaddr, (uptr)baseaddr+size, WX_STR(mode.ToString())
)
);
baseaddr, (uptr)baseaddr + size, WX_STR(mode.ToString())));
}
}

View File

@ -73,14 +73,16 @@ static u64 get_thread_time(uptr id = 0)
clockid_t cid;
if (id) {
int err = pthread_getcpuclockid((pthread_t)id, &cid);
if (err) return 0;
if (err)
return 0;
} else {
cid = CLOCK_THREAD_CPUTIME_ID;
}
struct timespec ts;
int err = clock_gettime(cid, &ts);
if (err) return 0;
if (err)
return 0;
return (u64)ts.tv_sec * (u64)1e6 + (u64)ts.tv_nsec / (u64)1e3;
}
@ -98,7 +100,8 @@ u64 Threading::pxThread::GetCpuTime() const
// thread has used on the CPU (scaled by the value returned by GetThreadTicksPerSecond(),
// which typically would be an OS-provided scalar or some sort).
if (!m_native_id) return 0;
if (!m_native_id)
return 0;
return get_thread_time(m_native_id);
}

View File

@ -66,7 +66,8 @@ static int xpthread_mutex_timedlock(
ts.tv_sec = 0;
ts.tv_nsec = TIMEDLOCK_EMU_SLEEP_NS;
int status;
while ((status = nanosleep(&ts, &ts)) == -1);
while ((status = nanosleep(&ts, &ts)) == -1)
;
// check if the timeout has expired, gettimeofday() is implemented
// efficiently (in userspace) on OSX
@ -91,18 +92,20 @@ static wxTimeSpan def_detach_timeout( 0, 0, 6, 0 );
void Threading::Mutex::Detach()
{
if( EBUSY != pthread_mutex_destroy(&m_mutex) ) return;
if (EBUSY != pthread_mutex_destroy(&m_mutex))
return;
if( IsRecursive() )
{
if (IsRecursive()) {
// Sanity check: Recursive locks could be held by our own thread, which would
// be considered an assertion failure, but can also be handled gracefully.
// (note: if the mutex is locked recursively more than twice then this assert won't
// detect it)
Release(); Release(); // in case of double recursion.
Release();
Release(); // in case of double recursion.
int result = pthread_mutex_destroy(&m_mutex);
if( pxAssertDev( result != EBUSY, "Detachment of a recursively-locked mutex (self-locked!)." ) ) return;
if (pxAssertDev(result != EBUSY, "Detachment of a recursively-locked mutex (self-locked!)."))
return;
}
if (Wait(def_detach_timeout))
@ -115,13 +118,14 @@ Threading::Mutex::~Mutex() throw()
{
try {
Mutex::Detach();
} DESTRUCTOR_CATCHALL;
}
DESTRUCTOR_CATCHALL;
}
Threading::MutexRecursive::MutexRecursive() : Mutex( false )
{
if( ++_attr_refcount == 1 )
Threading::MutexRecursive::MutexRecursive()
: Mutex(false)
{
if (++_attr_refcount == 1) {
if (0 != pthread_mutexattr_init(&_attr_recursive))
throw Exception::OutOfMemory(L"Recursive mutexing attributes");
@ -153,8 +157,7 @@ void Threading::Mutex::Recreate()
// unlocked.
bool Threading::Mutex::RecreateIfLocked()
{
if( !Wait(def_detach_timeout) )
{
if (!Wait(def_detach_timeout)) {
Recreate();
return true;
}
@ -195,17 +198,12 @@ bool Threading::Mutex::TryAcquire()
void Threading::Mutex::Acquire()
{
#if wxUSE_GUI
if( !wxThread::IsMain() || (wxTheApp == NULL) )
{
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
pthread_mutex_lock(&m_mutex);
}
else if( _WaitGui_RecursionGuard( L"Mutex::Acquire" ) )
{
} else if (_WaitGui_RecursionGuard(L"Mutex::Acquire")) {
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
pthread_mutex_lock(&m_mutex);
}
else
{
} else {
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
while (!AcquireWithoutYield(def_yieldgui_interval))
YieldToMain();
@ -218,22 +216,18 @@ void Threading::Mutex::Acquire()
bool Threading::Mutex::Acquire(const wxTimeSpan &timeout)
{
#if wxUSE_GUI
if( !wxThread::IsMain() || (wxTheApp == NULL) )
{
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
return AcquireWithoutYield(timeout);
}
else if( _WaitGui_RecursionGuard( L"Mutex::TimedAcquire" ) )
{
} else if (_WaitGui_RecursionGuard(L"Mutex::TimedAcquire")) {
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
return AcquireWithoutYield(timeout);
}
else
{
} else {
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
wxTimeSpan countdown((timeout));
do {
if( AcquireWithoutYield( def_yieldgui_interval ) ) break;
if (AcquireWithoutYield(def_yieldgui_interval))
break;
YieldToMain();
countdown -= def_yieldgui_interval;
} while (countdown.GetMilliseconds() > 0);
@ -274,8 +268,7 @@ void Threading::Mutex::WaitWithoutYield()
//
bool Threading::Mutex::Wait(const wxTimeSpan &timeout)
{
if( Acquire(timeout) )
{
if (Acquire(timeout)) {
Release();
return true;
}
@ -284,8 +277,7 @@ bool Threading::Mutex::Wait( const wxTimeSpan& timeout )
bool Threading::Mutex::WaitWithoutYield(const wxTimeSpan &timeout)
{
if( AcquireWithoutYield(timeout) )
{
if (AcquireWithoutYield(timeout)) {
Release();
return true;
}
@ -324,7 +316,8 @@ void Threading::ScopedLock::AssignAndLock( const Mutex* locker )
pxAssert(!m_IsLocked); // if we're already locked, changing the lock is bad mojo.
m_lock = const_cast<Mutex *>(locker);
if( !m_lock ) return;
if (!m_lock)
return;
m_IsLocked = true;
m_lock->Acquire();
@ -343,15 +336,18 @@ void Threading::ScopedLock::Assign( const Mutex* locker )
// Provides manual unlocking of a scoped lock prior to object destruction.
void Threading::ScopedLock::Release()
{
if( !m_IsLocked ) return;
if (!m_IsLocked)
return;
m_IsLocked = false;
if( m_lock ) m_lock->Release();
if (m_lock)
m_lock->Release();
}
// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
void Threading::ScopedLock::Acquire()
{
if( m_IsLocked || !m_lock ) return;
if (m_IsLocked || !m_lock)
return;
m_lock->Acquire();
m_IsLocked = true;
}
@ -359,6 +355,7 @@ void Threading::ScopedLock::Acquire()
Threading::ScopedLock::ScopedLock(const Mutex &locker, bool isTryLock)
{
m_lock = const_cast<Mutex *>(&locker);
if( !m_lock ) return;
if (!m_lock)
return;
m_IsLocked = isTryLock ? m_lock->TryAcquire() : false;
}

View File

@ -73,7 +73,8 @@ wxDirName& wxDirName::MakeAbsolute( const wxString& cwd )
void wxDirName::Rmdir()
{
if( !Exists() ) return;
if (!Exists())
return;
wxFileName::Rmdir();
// TODO : Throw exception if operation failed? Do we care?
}
@ -87,7 +88,8 @@ bool wxDirName::Mkdir()
#define wxS_DIR_DEFAULT 0777
#endif
if( Exists() ) return true;
if (Exists())
return true;
return wxFileName::Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
}
@ -105,7 +107,8 @@ bool Path::IsRelative( const wxString& path )
// Returns -1 if the file does not exist.
s64 Path::GetFileSize(const wxString &path)
{
if( !wxFile::Exists( path.c_str() ) ) return -1;
if (!wxFile::Exists(path.c_str()))
return -1;
return (s64)wxFileName::GetSize(path).GetValue();
}

View File

@ -36,12 +36,18 @@ namespace Perf
// Implementation of the Info object
////////////////////////////////////////////////////////////////////////////////
Info::Info(uptr x86, u32 size, const char* symbol) : m_x86(x86), m_size(size), m_dynamic(false)
Info::Info(uptr x86, u32 size, const char *symbol)
: m_x86(x86)
, m_size(size)
, m_dynamic(false)
{
strncpy(m_symbol, symbol, sizeof(m_symbol));
}
Info::Info(uptr x86, u32 size, const char* symbol, u32 pc) : m_x86(x86), m_size(size), m_dynamic(true)
Info::Info(uptr x86, u32 size, const char *symbol, u32 pc)
: m_x86(x86)
, m_size(size)
, m_dynamic(true)
{
snprintf(m_symbol, sizeof(m_symbol), "%s_0x%08x", symbol, pc);
}
@ -62,7 +68,8 @@ namespace Perf
void InfoVector::print(FILE *fp)
{
for(auto&& it : m_v) it.Print(fp);
for (auto &&it : m_v)
it.Print(fp);
}
void InfoVector::map(uptr x86, u32 size, const char *symbol)
@ -75,7 +82,8 @@ namespace Perf
#ifdef MERGE_BLOCK_RESULT
m_v.emplace_back(x86, size, symbol);
#else
if (size < 8 * _1kb) m_v.emplace_back(x86, size, symbol);
if (size < 8 * _1kb)
m_v.emplace_back(x86, size, symbol);
#endif
}
@ -136,5 +144,4 @@ namespace Perf
void dump_and_reset() {}
#endif
}

View File

@ -28,4 +28,3 @@
#include "General.h"
#endif

View File

@ -66,7 +66,8 @@ Threading::BaseScopedReadWriteLock::~BaseScopedReadWriteLock() throw()
// Provides manual unlocking of a scoped lock prior to object destruction.
void Threading::BaseScopedReadWriteLock::Release()
{
if( !m_IsLocked ) return;
if (!m_IsLocked)
return;
m_IsLocked = false;
m_lock.Release();
}
@ -84,7 +85,8 @@ Threading::ScopedReadLock::ScopedReadLock( RwMutex& locker )
// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
void Threading::ScopedReadLock::Acquire()
{
if( m_IsLocked ) return;
if (m_IsLocked)
return;
m_lock.AcquireRead();
m_IsLocked = true;
}
@ -99,7 +101,8 @@ Threading::ScopedWriteLock::ScopedWriteLock( RwMutex& locker )
// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
void Threading::ScopedWriteLock::Acquire()
{
if( m_IsLocked ) return;
if (m_IsLocked)
return;
m_lock.AcquireWrite();
m_IsLocked = true;
}

View File

@ -52,8 +52,7 @@ void Threading::Semaphore::Post( int multiple )
sem_post_multiple(&m_sema, multiple);
#else
// Only w32pthreads has the post_multiple, but it's easy enough to fake:
while( multiple > 0 )
{
while (multiple > 0) {
multiple--;
sem_post(&m_sema);
}
@ -82,17 +81,12 @@ bool Threading::Semaphore::WaitWithoutYield( const wxTimeSpan& timeout )
void Threading::Semaphore::Wait()
{
#if wxUSE_GUI
if( !wxThread::IsMain() || (wxTheApp == NULL) )
{
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
sem_wait(&m_sema);
}
else if( _WaitGui_RecursionGuard( L"Semaphore::Wait" ) )
{
} else if (_WaitGui_RecursionGuard(L"Semaphore::Wait")) {
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
sem_wait(&m_sema);
}
else
{
} else {
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
while (!WaitWithoutYield(def_yieldgui_interval))
YieldToMain();
@ -114,22 +108,18 @@ void Threading::Semaphore::Wait()
bool Threading::Semaphore::Wait(const wxTimeSpan &timeout)
{
#if wxUSE_GUI
if( !wxThread::IsMain() || (wxTheApp == NULL) )
{
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
return WaitWithoutYield(timeout);
}
else if( _WaitGui_RecursionGuard( L"Semaphore::TimedWait" ) )
{
} else if (_WaitGui_RecursionGuard(L"Semaphore::TimedWait")) {
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
return WaitWithoutYield(timeout);
}
else
{
} else {
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
wxTimeSpan countdown((timeout));
do {
if( WaitWithoutYield( def_yieldgui_interval ) ) break;
if (WaitWithoutYield(def_yieldgui_interval))
break;
YieldToMain();
countdown -= def_yieldgui_interval;
} while (countdown.GetMilliseconds() > 0);

View File

@ -93,9 +93,9 @@ void SplitString( wxArrayString& dest, const wxString& src, const wxString& deli
wxString JoinString(const wxArrayString &src, const wxString &separator)
{
wxString dest;
for( int i=0, len=src.GetCount(); i<len; ++i )
{
if( src[i].IsEmpty() ) continue;
for (int i = 0, len = src.GetCount(); i < len; ++i) {
if (src[i].IsEmpty())
continue;
if (!dest.IsEmpty())
dest += separator;
dest += src[i];
@ -106,9 +106,9 @@ wxString JoinString( const wxArrayString& src, const wxString& separator )
wxString JoinString(const wxChar **src, const wxString &separator)
{
wxString dest;
while( *src != NULL )
{
if( *src[0] == 0 ) continue;
while (*src != NULL) {
if (*src[0] == 0)
continue;
if (!dest.IsEmpty())
dest += separator;
@ -165,8 +165,10 @@ bool TryParse( wxPoint& dest, wxStringTokenizer& parts )
{
long result[2];
if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[0] ) ) return false;
if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[1] ) ) return false;
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[0]))
return false;
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[1]))
return false;
dest.x = result[0];
dest.y = result[1];
@ -177,8 +179,10 @@ bool TryParse( wxSize& dest, wxStringTokenizer& parts )
{
long result[2];
if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[0] ) ) return false;
if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[1] ) ) return false;
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[0]))
return false;
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[1]))
return false;
dest.SetWidth(result[0]);
dest.SetHeight(result[1]);
@ -210,8 +214,10 @@ bool TryParse( wxRect& dest, const wxString& src, const wxRect& defval, const wx
wxPoint point;
wxSize size;
if( !TryParse( point, parts ) ) return false;
if( !TryParse( size, parts ) ) return false;
if (!TryParse(point, parts))
return false;
if (!TryParse(size, parts))
return false;
dest = wxRect(point, size);
return true;
@ -244,7 +250,8 @@ ParsedAssignmentString::ParsedAssignmentString( const wxString& src )
//
void px_fputs(FILE *fp, const char *src)
{
if( fp == NULL ) return;
if (fp == NULL)
return;
#ifdef _WIN32
// Windows needs CR's partnered with all newlines, or else notepad.exe can't view
@ -252,14 +259,10 @@ void px_fputs( FILE* fp, const char* src )
const char *curchar = src;
bool prevcr = false;
while( *curchar != 0 )
{
if( *curchar == '\r' )
{
while (*curchar != 0) {
if (*curchar == '\r') {
prevcr = true;
}
else
{
} else {
// Only write a CR/LF pair if the current LF is not prefixed nor
// post-fixed by a CR.
if (*curchar == '\n' && !prevcr && (*(curchar + 1) != '\r'))

View File

@ -38,8 +38,7 @@ ConsoleLogSource_Threading::ConsoleLogSource_Threading()
static const TraceLogDescriptor myDesc =
{
L"p&xThread", L"pxThread",
pxLt("Threading activity: start, detach, sync, deletion, etc.")
};
pxLt("Threading activity: start, detach, sync, deletion, etc.")};
m_Descriptor = &myDesc;
}
@ -75,10 +74,10 @@ static void make_curthread_key( const pxThread* thr )
pxAssumeDev(!tkl_destructed, "total_key_lock is destroyed; program is shutting down; cannot create new thread key.");
ScopedLock lock(total_key_lock);
if( total_key_count++ != 0 ) return;
if (total_key_count++ != 0)
return;
if( 0 != pthread_key_create(&curthread_key, NULL) )
{
if (0 != pthread_key_create(&curthread_key, NULL)) {
pxThreadLog.Error(thr->GetName(), L"Thread key creation failed (probably out of memory >_<)");
curthread_key = 0;
}
@ -90,7 +89,8 @@ static void unmake_curthread_key()
if (!tkl_destructed)
lock.AssignAndLock(total_key_lock);
if( --total_key_count > 0 ) return;
if (--total_key_count > 0)
return;
if (curthread_key)
pthread_key_delete(curthread_key);
@ -116,12 +116,9 @@ pxThread* Threading::pxGetCurrentThread()
// nor the Main/UI thread.
wxString Threading::pxGetCurrentThreadName()
{
if( pxThread* thr = pxGetCurrentThread() )
{
if (pxThread *thr = pxGetCurrentThread()) {
return thr->GetName();
}
else if( wxThread::IsMain() )
{
} else if (wxThread::IsMain()) {
return L"Main/UI";
}
@ -152,10 +149,10 @@ bool Threading::_WaitGui_RecursionGuard( const wxChar* name )
//if( pxAssertDev( !guard.IsReentrant(), "Recursion during UI-bound threading wait object." ) ) return false;
if( !guard.IsReentrant() ) return false;
if (!guard.IsReentrant())
return false;
pxThreadLog.Write(pxGetCurrentThreadName(),
pxsFmt(L"Yield recursion in %s; opening modal dialog.", name)
);
pxsFmt(L"Yield recursion in %s; opening modal dialog.", name));
return true;
}
@ -189,12 +186,10 @@ Threading::pxThread::pxThread( const wxString& name )
// like marrying your sister, and then cheating on her with your daughter.
Threading::pxThread::~pxThread() throw()
{
try
{
try {
pxThreadLog.Write(GetName(), L"Executing default destructor!");
if( m_running )
{
if (m_running) {
pxThreadLog.Write(GetName(), L"Waiting for running thread to end...");
m_mtx_InThread.Wait();
pxThreadLog.Write(GetName(), L"Thread ended gracefully.");
@ -207,7 +202,8 @@ Threading::pxThread::~pxThread() throw()
bool Threading::pxThread::AffinityAssert_AllowFromSelf(const DiagnosticOrigin &origin) const
{
if( IsSelf() ) return true;
if (IsSelf())
return true;
if (IsDevBuild)
pxOnAssert(origin, pxsFmt(L"Thread affinity violation: Call allowed from '%s' thread only.", WX_STR(GetName())));
@ -217,7 +213,8 @@ bool Threading::pxThread::AffinityAssert_AllowFromSelf( const DiagnosticOrigin&
bool Threading::pxThread::AffinityAssert_DisallowFromSelf(const DiagnosticOrigin &origin) const
{
if( !IsSelf() ) return true;
if (!IsSelf())
return true;
if (IsDevBuild)
pxOnAssert(origin, pxsFmt(L"Thread affinity violation: Call is *not* allowed from '%s' thread.", WX_STR(GetName())));
@ -227,8 +224,7 @@ bool Threading::pxThread::AffinityAssert_DisallowFromSelf( const DiagnosticOrigi
void Threading::pxThread::FrankenMutex(Mutex &mutex)
{
if( mutex.RecreateIfLocked() )
{
if (mutex.RecreateIfLocked()) {
// Our lock is bupkis, which means the previous thread probably deadlocked.
// Let's create a new mutex lock to replace it.
@ -246,8 +242,7 @@ void Threading::pxThread::Start()
{
// Prevents sudden parallel startup, and or parallel startup + cancel:
ScopedLock startlock(m_mtx_start);
if( m_running )
{
if (m_running) {
pxThreadLog.Write(GetName(), L"Start() called on running thread; ignorning...");
return;
}
@ -261,8 +256,7 @@ void Threading::pxThread::Start()
if (pthread_create(&m_thread, NULL, _internal_callback, this) != 0)
throw Exception::ThreadCreationError(this).SetDiagMsg(L"Thread creation error: " + wxString(std::strerror(errno)));
if( !m_sem_startup.WaitWithoutYield( wxTimeSpan( 0, 0, 3, 0 ) ) )
{
if (!m_sem_startup.WaitWithoutYield(wxTimeSpan(0, 0, 3, 0))) {
RethrowException();
// And if the thread threw nothing of its own:
@ -291,17 +285,18 @@ bool Threading::pxThread::Detach()
{
AffinityAssert_DisallowFromSelf(pxDiagSpot);
if( m_detached.exchange(true) ) return false;
if (m_detached.exchange(true))
return false;
pthread_detach(m_thread);
return true;
}
bool Threading::pxThread::_basecancel()
{
if( !m_running ) return false;
if (!m_running)
return false;
if( m_detached )
{
if (m_detached) {
pxThreadLog.Warn(GetName(), L"Ignoring attempted cancellation of detached thread.");
return false;
}
@ -331,10 +326,10 @@ void Threading::pxThread::Cancel( bool isBlocking )
// Prevent simultaneous startup and cancel, necessary to avoid
ScopedLock startlock(m_mtx_start);
if( !_basecancel() ) return;
if (!_basecancel())
return;
if( isBlocking )
{
if (isBlocking) {
WaitOnSelf(m_mtx_InThread);
Detach();
}
@ -347,9 +342,11 @@ bool Threading::pxThread::Cancel( const wxTimeSpan& timespan )
// Prevent simultaneous startup and cancel:
ScopedLock startlock(m_mtx_start);
if( !_basecancel() ) return true;
if (!_basecancel())
return true;
if( !WaitOnSelf( m_mtx_InThread, timespan ) ) return false;
if (!WaitOnSelf(m_mtx_InThread, timespan))
return false;
Detach();
return true;
}
@ -426,18 +423,15 @@ void Threading::YieldToMain()
void Threading::pxThread::_selfRunningTest(const wxChar *name) const
{
if( HasPendingException() )
{
if (HasPendingException()) {
pxThreadLog.Error(GetName(), pxsFmt(L"An exception was thrown while waiting on a %s.", name));
RethrowException();
}
if( !m_running )
{
if (!m_running) {
throw Exception::CancelEvent(pxsFmt(
L"Blocking thread %s was terminated while another thread was waiting on a %s.",
WX_STR(GetName()), name )
);
WX_STR(GetName()), name));
}
// Thread is still alive and kicking (for now) -- yield to other messages and hope
@ -461,11 +455,12 @@ void Threading::pxThread::_selfRunningTest( const wxChar* name ) const
//
void Threading::pxThread::WaitOnSelf(Semaphore &sem) const
{
if( !AffinityAssert_DisallowFromSelf(pxDiagSpot) ) return;
if (!AffinityAssert_DisallowFromSelf(pxDiagSpot))
return;
while( true )
{
if( sem.WaitWithoutYield( wxTimeSpan(0, 0, 0, 333) ) ) return;
while (true) {
if (sem.WaitWithoutYield(wxTimeSpan(0, 0, 0, 333)))
return;
_selfRunningTest(L"semaphore");
}
}
@ -485,11 +480,12 @@ void Threading::pxThread::WaitOnSelf( Semaphore& sem ) const
//
void Threading::pxThread::WaitOnSelf(Mutex &mutex) const
{
if( !AffinityAssert_DisallowFromSelf(pxDiagSpot) ) return;
if (!AffinityAssert_DisallowFromSelf(pxDiagSpot))
return;
while( true )
{
if( mutex.WaitWithoutYield( wxTimeSpan(0, 0, 0, 333) ) ) return;
while (true) {
if (mutex.WaitWithoutYield(wxTimeSpan(0, 0, 0, 333)))
return;
_selfRunningTest(L"mutex");
}
}
@ -498,14 +494,15 @@ static const wxTimeSpan SelfWaitInterval( 0,0,0,333 );
bool Threading::pxThread::WaitOnSelf(Semaphore &sem, const wxTimeSpan &timeout) const
{
if( !AffinityAssert_DisallowFromSelf(pxDiagSpot) ) return true;
if (!AffinityAssert_DisallowFromSelf(pxDiagSpot))
return true;
wxTimeSpan runningout(timeout);
while( runningout.GetMilliseconds() > 0 )
{
while (runningout.GetMilliseconds() > 0) {
const wxTimeSpan interval((SelfWaitInterval < runningout) ? SelfWaitInterval : runningout);
if( sem.WaitWithoutYield( interval ) ) return true;
if (sem.WaitWithoutYield(interval))
return true;
_selfRunningTest(L"semaphore");
runningout -= interval;
}
@ -514,14 +511,15 @@ bool Threading::pxThread::WaitOnSelf( Semaphore& sem, const wxTimeSpan& timeout
bool Threading::pxThread::WaitOnSelf(Mutex &mutex, const wxTimeSpan &timeout) const
{
if( !AffinityAssert_DisallowFromSelf(pxDiagSpot) ) return true;
if (!AffinityAssert_DisallowFromSelf(pxDiagSpot))
return true;
wxTimeSpan runningout(timeout);
while( runningout.GetMilliseconds() > 0 )
{
while (runningout.GetMilliseconds() > 0) {
const wxTimeSpan interval((SelfWaitInterval < runningout) ? SelfWaitInterval : runningout);
if( mutex.WaitWithoutYield( interval ) ) return true;
if (mutex.WaitWithoutYield(interval))
return true;
_selfRunningTest(L"mutex");
runningout -= interval;
}
@ -548,14 +546,12 @@ void Threading::pxThread::_try_virtual_invoke( void (pxThread::*method)() )
// ----------------------------------------------------------------------------
// Neat repackaging for STL Runtime errors...
//
catch( std::runtime_error& ex )
{
catch (std::runtime_error &ex) {
m_except = new Exception::RuntimeError(ex, WX_STR(GetName()));
}
// ----------------------------------------------------------------------------
catch( Exception::RuntimeError& ex )
{
catch (Exception::RuntimeError &ex) {
BaseException *woot = ex.Clone();
woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName()));
m_except = woot;
@ -580,8 +576,7 @@ void Threading::pxThread::_try_virtual_invoke( void (pxThread::*method)() )
// ----------------------------------------------------------------------------
// BaseException -- same deal as LogicErrors.
//
catch( BaseException& ex )
{
catch (BaseException &ex) {
BaseException *woot = ex.Clone();
woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName()));
m_except = woot;
@ -677,7 +672,8 @@ void Threading::pxThread::OnCleanupInThread()
// callback function
void *Threading::pxThread::_internal_callback(void *itsme)
{
if( !pxAssertDev( itsme != NULL, wxNullChar ) ) return NULL;
if (!pxAssertDev(itsme != NULL, wxNullChar))
return NULL;
pxThread &owner = *((pxThread *)itsme);
pthread_cleanup_push(_pt_callback_cleanup, itsme);
@ -698,7 +694,8 @@ void Threading::pxThread::_DoSetThreadName( const wxString& name )
// Tells the thread to exit and then waits for thread termination.
void Threading::BaseTaskThread::Block()
{
if( !IsRunning() ) return;
if (!IsRunning())
return;
m_Done = true;
m_sem_event.Post();
pxThread::Block();
@ -719,7 +716,8 @@ void Threading::BaseTaskThread::PostTask()
// Blocks current thread execution pending the completion of the parallel task.
void Threading::BaseTaskThread::WaitForResult()
{
if( m_detached || !m_running ) return;
if (m_detached || !m_running)
return;
if (m_TaskPending)
#if wxUSE_GUI
m_post_TaskComplete.Wait();
@ -732,8 +730,7 @@ void Threading::BaseTaskThread::WaitForResult()
void Threading::BaseTaskThread::ExecuteTaskInThread()
{
while( !m_Done )
{
while (!m_Done) {
// Wait for a job -- or get a pthread_cancel. I'm easy.
m_sem_event.WaitWithoutYield();

View File

@ -38,8 +38,10 @@ Threading::WaitForTaskDialog::WaitForTaskDialog( const wxString& title, const wx
wxString m_title(title);
wxString m_heading(heading);
if( m_title.IsEmpty() ) m_title = _("Waiting for task...");
if( m_heading.IsEmpty() ) m_heading = m_title;
if (m_title.IsEmpty())
m_title = _("Waiting for task...");
if (m_heading.IsEmpty())
m_heading = m_title;
Bind(pxEvt_ThreadedTaskComplete, &WaitForTaskDialog::OnTaskComplete, this);

View File

@ -28,4 +28,3 @@ namespace Threading
extern void YieldToMain();
extern bool AllowDeletions();
}

View File

@ -90,7 +90,8 @@ VirtualMemoryReserve& VirtualMemoryReserve::SetName( const wxString& newname )
VirtualMemoryReserve &VirtualMemoryReserve::SetBaseAddr(uptr newaddr)
{
if (!pxAssertDev(!m_pages_reserved, "Invalid object state: you must release the virtual memory reserve prior to changing its base address!")) return *this;
if (!pxAssertDev(!m_pages_reserved, "Invalid object state: you must release the virtual memory reserve prior to changing its base address!"))
return *this;
m_baseptr = (void *)newaddr;
return *this;
@ -119,36 +120,36 @@ void* VirtualMemoryReserve::Reserve( size_t size, uptr base, uptr upper_bounds )
if (!pxAssertDev(m_baseptr == NULL, "(VirtualMemoryReserve) Invalid object state; object has already been reserved."))
return m_baseptr;
if (!size) size = m_defsize;
if (!size) return NULL;
if (!size)
size = m_defsize;
if (!size)
return NULL;
m_pages_reserved = (size + __pagesize - 4) / __pagesize;
uptr reserved_bytes = m_pages_reserved * __pagesize;
m_baseptr = (void *)HostSys::MmapReserve(base, reserved_bytes);
if (!m_baseptr || (upper_bounds != 0 && (((uptr)m_baseptr + reserved_bytes) > upper_bounds)))
{
if (!m_baseptr || (upper_bounds != 0 && (((uptr)m_baseptr + reserved_bytes) > upper_bounds))) {
DevCon.Warning(L"%s: host memory @ %ls -> %ls is unavailable; attempting to map elsewhere...",
WX_STR(m_name), pxsPtr(base), pxsPtr(base + size));
SafeSysMunmap(m_baseptr, reserved_bytes);
if (base)
{
if (base) {
// Let's try again at an OS-picked memory area, and then hope it meets needed
// boundschecking criteria below.
m_baseptr = HostSys::MmapReserve(0, reserved_bytes);
}
}
if ((upper_bounds != 0) && (((uptr)m_baseptr + reserved_bytes) > upper_bounds))
{
if ((upper_bounds != 0) && (((uptr)m_baseptr + reserved_bytes) > upper_bounds)) {
SafeSysMunmap(m_baseptr, reserved_bytes);
// returns null, caller should throw an exception or handle appropriately.
}
if (!m_baseptr) return NULL;
if (!m_baseptr)
return NULL;
FastFormatUnicode mbkb;
uint mbytes = reserved_bytes / _1mb;
@ -165,14 +166,16 @@ void* VirtualMemoryReserve::Reserve( size_t size, uptr base, uptr upper_bounds )
void VirtualMemoryReserve::ReprotectCommittedBlocks(const PageProtectionMode &newmode)
{
if (!m_pages_commited) return;
if (!m_pages_commited)
return;
HostSys::MemProtect(m_baseptr, m_pages_commited * __pagesize, newmode);
}
// Clears all committed blocks, restoring the allocation to a reserve only.
void VirtualMemoryReserve::Reset()
{
if (!m_pages_commited) return;
if (!m_pages_commited)
return;
ReprotectCommittedBlocks(PageAccess_None());
HostSys::MmapResetPtr(m_baseptr, m_pages_commited * __pagesize);
@ -186,8 +189,10 @@ void VirtualMemoryReserve::Release()
bool VirtualMemoryReserve::Commit()
{
if (!m_pages_reserved) return false;
if (!pxAssert(!m_pages_commited)) return true;
if (!m_pages_reserved)
return false;
if (!pxAssert(!m_pages_commited))
return true;
m_pages_commited = m_pages_reserved;
return HostSys::MmapCommitPtr(m_baseptr, m_pages_reserved * __pagesize, m_prot_mode);
@ -219,8 +224,7 @@ bool VirtualMemoryReserve::TryResize( uint newsize )
{
uint newPages = (newsize + __pagesize - 1) / __pagesize;
if (newPages > m_pages_reserved)
{
if (newPages > m_pages_reserved) {
uint toReservePages = newPages - m_pages_reserved;
uint toReserveBytes = toReservePages * __pagesize;
@ -228,18 +232,16 @@ bool VirtualMemoryReserve::TryResize( uint newsize )
m_baseptr = (void *)HostSys::MmapReserve((uptr)GetPtrEnd(), toReserveBytes);
if (!m_baseptr)
{
if (!m_baseptr) {
Console.Warning("%-32s could not be passively resized due to virtual memory conflict!");
Console.Indent().Warning("(attempted to map memory @ %08p -> %08p)", m_baseptr, (uptr)m_baseptr + toReserveBytes);
}
DevCon.WriteLn(Color_Gray, L"%-32s @ %08p -> %08p [%umb]", WX_STR(m_name),
m_baseptr, (uptr)m_baseptr + toReserveBytes, toReserveBytes / _1mb);
}
else if (newPages < m_pages_reserved)
{
if (m_pages_commited > newsize) return false;
} else if (newPages < m_pages_reserved) {
if (m_pages_commited > newsize)
return false;
uint toRemovePages = m_pages_reserved - newPages;
uint toRemoveBytes = toRemovePages * __pagesize;
@ -273,8 +275,7 @@ void BaseVmReserveListener::CommitBlocks( uptr page, uint blocks )
// Depending on the operating system, this call could fail if the system is low on either
// physical ram or virtual memory.
if (!HostSys::MmapCommitPtr(blockptr, blocksbytes, m_prot_mode))
{
if (!HostSys::MmapCommitPtr(blockptr, blocksbytes, m_prot_mode)) {
throw Exception::OutOfMemory(m_name)
.SetDiagMsg(pxsFmt("An additional %u blocks @ 0x%08x were requested, but could not be committed!", blocks, blockptr));
}
@ -290,15 +291,14 @@ void BaseVmReserveListener::CommitBlocks( uptr page, uint blocks )
void BaseVmReserveListener::OnPageFaultEvent(const PageFaultInfo &info, bool &handled)
{
sptr offset = (info.addr - (uptr)m_baseptr) / __pagesize;
if ((offset < 0) || ((uptr)offset >= m_pages_reserved)) return;
if ((offset < 0) || ((uptr)offset >= m_pages_reserved))
return;
if (!m_allow_writes)
{
if (!m_allow_writes) {
pxFailRel(pxsFmt(
L"Memory Protection Fault @ %ls (%s)\n"
L"Modification of this reserve has been disabled (m_allow_writes == false).",
pxsPtr(info.addr), WX_STR(m_name))
);
pxsPtr(info.addr), WX_STR(m_name)));
return;
}
@ -320,16 +320,11 @@ void BaseVmReserveListener::OnPageFaultEvent(const PageFaultInfo& info, bool& ha
handled = true;
#ifndef __WXMSW__
}
catch (Exception::BaseException& ex)
{
} catch (Exception::BaseException &ex) {
handled = false;
if (!wxThread::IsMain())
{
if (!wxThread::IsMain()) {
pxFailRel(ex.FormatDiagnosticMessage());
}
else
{
} else {
pxTrap();
}
}
@ -343,12 +338,17 @@ wxString PageProtectionMode::ToString() const
{
wxString modeStr;
if (m_read) modeStr += L"Read";
if (m_write) modeStr += L"Write";
if (m_exec) modeStr += L"Exec";
if (m_read)
modeStr += L"Read";
if (m_write)
modeStr += L"Write";
if (m_exec)
modeStr += L"Exec";
if (modeStr.IsEmpty()) return L"NoAccess";
if (modeStr.Length() <= 5) modeStr += L"Only";
if (modeStr.IsEmpty())
return L"NoAccess";
if (modeStr.Length() <= 5)
modeStr += L"Only";
return modeStr;
}

View File

@ -61,12 +61,9 @@ static DWORD ConvertToWinApi( const PageProtectionMode& mode )
// numbering (like flags) but is in fact not a flag value. *Someone* from the early
// microsoft days wasn't a very good coder, me thinks. --air
if (mode.CanExecute())
{
if (mode.CanExecute()) {
winmode = mode.CanWrite() ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ;
}
else if (mode.CanRead())
{
} else if (mode.CanRead()) {
winmode = mode.CanWrite() ? PAGE_READWRITE : PAGE_READONLY;
}
@ -81,21 +78,20 @@ void* HostSys::MmapReservePtr(void* base, size_t size)
bool HostSys::MmapCommitPtr(void *base, size_t size, const PageProtectionMode &mode)
{
void *result = VirtualAlloc(base, size, MEM_COMMIT, ConvertToWinApi(mode));
if (result) return true;
if (result)
return true;
const DWORD errcode = GetLastError();
if (errcode == ERROR_COMMITMENT_MINIMUM)
{
if (errcode == ERROR_COMMITMENT_MINIMUM) {
Console.Warning("(MmapCommit) Received windows error %u {Virtual Memory Minimum Too Low}.", ERROR_COMMITMENT_MINIMUM);
Sleep(1000); // Cut windows some time to rework its memory...
}
else if (errcode != ERROR_NOT_ENOUGH_MEMORY && errcode != ERROR_OUTOFMEMORY)
{
} else if (errcode != ERROR_NOT_ENOUGH_MEMORY && errcode != ERROR_OUTOFMEMORY) {
pxFailDev(L"VirtualAlloc COMMIT failed: " + Exception::WinApiError().GetMsgFromWindows());
return false;
}
if (!pxDoOutOfMemory) return false;
if (!pxDoOutOfMemory)
return false;
pxDoOutOfMemory(size);
return VirtualAlloc(base, size, MEM_COMMIT, ConvertToWinApi(mode)) != NULL;
}
@ -129,7 +125,8 @@ void* HostSys::Mmap(uptr base, size_t size)
void HostSys::Munmap(uptr base, size_t size)
{
if (!base) return;
if (!base)
return;
//VirtualFree((void*)base, size, MEM_DECOMMIT);
VirtualFree((void *)base, 0, MEM_RELEASE);
}
@ -139,18 +136,15 @@ void HostSys::MemProtect( void* baseaddr, size_t size, const PageProtectionMode&
pxAssertDev(((size & (__pagesize - 1)) == 0), pxsFmt(
L"Memory block size must be a multiple of the target platform's page size.\n"
L"\tPage Size: 0x%04x (%d), Block Size: 0x%04x (%d)",
__pagesize, __pagesize, size, size )
);
__pagesize, __pagesize, size, size));
DWORD OldProtect; // enjoy my uselessness, yo!
if (!VirtualProtect( baseaddr, size, ConvertToWinApi(mode), &OldProtect ))
{
if (!VirtualProtect(baseaddr, size, ConvertToWinApi(mode), &OldProtect)) {
Exception::WinApiError apiError;
apiError.SetDiagMsg(
pxsFmt(L"VirtualProtect failed @ 0x%08X -> 0x%08X (mode=%s)",
baseaddr, (uptr)baseaddr + size, mode.ToString().c_str()
));
baseaddr, (uptr)baseaddr + size, mode.ToString().c_str()));
pxFailDev(apiError.FormatDiagnosticMessage());
}

View File

@ -115,8 +115,7 @@ wxString GetOSVersionString()
// Test for the specific product.
if ( osvi.dwMajorVersion == 10 )
{
if (osvi.dwMajorVersion == 10) {
if (osvi.dwMinorVersion == 0)
retval += (osvi.wProductType == VER_NT_WORKSTATION) ? L"Windows 10 " : L"Windows Server 2016 ";
@ -124,23 +123,41 @@ wxString GetOSVersionString()
pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
switch( dwType )
{
case PRODUCT_CORE: retval += L"Home"; break;
case PRODUCT_CORE_N: retval += L"Home N"; break;
case PRODUCT_PROFESSIONAL: retval += L"Pro"; break;
case PRODUCT_PROFESSIONAL_N: retval += L"Pro N"; break;
case PRODUCT_ENTERPRISE: retval += L"Enterprise"; break;
case PRODUCT_ENTERPRISE_N: retval += L"Enterprise N"; break;
case PRODUCT_ENTERPRISE_S: retval += L"Enterprise 2015 LTSB"; break;
case PRODUCT_ENTERPRISE_S_N: retval += L"Enterprise 2015 LTSB N"; break;
case PRODUCT_EDUCATION: retval += L"Education"; break;
case PRODUCT_EDUCATION_N: retval += L"Education N"; break;
switch (dwType) {
case PRODUCT_CORE:
retval += L"Home";
break;
case PRODUCT_CORE_N:
retval += L"Home N";
break;
case PRODUCT_PROFESSIONAL:
retval += L"Pro";
break;
case PRODUCT_PROFESSIONAL_N:
retval += L"Pro N";
break;
case PRODUCT_ENTERPRISE:
retval += L"Enterprise";
break;
case PRODUCT_ENTERPRISE_N:
retval += L"Enterprise N";
break;
case PRODUCT_ENTERPRISE_S:
retval += L"Enterprise 2015 LTSB";
break;
case PRODUCT_ENTERPRISE_S_N:
retval += L"Enterprise 2015 LTSB N";
break;
case PRODUCT_EDUCATION:
retval += L"Education";
break;
case PRODUCT_EDUCATION_N:
retval += L"Education N";
break;
}
}
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion > 1 )
{
if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion > 1) {
if (osvi.dwMinorVersion == 2)
retval += (osvi.wProductType == VER_NT_WORKSTATION) ? L"Windows 8 " : L"Windows Server 2012 ";
@ -151,23 +168,41 @@ wxString GetOSVersionString()
pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
switch( dwType )
{
case PRODUCT_PROFESSIONAL: retval += L"Pro"; break;
case PRODUCT_PROFESSIONAL_N: retval += L"Pro N"; break;
case PRODUCT_PROFESSIONAL_WMC: retval += L"Pro with Media Center"; break;
case PRODUCT_ENTERPRISE: retval += L"Enterprise"; break;
case PRODUCT_ENTERPRISE_N: retval += L"Enterprise N"; break;
case PRODUCT_SERVER_FOUNDATION: retval += L"Foundation"; break;
case PRODUCT_STANDARD_SERVER: retval += L"Standard"; break;
case PRODUCT_STANDARD_SERVER_CORE: retval += L"Standard (core)"; break;
case PRODUCT_DATACENTER_SERVER: retval += L"Datacenter"; break;
case PRODUCT_DATACENTER_SERVER_CORE: retval += L"Datacenter (core)"; break;
switch (dwType) {
case PRODUCT_PROFESSIONAL:
retval += L"Pro";
break;
case PRODUCT_PROFESSIONAL_N:
retval += L"Pro N";
break;
case PRODUCT_PROFESSIONAL_WMC:
retval += L"Pro with Media Center";
break;
case PRODUCT_ENTERPRISE:
retval += L"Enterprise";
break;
case PRODUCT_ENTERPRISE_N:
retval += L"Enterprise N";
break;
case PRODUCT_SERVER_FOUNDATION:
retval += L"Foundation";
break;
case PRODUCT_STANDARD_SERVER:
retval += L"Standard";
break;
case PRODUCT_STANDARD_SERVER_CORE:
retval += L"Standard (core)";
break;
case PRODUCT_DATACENTER_SERVER:
retval += L"Datacenter";
break;
case PRODUCT_DATACENTER_SERVER_CORE:
retval += L"Datacenter (core)";
break;
}
}
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion <= 1 )
{
if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion <= 1) {
if (osvi.dwMinorVersion == 0)
retval += (osvi.wProductType == VER_NT_WORKSTATION) ? L"Windows Vista " : L"Windows Server 2008 ";
@ -178,29 +213,59 @@ wxString GetOSVersionString()
pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
switch( dwType )
{
case PRODUCT_ULTIMATE: retval += L"Ultimate Edition"; break;
case PRODUCT_HOME_PREMIUM: retval += L"Home Premium Edition"; break;
case PRODUCT_HOME_BASIC: retval += L"Home Basic Edition"; break;
case PRODUCT_ENTERPRISE: retval += L"Enterprise Edition"; break;
case PRODUCT_BUSINESS: retval += L"Business Edition"; break;
case PRODUCT_STARTER: retval += L"Starter Edition"; break;
case PRODUCT_CLUSTER_SERVER: retval += L"Cluster Server Edition"; break;
case PRODUCT_DATACENTER_SERVER: retval += L"Datacenter Edition"; break;
case PRODUCT_DATACENTER_SERVER_CORE: retval += L"Datacenter Edition (core installation)"; break;
case PRODUCT_ENTERPRISE_SERVER: retval += L"Enterprise Edition"; break;
case PRODUCT_ENTERPRISE_SERVER_CORE: retval += L"Enterprise Edition (core installation)"; break;
case PRODUCT_SMALLBUSINESS_SERVER: retval += L"Small Business Server"; break;
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: retval += L"Small Business Server Premium Edition"; break;
case PRODUCT_STANDARD_SERVER: retval += L"Standard Edition"; break;
case PRODUCT_STANDARD_SERVER_CORE: retval += L"Standard Edition (core installation)"; break;
case PRODUCT_WEB_SERVER: retval += L"Web Server Edition"; break;
switch (dwType) {
case PRODUCT_ULTIMATE:
retval += L"Ultimate Edition";
break;
case PRODUCT_HOME_PREMIUM:
retval += L"Home Premium Edition";
break;
case PRODUCT_HOME_BASIC:
retval += L"Home Basic Edition";
break;
case PRODUCT_ENTERPRISE:
retval += L"Enterprise Edition";
break;
case PRODUCT_BUSINESS:
retval += L"Business Edition";
break;
case PRODUCT_STARTER:
retval += L"Starter Edition";
break;
case PRODUCT_CLUSTER_SERVER:
retval += L"Cluster Server Edition";
break;
case PRODUCT_DATACENTER_SERVER:
retval += L"Datacenter Edition";
break;
case PRODUCT_DATACENTER_SERVER_CORE:
retval += L"Datacenter Edition (core installation)";
break;
case PRODUCT_ENTERPRISE_SERVER:
retval += L"Enterprise Edition";
break;
case PRODUCT_ENTERPRISE_SERVER_CORE:
retval += L"Enterprise Edition (core installation)";
break;
case PRODUCT_SMALLBUSINESS_SERVER:
retval += L"Small Business Server";
break;
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
retval += L"Small Business Server Premium Edition";
break;
case PRODUCT_STANDARD_SERVER:
retval += L"Standard Edition";
break;
case PRODUCT_STANDARD_SERVER_CORE:
retval += L"Standard Edition (core installation)";
break;
case PRODUCT_WEB_SERVER:
retval += L"Web Server Edition";
break;
}
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
{
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) {
if (GetSystemMetrics(SM_SERVERR2))
retval += L"Windows Server 2003 R2, ";
else if (osvi.wSuiteMask == VER_SUITE_STORAGE_SERVER)
@ -213,10 +278,8 @@ wxString GetOSVersionString()
retval += L"Windows Server 2003, ";
// Test for the server type.
if ( osvi.wProductType != VER_NT_WORKSTATION )
{
if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
{
if (osvi.wProductType != VER_NT_WORKSTATION) {
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
retval += L"Datacenter x64 Edition";
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
@ -225,8 +288,7 @@ wxString GetOSVersionString()
retval += L"Standard x64 Edition";
}
else
{
else {
if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER)
retval += L"Compute Cluster Edition";
else if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
@ -241,22 +303,17 @@ wxString GetOSVersionString()
}
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
{
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) {
retval += L"Windows XP ";
retval += (osvi.wSuiteMask & VER_SUITE_PERSONAL) ? L"Home Edition" : L"Professional";
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
{
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) {
retval += L"Windows 2000 ";
if ( osvi.wProductType == VER_NT_WORKSTATION )
{
if (osvi.wProductType == VER_NT_WORKSTATION) {
retval += L"Professional";
}
else
{
} else {
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
retval += L"Datacenter Server";
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
@ -273,8 +330,7 @@ wxString GetOSVersionString()
retval += wxsFormat(L" (build %d)", osvi.dwBuildNumber);
if ( osvi.dwMajorVersion >= 6 )
{
if (osvi.dwMajorVersion >= 6) {
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
retval += L", 64-bit";
else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
@ -295,7 +351,8 @@ Exception::WinApiError::WinApiError()
wxString Exception::WinApiError::GetMsgFromWindows() const
{
if (!ErrorId) return L"No valid error number was assigned to this exception!";
if (!ErrorId)
return L"No valid error number was assigned to this exception!";
const DWORD BUF_LEN = 2048;
TCHAR t_Msg[BUF_LEN];

View File

@ -75,7 +75,8 @@ u64 Threading::GetThreadTicksPerSecond()
u64 Threading::pxThread::GetCpuTime() const
{
if (!m_native_handle) return 0;
if (!m_native_handle)
return 0;
FileTimeSucks user, kernel;
FILETIME dummy;
@ -132,9 +133,9 @@ void Threading::pxThread::_DoSetThreadName( const char* name )
__try {
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
} __except(EXCEPTION_EXECUTE_HANDLER) { }
} __except (EXCEPTION_EXECUTE_HANDLER) {
}
#endif
}
#endif

View File

@ -44,8 +44,7 @@ void pxCheckBox::Init(const wxString& label, const wxString& subtext, int flags)
*this += m_checkbox | pxSizerFlags::StdExpand();
static const int Indentation = 23;
if( !subtext.IsEmpty() )
{
if (!subtext.IsEmpty()) {
m_subtext = new pxStaticText(this, subtext, wxALIGN_LEFT);
wxFlexGridSizer &spaced(*new wxFlexGridSizer(3));
@ -63,8 +62,7 @@ void pxCheckBox::Init(const wxString& label, const wxString& subtext, int flags)
pxCheckBox &pxCheckBox::SetSubPadding(int pad)
{
m_subPadding = pad;
if( m_sizerItem_subtext )
{
if (m_sizerItem_subtext) {
m_sizerItem_subtext->SetBorder(m_subPadding);
Fit();
}
@ -124,7 +122,8 @@ void pxCheckBox::OnSubtextClicked( wxCommandEvent& evt )
void operator+=(wxSizer &target, pxCheckBox *src)
{
if( src ) target.Add( src, pxExpand );
if (src)
target.Add(src, pxExpand);
}
void operator+=(wxSizer &target, pxCheckBox &src)

View File

@ -50,10 +50,10 @@ void pxRadioPanel::Reset()
{
m_IsRealized = false;
const int numbuttons = m_buttonStrings.size();
if( numbuttons == 0 ) return;
if (numbuttons == 0)
return;
for( int i=0; i<numbuttons; ++i)
{
for (int i = 0; i < numbuttons; ++i) {
safe_delete(m_objects[i].LabelObj);
safe_delete(m_objects[i].SubTextObj);
}
@ -63,8 +63,10 @@ void pxRadioPanel::Reset()
void pxRadioPanel::Realize()
{
const int numbuttons = m_buttonStrings.size();
if( numbuttons == 0 ) return;
if( m_IsRealized ) return;
if (numbuttons == 0)
return;
if (m_IsRealized)
return;
m_IsRealized = true;
m_objects.MakeRoomFor(numbuttons);
@ -80,21 +82,19 @@ void pxRadioPanel::Realize()
for (int i = 1; i < numbuttons; ++i)
m_objects[i].LabelObj = new wxRadioButton(this, wxID_ANY, m_buttonStrings[i].Label);
for( int i=0; i<numbuttons; ++i )
{
for (int i = 0; i < numbuttons; ++i) {
m_objects[i].SubTextObj = NULL;
if( m_buttonStrings[i].SubText.IsEmpty() ) continue;
if (m_buttonStrings[i].SubText.IsEmpty())
continue;
m_objects[i].SubTextObj = new pxStaticText(this, m_buttonStrings[i].SubText, wxALIGN_LEFT);
}
pxAssert(GetSizer() != NULL);
for( int i=0; i<numbuttons; ++i )
{
for (int i = 0; i < numbuttons; ++i) {
*this += m_objects[i].LabelObj | pxSizerFlags::StdExpand();
if( pxStaticText* subobj = m_objects[i].SubTextObj )
{
if (pxStaticText *subobj = m_objects[i].SubTextObj) {
*this += subobj | pxBorder(wxLEFT, m_Indentation).Expand();
*this += 9 + m_padding.GetHeight();
}
@ -129,7 +129,8 @@ pxRadioPanel& pxRadioPanel::SetToolTip(int idx, const wxString &tip)
pxRadioPanel &pxRadioPanel::SetSelection(int idx)
{
if( !VerifyRealizedState() ) return *this;
if (!VerifyRealizedState())
return *this;
pxAssert(m_objects[idx].LabelObj != NULL);
m_objects[idx].LabelObj->SetValue(true);
@ -138,8 +139,7 @@ pxRadioPanel& pxRadioPanel::SetSelection( int idx )
void pxRadioPanel::_RealizeDefaultOption()
{
if( m_IsRealized && m_DefaultIdx != -1 )
{
if (m_IsRealized && m_DefaultIdx != -1) {
wxFont def(GetFont());
def.SetWeight(wxFONTWEIGHT_BOLD);
//def.SetStyle( wxFONTSTYLE_ITALIC );
@ -152,10 +152,10 @@ void pxRadioPanel::_RealizeDefaultOption()
// Not intended for restoring default value at later time.
pxRadioPanel &pxRadioPanel::SetDefaultItem(int idx)
{
if( idx == m_DefaultIdx ) return *this;
if (idx == m_DefaultIdx)
return *this;
if( m_IsRealized && m_DefaultIdx != -1 )
{
if (m_IsRealized && m_DefaultIdx != -1) {
wxFont def(GetFont());
m_objects[m_DefaultIdx].LabelObj->SetFont(def);
m_objects[m_DefaultIdx].LabelObj->SetForegroundColour(GetForegroundColour());
@ -192,12 +192,13 @@ RadioPanelItem& pxRadioPanel::Item(int idx)
int pxRadioPanel::GetSelection() const
{
if( !VerifyRealizedState() ) return 0;
if (!VerifyRealizedState())
return 0;
for( uint i=0; i<m_buttonStrings.size(); ++i )
{
for (uint i = 0; i < m_buttonStrings.size(); ++i) {
if (wxRadioButton *woot = m_objects[i].LabelObj)
if( woot->GetValue() ) return i;
if (woot->GetValue())
return i;
}
// Technically radio buttons should never allow for a case where none are selected.
@ -213,38 +214,44 @@ int pxRadioPanel::GetSelection() const
// Returns the wxWindowID for the currently selected radio button.
wxWindowID pxRadioPanel::GetSelectionId() const
{
if( !VerifyRealizedState() ) return 0;
if (!VerifyRealizedState())
return 0;
return m_objects[GetSelection()].LabelObj->GetId();
}
bool pxRadioPanel::IsSelected(int idx) const
{
if( !VerifyRealizedState() ) return false;
if (!VerifyRealizedState())
return false;
pxAssert(m_objects[idx].LabelObj != NULL);
return m_objects[idx].LabelObj->GetValue();
}
pxStaticText *pxRadioPanel::GetSubText(int idx)
{
if( !VerifyRealizedState() ) return NULL;
if (!VerifyRealizedState())
return NULL;
return m_objects[idx].SubTextObj;
}
const pxStaticText *pxRadioPanel::GetSubText(int idx) const
{
if( !VerifyRealizedState() ) return NULL;
if (!VerifyRealizedState())
return NULL;
return m_objects[idx].SubTextObj;
}
wxRadioButton *pxRadioPanel::GetButton(int idx)
{
if( !VerifyRealizedState() ) return NULL;
if (!VerifyRealizedState())
return NULL;
return m_objects[idx].LabelObj;
}
const wxRadioButton *pxRadioPanel::GetButton(int idx) const
{
if( !VerifyRealizedState() ) return NULL;
if (!VerifyRealizedState())
return NULL;
return m_objects[idx].LabelObj;
}

View File

@ -81,7 +81,8 @@ pxStaticText& pxStaticText::SetMinHeight( int height )
pxStaticText &pxStaticText::SetHeight(int lines)
{
if( !pxAssert(lines > 0) ) lines = 2;
if (!pxAssert(lines > 0))
lines = 2;
m_heightInLines = lines;
const int newHeight = (pxGetCharHeight(this) * m_heightInLines) + (m_paddingPix_vert * 2);
@ -167,17 +168,16 @@ wxSize pxStaticText::GetBestWrappedSize( const wxClientDC& dc ) const
double parentalFactor = 1.0;
const wxWindow *millrun = this;
while( millrun )
{
while (millrun) {
// IMPORTANT : wxWizard changes its min size and then expects everything else
// to play nice and NOT resize according to the new min size. (wtf stupid)
// Anyway, this fixes it -- ignore min size specifier on wxWizard!
if( wxIsKindOf( millrun, wxWizard ) ) break;
if (wxIsKindOf(millrun, wxWizard))
break;
int min = (int)((millrun->GetMinWidth() - parentalAdjust) * parentalFactor);
if( min > 0 && ((idealWidth < 0 ) || (min < idealWidth)) )
{
if (min > 0 && ((idealWidth < 0) || (min < idealWidth))) {
idealWidth = min;
}
@ -185,8 +185,7 @@ wxSize pxStaticText::GetBestWrappedSize( const wxClientDC& dc ) const
millrun = millrun->GetParent();
}
if( idealWidth <= 0 )
{
if (idealWidth <= 0) {
// FIXME: The minimum size of this control is unknown, so let's just pick a guess based on
// the size of the user's display area.
@ -200,7 +199,8 @@ pxStaticText& pxStaticText::WrapAt( int width )
{
m_autowrap = false;
if( (width <= 1) || (width == m_wrappedWidth) ) return *this;
if ((width <= 1) || (width == m_wrappedWidth))
return *this;
wxString wrappedLabel;
m_wrappedWidth = width;
@ -208,22 +208,19 @@ pxStaticText& pxStaticText::WrapAt( int width )
if (width > 1)
wrappedLabel = pxTextWrapper().Wrap(this, m_label, width).GetResult();
if(m_wrappedLabel != wrappedLabel )
{
if (m_wrappedLabel != wrappedLabel) {
m_wrappedLabel = wrappedLabel;
wxSize area = wxClientDC(this).GetMultiLineTextExtent(m_wrappedLabel);
SetMinSize(wxSize(
area.GetWidth() + calcPaddingWidth(area.GetWidth()),
area.GetHeight() + calcPaddingHeight(area.GetHeight())
) );
area.GetHeight() + calcPaddingHeight(area.GetHeight())));
}
return *this;
}
bool pxStaticText::_updateWrapping(bool textChanged)
{
if( !m_autowrap )
{
if (!m_autowrap) {
//m_wrappedLabel = wxEmptyString;
//m_wrappedWidth = -1;
return false;
@ -233,7 +230,8 @@ bool pxStaticText::_updateWrapping( bool textChanged )
int newWidth = GetSize().GetWidth();
newWidth -= (int)(newWidth * m_paddingPct_horiz * 2) + (m_paddingPix_horiz * 2);
if( !textChanged && (newWidth == m_wrappedWidth) ) return false;
if (!textChanged && (newWidth == m_wrappedWidth))
return false;
// Note: during various stages of sizer-calc, width can be 1, 0, or -1.
// We ignore wrapping in these cases. (the PaintEvent also checks the wrapping
@ -244,7 +242,8 @@ bool pxStaticText::_updateWrapping( bool textChanged )
if (m_wrappedWidth > 1)
wrappedLabel = pxTextWrapper().Wrap(this, m_label, m_wrappedWidth).GetResult();
if( m_wrappedLabel == wrappedLabel ) return false;
if (m_wrappedLabel == wrappedLabel)
return false;
m_wrappedLabel = wrappedLabel;
return true;
@ -252,14 +251,14 @@ bool pxStaticText::_updateWrapping( bool textChanged )
void pxStaticText::UpdateWrapping(bool textChanged)
{
if( _updateWrapping( textChanged ) ) Refresh();
if (_updateWrapping(textChanged))
Refresh();
}
void pxStaticText::SetLabel(const wxString &label)
{
const bool labelChanged(label != m_label);
if( labelChanged )
{
if (labelChanged) {
m_label = label;
Refresh();
}
@ -272,14 +271,14 @@ void pxStaticText::SetLabel(const wxString& label)
wxFont pxStaticText::GetFontOk() const
{
wxFont font(GetFont());
if( !font.Ok() ) return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
if (!font.Ok())
return wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
return font;
}
bool pxStaticText::Enable(bool enabled)
{
if( _parent::Enable(enabled))
{
if (_parent::Enable(enabled)) {
Refresh();
return true;
}
@ -291,7 +290,8 @@ void pxStaticText::paintEvent(wxPaintEvent& evt)
wxPaintDC dc(this);
const int dcWidth = dc.GetSize().GetWidth();
const int dcHeight = dc.GetSize().GetHeight();
if( dcWidth < 1 ) return;
if (dcWidth < 1)
return;
dc.SetFont(GetFontOk());
if (IsEnabled())
@ -303,7 +303,8 @@ void pxStaticText::paintEvent(wxPaintEvent& evt)
writer.Align(m_align);
const wxString &label(m_autowrap ? m_wrappedLabel : m_label);
if( m_autowrap ) _updateWrapping( false );
if (m_autowrap)
_updateWrapping(false);
int tWidth, tHeight;
dc.GetMultiLineTextExtent(label, &tWidth, &tHeight);
@ -328,13 +329,10 @@ wxSize pxStaticText::DoGetBestSize() const
wxSize best;
if( m_autowrap )
{
if (m_autowrap) {
best = GetBestWrappedSize(dc);
//best.x = wxDefaultCoord;
}
else
{
} else {
// No autowrapping, so we can force a specific size here!
best = dc.GetMultiLineTextExtent(GetLabel());
best.x += calcPaddingWidth(best.x);
@ -369,7 +367,8 @@ void pxStaticHeading::SetPaddingDefaults()
void operator+=(wxSizer &target, pxStaticText *src)
{
if( src ) target.Add( src, pxExpand );
if (src)
target.Add(src, pxExpand);
}
void operator+=(wxSizer &target, pxStaticText &src)

View File

@ -37,7 +37,8 @@ bool pxStreamBase::IsOk() const
wxFileOffset pxStreamBase::Length() const
{
if (!GetWxStreamBase()) return 0;
if (!GetWxStreamBase())
return 0;
return GetWxStreamBase()->GetLength();
}
@ -86,8 +87,7 @@ void pxInputStream::SetStream( const wxString& filename, wxInputStream* stream )
void pxInputStream::Read(void *dest, size_t size)
{
m_stream_in->Read(dest, size);
if (m_stream_in->GetLastError() == wxSTREAM_READ_ERROR)
{
if (m_stream_in->GetLastError() == wxSTREAM_READ_ERROR) {
int err = errno;
if (!err)
throw Exception::BadStream(m_filename).SetDiagMsg(L"Cannot read from file (bad file handle?)");
@ -112,7 +112,6 @@ pxOutputStream::pxOutputStream(const wxString& filename, std::unique_ptr<wxOutpu
: pxStreamBase(filename)
, m_stream_out(std::move(output))
{
}
pxOutputStream::pxOutputStream(const wxString &filename, wxOutputStream *output)
@ -149,8 +148,7 @@ void pxOutputStream::SetStream( const wxString& filename, wxOutputStream* stream
void pxOutputStream::Write(const void *src, size_t size)
{
m_stream_out->Write(src, size);
if(m_stream_out->GetLastError() == wxSTREAM_WRITE_ERROR)
{
if (m_stream_out->GetLastError() == wxSTREAM_WRITE_ERROR) {
int err = errno;
if (!err)
throw Exception::BadStream(m_filename).SetDiagMsg(L"Cannot write to file/stream.");
@ -170,25 +168,30 @@ bool pxReadLine( wxInputStream& input, std::string& dest )
{
dest.clear();
bool isUTF8 = false;
while ( true )
{
while (true) {
char c;
input.Read(&c, sizeof(c));
if( c == 0 ) break;
if( input.Eof() ) break;
if( c == '\n' ) break; // eat on UNIX
if( c == '\r' )
{
if (c == 0)
break;
if (input.Eof())
break;
if (c == '\n')
break; // eat on UNIX
if (c == '\r') {
input.Read(&c, sizeof(c));
if( c == 0 ) break;
if( input.Eof() ) break;
if( c == '\n' ) break;
if (c == 0)
break;
if (input.Eof())
break;
if (c == '\n')
break;
input.Ungetch(c);
break;
}
dest += c;
if( c & 0x80 ) isUTF8 = true;
if (c & 0x80)
isUTF8 = true;
}
return isUTF8;
@ -199,12 +202,12 @@ void pxReadLine( wxInputStream& input, wxString& dest, std::string& intermed )
dest.clear();
if (pxReadLine(input, intermed))
dest = fromUTF8(intermed.c_str());
else
{
else {
// Optimized ToAscii conversion.
// wx3.0 : NOT COMPATIBLE!! (on linux anyway)
const char *ascii = intermed.c_str();
while( *ascii != 0 ) dest += (wchar_t)(unsigned char)*ascii++;
while (*ascii != 0)
dest += (wchar_t)(unsigned char)*ascii++;
}
}
@ -228,8 +231,7 @@ void pxWriteLine( wxOutputStream& output )
void pxWriteLine(wxOutputStream &output, const wxString &text)
{
if( !text.IsEmpty() )
{
if (!text.IsEmpty()) {
pxToUTF8 utf8(text);
output.Write(utf8, utf8.Length());
}
@ -238,7 +240,8 @@ void pxWriteLine( wxOutputStream& output, const wxString& text )
void pxWriteMultiline(wxOutputStream &output, const wxString &src)
{
if( src.IsEmpty() ) return;
if (src.IsEmpty())
return;
wxString result(src);
result.Replace(L"\r\n", L"\n");

View File

@ -37,10 +37,8 @@ const wxChar* __fastcall pxExpandMsg( const wxChar* englishContent )
//
const wxChar *__fastcall pxGetTranslation(const wxChar *message)
{
if( IsDevBuild )
{
if( wxStrlen( message ) > 128 )
{
if (IsDevBuild) {
if (wxStrlen(message) > 128) {
Console.Warning("pxGetTranslation: Long message detected, maybe use pxE() instead?");
Console.WriteLn(Color_Green, L"Message: %s", message);
}

View File

@ -93,12 +93,9 @@ void pxWindowTextWriter::_DoWriteLn( const wxChar* msg )
wxPoint dispos(m_curpos);
if( m_align & wxALIGN_CENTER_HORIZONTAL )
{
if (m_align & wxALIGN_CENTER_HORIZONTAL) {
dispos.x = (m_dc.GetSize().GetWidth() - tWidth) / 2;
}
else if( m_align & wxALIGN_RIGHT )
{
} else if (m_align & wxALIGN_RIGHT) {
dispos.x = m_dc.GetSize().GetWidth() - tWidth;
}

View File

@ -64,7 +64,8 @@ static const char *upper_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static size_t strnlen(const char *s, size_t count)
{
const char *sc;
for (sc = s; *sc != '\0' && count--; ++sc);
for (sc = s; *sc != '\0' && count--; ++sc)
;
return sc - s;
}
#endif
@ -78,28 +79,23 @@ static void cvt(char (&buf)[_CVTBUFSIZE], double arg, int preci, int& decpt, int
r2 = 0;
sign = 0;
p = &buf[0];
if (arg < 0)
{
if (arg < 0) {
sign = 1;
arg = -arg;
}
arg = modf(arg, &fi);
p1 = &buf[_CVTBUFSIZE];
if (fi != 0)
{
while (fi != 0)
{
if (fi != 0) {
while (fi != 0) {
fj = modf(fi / 10, &fi);
*--p1 = (int)((fj + .03) * 10) + '0';
r2++;
}
while (p1 < &buf[_CVTBUFSIZE]) *p++ = *p1++;
}
else if (arg > 0)
{
while ((fj = arg * 10) < 1)
{
while (p1 < &buf[_CVTBUFSIZE])
*p++ = *p1++;
} else if (arg > 0) {
while ((fj = arg * 10) < 1) {
arg = fj;
r2--;
}
@ -107,38 +103,34 @@ static void cvt(char (&buf)[_CVTBUFSIZE], double arg, int preci, int& decpt, int
p1 = &buf[preci];
if (eflag == 0) p1 += r2;
if (eflag == 0)
p1 += r2;
decpt = r2;
if (p1 < &buf[0])
{
if (p1 < &buf[0]) {
buf[0] = '\0';
return;
}
while (p <= p1 && p < &buf[_CVTBUFSIZE])
{
while (p <= p1 && p < &buf[_CVTBUFSIZE]) {
arg *= 10;
arg = modf(arg, &fj);
*p++ = (int)fj + '0';
}
if (p1 >= &buf[_CVTBUFSIZE])
{
if (p1 >= &buf[_CVTBUFSIZE]) {
buf[_CVTBUFSIZE - 1] = '\0';
return;
}
p = p1;
*p1 += 5;
while (*p1 > '9')
{
while (*p1 > '9') {
*p1 = '0';
if (p1 > buf)
++*--p1;
else
{
else {
*p1 = '1';
decpt++;
if (eflag == 0)
{
if (p > buf) *p = '0';
if (eflag == 0) {
if (p > buf)
*p = '0';
p++;
}
}
@ -160,7 +152,8 @@ static void fcvtbuf(char (&buf)[_CVTBUFSIZE], double arg, int preci, int& decpt,
static int skip_atoi(const char **s)
{
int i = 0;
while (is_digit(**s)) i = i*10 + *((*s)++) - '0';
while (is_digit(**s))
i = i * 10 + *((*s)++) - '0';
return i;
}
@ -171,34 +164,30 @@ static void number(std::string& dest, T num, int base, int size, int precision,
const char *dig = digits;
int i;
if (type & LARGE) dig = upper_digits;
if (type & LEFT) type &= ~ZEROPAD;
if (base < 2 || base > 36) return;
if (type & LARGE)
dig = upper_digits;
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return;
c = (type & ZEROPAD) ? '0' : ' ';
sign = 0;
if (type & SIGN)
{
if (num < 0)
{
if (type & SIGN) {
if (num < 0) {
sign = '-';
num = -num;
size--;
}
else if (type & PLUS)
{
} else if (type & PLUS) {
sign = '+';
size--;
}
else if (type & SPACE)
{
} else if (type & SPACE) {
sign = ' ';
size--;
}
}
if (type & SPECIAL)
{
if (type & SPECIAL) {
if (base == 16)
size -= 2;
else if (base == 8)
@ -209,47 +198,49 @@ static void number(std::string& dest, T num, int base, int size, int precision,
if (num == 0)
tmp[i++] = '0';
else
{
if( base == 16 )
{
while (num != 0)
{
else {
if (base == 16) {
while (num != 0) {
tmp[i++] = dig[num & 0xf];
num = (uint)num >> 4;
}
}
else
{
while (num != 0)
{
} else {
while (num != 0) {
tmp[i++] = dig[num % (uint)base];
num /= (uint)base;
}
}
}
if (i > precision) precision = i;
if (i > precision)
precision = i;
size -= precision;
if (!(type & (ZEROPAD | LEFT))) while (size-- > 0) dest += ' ';
if (sign) dest += sign;
if (!(type & (ZEROPAD | LEFT)))
while (size-- > 0)
dest += ' ';
if (sign)
dest += sign;
if (type & SPECIAL)
{
if (type & SPECIAL) {
if (base == 8)
dest += '0';
else if (base == 16)
{
else if (base == 16) {
dest += '0';
dest += digits[33];
}
}
if( !(type & LEFT) && size > 0) { dest.append( size, c ); size = 0; }
if( i < precision ) dest.append( precision-i, '0' );
while (i-- > 0) dest += tmp[i];
if( size > 0 ) dest.append( size, ' ' );
if (!(type & LEFT) && size > 0) {
dest.append(size, c);
size = 0;
}
if (i < precision)
dest.append(precision - i, '0');
while (i-- > 0)
dest += tmp[i];
if (size > 0)
dest.append(size, ' ');
//if (!(type & LEFT)) while (size-- > 0) dest += c;
//while (i < precision--) dest += '0';
@ -263,18 +254,23 @@ static void eaddr( std::string& dest, unsigned char *addr, int size, int precisi
const char *dig = digits;
int i, len;
if (type & LARGE) dig = upper_digits;
if (type & LARGE)
dig = upper_digits;
len = 0;
for (i = 0; i < 6; i++)
{
if (i != 0) tmp[len++] = ':';
for (i = 0; i < 6; i++) {
if (i != 0)
tmp[len++] = ':';
tmp[len++] = dig[addr[i] >> 4];
tmp[len++] = dig[addr[i] & 0x0F];
}
if (!(type & LEFT)) while (len < size--) dest += ' ';
for (i = 0; i < len; ++i) dest += tmp[i];
while (len < size--) dest += ' ';
if (!(type & LEFT))
while (len < size--)
dest += ' ';
for (i = 0; i < len; ++i)
dest += tmp[i];
while (len < size--)
dest += ' ';
}
static void iaddr(std::string &dest, unsigned char *addr, int size, int precision, int type)
@ -283,24 +279,20 @@ static void iaddr( std::string& dest, unsigned char *addr, int size, int precisi
int i, n, len;
len = 0;
for (i = 0; i < 4; i++)
{
if (i != 0) tmp[len++] = '.';
for (i = 0; i < 4; i++) {
if (i != 0)
tmp[len++] = '.';
n = addr[i];
if (n == 0)
tmp[len++] = digits[0];
else
{
if (n >= 100)
{
else {
if (n >= 100) {
tmp[len++] = digits[n / 100];
n = n % 100;
tmp[len++] = digits[n / 10];
n = n % 10;
}
else if (n >= 10)
{
} else if (n >= 10) {
tmp[len++] = digits[n / 10];
n = n % 10;
}
@ -309,9 +301,13 @@ static void iaddr( std::string& dest, unsigned char *addr, int size, int precisi
}
}
if (!(type & LEFT)) while (len < size--) dest += ' ';
for (i = 0; i < len; ++i) dest += tmp[i];
while (len < size--) dest += ' ';
if (!(type & LEFT))
while (len < size--)
dest += ' ';
for (i = 0; i < len; ++i)
dest += tmp[i];
while (len < size--)
dest += ' ';
}
#ifndef NOFLOAT
@ -323,58 +319,50 @@ static void cfltcvt(double value, char *buffer, char fmt, int precision)
int capexp = 0;
int magnitude;
if (fmt == 'G' || fmt == 'E')
{
if (fmt == 'G' || fmt == 'E') {
capexp = 1;
fmt += 'a' - 'A';
}
if (fmt == 'g')
{
if (fmt == 'g') {
ecvtbuf(cvtbuf, value, precision, decpt, sign);
magnitude = decpt - 1;
if (magnitude < -4 || magnitude > precision - 1)
{
if (magnitude < -4 || magnitude > precision - 1) {
fmt = 'e';
precision -= 1;
}
else
{
} else {
fmt = 'f';
precision -= decpt;
}
}
if (fmt == 'e')
{
if (fmt == 'e') {
ecvtbuf(cvtbuf, value, precision + 1, decpt, sign);
const char *digits = cvtbuf;
if (sign) *buffer++ = '-';
if (sign)
*buffer++ = '-';
*buffer++ = *digits;
if (precision > 0) *buffer++ = '.';
if (precision > 0)
*buffer++ = '.';
memcpy(buffer, digits + 1, precision);
buffer += precision;
*buffer++ = capexp ? 'E' : 'e';
if (decpt == 0)
{
if (decpt == 0) {
if (value == 0.0)
exp = 0;
else
exp = -1;
}
else
} else
exp = decpt - 1;
if (exp < 0)
{
if (exp < 0) {
*buffer++ = '-';
exp = -exp;
}
else
} else
*buffer++ = '+';
buffer[2] = (exp % 10) + '0';
@ -383,40 +371,35 @@ static void cfltcvt(double value, char *buffer, char fmt, int precision)
exp = exp / 10;
buffer[0] = (exp % 10) + '0';
buffer += 3;
}
else if (fmt == 'f')
{
} else if (fmt == 'f') {
fcvtbuf(cvtbuf, value, precision, decpt, sign);
const char *digits = cvtbuf;
if (sign) *buffer++ = '-';
if (*digits)
{
if (decpt <= 0)
{
if (sign)
*buffer++ = '-';
if (*digits) {
if (decpt <= 0) {
*buffer++ = '0';
*buffer++ = '.';
for (pos = 0; pos < -decpt; pos++) *buffer++ = '0';
while (*digits) *buffer++ = *digits++;
}
else
{
pos = 0;
for (pos = 0; pos < -decpt; pos++)
*buffer++ = '0';
while (*digits)
{
if (pos++ == decpt) *buffer++ = '.';
*buffer++ = *digits++;
} else {
pos = 0;
while (*digits) {
if (pos++ == decpt)
*buffer++ = '.';
*buffer++ = *digits++;
}
}
}
else
{
} else {
*buffer++ = '0';
if (precision > 0)
{
if (precision > 0) {
*buffer++ = '.';
for (pos = 0; pos < precision; pos++) *buffer++ = '0';
for (pos = 0; pos < precision; pos++)
*buffer++ = '0';
}
}
}
@ -426,26 +409,23 @@ static void cfltcvt(double value, char *buffer, char fmt, int precision)
static void forcdecpt(char *buffer)
{
while (*buffer)
{
if (*buffer == '.') return;
if (*buffer == 'e' || *buffer == 'E') break;
while (*buffer) {
if (*buffer == '.')
return;
if (*buffer == 'e' || *buffer == 'E')
break;
buffer++;
}
if (*buffer)
{
if (*buffer) {
int n = strlen(buffer);
while (n > 0)
{
while (n > 0) {
buffer[n + 1] = buffer[n];
n--;
}
*buffer = '.';
}
else
{
} else {
*buffer++ = '.';
*buffer = '\0';
}
@ -455,14 +435,18 @@ static void cropzeros(char *buffer)
{
char *stop;
while (*buffer && *buffer != '.') buffer++;
if (*buffer++)
{
while (*buffer && *buffer != 'e' && *buffer != 'E') buffer++;
while (*buffer && *buffer != '.')
buffer++;
if (*buffer++) {
while (*buffer && *buffer != 'e' && *buffer != 'E')
buffer++;
stop = buffer--;
while (*buffer == '0') buffer--;
if (*buffer == '.') buffer--;
while ( (*++buffer = *stop++) != 0 );
while (*buffer == '0')
buffer--;
if (*buffer == '.')
buffer--;
while ((*++buffer = *stop++) != 0)
;
}
}
@ -473,26 +457,21 @@ static void flt( std::string& dest, double num, int size, int precision, char fm
int n;
// Left align means no zero padding
if (flags & LEFT) flags &= ~ZEROPAD;
if (flags & LEFT)
flags &= ~ZEROPAD;
// Determine padding and sign char
c = (flags & ZEROPAD) ? '0' : ' ';
sign = 0;
if (flags & SIGN)
{
if (num < 0.0)
{
if (flags & SIGN) {
if (num < 0.0) {
sign = '-';
num = -num;
size--;
}
else if (flags & PLUS)
{
} else if (flags & PLUS) {
sign = '+';
size--;
}
else if (flags & SPACE)
{
} else if (flags & SPACE) {
sign = ' ';
size--;
}
@ -508,21 +487,31 @@ static void flt( std::string& dest, double num, int size, int precision, char fm
cfltcvt(num, tmp, fmt, precision);
// '#' and precision == 0 means force a decimal point
if ((flags & SPECIAL) && precision == 0) forcdecpt(tmp);
if ((flags & SPECIAL) && precision == 0)
forcdecpt(tmp);
// 'g' format means crop zero unless '#' given
if (fmt == 'g' && !(flags & SPECIAL)) cropzeros(tmp);
if (fmt == 'g' && !(flags & SPECIAL))
cropzeros(tmp);
n = strlen(tmp);
// Output number with alignment and padding
size -= n;
if (!(flags & (ZEROPAD | LEFT)) && size > 0) { dest.append( size, ' ' ); size = 0; }
if (sign) dest += sign;
if (!(flags & LEFT) && size > 0) { dest.append( size, c ); size = 0; }
if (!(flags & (ZEROPAD | LEFT)) && size > 0) {
dest.append(size, ' ');
size = 0;
}
if (sign)
dest += sign;
if (!(flags & LEFT) && size > 0) {
dest.append(size, c);
size = 0;
}
dest.append(tmp, n);
if(size > 0) dest.append( size, ' ' );
if (size > 0)
dest.append(size, ' ');
}
#endif
@ -540,10 +529,8 @@ static void vssappendf(std::string& dest, const char* format, va_list args)
int precision; // Min. # of digits for integers; max number of chars for from string
int qualifier; // 'h', 'l', or 'L' for integer fields
for( const char* fmt = format; *fmt; ++fmt )
{
if (*fmt != '%')
{
for (const char *fmt = format; *fmt; ++fmt) {
if (*fmt != '%') {
dest += *fmt;
continue;
}
@ -552,25 +539,32 @@ static void vssappendf(std::string& dest, const char* format, va_list args)
flags = 0;
repeat:
fmt++; // This also skips first '%'
switch (*fmt)
{
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
switch (*fmt) {
case '-':
flags |= LEFT;
goto repeat;
case '+':
flags |= PLUS;
goto repeat;
case ' ':
flags |= SPACE;
goto repeat;
case '#':
flags |= SPECIAL;
goto repeat;
case '0':
flags |= ZEROPAD;
goto repeat;
}
// Get field width
field_width = -1;
if (is_digit(*fmt))
field_width = skip_atoi(&fmt);
else if (*fmt == '*')
{
else if (*fmt == '*') {
fmt++;
field_width = va_arg(args, int);
if (field_width < 0)
{
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
@ -578,23 +572,21 @@ repeat:
// Get the precision
precision = -1;
if (*fmt == '.')
{
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt))
precision = skip_atoi(&fmt);
else if (*fmt == '*')
{
else if (*fmt == '*') {
++fmt;
precision = va_arg(args, int);
}
if (precision < 0) precision = 0;
if (precision < 0)
precision = 0;
}
// Get the conversion qualifier
qualifier = -1;
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' )
{
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
fmt++;
}
@ -602,39 +594,36 @@ repeat:
// Default base
base = 10;
switch (*fmt)
{
switch (*fmt) {
case 'c':
if (!(flags & LEFT)) while (--field_width > 0) dest += ' ';
if (!(flags & LEFT))
while (--field_width > 0)
dest += ' ';
dest += (unsigned char)va_arg(args, int);
while (--field_width > 0) dest += ' ';
while (--field_width > 0)
dest += ' ';
continue;
case 's':
{
case 's': {
// let's add support for std::string as a formatted parameter! (air)
if( qualifier == 'h' )
{
if (qualifier == 'h') {
static const std::string nullstring("<NULL>");
const std::string *ss = va_arg(args, std::string *);
if( ss == NULL ) ss = &nullstring;
if (ss == NULL)
ss = &nullstring;
int len = ss->length();
if( precision < 0 )
{
if (precision < 0) {
// no precision override so just copy the whole string.
if (!(flags & LEFT) && (len < field_width))
{
if (!(flags & LEFT) && (len < field_width)) {
dest.append(field_width - len, ' ');
field_width = 0;
}
dest += *ss;
}
else
{
if( len > precision ) len = precision;
if (!(flags & LEFT) && (len < field_width))
{
} else {
if (len > precision)
len = precision;
if (!(flags & LEFT) && (len < field_width)) {
dest.append(field_width - len, ' ');
field_width = 0;
}
@ -643,33 +632,33 @@ repeat:
if (len < field_width)
dest.append(field_width - len, ' ');
}
else
{
} else {
const char *s = va_arg(args, char *);
if (!s) s = "<NULL>";
if (!s)
s = "<NULL>";
int len = strlen(s);
if( precision < 0 )
{
if (!(flags & LEFT)) while (len < field_width--) dest += ' ';
if (precision < 0) {
if (!(flags & LEFT))
while (len < field_width--)
dest += ' ';
dest += s;
}
else
{
if( len > precision ) len = precision;
if (!(flags & LEFT)) while (len < field_width--) dest += ' ';
} else {
if (len > precision)
len = precision;
if (!(flags & LEFT))
while (len < field_width--)
dest += ' ';
dest.append(s, s + len);
}
while (len < field_width--) dest += ' ';
while (len < field_width--)
dest += ' ';
}
}
continue;
case 'p':
{
if (field_width == -1)
{
case 'p': {
if (field_width == -1) {
field_width = 2 * sizeof(void *);
flags |= ZEROPAD;
}
@ -679,13 +668,10 @@ repeat:
continue;
case 'n':
if (qualifier == 'l')
{
if (qualifier == 'l') {
long *ip = va_arg(args, long *);
*ip = dest.length();
}
else
{
} else {
int *ip = va_arg(args, int *);
*ip = dest.length();
}
@ -734,7 +720,8 @@ repeat:
#endif
default:
if (*fmt != '%') dest += '%';
if (*fmt != '%')
dest += '%';
if (*fmt)
dest += *fmt;
else
@ -742,13 +729,10 @@ repeat:
continue;
}
if (qualifier == 'L')
{
if (qualifier == 'L') {
// 64-bit integer support! (air)
number(dest, va_arg(args, s64), base, field_width, precision, flags);
}
else
{
} else {
s32 num;
// Modern 32 bit compilers pass parameters into va_arg by 32 bit scale always,
// so no point in using or checking for the 'h' parameter.

View File

@ -32,8 +32,7 @@ ConsoleLogSource_App::ConsoleLogSource_App()
static const TraceLogDescriptor myDesc =
{
L"AppEvents", L"App Events",
pxLt("Includes idle event processing and some other uncommon event usages.")
};
pxLt("Includes idle event processing and some other uncommon event usages.")};
m_Descriptor = &myDesc;
}
@ -59,12 +58,9 @@ void SynchronousActionState::SetException( const BaseException& ex )
void SynchronousActionState::SetException(BaseException *ex)
{
if( !m_posted )
{
if (!m_posted) {
m_exception = ScopedExcept(ex);
}
else if( wxTheApp )
{
} else if (wxTheApp) {
// transport the exception to the main thread, since the message is fully
// asynchronous, or has already entered an asynchronous state. Message is sent
// as a non-blocking action since proper handling of user errors on async messages
@ -78,7 +74,8 @@ void SynchronousActionState::SetException( BaseException* ex )
void SynchronousActionState::RethrowException() const
{
if( m_exception ) m_exception->Rethrow();
if (m_exception)
m_exception->Rethrow();
}
int SynchronousActionState::WaitForResult()
@ -108,7 +105,8 @@ void SynchronousActionState::ClearResult()
void SynchronousActionState::PostResult()
{
if( m_posted ) return;
if (m_posted)
return;
m_posted = true;
m_sema.Post();
}
@ -147,8 +145,7 @@ void pxActionEvent::SetException( BaseException* ex )
const wxString &prefix(pxsFmt(L"(%s) ", GetClassInfo()->GetClassName()));
ex->DiagMsg() = prefix + ex->DiagMsg();
if( !m_state )
{
if (!m_state) {
ScopedExcept exptr(ex); // auto-delete it after handling.
ex->Rethrow();
}
@ -200,14 +197,14 @@ pxSynchronousCommandEvent::pxSynchronousCommandEvent( const pxSynchronousCommand
void pxSynchronousCommandEvent::SetException(const BaseException &ex)
{
if( !m_sync ) ex.Rethrow();
if (!m_sync)
ex.Rethrow();
m_sync->SetException(ex);
}
void pxSynchronousCommandEvent::SetException(BaseException *ex)
{
if( !m_sync )
{
if (!m_sync) {
ScopedExcept exptr(ex); // auto-delete it after handling.
ex->Rethrow();
}
@ -261,7 +258,8 @@ public:
protected:
void InvokeEvent()
{
if( m_Method ) m_Method();
if (m_Method)
m_Method();
}
};
@ -278,7 +276,8 @@ pxExceptionEvent::pxExceptionEvent( const BaseException& ex )
void pxExceptionEvent::InvokeEvent()
{
ScopedExcept deleteMe(m_except);
if( deleteMe ) deleteMe->Rethrow();
if (deleteMe)
deleteMe->Rethrow();
}
// --------------------------------------------------------------------------------------
@ -321,7 +320,8 @@ void wxAppWithHelpers::PostIdleMethod( FnType_Void* method )
bool wxAppWithHelpers::Rpc_TryInvoke(FnType_Void *method)
{
if( wxThread::IsMain() ) return false;
if (wxThread::IsMain())
return false;
SynchronousActionState sync;
PostEvent(pxRpcEvent(method, sync));
@ -343,15 +343,15 @@ bool wxAppWithHelpers::Rpc_TryInvoke( FnType_Void* method )
//
bool wxAppWithHelpers::Rpc_TryInvokeAsync(FnType_Void *method)
{
if( wxThread::IsMain() ) return false;
if (wxThread::IsMain())
return false;
PostEvent(pxRpcEvent(method));
return true;
}
void wxAppWithHelpers::ProcessMethod(FnType_Void *method)
{
if( wxThread::IsMain() )
{
if (wxThread::IsMain()) {
method();
return;
}
@ -394,8 +394,7 @@ bool wxAppWithHelpers::ProcessEvent( pxActionEvent& evt )
{
if (wxThread::IsMain())
return _parent::ProcessEvent(evt);
else
{
else {
SynchronousActionState sync;
evt.SetSyncState(sync);
AddPendingEvent(evt);
@ -406,13 +405,10 @@ bool wxAppWithHelpers::ProcessEvent( pxActionEvent& evt )
bool wxAppWithHelpers::ProcessEvent(pxActionEvent *evt)
{
if( wxThread::IsMain() )
{
if (wxThread::IsMain()) {
std::unique_ptr<wxEvent> deleteMe(evt);
return _parent::ProcessEvent(*deleteMe);
}
else
{
} else {
SynchronousActionState sync;
evt->SetSyncState(sync);
AddPendingEvent(*evt);
@ -444,17 +440,14 @@ void pxActionEvent::_DoInvokeEvent()
try {
InvokeEvent();
}
catch( BaseException& ex )
{
} catch (BaseException &ex) {
SetException(ex);
}
catch( std::runtime_error& ex )
{
} catch (std::runtime_error &ex) {
SetException(new Exception::RuntimeError(ex));
}
if( m_state ) m_state->PostResult();
if (m_state)
m_state->PostResult();
}
void wxAppWithHelpers::OnSynchronousCommand(pxSynchronousCommandEvent &evt)
@ -466,17 +459,14 @@ void wxAppWithHelpers::OnSynchronousCommand( pxSynchronousCommandEvent& evt )
try {
ProcessEvent(evt);
}
catch( BaseException& ex )
{
} catch (BaseException &ex) {
evt.SetException(ex);
}
catch( std::runtime_error& ex )
{
} catch (std::runtime_error &ex) {
evt.SetException(new Exception::RuntimeError(ex, evt.GetClassInfo()->GetClassName()));
}
if( Semaphore* sema = evt.GetSemaphore() ) sema->Post();
if (Semaphore *sema = evt.GetSemaphore())
sema->Post();
}
void wxAppWithHelpers::AddIdleEvent(const wxEvent &evt)
@ -510,14 +500,12 @@ void wxAppWithHelpers::IdleEventDispatcher( const wxChar* action )
ScopedLock lock(m_IdleEventMutex);
while( node = m_IdleEventQueue.begin(), node != m_IdleEventQueue.end() )
{
while (node = m_IdleEventQueue.begin(), node != m_IdleEventQueue.end()) {
std::unique_ptr<wxEvent> deleteMe(*node);
m_IdleEventQueue.erase(node);
lock.Release();
if( !Threading::AllowDeletions() && (deleteMe->GetEventType() == pxEvt_DeleteThread) )
{
if (!Threading::AllowDeletions() && (deleteMe->GetEventType() == pxEvt_DeleteThread)) {
// Threads that have active semaphores or mutexes (other threads are waiting on them) cannot
// be deleted because those mutex/sema objects will become invalid and cause the pending
// thread to crash. So we disallow deletions when those waits are in action, and continue
@ -525,9 +513,7 @@ void wxAppWithHelpers::IdleEventDispatcher( const wxChar* action )
pxThreadLog.Write(((pxThread *)((wxCommandEvent *)deleteMe.get())->GetClientData())->GetName(), L"Deletion postponed due to mutex or semaphore dependency.");
postponed.push_back(deleteMe.release());
}
else
{
} else {
pxAppLog.Write(L"(AppIdleQueue%s) Dispatching event '%s'", action, deleteMe->GetClassInfo()->GetClassName());
ProcessEvent(*deleteMe); // dereference to prevent auto-deletion by ProcessEvent
}
@ -602,14 +588,12 @@ void wxAppWithHelpers::PostAction( const pxActionEvent& evt )
void wxAppWithHelpers::ProcessAction(pxActionEvent &evt)
{
if( !wxThread::IsMain() )
{
if (!wxThread::IsMain()) {
SynchronousActionState sync;
evt.SetSyncState(sync);
AddPendingEvent(evt);
sync.WaitForResult();
}
else
} else
evt._DoInvokeEvent();
}
@ -654,7 +638,8 @@ void wxAppWithHelpers::OnInvokeAction( pxActionEvent& evt )
void wxAppWithHelpers::OnDeleteObject(wxCommandEvent &evt)
{
if( evt.GetClientData() == NULL ) return;
if (evt.GetClientData() == NULL)
return;
delete (BaseDeletableObject *)evt.GetClientData();
}
@ -675,8 +660,7 @@ wxAppTraits* wxAppWithHelpers::CreateTraits()
void wxAppWithHelpers::OnDeleteThread(wxCommandEvent &evt)
{
std::unique_ptr<pxThread> thr((pxThread *)evt.GetClientData());
if( !thr )
{
if (!thr) {
pxThreadLog.Write(L"null", L"OnDeleteThread: NULL thread object received (and ignored).");
return;
}
@ -698,4 +682,3 @@ wxAppWithHelpers::wxAppWithHelpers()
tls_insurance = 1;
#endif
}

View File

@ -39,8 +39,7 @@ const pxStretchType
wxSizerFlags pxAlignmentType::Apply(wxSizerFlags flags) const
{
switch( intval )
{
switch (intval) {
case Centre:
flags.Align(flags.GetFlags() | wxALIGN_CENTRE_HORIZONTAL);
break;
@ -70,8 +69,7 @@ wxSizerFlags pxAlignmentType::Apply( wxSizerFlags flags ) const
wxSizerFlags pxStretchType::Apply(wxSizerFlags flags) const
{
switch( intval )
{
switch (intval) {
case Shrink:
//pxFail( "wxSHRINK is an ignored stretch flag." );
break;
@ -107,10 +105,14 @@ wxSizerFlags operator& ( const wxSizerFlags& _flgs, const wxSizerFlags& _flgs2 )
uint allflags = (_flgs.GetFlags() | _flgs2.GetFlags());
retval.Align(allflags & wxALIGN_MASK);
if( allflags & wxEXPAND ) retval.Expand();
if( allflags & wxSHAPED ) retval.Shaped();
if( allflags & wxFIXED_MINSIZE ) retval.FixedMinSize();
if( allflags & wxRESERVE_SPACE_EVEN_IF_HIDDEN ) retval.ReserveSpaceEvenIfHidden();
if (allflags & wxEXPAND)
retval.Expand();
if (allflags & wxSHAPED)
retval.Shaped();
if (allflags & wxFIXED_MINSIZE)
retval.FixedMinSize();
if (allflags & wxRESERVE_SPACE_EVEN_IF_HIDDEN)
retval.ReserveSpaceEvenIfHidden();
// Compounding borders is probably a fair approach:
retval.Border(allflags & wxALL, _flgs.GetBorderInPixels() + _flgs2.GetBorderInPixels());
@ -156,13 +158,15 @@ void operator+=( wxSizer& target, const pxStretchSpacer& spacer )
void operator+=(wxWindow &target, int spacer)
{
if( !pxAssert( target.GetSizer() != NULL ) ) return;
if (!pxAssert(target.GetSizer() != NULL))
return;
target.GetSizer()->AddSpacer(spacer);
}
void operator+=(wxWindow &target, const pxStretchSpacer &spacer)
{
if( !pxAssert( target.GetSizer() != NULL ) ) return;
if (!pxAssert(target.GetSizer() != NULL))
return;
target.GetSizer()->AddStretchSpacer(spacer.proportion);
}
@ -172,13 +176,15 @@ void operator+=( wxWindow& target, const pxStretchSpacer& spacer )
void operator+=(wxSizer *target, wxWindow &src)
{
if( !pxAssert( target != NULL ) ) return;
if (!pxAssert(target != NULL))
return;
target->Add(&src);
}
void operator+=(wxSizer *target, wxSizer &src)
{
if( !pxAssert( target != NULL ) ) return;
if (!pxAssert(target != NULL))
return;
target->Add(&src);
}
@ -278,7 +284,8 @@ static bool is_cjk_char(const uint ch)
// FIXME: add range from Japanese-specific and Korean-specific section if you know the
// characters are used today.
if (ch < 0x2e80) return false; // shortcut for common non-CJK
if (ch < 0x2e80)
return false; // shortcut for common non-CJK
return
// Han Ideographs: all except Supplement
@ -325,8 +332,8 @@ static bool is_cjk_char(const uint ch)
*/
static bool no_break_after(const uint ch)
{
switch( ch )
{
// clang-format off
switch (ch) {
/**
* don't break after these Japanese/Chinese characters
*/
@ -341,14 +348,15 @@ static bool no_break_after(const uint ch)
return true;
}
// clang-format on
return false;
}
static bool no_break_before(const uint ch)
{
switch(ch)
{
// clang-format off
switch (ch) {
/**
* don't break before these Japanese characters
*/
@ -375,15 +383,17 @@ static bool no_break_before(const uint ch)
* and right side of different kinds of brackets, quotes
*/
return true;
}
// clang-format on
return false;
}
pxTextWrapperBase &pxTextWrapperBase::Wrap(const wxWindow &win, const wxString &text, int widthMax)
{
if( text.IsEmpty() ) return *this;
if (text.IsEmpty())
return *this;
const wxChar *lastSpace = NULL;
bool wasWrapped = false;
@ -392,10 +402,8 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
line.Alloc(text.Length() + 12);
const wxChar *lineStart = text.wc_str();
for ( const wxChar *p = lineStart; ; p++ )
{
if ( IsStartOfNewLine() )
{
for (const wxChar *p = lineStart;; p++) {
if (IsStartOfNewLine()) {
OnNewLine();
lastSpace = NULL;
@ -407,36 +415,29 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
line.clear();
}
if ( *p == L'\n' || *p == L'\0' )
{
if (*p == L'\n' || *p == L'\0') {
wasWrapped = false;
DoOutputLine(line);
if (*p == L'\0')
break;
}
else // not EOL
{
if (is_cjk_char(*p))
{
if (!no_break_before(*p))
} else // not EOL
{
if (is_cjk_char(*p)) {
if (!no_break_before(*p)) {
if (p == lineStart || !no_break_after(*(p - 1)))
lastSpace = p;
}
}
else if ( *p == L' ' || *p == L',' || *p == L'/' )
} else if (*p == L' ' || *p == L',' || *p == L'/')
lastSpace = p;
line += *p;
if ( widthMax >= 0 && lastSpace )
{
if (widthMax >= 0 && lastSpace) {
int width;
win.GetTextExtent(line, &width, NULL);
if ( width > widthMax )
{
if (width > widthMax) {
wasWrapped = true;
// remove the last word from this line
@ -449,7 +450,6 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
if (*p != L' ')
p--;
}
}
//else: no wrapping at all or impossible to wrap
@ -486,7 +486,8 @@ pxTextWrapper& pxTextWrapper::Wrap( const wxWindow& win, const wxString& text, i
pxTextWrapper &pxTextWrapper::Wrap(const wxWindow *win, const wxString &text, int widthMax)
{
if( win ) _parent::Wrap( *win, text, widthMax );
if (win)
_parent::Wrap(*win, text, widthMax);
return *this;
}
@ -523,10 +524,10 @@ ScopedBusyCursor::ScopedBusyCursor( BusyCursorType busytype )
ScopedBusyCursor::~ScopedBusyCursor() throw()
{
if( !pxAssert( wxTheApp != NULL ) ) return;
if (!pxAssert(wxTheApp != NULL))
return;
if( !pxAssert( !m_cursorStack.empty() ) )
{
if (!pxAssert(!m_cursorStack.empty())) {
SetManualBusyCursor(m_defBusyType);
return;
}
@ -542,7 +543,8 @@ ScopedBusyCursor::~ScopedBusyCursor() throw()
void ScopedBusyCursor::SetDefault(BusyCursorType busytype)
{
if( busytype == m_defBusyType ) return;
if (busytype == m_defBusyType)
return;
m_defBusyType = busytype;
if (m_cursorStack.empty())
@ -551,11 +553,16 @@ void ScopedBusyCursor::SetDefault( BusyCursorType busytype )
void ScopedBusyCursor::SetManualBusyCursor(BusyCursorType busytype)
{
switch( busytype )
{
case Cursor_NotBusy: wxSetCursor( wxNullCursor ); break;
case Cursor_KindaBusy: wxSetCursor( StockCursors.GetArrowWait() ); break;
case Cursor_ReallyBusy: wxSetCursor( *wxHOURGLASS_CURSOR ); break;
switch (busytype) {
case Cursor_NotBusy:
wxSetCursor(wxNullCursor);
break;
case Cursor_KindaBusy:
wxSetCursor(StockCursors.GetArrowWait());
break;
case Cursor_ReallyBusy:
wxSetCursor(*wxHOURGLASS_CURSOR);
break;
}
}
@ -577,7 +584,8 @@ MoreStockCursors StockCursors;
void pxSetToolTip(wxWindow *wind, const wxString &src)
{
if( wind == NULL ) return; // Silently ignore nulls
if (wind == NULL)
return; // Silently ignore nulls
wind->SetToolTip(src);
// Make tooltips show for as long as possible on Windows. Linux (GTK) can
@ -598,7 +606,8 @@ wxFont pxGetFixedFont( int ptsize, wxFontWeight weight )
return wxFont(
ptsize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, weight, false
#ifdef __WXMSW__
,L"Lucida Console" // better than courier new (win32 only)
,
L"Lucida Console" // better than courier new (win32 only)
#endif
);
}

View File

@ -133,8 +133,7 @@ wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, const wxString& titl
: wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, cflags.GetWxWindowFlags())
{
m_hasContextHelp = cflags.hasContextHelp;
if( (int)cflags.BoxSizerOrient != 0 )
{
if ((int)cflags.BoxSizerOrient != 0) {
SetSizer(new wxBoxSizer(cflags.BoxSizerOrient));
*this += StdPadding;
}
@ -197,18 +196,17 @@ void wxDialogWithHelpers::DoAutoCenter()
// a lot since the main window is small).
bool centerfail = true;
if( wxWindow* parent = GetParent() )
{
if (wxWindow *parent = GetParent()) {
const wxSize parentSize(parent->GetSize());
if( (parentSize.x > ((int)GetSize().x * 1.5)) || (parentSize.y > ((int)GetSize().y * 1.5)) )
{
if ((parentSize.x > ((int)GetSize().x * 1.5)) || (parentSize.y > ((int)GetSize().y * 1.5))) {
CenterOnParent();
centerfail = false;
}
}
if( centerfail ) CenterOnScreen();
if (centerfail)
CenterOnScreen();
}
void wxDialogWithHelpers::SmartCenterFit()
@ -216,21 +214,19 @@ void wxDialogWithHelpers::SmartCenterFit()
Fit();
const wxString dlgName(GetDialogName());
if( dlgName.IsEmpty() )
{
DoAutoCenter(); return;
if (dlgName.IsEmpty()) {
DoAutoCenter();
return;
}
if( wxConfigBase* cfg = wxConfigBase::Get( false ) )
{
if (wxConfigBase *cfg = wxConfigBase::Get(false)) {
wxRect screenRect(GetScreenRect());
IniLoader loader(cfg);
ScopedIniGroup group(loader, L"DialogPositions");
cfg->SetRecordDefaults(false);
if( GetWindowStyle() & wxRESIZE_BORDER )
{
if (GetWindowStyle() & wxRESIZE_BORDER) {
wxSize size;
loader.Entry(dlgName + L"_Size", size, screenRect.GetSize());
SetSize(size);
@ -238,8 +234,7 @@ void wxDialogWithHelpers::SmartCenterFit()
if (!cfg->Exists(dlgName + L"_Pos"))
DoAutoCenter();
else
{
else {
wxPoint pos;
loader.Entry(dlgName + L"_Pos", pos, screenRect.GetPosition());
SetPosition(pos);
@ -263,8 +258,7 @@ int wxDialogWithHelpers::ShowModal()
// 75% larger than the fitted dialog.
bool wxDialogWithHelpers::Show(bool show)
{
if( show )
{
if (show) {
SmartCenterFit();
m_CreatedRect = GetScreenRect();
}
@ -293,18 +287,15 @@ void wxDialogWithHelpers::RememberPosition()
// ... not sure how to fix that yet. I could register a list of open windows into wxAppWithHelpers
// that systematically get closed. Seems like work, maybe later. --air
if( wxConfigBase* cfg = IsIconized() ? NULL : wxConfigBase::Get( false ) )
{
if (wxConfigBase *cfg = IsIconized() ? NULL : wxConfigBase::Get(false)) {
const wxString dlgName(GetDialogName());
const wxRect screenRect(GetScreenRect());
if( !dlgName.IsEmpty() && ( m_CreatedRect != screenRect) )
{
if (!dlgName.IsEmpty() && (m_CreatedRect != screenRect)) {
wxPoint pos(screenRect.GetPosition());
IniSaver saver(cfg);
ScopedIniGroup group(saver, L"DialogPositions");
if( GetWindowStyle() & wxRESIZE_BORDER )
{
if (GetWindowStyle() & wxRESIZE_BORDER) {
wxSize size(screenRect.GetSize());
saver.Entry(dlgName + L"_Size", size, screenRect.GetSize());
}
@ -340,8 +331,7 @@ void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply )
#ifndef GCC_4_6_LTO_COMPILATION_ISSUE
// Add the context-sensitive help button on the caption for the platforms
// which support it (currently MSW only)
if( m_hasContextHelp )
{
if (m_hasContextHelp) {
SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
#ifndef __WXMSW__
*m_extraButtonSizer += new wxContextHelpButton(this) | StdButton();
@ -365,7 +355,8 @@ void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply )
void wxDialogWithHelpers::AddOkCancel(wxSizer *sizer, bool hasApply)
{
if( sizer == NULL ) sizer = GetSizer();
if (sizer == NULL)
sizer = GetSizer();
pxAssert(sizer);
AddOkCancel(*sizer, hasApply);
}
@ -469,7 +460,8 @@ wxPanelWithHelpers& wxPanelWithHelpers::SetMinWidth( int newWidth )
int pxGetCharHeight(const wxWindow *wind, int rows)
{
if( !wind ) return 0;
if (!wind)
return 0;
wxClientDC dc(wx_const_cast(wxWindow *, wind));
dc.SetFont(wind->GetFont());
#ifdef __linux__

Some files were not shown because too many files have changed in this diff Show More