mirror of https://github.com/PCSX2/pcsx2.git
Merge pull request #1659 from PCSX2/greg/clang-format-common
reformat main common directory
This commit is contained in:
commit
259521ec3e
|
@ -71,12 +71,14 @@
|
||||||
#define KEYPRESS 1
|
#define KEYPRESS 1
|
||||||
#define KEYRELEASE 2
|
#define KEYRELEASE 2
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
int size;
|
int size;
|
||||||
s8 *data;
|
s8 *data;
|
||||||
} freezeData;
|
} freezeData;
|
||||||
|
|
||||||
typedef struct _keyEvent {
|
typedef struct _keyEvent
|
||||||
|
{
|
||||||
u32 key;
|
u32 key;
|
||||||
u32 evt;
|
u32 evt;
|
||||||
} keyEvent;
|
} keyEvent;
|
||||||
|
@ -149,7 +151,8 @@ typedef char __keyEvent_Size__[(sizeof(keyEvent) == 8)?1:-1];
|
||||||
|
|
||||||
typedef int(CALLBACK *SIOchangeSlotCB)(int slot);
|
typedef int(CALLBACK *SIOchangeSlotCB)(int slot);
|
||||||
|
|
||||||
typedef struct _cdvdSubQ {
|
typedef struct _cdvdSubQ
|
||||||
|
{
|
||||||
u8 ctrl : 4; // control and mode bits
|
u8 ctrl : 4; // control and mode bits
|
||||||
u8 mode : 4; // control and mode bits
|
u8 mode : 4; // control and mode bits
|
||||||
u8 trackNum; // current track number (1 to 99)
|
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)
|
u8 discF; // current frame offset from first track (BCD encoded)
|
||||||
} cdvdSubQ;
|
} cdvdSubQ;
|
||||||
|
|
||||||
typedef struct _cdvdTD { // NOT bcd coded
|
typedef struct _cdvdTD
|
||||||
|
{ // NOT bcd coded
|
||||||
u32 lsn;
|
u32 lsn;
|
||||||
u8 type;
|
u8 type;
|
||||||
} cdvdTD;
|
} cdvdTD;
|
||||||
|
|
||||||
typedef struct _cdvdTN {
|
typedef struct _cdvdTN
|
||||||
|
{
|
||||||
u8 strack; //number of the first track (usually 1)
|
u8 strack; //number of the first track (usually 1)
|
||||||
u8 etrack; //number of the last track
|
u8 etrack; //number of the last track
|
||||||
} cdvdTN;
|
} cdvdTN;
|
||||||
|
@ -215,7 +220,8 @@ typedef int (*DEV9handler)(void);
|
||||||
typedef void (*USBcallback)(int cycles);
|
typedef void (*USBcallback)(int cycles);
|
||||||
typedef int (*USBhandler)(void);
|
typedef int (*USBhandler)(void);
|
||||||
|
|
||||||
typedef struct _GSdriverInfo {
|
typedef struct _GSdriverInfo
|
||||||
|
{
|
||||||
char name[8];
|
char name[8];
|
||||||
void *common;
|
void *common;
|
||||||
} GSdriverInfo;
|
} GSdriverInfo;
|
||||||
|
|
|
@ -55,8 +55,7 @@ static void __forceinline PluginNullConfigure(std::wstring desc, s32 &log);
|
||||||
static void __forceinline PluginNullAbout(const wchar_t *aboutText);
|
static void __forceinline PluginNullAbout(const wchar_t *aboutText);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum FileMode
|
enum FileMode {
|
||||||
{
|
|
||||||
READ_FILE = 0,
|
READ_FILE = 0,
|
||||||
WRITE_FILE
|
WRITE_FILE
|
||||||
};
|
};
|
||||||
|
@ -70,8 +69,7 @@ struct PluginLog
|
||||||
{
|
{
|
||||||
LogFile = fopen(logname.c_str(), "w");
|
LogFile = fopen(logname.c_str(), "w");
|
||||||
|
|
||||||
if (LogFile)
|
if (LogFile) {
|
||||||
{
|
|
||||||
setvbuf(LogFile, NULL, _IONBF, 0);
|
setvbuf(LogFile, NULL, _IONBF, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -90,11 +88,14 @@ struct PluginLog
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
if (LogFile == NULL) return;
|
if (LogFile == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
if (WriteToFile) vfprintf(LogFile, fmt, list);
|
if (WriteToFile)
|
||||||
if (WriteToConsole) vfprintf(stdout, fmt, list);
|
vfprintf(LogFile, fmt, list);
|
||||||
|
if (WriteToConsole)
|
||||||
|
vfprintf(stdout, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,15 +103,20 @@ struct PluginLog
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
if (LogFile == NULL) return;
|
if (LogFile == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
if (WriteToFile) vfprintf(LogFile, fmt, list);
|
if (WriteToFile)
|
||||||
if (WriteToConsole) vfprintf(stdout, fmt, list);
|
vfprintf(LogFile, fmt, list);
|
||||||
|
if (WriteToConsole)
|
||||||
|
vfprintf(stdout, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
if (WriteToFile) fprintf(LogFile, "\n");
|
if (WriteToFile)
|
||||||
if (WriteToConsole) fprintf(stdout, "\n");
|
fprintf(LogFile, "\n");
|
||||||
|
if (WriteToConsole)
|
||||||
|
fprintf(stdout, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_MSC_VER) || !defined(UNICODE)
|
#if !defined(_MSC_VER) || !defined(UNICODE)
|
||||||
|
@ -119,7 +125,8 @@ struct PluginLog
|
||||||
va_list list;
|
va_list list;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
if (LogFile == NULL) return;
|
if (LogFile == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
vsprintf(buf, fmt, list);
|
vsprintf(buf, fmt, list);
|
||||||
|
@ -133,7 +140,8 @@ struct PluginLog
|
||||||
va_list list;
|
va_list list;
|
||||||
wchar_t buf[256];
|
wchar_t buf[256];
|
||||||
|
|
||||||
if (LogFile == NULL) return;
|
if (LogFile == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
vswprintf(buf, 256, fmt, list);
|
vswprintf(buf, 256, fmt, list);
|
||||||
|
@ -151,16 +159,14 @@ struct PluginConf
|
||||||
|
|
||||||
bool Open(std::string name, FileMode mode = READ_FILE)
|
bool Open(std::string name, FileMode mode = READ_FILE)
|
||||||
{
|
{
|
||||||
if (mode == READ_FILE)
|
if (mode == READ_FILE) {
|
||||||
{
|
|
||||||
ConfFile = fopen(name.c_str(), "r");
|
ConfFile = fopen(name.c_str(), "r");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ConfFile = fopen(name.c_str(), "w");
|
ConfFile = fopen(name.c_str(), "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfFile == NULL) return false;
|
if (ConfFile == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +195,8 @@ struct PluginConf
|
||||||
{
|
{
|
||||||
std::string buf = item + " = %d\n";
|
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);
|
vsprintf(msg, fmt, list);
|
||||||
va_end(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;
|
GtkWidget *dialog;
|
||||||
dialog = gtk_message_dialog_new(NULL,
|
dialog = gtk_message_dialog_new(NULL,
|
||||||
|
@ -265,7 +273,8 @@ static void SysMessage(const char *fmt, ...)
|
||||||
vsprintf(msg, fmt, list);
|
vsprintf(msg, fmt, list);
|
||||||
va_end(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?
|
// TODO OSX can we use WX MessageBox here or should Cocoa MessageBox used?
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,19 +38,24 @@
|
||||||
#define EXPORT_C(type) extern "C" __attribute__((externally_visible, visibility("default"))) type
|
#define EXPORT_C(type) extern "C" __attribute__((externally_visible, visibility("default"))) type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXPORT_C(u32) PS2EgetLibType(void);
|
EXPORT_C(u32)
|
||||||
EXPORT_C(u32) PS2EgetLibVersion2(u32 type);
|
PS2EgetLibType(void);
|
||||||
EXPORT_C(char*) PS2EgetLibName(void);
|
EXPORT_C(u32)
|
||||||
|
PS2EgetLibVersion2(u32 type);
|
||||||
|
EXPORT_C(char *)
|
||||||
|
PS2EgetLibName(void);
|
||||||
|
|
||||||
// Extended functions.
|
// Extended functions.
|
||||||
|
|
||||||
// allows the plugin to see the whole configuration when started up.
|
// 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.
|
// 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
|
// Alternately, this function serves the same purpose, but would work for emulators outside
|
||||||
// of pcsx2.
|
// of pcsx2.
|
||||||
EXPORT_C_(void) PS2EpassIniPath(const char *path);
|
EXPORT_C_(void)
|
||||||
|
PS2EpassIniPath(const char *path);
|
||||||
|
|
||||||
// PS2EgetLibType returns (may be OR'd)
|
// PS2EgetLibType returns (may be OR'd)
|
||||||
enum {
|
enum {
|
||||||
|
@ -83,13 +88,15 @@ FREEZE_SAVE = 1,
|
||||||
FREEZE_SIZE = 2
|
FREEZE_SIZE = 2
|
||||||
} FreezeModes;
|
} FreezeModes;
|
||||||
|
|
||||||
typedef struct _GSdriverInfo {
|
typedef struct _GSdriverInfo
|
||||||
|
{
|
||||||
char name[8];
|
char name[8];
|
||||||
void *common;
|
void *common;
|
||||||
} GSdriverInfo;
|
} GSdriverInfo;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#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;
|
HWND hWnd;
|
||||||
HMENU hMenu;
|
HMENU hMenu;
|
||||||
HWND hStatusWnd;
|
HWND hStatusWnd;
|
||||||
|
|
|
@ -174,8 +174,7 @@ extern "C" {
|
||||||
// Plugin Type / Version Enumerations
|
// Plugin Type / Version Enumerations
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
enum PS2E_ComponentTypes
|
enum PS2E_ComponentTypes {
|
||||||
{
|
|
||||||
PS2E_TYPE_GS = 0,
|
PS2E_TYPE_GS = 0,
|
||||||
PS2E_TYPE_PAD,
|
PS2E_TYPE_PAD,
|
||||||
PS2E_TYPE_SPU2,
|
PS2E_TYPE_SPU2,
|
||||||
|
@ -187,8 +186,7 @@ enum PS2E_ComponentTypes
|
||||||
PS2E_TYPE_Mcd,
|
PS2E_TYPE_Mcd,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PluginLibVersion
|
enum PluginLibVersion {
|
||||||
{
|
|
||||||
PS2E_VER_GS = 0x1000,
|
PS2E_VER_GS = 0x1000,
|
||||||
PS2E_VER_PAD = 0x1000,
|
PS2E_VER_PAD = 0x1000,
|
||||||
PS2E_VER_SPU2 = 0x1000,
|
PS2E_VER_SPU2 = 0x1000,
|
||||||
|
@ -199,8 +197,7 @@ enum PluginLibVersion
|
||||||
PS2E_VER_SIO = 0x1000
|
PS2E_VER_SIO = 0x1000
|
||||||
};
|
};
|
||||||
|
|
||||||
enum OSDIconTypes
|
enum OSDIconTypes {
|
||||||
{
|
|
||||||
OSD_Icon_None = 0,
|
OSD_Icon_None = 0,
|
||||||
OSD_Icon_Error,
|
OSD_Icon_Error,
|
||||||
OSD_Icon_Notice, // An exclamation point maybe?
|
OSD_Icon_Notice, // An exclamation point maybe?
|
||||||
|
@ -215,8 +212,7 @@ enum OSDIconTypes
|
||||||
OSD_Icon_ReserveEnd = 0x1000
|
OSD_Icon_ReserveEnd = 0x1000
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PS2E_MenuItemStyle
|
enum PS2E_MenuItemStyle {
|
||||||
{
|
|
||||||
MenuType_Normal = 0,
|
MenuType_Normal = 0,
|
||||||
MenuType_Checked,
|
MenuType_Checked,
|
||||||
MenuType_Radio,
|
MenuType_Radio,
|
||||||
|
@ -386,7 +382,8 @@ typedef struct _PS2E_MenuItemAPI
|
||||||
// Returns:
|
// Returns:
|
||||||
// TRUE if the image was loaded successfully, or FALSE if the image was not found,
|
// 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).
|
// 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
|
// 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
|
// the operating system platform). Image is loaded from memory using a memory stream
|
||||||
|
@ -395,7 +392,8 @@ typedef struct _PS2E_MenuItemAPI
|
||||||
// Returns:
|
// Returns:
|
||||||
// TRUE if the image was loaded successfully, or FALSE if the image data is invalid
|
// TRUE if the image was loaded successfully, or FALSE if the image data is invalid
|
||||||
// (not a PNG, or data corrupted).
|
// (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.
|
// Assigns the menu item's style.
|
||||||
void(PS2E_CALLBACK *MenuItem_SetStyle)(PS2E_MenuItemHandle mitem, PS2E_MenuItemStyle 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);
|
void(PS2E_CALLBACK *MenuItem_Enable)(PS2E_MenuItemHandle mitem, BOOL enable);
|
||||||
|
|
||||||
// Returns the current enable status of the specified menu item.
|
// 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];
|
void *reserved[4];
|
||||||
|
|
||||||
|
@ -526,7 +525,8 @@ typedef struct _PS2E_EmulatorInfo
|
||||||
// Returns:
|
// Returns:
|
||||||
// 0 - Value was retrieved successfully.
|
// 0 - Value was retrieved successfully.
|
||||||
// 1 - Unknown value. Contents of dest are unchanged.
|
// 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
|
// GetBoolean
|
||||||
// Assigns *dest either 1 (true) or 0 (false). Note to Emulators: Returning any non-
|
// Assigns *dest either 1 (true) or 0 (false). Note to Emulators: Returning any non-
|
||||||
|
@ -536,7 +536,8 @@ typedef struct _PS2E_EmulatorInfo
|
||||||
// Returns:
|
// Returns:
|
||||||
// 0 - Value was retrieved successfully.
|
// 0 - Value was retrieved successfully.
|
||||||
// 1 - Unknown value. Contents of dest are unchanged.
|
// 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
|
// GetString
|
||||||
// Copies an ASCII-Z string into the dest pointer, to max length allowed. The result
|
// Copies an ASCII-Z string into the dest pointer, to max length allowed. The result
|
||||||
|
@ -546,7 +547,8 @@ typedef struct _PS2E_EmulatorInfo
|
||||||
// Returns:
|
// Returns:
|
||||||
// 0 - Value was retrieved successfully.
|
// 0 - Value was retrieved successfully.
|
||||||
// 1 - Unknown value. Contents of dest are unchanged.
|
// 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
|
// GetStringAlloc
|
||||||
// Provides an alternative to GetString, that can retrieve strings of arbitrary length.
|
// 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-
|
// have provisions in its interface to allow for the forced disabling of extended CPU cap-
|
||||||
// abilities, for testing purposes.
|
// 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
|
// NewComponentInstance
|
||||||
// The emulator calls this function to fetch the API for the requested component.
|
// 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
|
// Plugins may optionally prepare more detailed information on why the plugin failed
|
||||||
// it's availability test which the emu can request via GetLastError.
|
// 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
|
// DeleteComponentInstance
|
||||||
// Called by the emulator when the plugin component is to be shutdown. The component API
|
// 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
|
// Returns TRUE if the snapshot succeeded, or FALSE if it failed (contents of dest
|
||||||
// are considered indeterminate and will be ignored by the emu).
|
// 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
|
// OSD_QueueMessage
|
||||||
// Queues a message to the GS for display to the user. The GS can print the message
|
// 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
|
// (if any critical errors accumulated during GStransferTags or GStransferImage, they
|
||||||
// should also be handled here by returning FALSE)
|
// should also be handled here by returning FALSE)
|
||||||
//
|
//
|
||||||
BOOL (PS2E_CALLBACK* GsVsync)(int field);
|
BOOL(PS2E_CALLBACK *GsVsync)
|
||||||
|
(int field);
|
||||||
|
|
||||||
// GSwriteRegs
|
// GSwriteRegs
|
||||||
// Sends a GIFtag and associated register data. This is the main transfer method for all
|
// 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:
|
// Returns:
|
||||||
// False if the card is not available, or True if it is available.
|
// 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)
|
// McdGetSectorSize (can be NULL)
|
||||||
// Requests memorycard formatting information from the Mcd provider. See the description of
|
// 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
|
// False on failure, and True on success. Emulator may use GetLastError to retrieve additional
|
||||||
// information for logging or displaying to the user.
|
// 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
|
// McdSave
|
||||||
// Saves the provided block of data to the memorycard at the specified seek address.
|
// 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
|
// False on failure, and True on success. Emulator may use GetLastError to retrieve additional
|
||||||
// information for logging or displaying to the user.
|
// 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
|
// McdEraseBlock
|
||||||
// Saves "cleared" data to the memorycard at the specified seek address. Cleared data
|
// 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
|
// False on failure, and True on success. Emulator may use GetLastError to retrieve additional
|
||||||
// information for logging or displaying to the user.
|
// 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);
|
u64(PS2E_CALLBACK *McdGetCRC)(PS2E_THISPTR thisptr, uint port, uint slot);
|
||||||
|
|
||||||
|
@ -1120,14 +1130,12 @@ typedef struct _PS2E_ComponentAPI_Mcd
|
||||||
// KeyEvent type enumerations
|
// KeyEvent type enumerations
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
enum PS2E_KeyEventTypes
|
enum PS2E_KeyEventTypes {
|
||||||
{
|
|
||||||
PS2E_KEY_UP = 0,
|
PS2E_KEY_UP = 0,
|
||||||
PS2E_KEY_DOWN
|
PS2E_KEY_DOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PS2E_KeyModifiers
|
enum PS2E_KeyModifiers {
|
||||||
{
|
|
||||||
PS2E_SHIFT = 1,
|
PS2E_SHIFT = 1,
|
||||||
PS2E_CONTROL = 2,
|
PS2E_CONTROL = 2,
|
||||||
PS2E_ALT = 4
|
PS2E_ALT = 4
|
||||||
|
@ -1176,7 +1184,8 @@ typedef struct _PS2E_ComponentAPI_Pad
|
||||||
// Returns:
|
// Returns:
|
||||||
// False if the card/pad is not available, or True if it is available.
|
// 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
|
// PadStartPoll
|
||||||
// Called by the emulator to start polling the specified pad.
|
// Called by the emulator to start polling the specified pad.
|
||||||
|
|
|
@ -37,4 +37,3 @@ public:
|
||||||
wxStandardPaths &GetStandardPaths();
|
wxStandardPaths &GetStandardPaths();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -155,8 +155,12 @@ extern pxDoAssertFnType* pxDoAssert;
|
||||||
#define pxAssumeMsg(cond, msg) (__assume(cond))
|
#define pxAssumeMsg(cond, msg) (__assume(cond))
|
||||||
#define pxAssumeDev(cond, msg) (__assume(cond))
|
#define pxAssumeDev(cond, msg) (__assume(cond))
|
||||||
|
|
||||||
# define pxFail(msg) do{} while(0)
|
#define pxFail(msg) \
|
||||||
# define pxFailDev(msg) do{} while(0)
|
do { \
|
||||||
|
} while (0)
|
||||||
|
#define pxFailDev(msg) \
|
||||||
|
do { \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -199,8 +203,7 @@ extern void pxOnAssert( const DiagnosticOrigin& origin, const FastFormatUnicode&
|
||||||
//
|
//
|
||||||
#ifndef jNO_DEFAULT
|
#ifndef jNO_DEFAULT
|
||||||
#define jNO_DEFAULT \
|
#define jNO_DEFAULT \
|
||||||
default: \
|
default: { \
|
||||||
{ \
|
|
||||||
pxAssumeDev(0, "Incorrect usage of jNO_DEFAULT detected (default case is not unreachable!)"); \
|
pxAssumeDev(0, "Incorrect usage of jNO_DEFAULT detected (default case is not unreachable!)"); \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
|
|
||||||
#include "StringHelpers.h"
|
#include "StringHelpers.h"
|
||||||
|
|
||||||
enum ConsoleColors
|
enum ConsoleColors {
|
||||||
{
|
|
||||||
Color_Current = -1,
|
Color_Current = -1,
|
||||||
|
|
||||||
Color_Default = 0,
|
Color_Default = 0,
|
||||||
|
|
|
@ -62,23 +62,47 @@
|
||||||
// EnumToString(value);
|
// EnumToString(value);
|
||||||
//
|
//
|
||||||
#define ImplementEnumOperators(enumName) \
|
#define ImplementEnumOperators(enumName) \
|
||||||
static __fi enumName& operator++ ( enumName& src ) { src = (enumName)((int)src+1); return src; } \
|
static __fi enumName &operator++(enumName &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; } \
|
src = (enumName)((int)src + 1); \
|
||||||
static __fi enumName operator-- ( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src-1); return orig; } \
|
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 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 ) { \
|
static __fi bool EnumIsValid(enumName id) \
|
||||||
return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); } \
|
{ \
|
||||||
static __fi void EnumAssert( enumName id ) { \
|
return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); \
|
||||||
pxAssert( EnumIsValid(id) ); } \
|
} \
|
||||||
|
static __fi void EnumAssert(enumName id) \
|
||||||
|
{ \
|
||||||
|
pxAssert(EnumIsValid(id)); \
|
||||||
|
} \
|
||||||
\
|
\
|
||||||
extern const wxChar *EnumToString(enumName id)
|
extern const wxChar *EnumToString(enumName id)
|
||||||
|
|
||||||
class pxEnumEnd_t { };
|
class pxEnumEnd_t
|
||||||
|
{
|
||||||
|
};
|
||||||
static const pxEnumEnd_t pxEnumEnd = {};
|
static const pxEnumEnd_t pxEnumEnd = {};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -52,8 +52,7 @@ protected:
|
||||||
//
|
//
|
||||||
void _loadImage()
|
void _loadImage()
|
||||||
{
|
{
|
||||||
if( !m_Image.Ok() )
|
if (!m_Image.Ok()) {
|
||||||
{
|
|
||||||
wxMemoryInputStream joe(ImageType::Data, ImageType::Length);
|
wxMemoryInputStream joe(ImageType::Data, ImageType::Length);
|
||||||
m_Image.LoadFile(joe, ImageType::GetFormat());
|
m_Image.LoadFile(joe, ImageType::GetFormat());
|
||||||
|
|
||||||
|
@ -63,8 +62,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EmbeddedImage() :
|
EmbeddedImage()
|
||||||
m_Image()
|
: m_Image()
|
||||||
, m_ResampleTo(wxDefaultSize)
|
, m_ResampleTo(wxDefaultSize)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -78,8 +77,8 @@ public:
|
||||||
// sampling images (basically resembles a pixel resize). ResampleBox produces much cleaner
|
// sampling images (basically resembles a pixel resize). ResampleBox produces much cleaner
|
||||||
// results.
|
// results.
|
||||||
//
|
//
|
||||||
EmbeddedImage( int newWidth, int newHeight ) :
|
EmbeddedImage(int newWidth, int newHeight)
|
||||||
m_Image()
|
: m_Image()
|
||||||
, m_ResampleTo(newWidth, newHeight)
|
, m_ResampleTo(newWidth, newHeight)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -119,4 +118,3 @@ public:
|
||||||
return m_Image;
|
return m_Image;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -57,13 +57,15 @@ public:
|
||||||
|
|
||||||
void Add(ListenerType *listener)
|
void Add(ListenerType *listener)
|
||||||
{
|
{
|
||||||
if( listener == NULL ) return;
|
if (listener == NULL)
|
||||||
|
return;
|
||||||
Add(*listener);
|
Add(*listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Remove(ListenerType *listener)
|
void Remove(ListenerType *listener)
|
||||||
{
|
{
|
||||||
if( listener == NULL ) return;
|
if (listener == NULL)
|
||||||
|
return;
|
||||||
Remove(*listener);
|
Remove(*listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,11 @@ typename EventSource<ListenerType>::ListenerIterator EventSource<ListenerType>::
|
||||||
ScopedLock locker(m_listeners_lock);
|
ScopedLock locker(m_listeners_lock);
|
||||||
|
|
||||||
// Check for duplicates before adding the event.
|
// Check for duplicates before adding the event.
|
||||||
if( IsDebugBuild )
|
if (IsDebugBuild) {
|
||||||
{
|
|
||||||
ListenerIterator iter = m_listeners.begin();
|
ListenerIterator iter = m_listeners.begin();
|
||||||
while( iter != m_listeners.end() )
|
while (iter != m_listeners.end()) {
|
||||||
{
|
if ((*iter) == &listener)
|
||||||
if( (*iter) == &listener ) return iter;
|
return iter;
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,24 +64,17 @@ typename EventSource<ListenerType>::ListenerIterator EventSource<ListenerType>::
|
||||||
template <typename ListenerType>
|
template <typename ListenerType>
|
||||||
__fi void EventSource<ListenerType>::_DispatchRaw(ListenerIterator iter, const ListenerIterator &iend, const EvtParams &evtparams)
|
__fi void EventSource<ListenerType>::_DispatchRaw(ListenerIterator iter, const ListenerIterator &iend, const EvtParams &evtparams)
|
||||||
{
|
{
|
||||||
while( iter != iend )
|
while (iter != iend) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
(*iter)->DispatchEvent(evtparams);
|
(*iter)->DispatchEvent(evtparams);
|
||||||
}
|
} catch (Exception::RuntimeError &ex) {
|
||||||
catch( Exception::RuntimeError& ex )
|
|
||||||
{
|
|
||||||
if (IsDevBuild) {
|
if (IsDevBuild) {
|
||||||
pxFailDev(L"Ignoring runtime error thrown from event listener (event listeners should not throw exceptions!): " + ex.FormatDiagnosticMessage());
|
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());
|
Console.Error(L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage());
|
||||||
}
|
}
|
||||||
}
|
} catch (BaseException &ex) {
|
||||||
catch( BaseException& ex )
|
if (IsDevBuild) {
|
||||||
{
|
|
||||||
if( IsDevBuild )
|
|
||||||
{
|
|
||||||
ex.DiagMsg() = L"Non-runtime BaseException thrown from event listener .. " + ex.DiagMsg();
|
ex.DiagMsg() = L"Non-runtime BaseException thrown from event listener .. " + ex.DiagMsg();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
@ -95,12 +87,12 @@ __fi void EventSource<ListenerType>::_DispatchRaw( ListenerIterator iter, const
|
||||||
template <typename ListenerType>
|
template <typename ListenerType>
|
||||||
void EventSource<ListenerType>::Dispatch(const EvtParams &evtparams)
|
void EventSource<ListenerType>::Dispatch(const EvtParams &evtparams)
|
||||||
{
|
{
|
||||||
if( !m_cache_valid )
|
if (!m_cache_valid) {
|
||||||
{
|
|
||||||
m_cache_copy = m_listeners;
|
m_cache_copy = m_listeners;
|
||||||
m_cache_valid = true;
|
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);
|
_DispatchRaw(m_cache_copy.begin(), m_cache_copy.end(), evtparams);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,8 @@ void pxTrap();
|
||||||
fprintf(stderr, "ERROR: (out of memory?)\n"); \
|
fprintf(stderr, "ERROR: (out of memory?)\n"); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
catch(...) { \
|
catch (...) \
|
||||||
|
{ \
|
||||||
/* Unreachable code */ \
|
/* Unreachable code */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +155,7 @@ namespace Exception
|
||||||
#define DEFINE_EXCEPTION_COPYTORS(classname, parent) \
|
#define DEFINE_EXCEPTION_COPYTORS(classname, parent) \
|
||||||
private: \
|
private: \
|
||||||
typedef parent _parent; \
|
typedef parent _parent; \
|
||||||
|
\
|
||||||
public: \
|
public: \
|
||||||
virtual ~classname() throw() {} \
|
virtual ~classname() throw() {} \
|
||||||
virtual void Rethrow() const { throw * this; } \
|
virtual void Rethrow() const { throw * this; } \
|
||||||
|
@ -161,9 +163,21 @@ public: \
|
||||||
|
|
||||||
#define DEFINE_EXCEPTION_MESSAGES(classname) \
|
#define DEFINE_EXCEPTION_MESSAGES(classname) \
|
||||||
public: \
|
public: \
|
||||||
classname& SetBothMsgs( const wxChar* msg_diag ) { BaseException::SetBothMsgs(msg_diag); return *this; } \
|
classname &SetBothMsgs(const wxChar *msg_diag) \
|
||||||
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; }
|
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 DEFINE_RUNTIME_EXCEPTION(classname, parent, message) \
|
||||||
DEFINE_EXCEPTION_COPYTORS(classname, parent) \
|
DEFINE_EXCEPTION_COPYTORS(classname, parent) \
|
||||||
|
@ -271,12 +285,21 @@ public: \
|
||||||
// ---------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#define DEFINE_STREAM_EXCEPTION_ACCESSORS(classname) \
|
#define DEFINE_STREAM_EXCEPTION_ACCESSORS(classname) \
|
||||||
virtual classname& SetStreamName( const wxString& name ) { StreamName = name; return *this; } \
|
virtual classname &SetStreamName(const wxString &name) \
|
||||||
virtual classname& SetStreamName( const char* name ) { StreamName = fromUTF8(name); return *this; }
|
{ \
|
||||||
|
StreamName = name; \
|
||||||
|
return *this; \
|
||||||
|
} \
|
||||||
|
virtual classname &SetStreamName(const char *name) \
|
||||||
|
{ \
|
||||||
|
StreamName = fromUTF8(name); \
|
||||||
|
return *this; \
|
||||||
|
}
|
||||||
|
|
||||||
#define DEFINE_STREAM_EXCEPTION(classname, parent) \
|
#define DEFINE_STREAM_EXCEPTION(classname, parent) \
|
||||||
DEFINE_RUNTIME_EXCEPTION(classname, parent, wxEmptyString) \
|
DEFINE_RUNTIME_EXCEPTION(classname, parent, wxEmptyString) \
|
||||||
classname( const wxString& filename ) { \
|
classname(const wxString &filename) \
|
||||||
|
{ \
|
||||||
StreamName = filename; \
|
StreamName = filename; \
|
||||||
} \
|
} \
|
||||||
DEFINE_STREAM_EXCEPTION_ACCESSORS(classname)
|
DEFINE_STREAM_EXCEPTION_ACCESSORS(classname)
|
||||||
|
|
|
@ -122,8 +122,16 @@ bool FixedInt<Precision>::OverflowCheck( double signedval )
|
||||||
return (signedval >= (INT_MAX / Precision));
|
return (signedval >= (INT_MAX / Precision));
|
||||||
}
|
}
|
||||||
|
|
||||||
template< int Precision > int FixedInt<Precision>::GetWhole() const { return Raw / Precision; }
|
template <int Precision>
|
||||||
template< int Precision > int FixedInt<Precision>::GetFraction() const { return Raw % Precision; }
|
int FixedInt<Precision>::GetWhole() const
|
||||||
|
{
|
||||||
|
return Raw / Precision;
|
||||||
|
}
|
||||||
|
template <int Precision>
|
||||||
|
int FixedInt<Precision>::GetFraction() const
|
||||||
|
{
|
||||||
|
return Raw % Precision;
|
||||||
|
}
|
||||||
|
|
||||||
template <int Precision>
|
template <int Precision>
|
||||||
FixedInt<Precision> &FixedInt<Precision>::SetRaw(s32 rawsrc)
|
FixedInt<Precision> &FixedInt<Precision>::SetRaw(s32 rawsrc)
|
||||||
|
@ -163,7 +171,8 @@ wxString FixedInt<Precision>::ToString() const
|
||||||
template <int Precision>
|
template <int Precision>
|
||||||
wxString FixedInt<Precision>::ToString(int fracDigits) const
|
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.
|
pxAssert(fracDigits <= 7); // higher numbers would just cause overflows and bad mojo.
|
||||||
int mulby = (int)pow(10.0, fracDigits);
|
int mulby = (int)pow(10.0, fracDigits);
|
||||||
|
@ -209,12 +218,12 @@ bool FixedInt<Precision>::TryFromString( FixedInt<Precision>& dest, const wxStri
|
||||||
if (!afterFirst.IsEmpty())
|
if (!afterFirst.IsEmpty())
|
||||||
success = success && afterFirst.ToLong(&frac);
|
success = success && afterFirst.ToLong(&frac);
|
||||||
|
|
||||||
if( !success ) return false;
|
if (!success)
|
||||||
|
return false;
|
||||||
|
|
||||||
dest.SetWhole(whole);
|
dest.SetWhole(whole);
|
||||||
|
|
||||||
if( afterFirst.Length() != 0 && frac != 0 )
|
if (afterFirst.Length() != 0 && frac != 0) {
|
||||||
{
|
|
||||||
int fracPower = (int)pow(10.0, (int)afterFirst.Length());
|
int fracPower = (int)pow(10.0, (int)afterFirst.Length());
|
||||||
dest.SetFraction((frac * Precision) / fracPower);
|
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> FixedInt<Precision>::FromString(const wxString &parseFrom, const FixedInt<Precision> &defval)
|
||||||
{
|
{
|
||||||
FixedInt<Precision> dest;
|
FixedInt<Precision> dest;
|
||||||
if( !TryFromString( dest, parseFrom ) ) return defval;
|
if (!TryFromString(dest, parseFrom))
|
||||||
|
return defval;
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +244,8 @@ template< int Precision >
|
||||||
FixedInt<Precision> FixedInt<Precision>::FromString(const wxString parseFrom)
|
FixedInt<Precision> FixedInt<Precision>::FromString(const wxString parseFrom)
|
||||||
{
|
{
|
||||||
FixedInt<Precision> dest;
|
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));
|
.SetDiagMsg(wxsFormat(L"Parse error on FixedInt<%d>::FromString", Precision));
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
|
|
|
@ -22,11 +22,17 @@
|
||||||
// Macro used for removing some of the redtape involved in defining bitfield/union helpers.
|
// Macro used for removing some of the redtape involved in defining bitfield/union helpers.
|
||||||
//
|
//
|
||||||
#define BITFIELD32() \
|
#define BITFIELD32() \
|
||||||
union { \
|
union \
|
||||||
|
{ \
|
||||||
u32 bitset; \
|
u32 bitset; \
|
||||||
struct {
|
struct \
|
||||||
|
{
|
||||||
|
|
||||||
#define BITFIELD_END }; };
|
#define BITFIELD_END \
|
||||||
|
} \
|
||||||
|
; \
|
||||||
|
} \
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
|
@ -44,11 +50,16 @@ class RecursionGuard
|
||||||
public:
|
public:
|
||||||
int &Counter;
|
int &Counter;
|
||||||
|
|
||||||
RecursionGuard( int& counter ) : Counter( counter )
|
RecursionGuard(int &counter)
|
||||||
{ ++Counter; }
|
: Counter(counter)
|
||||||
|
{
|
||||||
|
++Counter;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~RecursionGuard() throw()
|
virtual ~RecursionGuard() throw()
|
||||||
{ --Counter; }
|
{
|
||||||
|
--Counter;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsReentrant() const { return Counter > 1; }
|
bool IsReentrant() const { return Counter > 1; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace HashTools {
|
namespace HashTools
|
||||||
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Type that represents a hashcode; returned by all hash functions.
|
/// Type that represents a hashcode; returned by all hash functions.
|
||||||
|
@ -27,6 +28,4 @@ namespace HashTools {
|
||||||
typedef u32 hash_key_t;
|
typedef u32 hash_key_t;
|
||||||
|
|
||||||
hash_key_t Hash(const char *data, int len);
|
hash_key_t Hash(const char *data, int len);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,11 @@ public:
|
||||||
void SetPath(const wxString &path);
|
void SetPath(const wxString &path);
|
||||||
void Flush();
|
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; }
|
bool IsOk() const { return m_Config != NULL; }
|
||||||
|
|
||||||
virtual bool IsLoading() const = 0;
|
virtual bool IsLoading() const = 0;
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
#include "Pcsx2Defs.h"
|
#include "Pcsx2Defs.h"
|
||||||
|
|
||||||
// On GCC >= 4.7, this is equivalent to __builtin_clrsb(n);
|
// 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 the sign bit is 1, we invert the bits to 0 for count-leading-zero.
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
n = ~n;
|
n = ~n;
|
||||||
|
@ -38,4 +39,3 @@ inline u32 count_leading_sign_bits(s32 n) {
|
||||||
return __builtin_clz(n);
|
return __builtin_clz(n);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
|
|
||||||
#include <xmmintrin.h>
|
#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>
|
template <u8 data>
|
||||||
__noinline void memset_sse_a(void *dest, const size_t size)
|
__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;
|
__m128 srcreg;
|
||||||
|
|
||||||
if (data != 0)
|
if (data != 0) {
|
||||||
{
|
|
||||||
static __aligned16 const u8 loadval[8] = {data, data, data, data, data, data, data, data};
|
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);
|
srcreg = _mm_loadh_pi(_mm_load_ps((float *)loadval), (__m64 *)loadval);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
srcreg = _mm_setzero_ps();
|
srcreg = _mm_setzero_ps();
|
||||||
|
|
||||||
float(*destxmm)[4] = (float(*)[4])dest;
|
float(*destxmm)[4] = (float(*)[4])dest;
|
||||||
|
|
||||||
switch( MZFqwc & 0x07 )
|
switch (MZFqwc & 0x07) {
|
||||||
{
|
|
||||||
StoreDestIdx(0x07);
|
StoreDestIdx(0x07);
|
||||||
StoreDestIdx(0x06);
|
StoreDestIdx(0x06);
|
||||||
StoreDestIdx(0x05);
|
StoreDestIdx(0x05);
|
||||||
|
@ -50,8 +49,7 @@ __noinline void memset_sse_a( void* dest, const size_t size )
|
||||||
}
|
}
|
||||||
|
|
||||||
destxmm += (MZFqwc & 0x07);
|
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[0][0], srcreg);
|
||||||
_mm_store_ps(&destxmm[1][0], srcreg);
|
_mm_store_ps(&destxmm[1][0], srcreg);
|
||||||
_mm_store_ps(&destxmm[2][0], srcreg);
|
_mm_store_ps(&destxmm[2][0], srcreg);
|
||||||
|
|
|
@ -94,7 +94,6 @@ protected:
|
||||||
{
|
{
|
||||||
Owner->OnPageFaultEvent(info, handled);
|
Owner->OnPageFaultEvent(info, handled);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
@ -109,7 +108,10 @@ protected:
|
||||||
bool m_handled;
|
bool m_handled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrcType_PageFault() : m_handled(false) {}
|
SrcType_PageFault()
|
||||||
|
: m_handled(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
virtual ~SrcType_PageFault() throw() {}
|
virtual ~SrcType_PageFault() throw() {}
|
||||||
|
|
||||||
bool WasHandled() const { return m_handled; }
|
bool WasHandled() const { return m_handled; }
|
||||||
|
@ -254,7 +256,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// This function is called from OnPageFaultEvent after the address has been translated
|
// This function is called from OnPageFaultEvent after the address has been translated
|
||||||
// and confirmed to apply to this reserved area in question. OnPageFaultEvent contains
|
// and confirmed to apply to this reserved area in question. OnPageFaultEvent contains
|
||||||
// a try/catch exception handler, which ensures "reasonable" error response behavior if
|
// 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);
|
extern int SysPageFaultExceptionFilter(struct _EXCEPTION_POINTERS *eps);
|
||||||
|
|
||||||
#define PCSX2_PAGEFAULT_PROTECT __try
|
#define PCSX2_PAGEFAULT_PROTECT __try
|
||||||
# define PCSX2_PAGEFAULT_EXCEPT __except(SysPageFaultExceptionFilter(GetExceptionInformation())) {}
|
#define PCSX2_PAGEFAULT_EXCEPT \
|
||||||
|
__except (SysPageFaultExceptionFilter(GetExceptionInformation())) {}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error PCSX2 - Unsupported operating system platform.
|
#error PCSX2 - Unsupported operating system platform.
|
||||||
|
@ -294,4 +296,3 @@ extern void _platform_InstallSignalHandler();
|
||||||
#include "Threading.h"
|
#include "Threading.h"
|
||||||
extern SrcType_PageFault *Source_PageFault;
|
extern SrcType_PageFault *Source_PageFault;
|
||||||
extern Threading::Mutex PageFault_Mutex;
|
extern Threading::Mutex PageFault_Mutex;
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,14 @@ public:
|
||||||
Assign(src.GetPath(), wxEmptyString);
|
Assign(src.GetPath(), wxEmptyString);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDirName() : wxFileName() {}
|
wxDirName()
|
||||||
wxDirName( const wxDirName& src ) : wxFileName( src ) { }
|
: wxFileName()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
wxDirName(const wxDirName &src)
|
||||||
|
: wxFileName(src)
|
||||||
|
{
|
||||||
|
}
|
||||||
explicit wxDirName(const char *src) { Assign(fromUTF8(src)); }
|
explicit wxDirName(const char *src) { Assign(fromUTF8(src)); }
|
||||||
explicit wxDirName(const wxString &src) { Assign(src); }
|
explicit wxDirName(const wxString &src) { Assign(src); }
|
||||||
|
|
||||||
|
@ -80,8 +86,7 @@ public:
|
||||||
|
|
||||||
wxFileName f(file);
|
wxFileName f(file);
|
||||||
|
|
||||||
while( 1 )
|
while (1) {
|
||||||
{
|
|
||||||
if (this->SameAs(wxDirName(f.GetPath())))
|
if (this->SameAs(wxDirName(f.GetPath())))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -114,15 +119,14 @@ public:
|
||||||
if (base.IsRelative() || subject.IsRelative())
|
if (base.IsRelative() || subject.IsRelative())
|
||||||
return subject.GetFullPath();
|
return subject.GetFullPath();
|
||||||
|
|
||||||
wxString bv( base.GetVolume() ); bv.MakeUpper();
|
wxString bv(base.GetVolume());
|
||||||
wxString sv( subject.GetVolume() ); sv.MakeUpper();
|
bv.MakeUpper();
|
||||||
|
wxString sv(subject.GetVolume());
|
||||||
|
sv.MakeUpper();
|
||||||
|
|
||||||
if( base.IsContains( subject ) )
|
if (base.IsContains(subject)) {
|
||||||
{
|
|
||||||
subject.MakeRelativeTo(base.GetFullPath());
|
subject.MakeRelativeTo(base.GetFullPath());
|
||||||
}
|
} else if (base.HasVolume() && subject.HasVolume() && bv == sv) {
|
||||||
else if( base.HasVolume() && subject.HasVolume() && bv == sv )
|
|
||||||
{
|
|
||||||
wxString unusedVolume;
|
wxString unusedVolume;
|
||||||
wxString pathSansVolume;
|
wxString pathSansVolume;
|
||||||
subject.SplitVolume(subject.GetFullPath(), &unusedVolume, &pathSansVolume);
|
subject.SplitVolume(subject.GetFullPath(), &unusedVolume, &pathSansVolume);
|
||||||
|
@ -163,9 +167,21 @@ public:
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
wxDirName& operator=(const wxDirName& dirname) { Assign( dirname ); return *this; }
|
wxDirName &operator=(const wxDirName &dirname)
|
||||||
wxDirName& operator=(const wxString& dirname) { Assign( dirname ); return *this; }
|
{
|
||||||
wxDirName& operator=(const char* dirname) { Assign( fromUTF8(dirname) ); return *this; }
|
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); }
|
wxFileName operator+(const wxFileName &right) const { return Combine(right); }
|
||||||
wxDirName operator+(const wxDirName &right) const { return Combine(right); }
|
wxDirName operator+(const wxDirName &right) const { return Combine(right); }
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace Perf {
|
namespace Perf
|
||||||
|
{
|
||||||
|
|
||||||
struct Info
|
struct Info
|
||||||
{
|
{
|
||||||
|
@ -37,14 +38,12 @@ namespace Perf {
|
||||||
char m_prefix[20];
|
char m_prefix[20];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InfoVector(const char *prefix);
|
InfoVector(const char *prefix);
|
||||||
|
|
||||||
void print(FILE *fp);
|
void print(FILE *fp);
|
||||||
void map(uptr x86, u32 size, const char *symbol);
|
void map(uptr x86, u32 size, const char *symbol);
|
||||||
void map(uptr x86, u32 size, u32 pc);
|
void map(uptr x86, u32 size, u32 pc);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void dump();
|
void dump();
|
||||||
|
|
|
@ -131,7 +131,8 @@ namespace Threading
|
||||||
void AddListener(EventListener_Thread &evt);
|
void AddListener(EventListener_Thread &evt);
|
||||||
void AddListener(EventListener_Thread *evt)
|
void AddListener(EventListener_Thread *evt)
|
||||||
{
|
{
|
||||||
if( evt == NULL ) return;
|
if (evt == NULL)
|
||||||
|
return;
|
||||||
AddListener(*evt);
|
AddListener(*evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,8 +251,8 @@ namespace Threading
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~BaseTaskThread() throw() {}
|
virtual ~BaseTaskThread() throw() {}
|
||||||
BaseTaskThread() :
|
BaseTaskThread()
|
||||||
m_Done( false )
|
: m_Done(false)
|
||||||
, m_TaskPending(false)
|
, m_TaskPending(false)
|
||||||
, m_post_TaskComplete()
|
, m_post_TaskComplete()
|
||||||
{
|
{
|
||||||
|
|
|
@ -205,12 +205,11 @@ public:
|
||||||
|
|
||||||
virtual ~SafeAlignedArray() throw();
|
virtual ~SafeAlignedArray() throw();
|
||||||
|
|
||||||
explicit SafeAlignedArray( const wxChar* name=L"Unnamed" ) :
|
explicit SafeAlignedArray(const wxChar *name = L"Unnamed")
|
||||||
SafeArray<T>::SafeArray( name )
|
: SafeArray<T>::SafeArray(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit SafeAlignedArray(int initialSize, const wxChar *name = L"Unnamed");
|
explicit SafeAlignedArray(int initialSize, const wxChar *name = L"Unnamed");
|
||||||
virtual SafeAlignedArray<T, Alignment> *Clone() const;
|
virtual SafeAlignedArray<T, Alignment> *Clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,17 +39,16 @@ T* SafeArray<T>::_virtual_realloc( int newsize )
|
||||||
{
|
{
|
||||||
T *retval = (T *)((m_ptr == NULL) ?
|
T *retval = (T *)((m_ptr == NULL) ?
|
||||||
malloc(newsize * sizeof(T)) :
|
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
|
// Zero everything out to 0xbaadf00d, so that its obviously uncleared
|
||||||
// to a debuggee
|
// to a debuggee
|
||||||
|
|
||||||
u32 *fill = (u32 *)&retval[m_size];
|
u32 *fill = (u32 *)&retval[m_size];
|
||||||
const u32 *end = (u32 *)((((uptr)&retval[newsize - 1]) - 3) & ~0x3);
|
const u32 *end = (u32 *)((((uptr)&retval[newsize - 1]) - 3) & ~0x3);
|
||||||
for( ; fill<end; ++fill ) *fill = 0xbaadf00d;
|
for (; fill < end; ++fill)
|
||||||
|
*fill = 0xbaadf00d;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -103,7 +102,8 @@ T* SafeArray<T>::_getPtr( uint i ) const
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SafeArray<T>::ExactAlloc(int newsize)
|
void SafeArray<T>::ExactAlloc(int newsize)
|
||||||
{
|
{
|
||||||
if( newsize == m_size ) return;
|
if (newsize == m_size)
|
||||||
|
return;
|
||||||
|
|
||||||
m_ptr = _virtual_realloc(newsize);
|
m_ptr = _virtual_realloc(newsize);
|
||||||
if (m_ptr == NULL)
|
if (m_ptr == NULL)
|
||||||
|
@ -131,8 +131,7 @@ T* SafeAlignedArray<T,Alignment>::_virtual_realloc( int newsize )
|
||||||
{
|
{
|
||||||
return (T *)((this->m_ptr == NULL) ?
|
return (T *)((this->m_ptr == NULL) ?
|
||||||
_aligned_malloc(newsize * sizeof(T), Alignment) :
|
_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.
|
// 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>
|
template <typename T, uint Alignment>
|
||||||
SafeAlignedArray<T,Alignment>::SafeAlignedArray( int initialSize, const wxChar* name ) :
|
SafeAlignedArray<T, Alignment>::SafeAlignedArray(int initialSize, const wxChar *name)
|
||||||
SafeArray<T>::SafeArray(
|
: SafeArray<T>::SafeArray(
|
||||||
name,
|
name,
|
||||||
(T *)_aligned_malloc(initialSize * sizeof(T), Alignment),
|
(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)
|
throw Exception::OutOfMemory(Name)
|
||||||
.SetDiagMsg(wxsFormat(L"called from 'SafeList::ctor' [length=%d]", m_length));
|
.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();
|
new (&m_ptr[i]) T();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -221,16 +217,14 @@ T* SafeList<T>::_getPtr( uint i ) const
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SafeList<T>::MakeRoomFor(int blockSize)
|
void SafeList<T>::MakeRoomFor(int blockSize)
|
||||||
{
|
{
|
||||||
if( blockSize > m_allocsize )
|
if (blockSize > m_allocsize) {
|
||||||
{
|
|
||||||
const int newalloc = blockSize + ChunkSize;
|
const int newalloc = blockSize + ChunkSize;
|
||||||
m_ptr = _virtual_realloc(newalloc);
|
m_ptr = _virtual_realloc(newalloc);
|
||||||
if (m_ptr == NULL)
|
if (m_ptr == NULL)
|
||||||
throw Exception::OutOfMemory(Name)
|
throw Exception::OutOfMemory(Name)
|
||||||
.SetDiagMsg(wxsFormat(L"Called from 'SafeList::MakeRoomFor' [oldlen=%d] [newlen=%d]", m_length, blockSize));
|
.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();
|
new (&m_ptr[m_allocsize]) T();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,8 @@ public:
|
||||||
// Makes enough room for the requested size. Existing data in the array is retained.
|
// Makes enough room for the requested size. Existing data in the array is retained.
|
||||||
void MakeRoomFor(uint size)
|
void MakeRoomFor(uint size)
|
||||||
{
|
{
|
||||||
if (size <= m_size) return;
|
if (size <= m_size)
|
||||||
|
return;
|
||||||
Resize(size);
|
Resize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +178,8 @@ class ScopedAlloc : public BaseScopedAlloc<T>
|
||||||
typedef BaseScopedAlloc<T> _parent;
|
typedef BaseScopedAlloc<T> _parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScopedAlloc( size_t size=0 ) : _parent()
|
ScopedAlloc(size_t size = 0)
|
||||||
|
: _parent()
|
||||||
{
|
{
|
||||||
Alloc(size);
|
Alloc(size);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +193,8 @@ public:
|
||||||
{
|
{
|
||||||
safe_free(this->m_buffer);
|
safe_free(this->m_buffer);
|
||||||
this->m_size = newsize;
|
this->m_size = newsize;
|
||||||
if (!this->m_size) return;
|
if (!this->m_size)
|
||||||
|
return;
|
||||||
|
|
||||||
this->m_buffer = (T *)malloc(this->m_size * sizeof(T));
|
this->m_buffer = (T *)malloc(this->m_size * sizeof(T));
|
||||||
if (!this->m_buffer)
|
if (!this->m_buffer)
|
||||||
|
@ -225,7 +228,8 @@ class ScopedAlignedAlloc : public BaseScopedAlloc<T>
|
||||||
typedef BaseScopedAlloc<T> _parent;
|
typedef BaseScopedAlloc<T> _parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScopedAlignedAlloc( size_t size=0 ) : _parent()
|
ScopedAlignedAlloc(size_t size = 0)
|
||||||
|
: _parent()
|
||||||
{
|
{
|
||||||
Alloc(size);
|
Alloc(size);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +243,8 @@ public:
|
||||||
{
|
{
|
||||||
safe_aligned_free(this->m_buffer);
|
safe_aligned_free(this->m_buffer);
|
||||||
this->m_size = newsize;
|
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);
|
this->m_buffer = (T *)_aligned_malloc(this->m_size * sizeof(T), align);
|
||||||
if (!this->m_buffer)
|
if (!this->m_buffer)
|
||||||
|
|
|
@ -44,7 +44,8 @@ public:
|
||||||
ScopedPtrMT &Reassign(T *ptr = nullptr)
|
ScopedPtrMT &Reassign(T *ptr = nullptr)
|
||||||
{
|
{
|
||||||
T *doh = m_ptr.exchange(ptr);
|
T *doh = m_ptr.exchange(ptr);
|
||||||
if ( ptr != doh ) delete doh;
|
if (ptr != doh)
|
||||||
|
delete doh;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,16 @@ public:
|
||||||
|
|
||||||
ConsoleLogSource_Threading();
|
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);
|
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);
|
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);
|
return _parent::Error(wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -101,7 +104,8 @@ namespace Exception
|
||||||
Threading::pxThread *m_thread;
|
Threading::pxThread *m_thread;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseThreadError() {
|
BaseThreadError()
|
||||||
|
{
|
||||||
m_thread = NULL;
|
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
|
// Can be done with a TryAcquire/Release but it is likely better to do it outside of the object
|
||||||
bool IsLocked()
|
bool IsLocked()
|
||||||
{ pxAssertMsg(0, "IsLocked isn't supported for NonblockingMutex"); return false; }
|
{
|
||||||
|
pxAssertMsg(0, "IsLocked isn't supported for NonblockingMutex");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Release()
|
void Release()
|
||||||
{
|
{
|
||||||
|
@ -336,7 +343,10 @@ namespace Threading
|
||||||
class ScopedTryLock : public ScopedLock
|
class ScopedTryLock : public ScopedLock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScopedTryLock( const Mutex& locker ) : ScopedLock( locker, true ) { }
|
ScopedTryLock(const Mutex &locker)
|
||||||
|
: ScopedLock(locker, true)
|
||||||
|
{
|
||||||
|
}
|
||||||
virtual ~ScopedTryLock() throw() {}
|
virtual ~ScopedTryLock() throw() {}
|
||||||
bool Failed() const { return !m_IsLocked; }
|
bool Failed() const { return !m_IsLocked; }
|
||||||
};
|
};
|
||||||
|
@ -355,8 +365,8 @@ namespace Threading
|
||||||
bool m_IsLocked;
|
bool m_IsLocked;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScopedNonblockingLock( NonblockingMutex& locker ) :
|
ScopedNonblockingLock(NonblockingMutex &locker)
|
||||||
m_lock( locker )
|
: m_lock(locker)
|
||||||
, m_IsLocked(m_lock.TryAcquire())
|
, 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,
|
// Note that the isLockedBool should only be used as an indicator for the locked status,
|
||||||
// and not actually depended on for thread synchronization...
|
// and not actually depended on for thread synchronization...
|
||||||
|
|
||||||
struct ScopedLockBool {
|
struct ScopedLockBool
|
||||||
|
{
|
||||||
ScopedLock m_lock;
|
ScopedLock m_lock;
|
||||||
std::atomic<bool> &m_bool;
|
std::atomic<bool> &m_bool;
|
||||||
|
|
||||||
ScopedLockBool(Mutex &mutexToLock, std::atomic<bool> &isLockedBool)
|
ScopedLockBool(Mutex &mutexToLock, std::atomic<bool> &isLockedBool)
|
||||||
: m_lock(mutexToLock),
|
: m_lock(mutexToLock)
|
||||||
m_bool(isLockedBool) {
|
, m_bool(isLockedBool)
|
||||||
|
{
|
||||||
m_bool.store(m_lock.IsLocked(), std::memory_order_relaxed);
|
m_bool.store(m_lock.IsLocked(), std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
virtual ~ScopedLockBool() throw() {
|
virtual ~ScopedLockBool() throw()
|
||||||
|
{
|
||||||
m_bool.store(false, std::memory_order_relaxed);
|
m_bool.store(false, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
void Acquire() {
|
void Acquire()
|
||||||
|
{
|
||||||
m_lock.Acquire();
|
m_lock.Acquire();
|
||||||
m_bool.store(m_lock.IsLocked(), std::memory_order_relaxed);
|
m_bool.store(m_lock.IsLocked(), std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
void Release() {
|
void Release()
|
||||||
|
{
|
||||||
m_bool.store(false, std::memory_order_relaxed);
|
m_bool.store(false, std::memory_order_relaxed);
|
||||||
m_lock.Release();
|
m_lock.Release();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,5 +49,4 @@ namespace Threading
|
||||||
void OnTaskComplete(wxCommandEvent &evt);
|
void OnTaskComplete(wxCommandEvent &evt);
|
||||||
//void OnTimer( wxTimerEvent& evt );
|
//void OnTimer( wxTimerEvent& evt );
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,7 @@ public:
|
||||||
|
|
||||||
void Dispose()
|
void Dispose()
|
||||||
{
|
{
|
||||||
if (!m_IsDisposed)
|
if (!m_IsDisposed) {
|
||||||
{
|
|
||||||
m_IsDisposed = true;
|
m_IsDisposed = true;
|
||||||
KillKey();
|
KillKey();
|
||||||
}
|
}
|
||||||
|
@ -81,7 +80,8 @@ protected:
|
||||||
|
|
||||||
static void _aligned_delete_and_free(void *ptr)
|
static void _aligned_delete_and_free(void *ptr)
|
||||||
{
|
{
|
||||||
if (!ptr) return;
|
if (!ptr)
|
||||||
|
return;
|
||||||
((T *)ptr)->~T();
|
((T *)ptr)->~T();
|
||||||
_aligned_free(ptr);
|
_aligned_free(ptr);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,9 @@ protected:
|
||||||
public:
|
public:
|
||||||
TlsVariable() {}
|
TlsVariable() {}
|
||||||
TlsVariable(const T &initval)
|
TlsVariable(const T &initval)
|
||||||
: m_initval(initval) { }
|
: m_initval(initval)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// This is needed; The C++ standard likes making life suck for programmers.
|
// This is needed; The C++ standard likes making life suck for programmers.
|
||||||
using BaseTlsVariable<T>::GetRef;
|
using BaseTlsVariable<T>::GetRef;
|
||||||
|
@ -152,7 +154,8 @@ Threading::BaseTlsVariable<T>::BaseTlsVariable()
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Threading::BaseTlsVariable<T>::KillKey()
|
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!)
|
// 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
|
// 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 *Threading::BaseTlsVariable<T>::GetPtr() const
|
||||||
{
|
{
|
||||||
T *result = (T *)pthread_getspecific(m_thread_key);
|
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));
|
pthread_setspecific(m_thread_key, result = (T *)_aligned_malloc(sizeof(T), 16));
|
||||||
CreateInstance(result);
|
CreateInstance(result);
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
|
@ -182,8 +184,7 @@ T* Threading::BaseTlsVariable<T>::GetPtr() const
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Threading::BaseTlsVariable<T>::CreateKey()
|
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.");
|
pxFailRel("Thread Local Storage Error: key creation failed. This will most likely lead to a rapid application crash.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,11 @@ public:
|
||||||
bool Enabled;
|
bool Enabled;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseTraceLogSource() : m_Descriptor(NULL), Enabled(false) {}
|
BaseTraceLogSource()
|
||||||
|
: m_Descriptor(NULL)
|
||||||
|
, Enabled(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TraceLog_ImplementBaseAPI(BaseTraceLogSource)
|
TraceLog_ImplementBaseAPI(BaseTraceLogSource)
|
||||||
|
@ -107,7 +111,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool HasDescription() const { return m_Descriptor->Description != NULL; }
|
virtual bool HasDescription() const { return m_Descriptor->Description != NULL; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
@ -159,7 +162,10 @@ public:
|
||||||
ConsoleColors DefaultColor;
|
ConsoleColors DefaultColor;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ConsoleLogSource() : DefaultColor(Color_Gray) {}
|
ConsoleLogSource()
|
||||||
|
: DefaultColor(Color_Gray)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConsoleLog_ImplementBaseAPI(ConsoleLogSource)
|
ConsoleLog_ImplementBaseAPI(ConsoleLogSource)
|
||||||
|
@ -280,4 +286,3 @@ public:
|
||||||
Console.DoWriteLn(msg);
|
Console.DoWriteLn(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ protected:
|
||||||
int m_subPadding;
|
int m_subPadding;
|
||||||
|
|
||||||
wxSizerItem *m_sizerItem_subtext;
|
wxSizerItem *m_sizerItem_subtext;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
pxCheckBox(wxWindow *parent, const wxString &label, const wxString &subtext = wxEmptyString, int flags = wxCHK_2STATE);
|
pxCheckBox(wxWindow *parent, const wxString &label, const wxString &subtext = wxEmptyString, int flags = wxCHK_2STATE);
|
||||||
pxCheckBox(wxWindow *parent, const wxString &label, int flags);
|
pxCheckBox(wxWindow *parent, const wxString &label, int flags);
|
||||||
|
@ -50,12 +51,36 @@ public:
|
||||||
pxCheckBox &SetIndeterminate();
|
pxCheckBox &SetIndeterminate();
|
||||||
pxCheckBox &SetState(wxCheckBoxState state);
|
pxCheckBox &SetState(wxCheckBoxState state);
|
||||||
|
|
||||||
wxCheckBoxState GetState() const { pxAssert( m_checkbox != NULL ); return m_checkbox->Get3StateValue(); }
|
wxCheckBoxState GetState() const
|
||||||
bool GetValue() const { pxAssert( m_checkbox != NULL ); return m_checkbox->GetValue(); }
|
{
|
||||||
bool IsChecked() const { pxAssert( m_checkbox != NULL ); return m_checkbox->IsChecked(); }
|
pxAssert(m_checkbox != NULL);
|
||||||
bool IsIndeterminate() const { pxAssert( m_checkbox != NULL ); return m_checkbox->Get3StateValue() == wxCHK_UNDETERMINED; }
|
return m_checkbox->Get3StateValue();
|
||||||
operator wxCheckBox&() { pxAssert( m_checkbox != NULL ); return *m_checkbox; }
|
}
|
||||||
operator const wxCheckBox&() const { pxAssert( m_checkbox != NULL ); return *m_checkbox; }
|
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; }
|
wxCheckBox *GetWxPtr() { return m_checkbox; }
|
||||||
const wxCheckBox *GetWxPtr() const { 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);
|
target.Add(src.window, src.flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,11 +73,13 @@ class pxSimpleEvent : public wxEvent
|
||||||
public:
|
public:
|
||||||
explicit pxSimpleEvent(int evtid = 0)
|
explicit pxSimpleEvent(int evtid = 0)
|
||||||
: wxEvent(0, evtid)
|
: wxEvent(0, evtid)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
pxSimpleEvent(wxWindowID winId, int evtid)
|
pxSimpleEvent(wxWindowID winId, int evtid)
|
||||||
: wxEvent(winId, evtid)
|
: wxEvent(winId, evtid)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual wxEvent *Clone() const { return new pxSimpleEvent(*this); }
|
virtual wxEvent *Clone() const { return new pxSimpleEvent(*this); }
|
||||||
};
|
};
|
||||||
|
@ -241,18 +243,62 @@ protected:
|
||||||
public:
|
public:
|
||||||
MsgButtons() { bitset = 0; }
|
MsgButtons() { bitset = 0; }
|
||||||
|
|
||||||
MsgButtons& OK() { m_OK = true; return *this; }
|
MsgButtons &OK()
|
||||||
MsgButtons& Cancel() { m_Cancel = true; return *this; }
|
{
|
||||||
MsgButtons& Apply() { m_Apply = true; return *this; }
|
m_OK = true;
|
||||||
MsgButtons& Yes() { m_Yes = true; return *this; }
|
return *this;
|
||||||
MsgButtons& No() { m_No = true; return *this; }
|
}
|
||||||
MsgButtons& ToAll() { m_AllowToAll = 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 &Abort()
|
||||||
MsgButtons& Retry() { m_Retry = true; return *this; }
|
{
|
||||||
MsgButtons& Ignore() { m_Ignore = true; return *this; }
|
m_Abort = true;
|
||||||
MsgButtons& Reset() { m_Reset = true; return *this; }
|
return *this;
|
||||||
MsgButtons& Close() { m_Close = 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
|
// label - native language label displayed to user
|
||||||
// id - raw ASCII identifier used in the config file (do not translate, hence char*)
|
// id - raw ASCII identifier used in the config file (do not translate, hence char*)
|
||||||
|
@ -263,8 +309,16 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgButtons& OKCancel() { m_OK = m_Cancel = true; return *this; }
|
MsgButtons &OKCancel()
|
||||||
MsgButtons& YesNo() { m_Yes = m_No = true; return *this; }
|
{
|
||||||
|
m_OK = m_Cancel = true;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
MsgButtons &YesNo()
|
||||||
|
{
|
||||||
|
m_Yes = m_No = true;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
bool HasOK() const { return m_OK; }
|
bool HasOK() const { return m_OK; }
|
||||||
bool HasCancel() const { return m_Cancel; }
|
bool HasCancel() const { return m_Cancel; }
|
||||||
|
|
|
@ -122,4 +122,3 @@ inline void operator+=( wxSizer& target, const pxWindowAndFlags<pxStaticText>& s
|
||||||
{
|
{
|
||||||
target.Add(src.window, src.flags);
|
target.Add(src.window, src.flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,14 +85,16 @@ public:
|
||||||
void DeleteObject(BaseDeletableObject &obj);
|
void DeleteObject(BaseDeletableObject &obj);
|
||||||
void DeleteObject(BaseDeletableObject *obj)
|
void DeleteObject(BaseDeletableObject *obj)
|
||||||
{
|
{
|
||||||
if( obj == NULL ) return;
|
if (obj == NULL)
|
||||||
|
return;
|
||||||
DeleteObject(*obj);
|
DeleteObject(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteThread(Threading::pxThread &obj);
|
void DeleteThread(Threading::pxThread &obj);
|
||||||
void DeleteThread(Threading::pxThread *obj)
|
void DeleteThread(Threading::pxThread *obj)
|
||||||
{
|
{
|
||||||
if( obj == NULL ) return;
|
if (obj == NULL)
|
||||||
|
return;
|
||||||
DeleteThread(*obj);
|
DeleteThread(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +136,6 @@ protected:
|
||||||
void OnDeleteThread(wxCommandEvent &evt);
|
void OnDeleteThread(wxCommandEvent &evt);
|
||||||
void OnSynchronousCommand(pxSynchronousCommandEvent &evt);
|
void OnSynchronousCommand(pxSynchronousCommandEvent &evt);
|
||||||
void OnInvokeAction(pxActionEvent &evt);
|
void OnInvokeAction(pxActionEvent &evt);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Msgbox
|
namespace Msgbox
|
||||||
|
|
|
@ -69,4 +69,3 @@ extern bool pxReadLine( wxInputStream& input, std::string& dest );
|
||||||
extern void pxWriteLine(wxOutputStream &output);
|
extern void pxWriteLine(wxOutputStream &output);
|
||||||
extern void pxWriteLine(wxOutputStream &output, const wxString &text);
|
extern void pxWriteLine(wxOutputStream &output, const wxString &text);
|
||||||
extern void pxWriteMultiline(wxOutputStream &output, const wxString &src);
|
extern void pxWriteMultiline(wxOutputStream &output, const wxString &src);
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,7 @@ namespace pxSizerFlags
|
||||||
//
|
//
|
||||||
struct pxAlignmentType
|
struct pxAlignmentType
|
||||||
{
|
{
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
Centre,
|
Centre,
|
||||||
Center = Centre,
|
Center = Centre,
|
||||||
Middle,
|
Middle,
|
||||||
|
@ -104,8 +103,7 @@ struct pxAlignmentType
|
||||||
|
|
||||||
struct pxStretchType
|
struct pxStretchType
|
||||||
{
|
{
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
Shrink,
|
Shrink,
|
||||||
Expand,
|
Expand,
|
||||||
Shaped,
|
Shaped,
|
||||||
|
@ -246,21 +244,24 @@ extern void operator+=( wxWindow& target, const pxStretchSpacer& spacer );
|
||||||
template <typename WinType>
|
template <typename WinType>
|
||||||
void operator+=(wxWindow &target, WinType *src)
|
void operator+=(wxWindow &target, WinType *src)
|
||||||
{
|
{
|
||||||
if( !pxAssert( target.GetSizer() != NULL ) ) return;
|
if (!pxAssert(target.GetSizer() != NULL))
|
||||||
|
return;
|
||||||
*target.GetSizer() += src;
|
*target.GetSizer() += src;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename WinType>
|
template <typename WinType>
|
||||||
void operator+=(wxWindow &target, WinType &src)
|
void operator+=(wxWindow &target, WinType &src)
|
||||||
{
|
{
|
||||||
if( !pxAssert( target.GetSizer() != NULL ) ) return;
|
if (!pxAssert(target.GetSizer() != NULL))
|
||||||
|
return;
|
||||||
*target.GetSizer() += src;
|
*target.GetSizer() += src;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename WinType>
|
template <typename WinType>
|
||||||
void operator+=(wxWindow &target, const pxWindowAndFlags<WinType> &src)
|
void operator+=(wxWindow &target, const pxWindowAndFlags<WinType> &src)
|
||||||
{
|
{
|
||||||
if( !pxAssert( target.GetSizer() != NULL ) ) return;
|
if (!pxAssert(target.GetSizer() != NULL))
|
||||||
|
return;
|
||||||
*target.GetSizer() += src;
|
*target.GetSizer() += src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,13 +359,15 @@ public:
|
||||||
|
|
||||||
pxDialogCreationFlags &SetMinWidth(int width)
|
pxDialogCreationFlags &SetMinWidth(int width)
|
||||||
{
|
{
|
||||||
if( width > MinimumSize.x ) MinimumSize.SetWidth( width );
|
if (width > MinimumSize.x)
|
||||||
|
MinimumSize.SetWidth(width);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
pxDialogCreationFlags &SetMinHeight(int height)
|
pxDialogCreationFlags &SetMinHeight(int height)
|
||||||
{
|
{
|
||||||
if( height > MinimumSize.y ) MinimumSize.SetHeight( height );
|
if (height > MinimumSize.y)
|
||||||
|
MinimumSize.SetHeight(height);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,12 +477,18 @@ public:
|
||||||
int GetWxWindowFlags() const
|
int GetWxWindowFlags() const
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
if( isResizable ) retval |= wxRESIZE_BORDER;
|
if (isResizable)
|
||||||
if( hasCaption ) retval |= wxCAPTION;
|
retval |= wxRESIZE_BORDER;
|
||||||
if( hasMaximizeBox ) retval |= wxMAXIMIZE_BOX;
|
if (hasCaption)
|
||||||
if( hasMinimizeBox ) retval |= wxMINIMIZE_BOX;
|
retval |= wxCAPTION;
|
||||||
if( hasSystemMenu ) retval |= wxSYSTEM_MENU;
|
if (hasMaximizeBox)
|
||||||
if( hasCloseBox ) retval |= wxCLOSE_BOX;
|
retval |= wxMAXIMIZE_BOX;
|
||||||
|
if (hasMinimizeBox)
|
||||||
|
retval |= wxMINIMIZE_BOX;
|
||||||
|
if (hasSystemMenu)
|
||||||
|
retval |= wxSYSTEM_MENU;
|
||||||
|
if (hasCloseBox)
|
||||||
|
retval |= wxCLOSE_BOX;
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -640,7 +649,8 @@ protected:
|
||||||
public:
|
public:
|
||||||
pxTextWrapper(const wxString &wrapPrefix = wxEmptyString)
|
pxTextWrapper(const wxString &wrapPrefix = wxEmptyString)
|
||||||
: pxTextWrapperBase(wrapPrefix)
|
: pxTextWrapperBase(wrapPrefix)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~pxTextWrapper() throw() {}
|
virtual ~pxTextWrapper() throw() {}
|
||||||
|
|
||||||
|
@ -739,8 +749,7 @@ public:
|
||||||
const wxCursor &GetArrowWait();
|
const wxCursor &GetArrowWait();
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BusyCursorType
|
enum BusyCursorType {
|
||||||
{
|
|
||||||
Cursor_NotBusy,
|
Cursor_NotBusy,
|
||||||
Cursor_KindaBusy,
|
Cursor_KindaBusy,
|
||||||
Cursor_ReallyBusy,
|
Cursor_ReallyBusy,
|
||||||
|
|
|
@ -35,34 +35,55 @@
|
||||||
|
|
||||||
// Basic functions.
|
// Basic functions.
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDinit();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) CDVDopen(void *pDisplay, const char* pTitleFilename);
|
CDVDinit();
|
||||||
EXPORT_C_(void) CDVDclose();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) CDVDshutdown();
|
CDVDopen(void *pDisplay, const char *pTitleFilename);
|
||||||
EXPORT_C_(s32) CDVDreadTrack(u32 lsn, int mode);
|
EXPORT_C_(void)
|
||||||
|
CDVDclose();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
CDVDshutdown();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
CDVDreadTrack(u32 lsn, int mode);
|
||||||
|
|
||||||
// return can be NULL (for async modes)
|
// 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)
|
||||||
EXPORT_C_(s32) CDVDgetTN(cdvdTN *Buffer); //disk information
|
CDVDreadSubQ(u32 lsn, cdvdSubQ *subq); //read subq from disc (only cds have subq data)
|
||||||
EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) CDVDgetTOC(void* toc); //gets ps2 style toc from disc
|
CDVDgetTN(cdvdTN *Buffer); //disk information
|
||||||
EXPORT_C_(s32) CDVDgetDiskType(); //CDVD_TYPE_xxxx
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
|
CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
|
||||||
EXPORT_C_(s32) CDVDctrlTrayOpen(); //open disc tray
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) CDVDctrlTrayClose(); //close disc tray
|
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
|
// Extended functions
|
||||||
|
|
||||||
EXPORT_C_(void) CDVDkeyEvent(keyEvent *ev);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) CDVDconfigure();
|
CDVDkeyEvent(keyEvent *ev);
|
||||||
EXPORT_C_(s32) CDVDfreeze(u8 mode, freezeData *data);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) CDVDabout();
|
CDVDconfigure();
|
||||||
EXPORT_C_(s32) CDVDtest();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) CDVDnewDiskCB(void (*callback)());
|
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 ctrl : 4; // control and mode bits
|
||||||
u8 mode : 4; // control and mode bits
|
u8 mode : 4; // control and mode bits
|
||||||
u8 trackNum; // current track number (1 to 99)
|
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)
|
u8 discF; // current frame offset from first track (BCD encoded)
|
||||||
} cdvdSubQ;
|
} cdvdSubQ;
|
||||||
|
|
||||||
typedef struct _cdvdTD { // NOT bcd coded
|
typedef struct _cdvdTD
|
||||||
|
{ // NOT bcd coded
|
||||||
u32 lsn;
|
u32 lsn;
|
||||||
u8 type;
|
u8 type;
|
||||||
} cdvdTD;
|
} cdvdTD;
|
||||||
|
|
||||||
typedef struct _cdvdTN {
|
typedef struct _cdvdTN
|
||||||
|
{
|
||||||
u8 strack; //number of the first track (usually 1)
|
u8 strack; //number of the first track (usually 1)
|
||||||
u8 etrack; //number of the last track
|
u8 etrack; //number of the last track
|
||||||
} cdvdTN;
|
} cdvdTN;
|
||||||
|
|
|
@ -37,32 +37,51 @@ typedef int (*DEV9handler)(void);
|
||||||
// Basic functions.
|
// Basic functions.
|
||||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||||
// If you want to use them, need to save and restore current ones
|
// 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.
|
// pDisplay normally is passed a handle to the GS plugins window.
|
||||||
EXPORT_C_(s32) DEV9open(void *pDisplay);
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) DEV9close();
|
DEV9open(void *pDisplay);
|
||||||
EXPORT_C_(void) DEV9shutdown();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(u8) DEV9read8(u32 addr);
|
DEV9close();
|
||||||
EXPORT_C_(u16) DEV9read16(u32 addr);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(u32) DEV9read32(u32 addr);
|
DEV9shutdown();
|
||||||
EXPORT_C_(void) DEV9write8(u32 addr, u8 value);
|
EXPORT_C_(u8)
|
||||||
EXPORT_C_(void) DEV9write16(u32 addr, u16 value);
|
DEV9read8(u32 addr);
|
||||||
EXPORT_C_(void) DEV9write32(u32 addr, u32 value);
|
EXPORT_C_(u16)
|
||||||
EXPORT_C_(void) DEV9readDMA8Mem(u32 *pMem, int size);
|
DEV9read16(u32 addr);
|
||||||
EXPORT_C_(void) DEV9writeDMA8Mem(u32 *pMem, int size);
|
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,
|
// cycles = IOP cycles before calling callback,
|
||||||
// if callback returns 1 the irq is triggered, else not
|
// if callback returns 1 the irq is triggered, else not
|
||||||
EXPORT_C_(void) DEV9irqCallback(DEV9callback callback);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(DEV9handler) DEV9irqHandler(void);
|
DEV9irqCallback(DEV9callback callback);
|
||||||
|
EXPORT_C_(DEV9handler)
|
||||||
|
DEV9irqHandler(void);
|
||||||
|
|
||||||
// Extended functions
|
// Extended functions
|
||||||
|
|
||||||
EXPORT_C_(void) DEV9keyEvent(keyEvent *ev);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(s32) DEV9freeze(u8 mode, freezeData *data);
|
DEV9keyEvent(keyEvent *ev);
|
||||||
EXPORT_C_(void) DEV9configure();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) DEV9about();
|
DEV9freeze(u8 mode, freezeData *data);
|
||||||
EXPORT_C_(s32) DEV9test();
|
EXPORT_C_(void)
|
||||||
|
DEV9configure();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
DEV9about();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
DEV9test();
|
||||||
|
|
||||||
#endif // __DEV9API_H__
|
#endif // __DEV9API_H__
|
||||||
|
|
|
@ -37,22 +37,34 @@
|
||||||
|
|
||||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||||
// If you want to use them, need to save and restore current ones
|
// 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.
|
// pDisplay normally is passed a handle to the GS plugins window.
|
||||||
EXPORT_C_(s32) FWopen(void *pDisplay);
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) FWclose();
|
FWopen(void *pDisplay);
|
||||||
EXPORT_C_(void) FWshutdown();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(u32) FWread32(u32 addr);
|
FWclose();
|
||||||
EXPORT_C_(void) FWwrite32(u32 addr, u32 value);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) FWirqCallback(void (*callback)());
|
FWshutdown();
|
||||||
|
EXPORT_C_(u32)
|
||||||
|
FWread32(u32 addr);
|
||||||
|
EXPORT_C_(void)
|
||||||
|
FWwrite32(u32 addr, u32 value);
|
||||||
|
EXPORT_C_(void)
|
||||||
|
FWirqCallback(void (*callback)());
|
||||||
|
|
||||||
// Extended functions
|
// Extended functions
|
||||||
|
|
||||||
EXPORT_C_(void) FWkeyEvent(keyEvent *ev);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(s32) FWfreeze(u8 mode, freezeData *data);
|
FWkeyEvent(keyEvent *ev);
|
||||||
EXPORT_C_(void) FWconfigure();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) FWabout();
|
FWfreeze(u8 mode, freezeData *data);
|
||||||
EXPORT_C_(s32) FWtest();
|
EXPORT_C_(void)
|
||||||
|
FWconfigure();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
FWabout();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
FWtest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // __USBAPI_H__
|
#endif // __USBAPI_H__
|
||||||
|
|
|
@ -31,55 +31,86 @@
|
||||||
|
|
||||||
#include "Pcsx2Api.h"
|
#include "Pcsx2Api.h"
|
||||||
|
|
||||||
typedef struct _GSdriverInfo {
|
typedef struct _GSdriverInfo
|
||||||
|
{
|
||||||
char name[8];
|
char name[8];
|
||||||
void *common;
|
void *common;
|
||||||
} GSdriverInfo;
|
} GSdriverInfo;
|
||||||
|
|
||||||
// Basic functions.
|
// Basic functions.
|
||||||
EXPORT_C_(s32) GSinit();
|
EXPORT_C_(s32)
|
||||||
|
GSinit();
|
||||||
// pDisplay normally is passed a handle to the GS plugins window.
|
// pDisplay normally is passed a handle to the GS plugins window.
|
||||||
EXPORT_C_(s32) GSopen(void *pDisplay, char *Title, bool multithread);
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) GSclose();
|
GSopen(void *pDisplay, char *Title, bool multithread);
|
||||||
EXPORT_C_(void) GSshutdown();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) GSvsync(int field);
|
GSclose();
|
||||||
EXPORT_C_(void) GSgifTransfer1(u32 *pMem, u32 addr);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) GSgifTransfer2(u32 *pMem, u32 size);
|
GSshutdown();
|
||||||
EXPORT_C_(void) GSgifTransfer3(u32 *pMem, u32 size);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) GSgetLastTag(u64* ptag); // returns the last tag processed (64 bits)
|
GSvsync(int field);
|
||||||
EXPORT_C_(void) GSgifSoftReset(u32 mask);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) GSreadFIFO(u64 *mem);
|
GSgifTransfer1(u32 *pMem, u32 addr);
|
||||||
EXPORT_C_(void) GSreadFIFO2(u64 *mem, int qwc);
|
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
|
// Extended functions
|
||||||
|
|
||||||
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
||||||
EXPORT_C_(void) GSkeyEvent(keyEvent *ev);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) GSchangeSaveState(s32 state, const char* filename);
|
GSkeyEvent(keyEvent *ev);
|
||||||
EXPORT_C_(void) GSmakeSnapshot(char *path);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) GSmakeSnapshot2(char *pathname, int* snapdone, int savejpg);
|
GSchangeSaveState(s32 state, const char *filename);
|
||||||
EXPORT_C_(void) GSirqCallback(void (*callback)());
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) CALLBACK GSprintf(s32 timeout, char *fmt, ...);
|
GSmakeSnapshot(char *path);
|
||||||
EXPORT_C_(void) GSsetBaseMem(void*);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) GSsetGameCRC(s32 crc, s32 gameoptions);
|
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
|
// 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
|
// if start is true, starts recording spu2 data, else stops
|
||||||
// returns true if successful
|
// returns true if successful
|
||||||
// for now, pData is not used
|
// 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)
|
||||||
EXPORT_C_(void) GSwriteCSR(u32 value);
|
GSreset();
|
||||||
EXPORT_C_(void ) GSgetDriverInfo(GSdriverInfo *info);
|
EXPORT_C_(void)
|
||||||
|
GSwriteCSR(u32 value);
|
||||||
|
EXPORT_C_(void)
|
||||||
|
GSgetDriverInfo(GSdriverInfo *info);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
EXPORT_C_(s32) CALLBACK GSsetWindowInfo(winInfo *info);
|
EXPORT_C_(s32)
|
||||||
|
CALLBACK GSsetWindowInfo(winInfo *info);
|
||||||
#endif
|
#endif
|
||||||
EXPORT_C_(s32) GSfreeze(u8 mode, freezeData *data);
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) GSconfigure();
|
GSfreeze(u8 mode, freezeData *data);
|
||||||
EXPORT_C_(void) GSabout();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(s32) GStest();
|
GSconfigure();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
GSabout();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
GStest();
|
||||||
|
|
||||||
#endif // __GSAPI_H__
|
#endif // __GSAPI_H__
|
|
@ -35,19 +35,27 @@
|
||||||
/* So obsolete that everyone uses it. */
|
/* So obsolete that everyone uses it. */
|
||||||
|
|
||||||
// Basic functions.
|
// 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.
|
// pDisplay normally is passed a handle to the GS plugins window.
|
||||||
EXPORT_C_(s32) PADopen(void *pDisplay);
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) PADclose();
|
PADopen(void *pDisplay);
|
||||||
EXPORT_C_(void) PADshutdown();
|
EXPORT_C_(void)
|
||||||
|
PADclose();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
PADshutdown();
|
||||||
// PADkeyEvent is called every vsync (return NULL if no event)
|
// PADkeyEvent is called every vsync (return NULL if no event)
|
||||||
EXPORT_C_(keyEvent*) PADkeyEvent();
|
EXPORT_C_(keyEvent *)
|
||||||
EXPORT_C_(u8) PADstartPoll(u8 pad);
|
PADkeyEvent();
|
||||||
EXPORT_C_(u8) PADpoll(u8 value);
|
EXPORT_C_(u8)
|
||||||
|
PADstartPoll(u8 pad);
|
||||||
|
EXPORT_C_(u8)
|
||||||
|
PADpoll(u8 value);
|
||||||
// returns: 1 if supported pad1
|
// returns: 1 if supported pad1
|
||||||
// 2 if supported pad2
|
// 2 if supported pad2
|
||||||
// 3 if both are supported
|
// 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
|
// 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.
|
// 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
|
// the window (and input). Note that PADupdate can be called from a different
|
||||||
// thread than the other functions, so mutex or other multithreading primitives
|
// thread than the other functions, so mutex or other multithreading primitives
|
||||||
// have to be added to maintain data integrity.
|
// have to be added to maintain data integrity.
|
||||||
EXPORT_C_(void) PADupdate(u8 pad);
|
EXPORT_C_(void)
|
||||||
|
PADupdate(u8 pad);
|
||||||
|
|
||||||
// Extended functions
|
// Extended functions
|
||||||
EXPORT_C_(void) PADgsDriverInfo(GSdriverInfo *info);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(s32) PADfreeze(u8 mode, freezeData *data);
|
PADgsDriverInfo(GSdriverInfo *info);
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
PADfreeze(u8 mode, freezeData *data);
|
||||||
|
|
||||||
// Returns 1 if the pad plugin wants a multitap on the specified port.
|
// Returns 1 if the pad plugin wants a multitap on the specified port.
|
||||||
// 0 otherwise.
|
// 0 otherwise.
|
||||||
EXPORT_C_(s32) PADqueryMtap(u8 port);
|
EXPORT_C_(s32)
|
||||||
|
PADqueryMtap(u8 port);
|
||||||
|
|
||||||
// Sets the active pad slot for the specified port.
|
// Sets the active pad slot for the specified port.
|
||||||
// Both numbers are 1-based indices. Should return 0 if there's no
|
// Both numbers are 1-based indices. Should return 0 if there's no
|
||||||
// pad on the specified slot. Even if PADqueryMtap(port) returns 0,
|
// pad on the specified slot. Even if PADqueryMtap(port) returns 0,
|
||||||
// should handle this properly for slot != 1, so emulator can allow
|
// should handle this properly for slot != 1, so emulator can allow
|
||||||
// Multitap to be enabled/disabled elsewhere.
|
// 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)
|
||||||
EXPORT_C_(void) PADabout();
|
PADconfigure();
|
||||||
EXPORT_C_(s32) PADtest();
|
EXPORT_C_(void)
|
||||||
|
PADabout();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
PADtest();
|
||||||
|
|
||||||
#endif // __PADAPI_H__
|
#endif // __PADAPI_H__
|
|
@ -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
|
// 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.
|
// just to make each SIO plugin support only one type, for simplicity.
|
||||||
// SIOchangeSlotCB should *only* be called by MTAP plugins.
|
// 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,
|
// 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
|
// but not both a PAD and MTAP. Simplifies plugin selection and interface, as well
|
||||||
// as API.
|
// as API.
|
||||||
// pDisplay normally is passed a handle to the GS plugins window.
|
// pDisplay normally is passed a handle to the GS plugins window.
|
||||||
EXPORT_C_(s32) SIOopen(void *pDisplay);
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) SIOclose();
|
SIOopen(void *pDisplay);
|
||||||
EXPORT_C_(void) SIOshutdown();
|
EXPORT_C_(void)
|
||||||
|
SIOclose();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
SIOshutdown();
|
||||||
|
|
||||||
// Returns 0 if device doesn't exist. Means old pad plugins can just say nothing
|
// 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.
|
// 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.
|
// 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}
|
// returns: SIO_TYPE_{PAD,MTAP,RM,MC}
|
||||||
EXPORT_C_(u32) SIOquery();
|
EXPORT_C_(u32)
|
||||||
|
SIOquery();
|
||||||
|
|
||||||
// extended funcs
|
// extended funcs
|
||||||
|
|
||||||
EXPORT_C_(void) SIOconfigure();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(keyEvent*) CALLBACK SIOkeyEvent();
|
SIOconfigure();
|
||||||
|
EXPORT_C_(keyEvent *)
|
||||||
|
CALLBACK SIOkeyEvent();
|
||||||
|
|
||||||
// Save one type at a time. If a plugin supports all 4 types,
|
// Save one type at a time. If a plugin supports all 4 types,
|
||||||
// should expect 4 calls. Increases savestate compatibility.
|
// should expect 4 calls. Increases savestate compatibility.
|
||||||
EXPORT_C_(s32) SIOfreeze(u8 mode, freezeData *data, int type);
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) SIOabout();
|
SIOfreeze(u8 mode, freezeData *data, int type);
|
||||||
EXPORT_C_(s32) SIOtest();
|
EXPORT_C_(void)
|
||||||
|
SIOabout();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
SIOtest();
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SIO_TYPE_PAD = 0x00000001,
|
SIO_TYPE_PAD = 0x00000001,
|
||||||
|
|
|
@ -31,47 +31,74 @@
|
||||||
|
|
||||||
#include "Pcsx2Api.h"
|
#include "Pcsx2Api.h"
|
||||||
|
|
||||||
EXPORT_C_(s32) SPU2init();
|
EXPORT_C_(s32)
|
||||||
|
SPU2init();
|
||||||
// pDisplay normally is passed a handle to the GS plugins window.
|
// pDisplay normally is passed a handle to the GS plugins window.
|
||||||
EXPORT_C_(s32) SPU2open(void *pDisplay);
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) SPU2close();
|
SPU2open(void *pDisplay);
|
||||||
EXPORT_C_(void) SPU2shutdown();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) SPU2write(u32 mem, u16 value);
|
SPU2close();
|
||||||
EXPORT_C_(u16) SPU2read(u32 mem);
|
EXPORT_C_(void)
|
||||||
|
SPU2shutdown();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
SPU2write(u32 mem, u16 value);
|
||||||
|
EXPORT_C_(u16)
|
||||||
|
SPU2read(u32 mem);
|
||||||
|
|
||||||
// The following calls are depreciated.
|
// The following calls are depreciated.
|
||||||
EXPORT_C_(void) SPU2readDMA4Mem(u16 *pMem, u32 size);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) SPU2readDMA7Mem(u16 *pMem, u32 size);
|
SPU2readDMA4Mem(u16 *pMem, u32 size);
|
||||||
EXPORT_C_(void) SPU2writeDMA4Mem(u16 *pMem, u32 size);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) SPU2writeDMA7Mem(u16 *pMem, u32 size);
|
SPU2readDMA7Mem(u16 *pMem, u32 size);
|
||||||
EXPORT_C_(void) SPU2interruptDMA4();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) SPU2interruptDMA7();
|
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.
|
// These calls replace the calls above.
|
||||||
EXPORT_C_(void) SPU2readDMAMem(u16 *pMem, u32 size, u8 core);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) SPU2writeDMAMem(u16 *pMem, u32 size, u8 core);
|
SPU2readDMAMem(u16 *pMem, u32 size, u8 core);
|
||||||
EXPORT_C_(void) SPU2interruptDMA(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
|
// 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
|
// 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_(u32)
|
||||||
EXPORT_C_(void) SPU2WriteMemAddr(u8 core,u32 value);
|
SPU2ReadMemAddr(u8 core);
|
||||||
EXPORT_C_(void) SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
|
EXPORT_C_(void)
|
||||||
|
SPU2WriteMemAddr(u8 core, u32 value);
|
||||||
|
EXPORT_C_(void)
|
||||||
|
SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callback)());
|
||||||
|
|
||||||
// extended funcs
|
// extended funcs
|
||||||
|
|
||||||
// if start is true, starts recording spu2 data, else stops
|
// if start is true, starts recording spu2 data, else stops
|
||||||
// returns true if successful
|
// 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)
|
||||||
EXPORT_C_(void) SPU2setClockPtr(u32* ptr);
|
SPU2keyEvent(keyEvent *ev);
|
||||||
EXPORT_C_(void) SPU2async(u32 cycles);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(s32) SPU2freeze(u8 mode, freezeData *data);
|
SPU2setClockPtr(u32 *ptr);
|
||||||
EXPORT_C_(void) SPU2configure();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) SPU2about();
|
SPU2async(u32 cycles);
|
||||||
EXPORT_C_(s32) SPU2test();
|
EXPORT_C_(s32)
|
||||||
|
SPU2freeze(u8 mode, freezeData *data);
|
||||||
|
EXPORT_C_(void)
|
||||||
|
SPU2configure();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
SPU2about();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
SPU2test();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,31 +35,50 @@ typedef void (*USBcallback)(int cycles);
|
||||||
typedef int (*USBhandler)(void);
|
typedef int (*USBhandler)(void);
|
||||||
|
|
||||||
// Basic functions.
|
// Basic functions.
|
||||||
EXPORT_C_(s32) USBinit();
|
EXPORT_C_(s32)
|
||||||
|
USBinit();
|
||||||
// pDisplay normally is passed a handle to the GS plugins window.
|
// pDisplay normally is passed a handle to the GS plugins window.
|
||||||
EXPORT_C_(s32) USBopen(void *pDisplay);
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) USBclose();
|
USBopen(void *pDisplay);
|
||||||
EXPORT_C_(void) USBshutdown();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(u8) USBread8(u32 addr);
|
USBclose();
|
||||||
EXPORT_C_(u16) USBread16(u32 addr);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(u32) USBread32(u32 addr);
|
USBshutdown();
|
||||||
EXPORT_C_(void) USBwrite8(u32 addr, u8 value);
|
EXPORT_C_(u8)
|
||||||
EXPORT_C_(void) USBwrite16(u32 addr, u16 value);
|
USBread8(u32 addr);
|
||||||
EXPORT_C_(void) USBwrite32(u32 addr, u32 value);
|
EXPORT_C_(u16)
|
||||||
EXPORT_C_(void) USBasync(u32 cycles);
|
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,
|
// cycles = IOP cycles before calling callback,
|
||||||
// if callback returns 1 the irq is triggered, else not
|
// if callback returns 1 the irq is triggered, else not
|
||||||
EXPORT_C_(void) USBirqCallback(USBcallback callback);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(USBhandler) USBirqHandler(void);
|
USBirqCallback(USBcallback callback);
|
||||||
EXPORT_C_(void) USBsetRAM(void *mem);
|
EXPORT_C_(USBhandler)
|
||||||
|
USBirqHandler(void);
|
||||||
|
EXPORT_C_(void)
|
||||||
|
USBsetRAM(void *mem);
|
||||||
|
|
||||||
// Extended functions
|
// Extended functions
|
||||||
|
|
||||||
EXPORT_C_(void) USBkeyEvent(keyEvent *ev);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(s32) USBfreeze(u8 mode, freezeData *data);
|
USBkeyEvent(keyEvent *ev);
|
||||||
EXPORT_C_(void) USBconfigure();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) USBabout();
|
USBfreeze(u8 mode, freezeData *data);
|
||||||
EXPORT_C_(s32) USBtest();
|
EXPORT_C_(void)
|
||||||
|
USBconfigure();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
USBabout();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
USBtest();
|
||||||
|
|
||||||
#endif // __USBAPI_H__
|
#endif // __USBAPI_H__
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
// Implement BMI1/BMI2 instruction set
|
// Implement BMI1/BMI2 instruction set
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
struct xImplBMI_RVM
|
struct xImplBMI_RVM
|
||||||
{
|
{
|
||||||
|
@ -57,5 +58,4 @@ namespace x86Emitter {
|
||||||
void operator()( const xRegisterInt& to, const xIndirectVoid& from, u8 imm) const;
|
void operator()( const xRegisterInt& to, const xIndirectVoid& from, u8 imm) const;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
// Implementations here cover SHLD and SHRD.
|
// Implementations here cover SHLD and SHRD.
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
|
||||||
enum G1Type
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
enum G1Type {
|
||||||
G1Type_ADD = 0,
|
G1Type_ADD = 0,
|
||||||
G1Type_OR,
|
G1Type_OR,
|
||||||
G1Type_ADC,
|
G1Type_ADC,
|
||||||
|
@ -140,4 +140,3 @@ struct xImpl_G1Compare
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End namespace x86Emitter
|
} // End namespace x86Emitter
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
|
||||||
enum G2Type
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
enum G2Type {
|
||||||
G2Type_ROL = 0,
|
G2Type_ROL = 0,
|
||||||
G2Type_ROR,
|
G2Type_ROR,
|
||||||
G2Type_RCL,
|
G2Type_RCL,
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
|
||||||
enum G3Type
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
enum G3Type {
|
||||||
G3Type_NOT = 2,
|
G3Type_NOT = 2,
|
||||||
G3Type_NEG = 3,
|
G3Type_NEG = 3,
|
||||||
G3Type_MUL = 4,
|
G3Type_MUL = 4,
|
||||||
|
@ -105,5 +105,4 @@ struct xImpl_iMul
|
||||||
const xImplSimd_DestRegSSE SS;
|
const xImplSimd_DestRegSSE SS;
|
||||||
const xImplSimd_DestRegSSE SD;
|
const xImplSimd_DestRegSSE SD;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
// helpermess is currently broken >_<
|
// helpermess is currently broken >_<
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
// Implementations found here: Increment and Decrement Instructions!
|
// Implementations found here: Increment and Decrement Instructions!
|
||||||
// (They're soooo lonely... but I dunno where else to stick this class!)
|
// (They're soooo lonely... but I dunno where else to stick this class!)
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// xImpl_IncDec
|
// xImpl_IncDec
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
// Implementations found here: CALL and JMP! (unconditional only)
|
// Implementations found here: CALL and JMP! (unconditional only)
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
extern void xJccKnownTarget(JccComparisonType comparison, const void *target, bool slideForward);
|
extern void xJccKnownTarget(JccComparisonType comparison, const void *target, bool slideForward);
|
||||||
|
|
||||||
|
@ -35,8 +36,7 @@ struct xImpl_JmpCall
|
||||||
{
|
{
|
||||||
if (isJmp)
|
if (isJmp)
|
||||||
xJccKnownTarget(Jcc_Unconditional, (void *)(uptr)func, false); // double cast to/from (uptr) needed to appease GCC
|
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
|
// 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).
|
// always 5 bytes (16 bit calls are bad mojo, so no bother to do special logic).
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ struct xImpl_FastCall
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T > __fi
|
template <typename T>
|
||||||
void operator()( T* func, u32 a1, const xRegisterLong& a2) const
|
__fi void operator()(T *func, u32 a1, const xRegisterLong &a2) const
|
||||||
{
|
{
|
||||||
void *f = (void *)func;
|
void *f = (void *)func;
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ struct xImpl_FastCall
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T > __fi
|
template <typename T>
|
||||||
void operator()( T* func, const xIndirectVoid& a1) const
|
__fi void operator()(T *func, const xIndirectVoid &a1) const
|
||||||
{
|
{
|
||||||
void *f = (void *)func;
|
void *f = (void *)func;
|
||||||
|
|
||||||
|
@ -133,8 +133,8 @@ struct xImpl_FastCall
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T > __fi
|
template <typename T>
|
||||||
void operator()( T* func, u32 a1, u32 a2) const
|
__fi void operator()(T *func, u32 a1, u32 a2) const
|
||||||
{
|
{
|
||||||
void *f = (void *)func;
|
void *f = (void *)func;
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ struct xImpl_FastCall
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T > __fi
|
template <typename T>
|
||||||
void operator()( T* func, u32 a1) const
|
__fi void operator()(T *func, u32 a1) const
|
||||||
{
|
{
|
||||||
void *f = (void *)func;
|
void *f = (void *)func;
|
||||||
|
|
||||||
|
@ -184,4 +184,3 @@ struct xImpl_FastCall
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End namespace x86Emitter
|
} // End namespace x86Emitter
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
// Header: ix86_impl_movs.h -- covers mov, cmov, movsx/movzx, and SETcc (which shares
|
// Header: ix86_impl_movs.h -- covers mov, cmov, movsx/movzx, and SETcc (which shares
|
||||||
// with cmov many similarities).
|
// with cmov many similarities).
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// MovImplAll
|
// MovImplAll
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// _SimdShiftHelper
|
// _SimdShiftHelper
|
||||||
|
@ -178,7 +179,6 @@ struct xImplSimd_PSign
|
||||||
// is unchanged. If a data element in src is zero, the corresponding data element in
|
// is unchanged. If a data element in src is zero, the corresponding data element in
|
||||||
// dest is set to zero.
|
// dest is set to zero.
|
||||||
const xImplSimd_DestRegEither D;
|
const xImplSimd_DestRegEither D;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -314,4 +314,3 @@ struct xImplSimd_Round
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End namespace x86Emitter
|
} // End namespace x86Emitter
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
struct xImplSimd_MinMax
|
struct xImplSimd_MinMax
|
||||||
{
|
{
|
||||||
|
@ -120,4 +121,3 @@ struct xImplSimd_PMinMax
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace x86Emitter
|
} // end namespace x86Emitter
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
// =====================================================================================================
|
// =====================================================================================================
|
||||||
// xImpl_SIMD Types (template free!)
|
// xImpl_SIMD Types (template free!)
|
||||||
|
@ -70,4 +71,3 @@ struct xImplSimd_DestRegEither
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace x86Emitter
|
} // end namespace x86Emitter
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// xImplSimd_MovHL
|
// xImplSimd_MovHL
|
||||||
|
@ -169,6 +170,4 @@ struct xImplSimd_PMove
|
||||||
void DQ(const xRegisterSSE &to, const xRegisterSSE &from) const;
|
void DQ(const xRegisterSSE &to, const xRegisterSSE &from) const;
|
||||||
void DQ(const xRegisterSSE &to, const xIndirect64 &from) const;
|
void DQ(const xRegisterSSE &to, const xIndirect64 &from) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// xImplSimd_Shuffle
|
// 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.
|
// used to extract any single packed dword value from src into an x86 32 bit register.
|
||||||
const xImplSimd_InsertExtractHelper D;
|
const xImplSimd_InsertExtractHelper D;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
// Implementations found here: TEST + BTS/BT/BTC/BTR + BSF/BSR! (for lack of better location)
|
// Implementations found here: TEST + BTS/BT/BTC/BTR + BSF/BSR! (for lack of better location)
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// xImpl_Test
|
// xImpl_Test
|
||||||
|
@ -30,8 +31,7 @@ struct xImpl_Test
|
||||||
void operator()(const xRegisterInt &to, int imm) const;
|
void operator()(const xRegisterInt &to, int imm) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum G8Type
|
enum G8Type {
|
||||||
{
|
|
||||||
G8Type_BT = 4,
|
G8Type_BT = 4,
|
||||||
G8Type_BTS,
|
G8Type_BTS,
|
||||||
G8Type_BTR,
|
G8Type_BTR,
|
||||||
|
@ -72,4 +72,3 @@ struct xImpl_Group8
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End namespace x86Emitter
|
} // End namespace x86Emitter
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
// This header file is intended to be the future home of xchg, cmpxchg, xadd, and
|
// This header file is intended to be the future home of xchg, cmpxchg, xadd, and
|
||||||
// other threading-related exchange instructions.
|
// other threading-related exchange instructions.
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
} // End namespace x86Emitter
|
} // End namespace x86Emitter
|
||||||
|
|
|
@ -96,8 +96,7 @@ namespace x86Emitter
|
||||||
extern const xImpl_FastCall xFastCall;
|
extern const xImpl_FastCall xFastCall;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
extern const xImpl_CMov
|
extern const xImpl_CMov xCMOVA, xCMOVAE,
|
||||||
xCMOVA, xCMOVAE,
|
|
||||||
xCMOVB, xCMOVBE,
|
xCMOVB, xCMOVBE,
|
||||||
xCMOVG, xCMOVGE,
|
xCMOVG, xCMOVGE,
|
||||||
xCMOVL, xCMOVLE,
|
xCMOVL, xCMOVLE,
|
||||||
|
@ -111,8 +110,7 @@ namespace x86Emitter
|
||||||
xCMOVPE, xCMOVPO;
|
xCMOVPE, xCMOVPO;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
extern const xImpl_Set
|
extern const xImpl_Set xSETA, xSETAE,
|
||||||
xSETA, xSETAE,
|
|
||||||
xSETB, xSETBE,
|
xSETB, xSETBE,
|
||||||
xSETG, xSETGE,
|
xSETG, xSETGE,
|
||||||
xSETL, xSETLE,
|
xSETL, xSETLE,
|
||||||
|
@ -211,30 +209,110 @@ namespace x86Emitter
|
||||||
// the target (efficient!)
|
// the target (efficient!)
|
||||||
//
|
//
|
||||||
|
|
||||||
template< typename T > __fi void xJE( T* func ) { xJcc( Jcc_Equal, (void*)(uptr)func ); }
|
template <typename T>
|
||||||
template< typename T > __fi void xJZ( T* func ) { xJcc( Jcc_Zero, (void*)(uptr)func ); }
|
__fi void xJE(T *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 ); }
|
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>
|
||||||
template< typename T > __fi void xJNO( T* func ) { xJcc( Jcc_NotOverflow, (void*)(uptr)func ); }
|
__fi void xJO(T *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 ); }
|
xJcc(Jcc_Overflow, (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 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>
|
||||||
template< typename T > __fi void xJPO( T* func ) { xJcc( Jcc_ParityOdd, (void*)(uptr)func ); }
|
__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>
|
||||||
template< typename T > __fi void xJLE( T* func ) { xJcc( Jcc_LessOrEqual, (void*)(uptr)func ); }
|
__fi void xJL(T *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 ); }
|
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>
|
||||||
template< typename T > __fi void xJBE( T* func ) { xJcc( Jcc_BelowOrEqual, (void*)(uptr)func ); }
|
__fi void xJB(T *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 ); }
|
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!)
|
// Forward Jump Helpers (act as labels!)
|
||||||
|
@ -244,7 +322,10 @@ namespace x86Emitter
|
||||||
class xForward##label : public xForwardJump<OperandType> \
|
class xForward##label : public xForwardJump<OperandType> \
|
||||||
{ \
|
{ \
|
||||||
public: \
|
public: \
|
||||||
xForward##label() : xForwardJump<OperandType>( cond ) {} \
|
xForward##label() \
|
||||||
|
: xForwardJump<OperandType>(cond) \
|
||||||
|
{ \
|
||||||
|
} \
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
@ -498,6 +579,4 @@ namespace x86Emitter
|
||||||
extern const SimdImpl_Pack xPACK;
|
extern const SimdImpl_Pack xPACK;
|
||||||
extern const xImplSimd_PInsert xPINSR;
|
extern const xImplSimd_PInsert xPINSR;
|
||||||
extern const SimdImpl_PExtract xPEXTR;
|
extern const SimdImpl_PExtract xPEXTR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
#include "instructions.h"
|
#include "instructions.h"
|
||||||
|
|
||||||
|
|
||||||
namespace x86Emitter {
|
namespace x86Emitter
|
||||||
|
{
|
||||||
|
|
||||||
#define OpWriteSSE(pre, op) xOpWrite0F(pre, op, to, from)
|
#define OpWriteSSE(pre, op) xOpWrite0F(pre, op, to, from)
|
||||||
|
|
||||||
|
@ -40,17 +41,18 @@ namespace x86Emitter {
|
||||||
|
|
||||||
extern void _xMovRtoR(const xRegisterInt &to, const xRegisterInt &from);
|
extern void _xMovRtoR(const xRegisterInt &to, const xRegisterInt &from);
|
||||||
|
|
||||||
template< typename T > inline
|
template <typename T>
|
||||||
void xWrite( T val )
|
inline void xWrite(T val)
|
||||||
{
|
{
|
||||||
*(T *)x86Ptr = val;
|
*(T *)x86Ptr = val;
|
||||||
x86Ptr += sizeof(T);
|
x86Ptr += sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T1, typename T2 > __emitinline
|
template <typename T1, typename T2>
|
||||||
void xOpWrite( u8 prefix, u8 opcode, const T1& param1, const T2& param2 )
|
__emitinline void xOpWrite(u8 prefix, u8 opcode, const T1 ¶m1, const T2 ¶m2)
|
||||||
{
|
{
|
||||||
if( prefix != 0 ) xWrite8( prefix );
|
if (prefix != 0)
|
||||||
|
xWrite8(prefix);
|
||||||
EmitRex(param1, param2);
|
EmitRex(param1, param2);
|
||||||
|
|
||||||
xWrite8(opcode);
|
xWrite8(opcode);
|
||||||
|
@ -58,10 +60,11 @@ namespace x86Emitter {
|
||||||
EmitSibMagic(param1, param2);
|
EmitSibMagic(param1, param2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T1, typename T2 > __emitinline
|
template <typename T1, typename T2>
|
||||||
void xOpAccWrite( u8 prefix, u8 opcode, const T1& param1, const T2& param2 )
|
__emitinline void xOpAccWrite(u8 prefix, u8 opcode, const T1 ¶m1, const T2 ¶m2)
|
||||||
{
|
{
|
||||||
if( prefix != 0 ) xWrite8( prefix );
|
if (prefix != 0)
|
||||||
|
xWrite8(prefix);
|
||||||
EmitRex(param1, param2);
|
EmitRex(param1, param2);
|
||||||
|
|
||||||
xWrite8(opcode);
|
xWrite8(opcode);
|
||||||
|
@ -78,10 +81,11 @@ namespace x86Emitter {
|
||||||
// Prefixes are typically 0x66, 0xf2, or 0xf3. OpcodePrefixes are either 0x38 or
|
// Prefixes are typically 0x66, 0xf2, or 0xf3. OpcodePrefixes are either 0x38 or
|
||||||
// 0x3a [and other value will result in assertion failue].
|
// 0x3a [and other value will result in assertion failue].
|
||||||
//
|
//
|
||||||
template< typename T1, typename T2 > __emitinline
|
template <typename T1, typename T2>
|
||||||
void xOpWrite0F( u8 prefix, u16 opcode, const T1& param1, const T2& param2 )
|
__emitinline void xOpWrite0F(u8 prefix, u16 opcode, const T1 ¶m1, const T2 ¶m2)
|
||||||
{
|
{
|
||||||
if( prefix != 0 ) xWrite8( prefix );
|
if (prefix != 0)
|
||||||
|
xWrite8(prefix);
|
||||||
EmitRex(param1, param2);
|
EmitRex(param1, param2);
|
||||||
|
|
||||||
SimdPrefix(0, opcode);
|
SimdPrefix(0, opcode);
|
||||||
|
@ -89,22 +93,28 @@ namespace x86Emitter {
|
||||||
EmitSibMagic(param1, param2);
|
EmitSibMagic(param1, param2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T1, typename T2 > __emitinline
|
template <typename T1, typename T2>
|
||||||
void xOpWrite0F( u8 prefix, u16 opcode, const T1& param1, const T2& param2, u8 imm8 )
|
__emitinline void xOpWrite0F(u8 prefix, u16 opcode, const T1 ¶m1, const T2 ¶m2, u8 imm8)
|
||||||
{
|
{
|
||||||
xOpWrite0F(prefix, opcode, param1, param2);
|
xOpWrite0F(prefix, opcode, param1, param2);
|
||||||
xWrite8(imm8);
|
xWrite8(imm8);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T1, typename T2 > __emitinline
|
template <typename T1, typename T2>
|
||||||
void xOpWrite0F( u16 opcode, const T1& param1, const T2& param2 ) { xOpWrite0F( 0, opcode, param1, param2 ); }
|
__emitinline void xOpWrite0F(u16 opcode, const T1 ¶m1, const T2 ¶m2)
|
||||||
|
{
|
||||||
|
xOpWrite0F(0, opcode, param1, param2);
|
||||||
|
}
|
||||||
|
|
||||||
template< typename T1, typename T2 > __emitinline
|
template <typename T1, typename T2>
|
||||||
void xOpWrite0F( u16 opcode, const T1& param1, const T2& param2, u8 imm8 ) { xOpWrite0F( 0, opcode, param1, param2, imm8 ); }
|
__emitinline void xOpWrite0F(u16 opcode, const T1 ¶m1, const T2 ¶m2, u8 imm8)
|
||||||
|
{
|
||||||
|
xOpWrite0F(0, opcode, param1, param2, imm8);
|
||||||
|
}
|
||||||
|
|
||||||
// VEX 2 Bytes Prefix
|
// VEX 2 Bytes Prefix
|
||||||
template< typename T1, typename T2, typename T3 > __emitinline
|
template <typename T1, typename T2, typename T3>
|
||||||
void xOpWriteC5( u8 prefix, u8 opcode, const T1& param1, const T2& param2, const T3& param3 )
|
__emitinline void xOpWriteC5(u8 prefix, u8 opcode, const T1 ¶m1, const T2 ¶m2, const T3 ¶m3)
|
||||||
{
|
{
|
||||||
pxAssert(prefix == 0 || prefix == 0x66 || prefix == 0xF3 || prefix == 0xF2);
|
pxAssert(prefix == 0 || prefix == 0x66 || prefix == 0xF3 || prefix == 0xF2);
|
||||||
|
|
||||||
|
@ -131,8 +141,8 @@ namespace x86Emitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// VEX 3 Bytes Prefix
|
// VEX 3 Bytes Prefix
|
||||||
template< typename T1, typename T2, typename T3 > __emitinline
|
template <typename T1, typename T2, typename T3>
|
||||||
void xOpWriteC4( u8 prefix, u8 mb_prefix, u8 opcode, const T1& param1, const T2& param2, const T3& param3, int w = -1 )
|
__emitinline void xOpWriteC4(u8 prefix, u8 mb_prefix, u8 opcode, const T1 ¶m1, const T2 ¶m2, const T3 ¶m3, int w = -1)
|
||||||
{
|
{
|
||||||
pxAssert(prefix == 0 || prefix == 0x66 || prefix == 0xF3 || prefix == 0xF2);
|
pxAssert(prefix == 0 || prefix == 0x66 || prefix == 0xF3 || prefix == 0xF2);
|
||||||
pxAssert(mb_prefix == 0x0F || mb_prefix == 0x38 || mb_prefix == 0x3A);
|
pxAssert(mb_prefix == 0x0F || mb_prefix == 0x38 || mb_prefix == 0x3A);
|
||||||
|
@ -169,6 +179,4 @@ namespace x86Emitter {
|
||||||
xWrite8(opcode);
|
xWrite8(opcode);
|
||||||
EmitSibMagic(param1, param3);
|
EmitSibMagic(param1, param3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,4 +38,3 @@ extern void SibSB( uint ss, uint index, uint base );
|
||||||
extern void SET8R(int cc, int to);
|
extern void SET8R(int cc, int to);
|
||||||
extern u8 *J8Rel(int cc, int to);
|
extern u8 *J8Rel(int cc, int to);
|
||||||
extern u32 *J32Rel(int cc, u32 to);
|
extern u32 *J32Rel(int cc, u32 to);
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
|
|
||||||
#include "x86emitter.h"
|
#include "x86emitter.h"
|
||||||
|
|
||||||
enum x86VendorType
|
enum x86VendorType {
|
||||||
{
|
|
||||||
x86Vendor_Intel = 0,
|
x86Vendor_Intel = 0,
|
||||||
x86Vendor_AMD = 1,
|
x86Vendor_AMD = 1,
|
||||||
x86Vendor_Unknown = 2
|
x86Vendor_Unknown = 2
|
||||||
|
@ -53,8 +52,10 @@ public:
|
||||||
// x86 CPU Capabilities Section (all boolean flags!)
|
// x86 CPU Capabilities Section (all boolean flags!)
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
union {
|
union
|
||||||
struct {
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
u32 hasFloatingPointUnit : 1;
|
u32 hasFloatingPointUnit : 1;
|
||||||
u32 hasVirtual8086ModeEnhancements : 1;
|
u32 hasVirtual8086ModeEnhancements : 1;
|
||||||
u32 hasDebuggingExtensions : 1;
|
u32 hasDebuggingExtensions : 1;
|
||||||
|
@ -123,8 +124,7 @@ protected:
|
||||||
void CountLogicalCores();
|
void CountLogicalCores();
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SSE_RoundMode
|
enum SSE_RoundMode {
|
||||||
{
|
|
||||||
SSE_RoundMode_FIRST = 0,
|
SSE_RoundMode_FIRST = 0,
|
||||||
SSEround_Nearest = 0,
|
SSEround_Nearest = 0,
|
||||||
SSEround_NegInf,
|
SSEround_NegInf,
|
||||||
|
@ -199,4 +199,3 @@ extern SSE_MXCSR MXCSR_Mask;
|
||||||
|
|
||||||
|
|
||||||
extern __aligned16 x86capabilities x86caps;
|
extern __aligned16 x86capabilities x86caps;
|
||||||
|
|
||||||
|
|
|
@ -39,18 +39,22 @@
|
||||||
|
|
||||||
#include <cpuid.h>
|
#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]);
|
__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]);
|
__cpuid(InfoType, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ __attribute__((always_inline)) unsigned long long _xgetbv(unsigned int index)
|
static __inline__ __attribute__((always_inline)) unsigned long long _xgetbv(unsigned int index)
|
||||||
{
|
{
|
||||||
unsigned int eax, edx;
|
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;
|
return ((unsigned long long)edx << 32) | eax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,7 @@ static const uint iREGCNT_XMM = 8;
|
||||||
static const uint iREGCNT_GPR = 8;
|
static const uint iREGCNT_GPR = 8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum XMMSSEType
|
enum XMMSSEType {
|
||||||
{
|
|
||||||
XMMT_INT = 0, // integer (sse2 only)
|
XMMT_INT = 0, // integer (sse2 only)
|
||||||
XMMT_FPS = 1, // floating point
|
XMMT_FPS = 1, // floating point
|
||||||
//XMMT_FPD = 3, // double
|
//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.
|
// templated version of is_s8 is required, so that u16's get correct sign extension treatment.
|
||||||
template <typename T>
|
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]
|
// ALWAYS_USE_MOVAPS [define] / AlwaysUseMovaps [const]
|
||||||
|
@ -124,8 +127,7 @@ template< typename T > void xWrite( T val );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ModRM 'mod' field enumeration. Provided mostly for reference:
|
// 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_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_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],
|
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!
|
// JccComparisonType - enumerated possibilities for inspired code branching!
|
||||||
//
|
//
|
||||||
enum JccComparisonType
|
enum JccComparisonType {
|
||||||
{
|
|
||||||
Jcc_Unknown = -2,
|
Jcc_Unknown = -2,
|
||||||
Jcc_Unconditional = -1,
|
Jcc_Unconditional = -1,
|
||||||
Jcc_Overflow = 0x0,
|
Jcc_Overflow = 0x0,
|
||||||
|
@ -167,8 +168,7 @@ template< typename T > void xWrite( T val );
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// SSE2_ComparisonType - enumerated possibilities for SIMD data comparison!
|
// SSE2_ComparisonType - enumerated possibilities for SIMD data comparison!
|
||||||
//
|
//
|
||||||
enum SSE2_ComparisonType
|
enum SSE2_ComparisonType {
|
||||||
{
|
|
||||||
SSE2_Equal = 0,
|
SSE2_Equal = 0,
|
||||||
SSE2_Less,
|
SSE2_Less,
|
||||||
SSE2_LessOrEqual,
|
SSE2_LessOrEqual,
|
||||||
|
@ -204,16 +204,27 @@ template< typename T > void xWrite( T val );
|
||||||
|
|
||||||
bool Is8BitOp() const { return GetOperandSize() == 1; }
|
bool Is8BitOp() const { return GetOperandSize() == 1; }
|
||||||
u8 GetPrefix16() const { return GetOperandSize() == 2 ? 0x66 : 0; }
|
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
|
void xWriteImm(int imm) const
|
||||||
{
|
{
|
||||||
switch( GetOperandSize() )
|
switch (GetOperandSize()) {
|
||||||
{
|
case 1:
|
||||||
case 1: xWrite8( imm ); break;
|
xWrite8(imm);
|
||||||
case 2: xWrite16( imm ); break;
|
break;
|
||||||
case 4: xWrite32( imm ); break;
|
case 2:
|
||||||
case 8: xWrite64( imm ); break;
|
xWrite16(imm);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
xWrite32(imm);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
xWrite64(imm);
|
||||||
|
break;
|
||||||
|
|
||||||
jNO_DEFAULT
|
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)
|
// IsWide: return true if the register is 64 bits (requires a wide op on the rex prefix)
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
bool IsWide() const { return GetOperandSize() == 8; }
|
bool IsWide() const
|
||||||
|
{
|
||||||
|
return GetOperandSize() == 8;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
bool IsWide() const { return false; } // no 64 bits GPR
|
bool IsWide() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
} // no 64 bits GPR
|
||||||
#endif
|
#endif
|
||||||
// return true if the register is a valid YMM register
|
// return true if the register is a valid YMM register
|
||||||
bool IsWideSIMD() const { return GetOperandSize() == 32; }
|
bool IsWideSIMD() const { return GetOperandSize() == 32; }
|
||||||
|
@ -289,8 +306,14 @@ template< typename T > void xWrite( T val );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xRegisterInt() {}
|
xRegisterInt() {}
|
||||||
explicit xRegisterInt( const xRegisterBase& src ) : _parent( src ) {}
|
explicit xRegisterInt(const xRegisterBase &src)
|
||||||
explicit xRegisterInt( int regId ) : _parent( regId ) { }
|
: _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 Id == src.Id && (GetOperandSize() == src.GetOperandSize()); }
|
||||||
bool operator!=(const xRegisterInt &src) const { return !operator==(src); }
|
bool operator!=(const xRegisterInt &src) const { return !operator==(src); }
|
||||||
|
@ -304,8 +327,14 @@ template< typename T > void xWrite( T val );
|
||||||
typedef xRegisterInt _parent;
|
typedef xRegisterInt _parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xRegister8(): _parent() {}
|
xRegister8()
|
||||||
explicit xRegister8( int regId ) : _parent( regId ) {}
|
: _parent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit xRegister8(int regId)
|
||||||
|
: _parent(regId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual uint GetOperandSize() const { return 1; }
|
virtual uint GetOperandSize() const { return 1; }
|
||||||
|
|
||||||
|
@ -318,8 +347,14 @@ template< typename T > void xWrite( T val );
|
||||||
typedef xRegisterInt _parent;
|
typedef xRegisterInt _parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xRegister16(): _parent() {}
|
xRegister16()
|
||||||
explicit xRegister16( int regId ) : _parent( regId ) {}
|
: _parent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit xRegister16(int regId)
|
||||||
|
: _parent(regId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual uint GetOperandSize() const { return 2; }
|
virtual uint GetOperandSize() const { return 2; }
|
||||||
|
|
||||||
|
@ -332,8 +367,14 @@ template< typename T > void xWrite( T val );
|
||||||
typedef xRegisterInt _parent;
|
typedef xRegisterInt _parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xRegister32(): _parent() {}
|
xRegister32()
|
||||||
explicit xRegister32( int regId ) : _parent( regId ) {}
|
: _parent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit xRegister32(int regId)
|
||||||
|
: _parent(regId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual uint GetOperandSize() const { return 4; }
|
virtual uint GetOperandSize() const { return 4; }
|
||||||
|
|
||||||
|
@ -346,8 +387,14 @@ template< typename T > void xWrite( T val );
|
||||||
typedef xRegisterInt _parent;
|
typedef xRegisterInt _parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xRegister64(): _parent() {}
|
xRegister64()
|
||||||
explicit xRegister64( int regId ) : _parent( regId ) {}
|
: _parent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit xRegister64(int regId)
|
||||||
|
: _parent(regId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual uint GetOperandSize() const { return 8; }
|
virtual uint GetOperandSize() const { return 8; }
|
||||||
|
|
||||||
|
@ -366,8 +413,14 @@ template< typename T > void xWrite( T val );
|
||||||
typedef xRegisterBase _parent;
|
typedef xRegisterBase _parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xRegisterSSE(): _parent() {}
|
xRegisterSSE()
|
||||||
explicit xRegisterSSE( int regId ) : _parent( regId ) {}
|
: _parent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit xRegisterSSE(int regId)
|
||||||
|
: _parent(regId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual uint GetOperandSize() const { return 16; }
|
virtual uint GetOperandSize() const { return 16; }
|
||||||
|
|
||||||
|
@ -394,7 +447,10 @@ template< typename T > void xWrite( T val );
|
||||||
class xRegisterCL : public xRegister8
|
class xRegisterCL : public xRegister8
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
xRegisterCL(): xRegister8( 1 ) {}
|
xRegisterCL()
|
||||||
|
: xRegister8(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
@ -417,11 +473,26 @@ template< typename T > void xWrite( T val );
|
||||||
class xAddressReg : public xRegisterLong
|
class xAddressReg : public xRegisterLong
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
xAddressReg(): xRegisterLong() {}
|
xAddressReg()
|
||||||
xAddressReg( const xAddressReg& src ) : xRegisterLong( src.Id ) {}
|
: xRegisterLong()
|
||||||
xAddressReg( const xRegister32& src ) : xRegisterLong( src.Id ) {}
|
{
|
||||||
xAddressReg( const xRegister64& src ) : xRegisterLong( src.Id ) {}
|
}
|
||||||
explicit xAddressReg( int regId ) : xRegisterLong( regId ) {}
|
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.
|
// Returns true if the register is the stack pointer: ESP.
|
||||||
bool IsStackPointer() const { return Id == 4; }
|
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-(const void *right) const;
|
||||||
xAddressVoid operator*(int factor) const;
|
xAddressVoid operator*(int factor) const;
|
||||||
xAddressVoid operator<<(u32 shift) const;
|
xAddressVoid operator<<(u32 shift) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
@ -469,8 +539,14 @@ template< typename T > void xWrite( T val );
|
||||||
const xRegisterInt &m_convtype;
|
const xRegisterInt &m_convtype;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xRegister16or32( const xRegister32& src ) : m_convtype( src ) {}
|
xRegister16or32(const xRegister32 &src)
|
||||||
xRegister16or32( const xRegister16& src ) : m_convtype( src ) {}
|
: m_convtype(src)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
xRegister16or32(const xRegister16 &src)
|
||||||
|
: m_convtype(src)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
operator const xRegisterBase &() const { return m_convtype; }
|
operator const xRegisterBase &() const { return m_convtype; }
|
||||||
|
|
||||||
|
@ -486,9 +562,18 @@ template< typename T > void xWrite( T val );
|
||||||
const xRegisterInt &m_convtype;
|
const xRegisterInt &m_convtype;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xRegister16or32or64( const xRegister64& src ) : m_convtype( src ) {}
|
xRegister16or32or64(const xRegister64 &src)
|
||||||
xRegister16or32or64( const xRegister32& src ) : m_convtype( src ) {}
|
: m_convtype(src)
|
||||||
xRegister16or32or64( const xRegister16& 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; }
|
operator const xRegisterBase &() const { return m_convtype; }
|
||||||
|
|
||||||
|
@ -504,8 +589,14 @@ template< typename T > void xWrite( T val );
|
||||||
const xRegisterInt &m_convtype;
|
const xRegisterInt &m_convtype;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xRegister32or64( const xRegister64& src ) : m_convtype( src ) {}
|
xRegister32or64(const xRegister64 &src)
|
||||||
xRegister32or64( const xRegister32& src ) : m_convtype( src ) {}
|
: m_convtype(src)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
xRegister32or64(const xRegister32 &src)
|
||||||
|
: m_convtype(src)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
operator const xRegisterBase &() const { return m_convtype; }
|
operator const xRegisterBase &() const { return m_convtype; }
|
||||||
|
|
||||||
|
@ -517,6 +608,8 @@ template< typename T > void xWrite( T val );
|
||||||
|
|
||||||
extern const xRegisterEmpty xEmptyReg;
|
extern const xRegisterEmpty xEmptyReg;
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
extern const xRegisterSSE
|
extern const xRegisterSSE
|
||||||
xmm0, xmm1, xmm2, xmm3,
|
xmm0, xmm1, xmm2, xmm3,
|
||||||
xmm4, xmm5, xmm6, xmm7,
|
xmm4, xmm5, xmm6, xmm7,
|
||||||
|
@ -541,6 +634,8 @@ template< typename T > void xWrite( T val );
|
||||||
al, dl, bl,
|
al, dl, bl,
|
||||||
ah, ch, dh, bh;
|
ah, ch, dh, bh;
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
extern const xRegisterCL cl; // I'm special!
|
extern const xRegisterCL cl; // I'm special!
|
||||||
|
|
||||||
const xRegisterSSE &xRegisterSSE::GetInstance(uint id)
|
const xRegisterSSE &xRegisterSSE::GetInstance(uint id)
|
||||||
|
@ -550,8 +645,7 @@ template< typename T > void xWrite( T val );
|
||||||
&xmm0, &xmm1, &xmm2, &xmm3,
|
&xmm0, &xmm1, &xmm2, &xmm3,
|
||||||
&xmm4, &xmm5, &xmm6, &xmm7,
|
&xmm4, &xmm5, &xmm6, &xmm7,
|
||||||
&xmm8, &xmm9, &xmm10, &xmm11,
|
&xmm8, &xmm9, &xmm10, &xmm11,
|
||||||
&xmm12, &xmm13, &xmm14, &xmm15
|
&xmm12, &xmm13, &xmm14, &xmm15};
|
||||||
};
|
|
||||||
|
|
||||||
pxAssert(id < iREGCNT_XMM);
|
pxAssert(id < iREGCNT_XMM);
|
||||||
return *m_tbl_xmmRegs[id];
|
return *m_tbl_xmmRegs[id];
|
||||||
|
@ -608,16 +702,22 @@ template< typename T > void xWrite( T val );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xAddressInfo(const xAddressReg &base, const xAddressReg &index, int factor = 1, s32 displacement = 0)
|
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 )
|
/*xAddressInfo( const xAddressVoid& src )
|
||||||
: _parent( src ) {}*/
|
: _parent( src ) {}*/
|
||||||
|
|
||||||
explicit xAddressInfo(const xAddressReg &index, int displacement = 0)
|
explicit xAddressInfo(const xAddressReg &index, int displacement = 0)
|
||||||
: _parent( index, displacement ) {}
|
: _parent(index, displacement)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
explicit xAddressInfo(s32 displacement = 0)
|
explicit xAddressInfo(s32 displacement = 0)
|
||||||
: _parent( displacement ) {}
|
: _parent(displacement)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static xAddressInfo<BaseType> FromIndexReg(const xAddressReg &index, int scale = 0, s32 displacement = 0);
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
xAddressInfo<BaseType>& Add( const xAddressReg& src ) { _parent::Add(src); return *this; }
|
xAddressInfo<BaseType> &Add(const xAddressReg &src)
|
||||||
xAddressInfo<BaseType>& Add( const xAddressInfo<BaseType>& src ) { _parent::Add(src); return *this; }
|
{
|
||||||
|
_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 xAddressReg &right) const { return xAddressInfo(*this).Add(right); }
|
||||||
__fi xAddressInfo<BaseType> operator+(const xAddressInfo<BaseType> &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;
|
int m_imm;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xImmReg() : m_reg()
|
xImmReg()
|
||||||
|
: m_reg()
|
||||||
{
|
{
|
||||||
m_imm = 0;
|
m_imm = 0;
|
||||||
}
|
}
|
||||||
|
@ -760,10 +869,18 @@ template< typename T > void xWrite( T val );
|
||||||
typedef xIndirectVoid _parent;
|
typedef xIndirectVoid _parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit xIndirect( s32 disp ) : _parent( disp ) {}
|
explicit xIndirect(s32 disp)
|
||||||
explicit xIndirect( const xAddressInfo<OperandType>& src ) : _parent( src ) {}
|
: _parent(disp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit xIndirect(const xAddressInfo<OperandType> &src)
|
||||||
|
: _parent(src)
|
||||||
|
{
|
||||||
|
}
|
||||||
xIndirect(xAddressReg base, xAddressReg index, int scale = 0, s32 displacement = 0)
|
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); }
|
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
|
bool operator==(const xIndirect<OperandType> &src) const
|
||||||
{
|
{
|
||||||
return
|
return (Base == src.Base) && (Index == src.Index) &&
|
||||||
( Base == src.Base ) && ( Index == src.Index ) &&
|
|
||||||
(Scale == src.Scale) && (Displacement == src.Displacement);
|
(Scale == src.Scale) && (Displacement == src.Displacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,19 +925,40 @@ template< typename T > void xWrite( T val );
|
||||||
uint m_OpSize;
|
uint m_OpSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xIndirect64orLess( const xIndirect8& src ) : _parent( src ) { m_OpSize = src.GetOperandSize(); }
|
xIndirect64orLess(const xIndirect8 &src)
|
||||||
xIndirect64orLess( const xIndirect16& src ) : _parent( src ) { m_OpSize = src.GetOperandSize(); }
|
: _parent(src)
|
||||||
xIndirect64orLess( const xIndirect32& src ) : _parent( src ) { m_OpSize = src.GetOperandSize(); }
|
{
|
||||||
xIndirect64orLess( const xIndirect64& src ) : _parent( src ) { m_OpSize = src.GetOperandSize(); }
|
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; }
|
uint GetOperandSize() const { return m_OpSize; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//xIndirect64orLess( const xAddressVoid& src ) : _parent( src ) {}
|
//xIndirect64orLess( const xAddressVoid& src ) : _parent( src ) {}
|
||||||
|
|
||||||
explicit xIndirect64orLess( s32 disp ) : _parent( disp ) {}
|
explicit xIndirect64orLess(s32 disp)
|
||||||
xIndirect64orLess( xAddressReg base, xAddressReg index, int scale=0, s32 displacement=0 ) :
|
: _parent(disp)
|
||||||
_parent( base, index, scale, displacement ) {}
|
{
|
||||||
|
}
|
||||||
|
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
|
// The jump instruction is emitted at the point of object construction. The conditional
|
||||||
// type must be valid (Jcc_Unknown generates an assertion).
|
// 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.
|
// 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
|
// This method can be called multiple times, re-writing the jump instruction's target
|
||||||
|
|
|
@ -43,8 +43,7 @@ void CheckedStaticBox::SetValue( bool val )
|
||||||
{
|
{
|
||||||
wxWindowList &list = GetChildren();
|
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;
|
wxWindow *current = *iter;
|
||||||
if (current != &ThisToggle)
|
if (current != &ThisToggle)
|
||||||
current->Enable(val);
|
current->Enable(val);
|
||||||
|
@ -61,13 +60,13 @@ bool CheckedStaticBox::GetValue() const
|
||||||
// the enable request are true. If not, disable them!
|
// the enable request are true. If not, disable them!
|
||||||
bool CheckedStaticBox::Enable(bool enable)
|
bool CheckedStaticBox::Enable(bool enable)
|
||||||
{
|
{
|
||||||
if (!_parent::Enable(enable)) return false;
|
if (!_parent::Enable(enable))
|
||||||
|
return false;
|
||||||
|
|
||||||
bool val = enable && ThisToggle.GetValue();
|
bool val = enable && ThisToggle.GetValue();
|
||||||
wxWindowList &list = GetChildren();
|
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;
|
wxWindow *current = *iter;
|
||||||
if (current != &ThisToggle)
|
if (current != &ThisToggle)
|
||||||
current->Enable(val);
|
current->Enable(val);
|
||||||
|
|
|
@ -50,8 +50,7 @@ void Console_SetActiveHandler( const IConsoleWriter& writer, FILE* flushfp )
|
||||||
(writer.WriteRaw != NULL) && (writer.DoWriteLn != NULL) &&
|
(writer.WriteRaw != NULL) && (writer.DoWriteLn != NULL) &&
|
||||||
(writer.Newline != NULL) && (writer.SetTitle != NULL) &&
|
(writer.Newline != NULL) && (writer.SetTitle != NULL) &&
|
||||||
(writer.DoSetColor != 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;
|
Console = writer;
|
||||||
DevConWriter = writer;
|
DevConWriter = writer;
|
||||||
|
@ -67,7 +66,8 @@ void MSW_OutputDebugString( const wxString& text )
|
||||||
{
|
{
|
||||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||||
static bool hasDebugger = wxIsDebuggerRunning();
|
static bool hasDebugger = wxIsDebuggerRunning();
|
||||||
if( hasDebugger ) OutputDebugString( text );
|
if (hasDebugger)
|
||||||
|
OutputDebugString(text);
|
||||||
#else
|
#else
|
||||||
fputs(text.utf8_str(), stdout_fp);
|
fputs(text.utf8_str(), stdout_fp);
|
||||||
fflush(stdout_fp);
|
fflush(stdout_fp);
|
||||||
|
@ -105,41 +105,56 @@ const IConsoleWriter ConsoleWriter_Null =
|
||||||
#if defined(__unix__)
|
#if defined(__unix__)
|
||||||
static __fi const char *GetLinuxConsoleColor(ConsoleColors color)
|
static __fi const char *GetLinuxConsoleColor(ConsoleColors color)
|
||||||
{
|
{
|
||||||
switch(color)
|
switch (color) {
|
||||||
{
|
|
||||||
case Color_Black:
|
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_Red:
|
||||||
case Color_StrongRed: return "\033[31m\033[1m";
|
return "\033[31m";
|
||||||
|
case Color_StrongRed:
|
||||||
|
return "\033[31m\033[1m";
|
||||||
|
|
||||||
case Color_Green: return "\033[32m";
|
case Color_Green:
|
||||||
case Color_StrongGreen: return "\033[32m\033[1m";
|
return "\033[32m";
|
||||||
|
case Color_StrongGreen:
|
||||||
|
return "\033[32m\033[1m";
|
||||||
|
|
||||||
case Color_Yellow: return "\033[33m";
|
case Color_Yellow:
|
||||||
case Color_StrongYellow: return "\033[33m\033[1m";
|
return "\033[33m";
|
||||||
|
case Color_StrongYellow:
|
||||||
|
return "\033[33m\033[1m";
|
||||||
|
|
||||||
case Color_Blue: return "\033[34m";
|
case Color_Blue:
|
||||||
case Color_StrongBlue: return "\033[34m\033[1m";
|
return "\033[34m";
|
||||||
|
case Color_StrongBlue:
|
||||||
|
return "\033[34m\033[1m";
|
||||||
|
|
||||||
// No orange, so use magenta.
|
// No orange, so use magenta.
|
||||||
case Color_Orange:
|
case Color_Orange:
|
||||||
case Color_Magenta: return "\033[35m";
|
case Color_Magenta:
|
||||||
|
return "\033[35m";
|
||||||
case Color_StrongOrange:
|
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_Cyan:
|
||||||
case Color_StrongCyan: return "\033[36m\033[1m";
|
return "\033[36m";
|
||||||
|
case Color_StrongCyan:
|
||||||
|
return "\033[36m\033[1m";
|
||||||
|
|
||||||
// Use 'white' instead of grey.
|
// Use 'white' instead of grey.
|
||||||
case Color_Gray:
|
case Color_Gray:
|
||||||
case Color_White: return "\033[37m";
|
case Color_White:
|
||||||
|
return "\033[37m";
|
||||||
case Color_StrongGray:
|
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.
|
// On some other value being passed, clear any formatting.
|
||||||
case Color_Default:
|
case Color_Default:
|
||||||
default: return "\033[0m";
|
default:
|
||||||
|
return "\033[0m";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -230,7 +245,8 @@ const IConsoleWriter ConsoleWriter_Assert =
|
||||||
wxString IConsoleWriter::_addIndentation(const wxString &src, int glob_indent = 0) const
|
wxString IConsoleWriter::_addIndentation(const wxString &src, int glob_indent = 0) const
|
||||||
{
|
{
|
||||||
const int indent = glob_indent + _imm_indentation;
|
const int indent = glob_indent + _imm_indentation;
|
||||||
if( indent == 0 ) return src;
|
if (indent == 0)
|
||||||
|
return src;
|
||||||
|
|
||||||
wxString result(src);
|
wxString result(src);
|
||||||
const wxString indentStr(L'\t', indent);
|
const wxString indentStr(L'\t', indent);
|
||||||
|
@ -261,7 +277,8 @@ IConsoleWriter IConsoleWriter::Indent( int tabcount ) const
|
||||||
const IConsoleWriter &IConsoleWriter::SetColor(ConsoleColors color) const
|
const IConsoleWriter &IConsoleWriter::SetColor(ConsoleColors color) const
|
||||||
{
|
{
|
||||||
// Ignore current color requests since, well, the current color is already set. ;)
|
// 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.");
|
pxAssertMsg((color > Color_Current) && (color < ConsoleColors_Count), "Invalid ConsoleColor specified.");
|
||||||
|
|
||||||
|
@ -456,8 +473,7 @@ ConsoleColorScope::~ConsoleColorScope() throw()
|
||||||
|
|
||||||
void ConsoleColorScope::EnterScope()
|
void ConsoleColorScope::EnterScope()
|
||||||
{
|
{
|
||||||
if (!m_IsScoped)
|
if (!m_IsScoped) {
|
||||||
{
|
|
||||||
m_old_color = Console.GetColor();
|
m_old_color = Console.GetColor();
|
||||||
Console.SetColor(m_newcolor);
|
Console.SetColor(m_newcolor);
|
||||||
m_IsScoped = true;
|
m_IsScoped = true;
|
||||||
|
|
|
@ -157,12 +157,10 @@ void Threading::Semaphore::Wait()
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
|
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
|
||||||
WaitWithoutYield();
|
WaitWithoutYield();
|
||||||
}
|
} else if (_WaitGui_RecursionGuard(L"Semaphore::Wait")) {
|
||||||
else if(_WaitGui_RecursionGuard( L"Semaphore::Wait" )) {
|
|
||||||
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
||||||
WaitWithoutYield();
|
WaitWithoutYield();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
while (!WaitWithoutYield(def_yieldgui_interval)) {
|
while (!WaitWithoutYield(def_yieldgui_interval)) {
|
||||||
YieldToMain();
|
YieldToMain();
|
||||||
}
|
}
|
||||||
|
@ -186,17 +184,16 @@ bool Threading::Semaphore::Wait(const wxTimeSpan& timeout)
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
|
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
|
||||||
return WaitWithoutYield(timeout);
|
return WaitWithoutYield(timeout);
|
||||||
}
|
} else if (_WaitGui_RecursionGuard(L"Semaphore::TimedWait")) {
|
||||||
else if (_WaitGui_RecursionGuard( L"Semaphore::TimedWait")) {
|
|
||||||
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
||||||
return WaitWithoutYield(timeout);
|
return WaitWithoutYield(timeout);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
||||||
wxTimeSpan countdown((timeout));
|
wxTimeSpan countdown((timeout));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (WaitWithoutYield(def_yieldgui_interval)) break;
|
if (WaitWithoutYield(def_yieldgui_interval))
|
||||||
|
break;
|
||||||
YieldToMain();
|
YieldToMain();
|
||||||
countdown -= def_yieldgui_interval;
|
countdown -= def_yieldgui_interval;
|
||||||
} while (countdown.GetMilliseconds() > 0);
|
} while (countdown.GetMilliseconds() > 0);
|
||||||
|
|
|
@ -66,7 +66,8 @@ u64 Threading::GetThreadTicksPerSecond()
|
||||||
|
|
||||||
// gets the CPU time used by the current thread (both system and user), in
|
// gets the CPU time used by the current thread (both system and user), in
|
||||||
// microseconds, returns 0 on failure
|
// 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;
|
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
|
||||||
thread_basic_info_data_t info;
|
thread_basic_info_data_t info;
|
||||||
|
|
||||||
|
|
|
@ -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.
|
// we get meaningless assertions while unwinding stack traces after exceptions have occurred.
|
||||||
|
|
||||||
RecursionGuard guard(s_assert_guard);
|
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
|
// 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
|
// 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;
|
bool trapit;
|
||||||
|
|
||||||
if( pxDoAssert == NULL )
|
if (pxDoAssert == NULL) {
|
||||||
{
|
|
||||||
// Note: Format uses MSVC's syntax for output window hotlinking.
|
// Note: Format uses MSVC's syntax for output window hotlinking.
|
||||||
trapit = pxAssertImpl_LogIt(origin, msg);
|
trapit = pxAssertImpl_LogIt(origin, msg);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
trapit = pxDoAssert(origin, msg);
|
trapit = pxDoAssert(origin, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( trapit ) { pxTrap(); }
|
if (trapit) {
|
||||||
|
pxTrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__fi void pxOnAssert(const DiagnosticOrigin &origin, const char *msg)
|
__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",
|
SetDiagMsg(pxsFmt(L"STL Runtime Error%s: %s",
|
||||||
(prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()),
|
(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)
|
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",
|
SetDiagMsg(pxsFmt(L"STL Exception%s: %s",
|
||||||
(prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()),
|
(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;
|
FastFormatUnicode retmsg;
|
||||||
retmsg.Write(L"%s",
|
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())
|
if (!m_message_diag.IsEmpty())
|
||||||
retmsg.Write(L"\n\n%s", WX_STR(m_message_diag));
|
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)");
|
pxAssumeDev(errcode != 0, "Invalid NULL error code? (errno)");
|
||||||
|
|
||||||
switch( errcode )
|
switch (errcode) {
|
||||||
{
|
|
||||||
case EINVAL:
|
case EINVAL:
|
||||||
pxFailDev(L"Invalid argument");
|
pxFailDev(L"Invalid argument");
|
||||||
return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Invalid argument? (likely caused by an unforgivable programmer error!)");
|
return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Invalid argument? (likely caused by an unforgivable programmer error!)");
|
||||||
|
|
|
@ -37,11 +37,11 @@ static
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
__ri
|
__ri
|
||||||
#endif
|
#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;
|
va_list args;
|
||||||
while( true )
|
while (true) {
|
||||||
{
|
|
||||||
int size = buffer.GetLength();
|
int size = buffer.GetLength();
|
||||||
|
|
||||||
va_copy(args, argptr);
|
va_copy(args, argptr);
|
||||||
|
@ -53,7 +53,8 @@ void format_that_ascii_mess( CharBufferType& buffer, uint writepos, const char*
|
||||||
// always do it manually
|
// always do it manually
|
||||||
buffer[size - 1] = '\0';
|
buffer[size - 1] = '\0';
|
||||||
|
|
||||||
if (size >= MaxFormattedStringLength) break;
|
if (size >= MaxFormattedStringLength)
|
||||||
|
break;
|
||||||
|
|
||||||
// vsnprintf() may return either -1 (traditional Unix behavior) or the
|
// vsnprintf() may return either -1 (traditional Unix behavior) or the
|
||||||
// total number of characters which would have been written if 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 = size + (size / 4);
|
||||||
|
|
||||||
len += writepos;
|
len += writepos;
|
||||||
if (len < size) break;
|
if (len < size)
|
||||||
|
break;
|
||||||
buffer.Resize(len + 128);
|
buffer.Resize(len + 128);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,11 +78,11 @@ static
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
__ri
|
__ri
|
||||||
#endif
|
#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;
|
va_list args;
|
||||||
while( true )
|
while (true) {
|
||||||
{
|
|
||||||
int size = buffer.GetLength() / sizeof(wxChar);
|
int size = buffer.GetLength() / sizeof(wxChar);
|
||||||
|
|
||||||
va_copy(args, argptr);
|
va_copy(args, argptr);
|
||||||
|
@ -92,7 +94,8 @@ uint format_that_unicode_mess( CharBufferType& buffer, uint writepos, const wxCh
|
||||||
// always do it manually
|
// always do it manually
|
||||||
((wxChar *)buffer.GetPtr())[size - 1] = L'\0';
|
((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
|
// vsnprintf() may return either -1 (traditional Unix behavior) or the
|
||||||
// total number of characters which would have been written if 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 = size + (size / 4);
|
||||||
|
|
||||||
len += writepos;
|
len += writepos;
|
||||||
if (len < size) return len;
|
if (len < size)
|
||||||
|
return len;
|
||||||
buffer.Resize((len + 128) * sizeof(wxChar));
|
buffer.Resize((len + 128) * sizeof(wxChar));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "HashMap.h"
|
#include "HashMap.h"
|
||||||
|
|
||||||
namespace HashTools {
|
namespace HashTools
|
||||||
|
{
|
||||||
|
|
||||||
#define get16bits(d) (*((const u16 *)(d)))
|
#define get16bits(d) (*((const u16 *)(d)))
|
||||||
|
|
||||||
|
@ -57,14 +58,14 @@ u32 Hash(const s8 * data, int len)
|
||||||
u32 hash = len;
|
u32 hash = len;
|
||||||
int rem;
|
int rem;
|
||||||
|
|
||||||
if (len <= 0 || data == NULL) return 0;
|
if (len <= 0 || data == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
rem = len & 3;
|
rem = len & 3;
|
||||||
len >>= 2;
|
len >>= 2;
|
||||||
|
|
||||||
/* Main loop */
|
/* Main loop */
|
||||||
for (;len > 0; --len)
|
for (; len > 0; --len) {
|
||||||
{
|
|
||||||
hash += get16bits(data);
|
hash += get16bits(data);
|
||||||
u32 tmp = (get16bits(data + 2) << 11) ^ hash;
|
u32 tmp = (get16bits(data + 2) << 11) ^ hash;
|
||||||
hash = (hash << 16) ^ tmp;
|
hash = (hash << 16) ^ tmp;
|
||||||
|
@ -73,18 +74,20 @@ u32 Hash(const s8 * data, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle end cases */
|
/* Handle end cases */
|
||||||
switch (rem)
|
switch (rem) {
|
||||||
{
|
case 3:
|
||||||
case 3: hash += get16bits (data);
|
hash += get16bits(data);
|
||||||
hash ^= hash << 16;
|
hash ^= hash << 16;
|
||||||
hash ^= data[sizeof(u16)] << 18;
|
hash ^= data[sizeof(u16)] << 18;
|
||||||
hash += hash >> 11;
|
hash += hash >> 11;
|
||||||
break;
|
break;
|
||||||
case 2: hash += get16bits (data);
|
case 2:
|
||||||
|
hash += get16bits(data);
|
||||||
hash ^= hash << 11;
|
hash ^= hash << 11;
|
||||||
hash += hash >> 17;
|
hash += hash >> 17;
|
||||||
break;
|
break;
|
||||||
case 1: hash += *data;
|
case 1:
|
||||||
|
hash += *data;
|
||||||
hash ^= hash << 10;
|
hash ^= hash << 10;
|
||||||
hash += hash >> 1;
|
hash += hash >> 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,7 @@ void SetFullBaseDir( wxDirName appRoot )
|
||||||
static int _calcEnumLength(const wxChar *const *enumArray)
|
static int _calcEnumLength(const wxChar *const *enumArray)
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
while( *enumArray != NULL )
|
while (*enumArray != NULL) {
|
||||||
{
|
|
||||||
enumArray++;
|
enumArray++;
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
|
@ -81,22 +80,33 @@ IniInterface::~IniInterface()
|
||||||
|
|
||||||
void IniInterface::SetPath(const wxString &path)
|
void IniInterface::SetPath(const wxString &path)
|
||||||
{
|
{
|
||||||
if( m_Config ) m_Config->SetPath( path );
|
if (m_Config)
|
||||||
|
m_Config->SetPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniInterface::Flush()
|
void IniInterface::Flush()
|
||||||
{
|
{
|
||||||
if( m_Config ) m_Config->Flush();
|
if (m_Config)
|
||||||
|
m_Config->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// IniLoader (implementations)
|
// IniLoader (implementations)
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
IniLoader::IniLoader( wxConfigBase& config ) : IniInterface( config ) { }
|
IniLoader::IniLoader(wxConfigBase &config)
|
||||||
IniLoader::IniLoader( wxConfigBase* config ) : IniInterface( config ) { }
|
: IniInterface(config)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
IniLoader::IniLoader(wxConfigBase *config)
|
||||||
|
: IniInterface(config)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
IniLoader::IniLoader() : IniInterface() {}
|
IniLoader::IniLoader()
|
||||||
|
: IniInterface()
|
||||||
|
{
|
||||||
|
}
|
||||||
IniLoader::~IniLoader() throw() {}
|
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)
|
void IniLoader::Entry(const wxString &var, wxDirName &value, const wxDirName defvalue, bool isAllowRelative)
|
||||||
{
|
{
|
||||||
wxString dest;
|
wxString dest;
|
||||||
if( m_Config ) m_Config->Read( var, &dest, wxEmptyString );
|
if (m_Config)
|
||||||
|
m_Config->Read(var, &dest, wxEmptyString);
|
||||||
|
|
||||||
if (dest.IsEmpty())
|
if (dest.IsEmpty())
|
||||||
value = defvalue;
|
value = defvalue;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
value = dest;
|
value = dest;
|
||||||
if (isAllowRelative)
|
if (isAllowRelative)
|
||||||
value = g_fullBaseDirName + value;
|
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)
|
void IniLoader::Entry(const wxString &var, wxFileName &value, const wxFileName defvalue, bool isAllowRelative)
|
||||||
{
|
{
|
||||||
wxString dest(defvalue.GetFullPath());
|
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;
|
value = dest;
|
||||||
if (isAllowRelative)
|
if (isAllowRelative)
|
||||||
value = g_fullBaseDirName + value;
|
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?
|
// TODO : Stricter value checking on enabled/disabled?
|
||||||
wxString dest(defvalue ? L"enabled" : L"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");
|
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.. >_<
|
// has way too much rounding error so we really need to do things out manually.. >_<
|
||||||
|
|
||||||
wxString readval(value.ToString());
|
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);
|
value = Fixed100::FromString(readval, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniLoader::Entry(const wxString &var, wxPoint &value, const wxPoint defvalue)
|
void IniLoader::Entry(const wxString &var, wxPoint &value, const wxPoint defvalue)
|
||||||
{
|
{
|
||||||
if( !m_Config )
|
if (!m_Config) {
|
||||||
{
|
value = defvalue;
|
||||||
value = defvalue; return;
|
return;
|
||||||
}
|
}
|
||||||
TryParse(value, m_Config->Read(var, ToString(defvalue)), defvalue);
|
TryParse(value, m_Config->Read(var, ToString(defvalue)), defvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniLoader::Entry(const wxString &var, wxSize &value, const wxSize defvalue)
|
void IniLoader::Entry(const wxString &var, wxSize &value, const wxSize defvalue)
|
||||||
{
|
{
|
||||||
if( !m_Config )
|
if (!m_Config) {
|
||||||
{
|
value = defvalue;
|
||||||
value = defvalue; return;
|
return;
|
||||||
}
|
}
|
||||||
TryParse(value, m_Config->Read(var, ToString(defvalue)), defvalue);
|
TryParse(value, m_Config->Read(var, ToString(defvalue)), defvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniLoader::Entry(const wxString &var, wxRect &value, const wxRect defvalue)
|
void IniLoader::Entry(const wxString &var, wxRect &value, const wxRect defvalue)
|
||||||
{
|
{
|
||||||
if( !m_Config )
|
if (!m_Config) {
|
||||||
{
|
value = defvalue;
|
||||||
value = defvalue; return;
|
return;
|
||||||
}
|
}
|
||||||
TryParse(value, m_Config->Read(var, ToString(defvalue)), defvalue);
|
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...
|
// Confirm default value sanity...
|
||||||
|
|
||||||
const int cnt = _calcEnumLength(enumArray);
|
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.");
|
Console.Error("(LoadSettings) Default enumeration index is out of bounds. Truncating.");
|
||||||
defvalue = cnt - 1;
|
defvalue = cnt - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanity confirmed, proceed with craziness!
|
// Sanity confirmed, proceed with craziness!
|
||||||
|
|
||||||
if( !m_Config )
|
if (!m_Config) {
|
||||||
{
|
|
||||||
value = defvalue;
|
value = defvalue;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -241,16 +252,14 @@ void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const
|
||||||
m_Config->Read(var, &retval, enumArray[defvalue]);
|
m_Config->Read(var, &retval, enumArray[defvalue]);
|
||||||
|
|
||||||
int i = 0;
|
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'.",
|
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;
|
value = defvalue;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
value = i;
|
value = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,22 +267,33 @@ void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const
|
||||||
// IniSaver (implementations)
|
// IniSaver (implementations)
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
IniSaver::IniSaver( wxConfigBase& config ) : IniInterface( config ) { }
|
IniSaver::IniSaver(wxConfigBase &config)
|
||||||
IniSaver::IniSaver( wxConfigBase* config ) : IniInterface( config ) { }
|
: IniInterface(config)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
IniSaver::IniSaver(wxConfigBase *config)
|
||||||
|
: IniInterface(config)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
IniSaver::IniSaver() : IniInterface() {}
|
IniSaver::IniSaver()
|
||||||
|
: IniInterface()
|
||||||
|
{
|
||||||
|
}
|
||||||
IniSaver::~IniSaver() {}
|
IniSaver::~IniSaver() {}
|
||||||
|
|
||||||
void IniSaver::Entry(const wxString &var, wxString &value, const wxString defvalue)
|
void IniSaver::Entry(const wxString &var, wxString &value, const wxString defvalue)
|
||||||
{
|
{
|
||||||
if( !m_Config ) return;
|
if (!m_Config)
|
||||||
|
return;
|
||||||
m_Config->Write(var, value);
|
m_Config->Write(var, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniSaver::Entry(const wxString &var, wxDirName &value, const wxDirName defvalue, bool isAllowRelative)
|
void IniSaver::Entry(const wxString &var, wxDirName &value, const wxDirName defvalue, bool isAllowRelative)
|
||||||
{
|
{
|
||||||
if( !m_Config ) return;
|
if (!m_Config)
|
||||||
|
return;
|
||||||
wxDirName res(value);
|
wxDirName res(value);
|
||||||
|
|
||||||
if (res.IsAbsolute())
|
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)
|
void IniSaver::Entry(const wxString &var, wxFileName &value, const wxFileName defvalue, bool isAllowRelative)
|
||||||
{
|
{
|
||||||
if( !m_Config ) return;
|
if (!m_Config)
|
||||||
|
return;
|
||||||
wxFileName res(value);
|
wxFileName res(value);
|
||||||
|
|
||||||
if (res.IsAbsolute())
|
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)
|
void IniSaver::Entry(const wxString &var, int &value, const int defvalue)
|
||||||
{
|
{
|
||||||
if( !m_Config ) return;
|
if (!m_Config)
|
||||||
|
return;
|
||||||
m_Config->Write(var, value);
|
m_Config->Write(var, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniSaver::Entry(const wxString &var, uint &value, const uint defvalue)
|
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);
|
m_Config->Write(var, (int)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniSaver::Entry(const wxString &var, bool &value, const bool defvalue)
|
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");
|
m_Config->Write(var, value ? L"enabled" : L"disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniSaver::EntryBitBool(const wxString &var, bool value, const bool defvalue)
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IniSaver::EntryBitfield(const wxString &var, int value, const int defvalue)
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniSaver::Entry(const wxString &var, Fixed100 &value, const Fixed100 defvalue)
|
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
|
// 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.
|
// 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)
|
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));
|
m_Config->Write(var, ToString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniSaver::Entry(const wxString &var, wxSize &value, const wxSize defvalue)
|
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));
|
m_Config->Write(var, ToString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniSaver::Entry(const wxString &var, wxRect &value, const wxRect defvalue)
|
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));
|
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...
|
// 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.");
|
Console.Error("(SaveSettings) Default enumeration index is out of bounds. Truncating.");
|
||||||
defvalue = cnt - 1;
|
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.Warning(L"(SaveSettings) An illegal enumerated index was detected when saving '%s'", WX_STR(var));
|
||||||
Console.Indent().Warning(
|
Console.Indent().Warning(
|
||||||
L"Illegal Value: %d\n"
|
L"Illegal Value: %d\n"
|
||||||
L"Using Default: %d (%s)\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.
|
// Cause a debug assertion, since this is a fully recoverable error.
|
||||||
pxAssert(value < cnt);
|
pxAssert(value < cnt);
|
||||||
|
@ -392,4 +420,3 @@ void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const*
|
||||||
|
|
||||||
m_Config->Write(var, enumArray[value]);
|
m_Config->Write(var, enumArray[value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,10 +63,10 @@ static void SysPageFaultSignalFilter( int signal, siginfo_t *siginfo, void * )
|
||||||
|
|
||||||
// resumes execution right where we left off (re-executes instruction that
|
// resumes execution right where we left off (re-executes instruction that
|
||||||
// caused the SIGSEGV).
|
// 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));
|
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.
|
// Instigate a trap if we're in a debugger, and if not then do a SIGKILL.
|
||||||
|
|
||||||
pxTrap();
|
pxTrap();
|
||||||
if (!IsDebugBuild) raise( SIGKILL );
|
if (!IsDebugBuild)
|
||||||
|
raise(SIGKILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _platform_InstallSignalHandler()
|
void _platform_InstallSignalHandler()
|
||||||
|
@ -93,14 +94,12 @@ static __ri void PageSizeAssertionTest( size_t size )
|
||||||
pxAssertMsg((__pagesize == getpagesize()), pxsFmt(
|
pxAssertMsg((__pagesize == getpagesize()), pxsFmt(
|
||||||
"Internal system error: Operating system pagesize does not match compiled pagesize.\n\t"
|
"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)",
|
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(
|
pxAssertDev((size & (__pagesize - 1)) == 0, pxsFmt(
|
||||||
L"Memory block size must be a multiple of the target platform's page size.\n"
|
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)",
|
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.
|
// 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;
|
uint lnxmode = 0;
|
||||||
|
|
||||||
if (mode.CanWrite()) lnxmode |= PROT_WRITE;
|
if (mode.CanWrite())
|
||||||
if (mode.CanRead()) lnxmode |= PROT_READ;
|
lnxmode |= PROT_WRITE;
|
||||||
if (mode.CanExecute()) lnxmode |= PROT_EXEC | PROT_READ;
|
if (mode.CanRead())
|
||||||
|
lnxmode |= PROT_READ;
|
||||||
|
if (mode.CanExecute())
|
||||||
|
lnxmode |= PROT_EXEC | PROT_READ;
|
||||||
|
|
||||||
const int result = mprotect(baseaddr, size, lnxmode);
|
const int result = mprotect(baseaddr, size, lnxmode);
|
||||||
|
|
||||||
if (result == 0) return true;
|
if (result == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
switch(errno)
|
switch (errno) {
|
||||||
{
|
|
||||||
case EINVAL:
|
case EINVAL:
|
||||||
pxFailDev(pxsFmt(L"mprotect returned EINVAL @ 0x%08X -> 0x%08X (mode=%s)",
|
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;
|
break;
|
||||||
|
|
||||||
case EACCES:
|
case EACCES:
|
||||||
pxFailDev(pxsFmt(L"mprotect returned EACCES @ 0x%08X -> 0x%08X (mode=%s)",
|
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;
|
break;
|
||||||
|
|
||||||
case ENOMEM:
|
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
|
// 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).
|
// 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);
|
pxDoOutOfMemory(size);
|
||||||
return _memprotect(base, size, mode);
|
return _memprotect(base, size, mode);
|
||||||
}
|
}
|
||||||
|
@ -184,8 +187,8 @@ void HostSys::MmapResetPtr(void* base, size_t size)
|
||||||
|
|
||||||
pxAssertRel((uptr)result == (uptr)base, pxsFmt(
|
pxAssertRel((uptr)result == (uptr)base, pxsFmt(
|
||||||
"Virtual memory decommit failed: memory at 0x%08X -> 0x%08X could not be remapped. "
|
"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)
|
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)
|
void HostSys::Munmap(uptr base, size_t size)
|
||||||
{
|
{
|
||||||
if (!base) return;
|
if (!base)
|
||||||
|
return;
|
||||||
munmap((void *)base, size);
|
munmap((void *)base, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostSys::MemProtect(void *baseaddr, size_t size, const PageProtectionMode &mode)
|
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")
|
throw Exception::OutOfMemory(L"MemProtect")
|
||||||
.SetDiagMsg(pxsFmt(L"mprotect failed @ 0x%08X -> 0x%08X (mode=%s)",
|
.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())));
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,14 +73,16 @@ static u64 get_thread_time(uptr id = 0)
|
||||||
clockid_t cid;
|
clockid_t cid;
|
||||||
if (id) {
|
if (id) {
|
||||||
int err = pthread_getcpuclockid((pthread_t)id, &cid);
|
int err = pthread_getcpuclockid((pthread_t)id, &cid);
|
||||||
if (err) return 0;
|
if (err)
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
cid = CLOCK_THREAD_CPUTIME_ID;
|
cid = CLOCK_THREAD_CPUTIME_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
int err = clock_gettime(cid, &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;
|
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(),
|
// thread has used on the CPU (scaled by the value returned by GetThreadTicksPerSecond(),
|
||||||
// which typically would be an OS-provided scalar or some sort).
|
// 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);
|
return get_thread_time(m_native_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ static int xpthread_mutex_timedlock(
|
||||||
ts.tv_sec = 0;
|
ts.tv_sec = 0;
|
||||||
ts.tv_nsec = TIMEDLOCK_EMU_SLEEP_NS;
|
ts.tv_nsec = TIMEDLOCK_EMU_SLEEP_NS;
|
||||||
int status;
|
int status;
|
||||||
while ((status = nanosleep(&ts, &ts)) == -1);
|
while ((status = nanosleep(&ts, &ts)) == -1)
|
||||||
|
;
|
||||||
|
|
||||||
// check if the timeout has expired, gettimeofday() is implemented
|
// check if the timeout has expired, gettimeofday() is implemented
|
||||||
// efficiently (in userspace) on OSX
|
// efficiently (in userspace) on OSX
|
||||||
|
@ -91,18 +92,20 @@ static wxTimeSpan def_detach_timeout( 0, 0, 6, 0 );
|
||||||
|
|
||||||
void Threading::Mutex::Detach()
|
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
|
// Sanity check: Recursive locks could be held by our own thread, which would
|
||||||
// be considered an assertion failure, but can also be handled gracefully.
|
// 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
|
// (note: if the mutex is locked recursively more than twice then this assert won't
|
||||||
// detect it)
|
// detect it)
|
||||||
|
|
||||||
Release(); Release(); // in case of double recursion.
|
Release();
|
||||||
|
Release(); // in case of double recursion.
|
||||||
int result = pthread_mutex_destroy(&m_mutex);
|
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))
|
if (Wait(def_detach_timeout))
|
||||||
|
@ -115,13 +118,14 @@ Threading::Mutex::~Mutex() throw()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Mutex::Detach();
|
Mutex::Detach();
|
||||||
} DESTRUCTOR_CATCHALL;
|
}
|
||||||
|
DESTRUCTOR_CATCHALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Threading::MutexRecursive::MutexRecursive() : Mutex( false )
|
Threading::MutexRecursive::MutexRecursive()
|
||||||
{
|
: Mutex(false)
|
||||||
if( ++_attr_refcount == 1 )
|
|
||||||
{
|
{
|
||||||
|
if (++_attr_refcount == 1) {
|
||||||
if (0 != pthread_mutexattr_init(&_attr_recursive))
|
if (0 != pthread_mutexattr_init(&_attr_recursive))
|
||||||
throw Exception::OutOfMemory(L"Recursive mutexing attributes");
|
throw Exception::OutOfMemory(L"Recursive mutexing attributes");
|
||||||
|
|
||||||
|
@ -153,8 +157,7 @@ void Threading::Mutex::Recreate()
|
||||||
// unlocked.
|
// unlocked.
|
||||||
bool Threading::Mutex::RecreateIfLocked()
|
bool Threading::Mutex::RecreateIfLocked()
|
||||||
{
|
{
|
||||||
if( !Wait(def_detach_timeout) )
|
if (!Wait(def_detach_timeout)) {
|
||||||
{
|
|
||||||
Recreate();
|
Recreate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -195,17 +198,12 @@ bool Threading::Mutex::TryAcquire()
|
||||||
void Threading::Mutex::Acquire()
|
void Threading::Mutex::Acquire()
|
||||||
{
|
{
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
if( !wxThread::IsMain() || (wxTheApp == NULL) )
|
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
|
||||||
{
|
|
||||||
pthread_mutex_lock(&m_mutex);
|
pthread_mutex_lock(&m_mutex);
|
||||||
}
|
} else if (_WaitGui_RecursionGuard(L"Mutex::Acquire")) {
|
||||||
else if( _WaitGui_RecursionGuard( L"Mutex::Acquire" ) )
|
|
||||||
{
|
|
||||||
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
||||||
pthread_mutex_lock(&m_mutex);
|
pthread_mutex_lock(&m_mutex);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
||||||
while (!AcquireWithoutYield(def_yieldgui_interval))
|
while (!AcquireWithoutYield(def_yieldgui_interval))
|
||||||
YieldToMain();
|
YieldToMain();
|
||||||
|
@ -218,22 +216,18 @@ void Threading::Mutex::Acquire()
|
||||||
bool Threading::Mutex::Acquire(const wxTimeSpan &timeout)
|
bool Threading::Mutex::Acquire(const wxTimeSpan &timeout)
|
||||||
{
|
{
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
if( !wxThread::IsMain() || (wxTheApp == NULL) )
|
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
|
||||||
{
|
|
||||||
return AcquireWithoutYield(timeout);
|
return AcquireWithoutYield(timeout);
|
||||||
}
|
} else if (_WaitGui_RecursionGuard(L"Mutex::TimedAcquire")) {
|
||||||
else if( _WaitGui_RecursionGuard( L"Mutex::TimedAcquire" ) )
|
|
||||||
{
|
|
||||||
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
||||||
return AcquireWithoutYield(timeout);
|
return AcquireWithoutYield(timeout);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
||||||
wxTimeSpan countdown((timeout));
|
wxTimeSpan countdown((timeout));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if( AcquireWithoutYield( def_yieldgui_interval ) ) break;
|
if (AcquireWithoutYield(def_yieldgui_interval))
|
||||||
|
break;
|
||||||
YieldToMain();
|
YieldToMain();
|
||||||
countdown -= def_yieldgui_interval;
|
countdown -= def_yieldgui_interval;
|
||||||
} while (countdown.GetMilliseconds() > 0);
|
} while (countdown.GetMilliseconds() > 0);
|
||||||
|
@ -274,8 +268,7 @@ void Threading::Mutex::WaitWithoutYield()
|
||||||
//
|
//
|
||||||
bool Threading::Mutex::Wait(const wxTimeSpan &timeout)
|
bool Threading::Mutex::Wait(const wxTimeSpan &timeout)
|
||||||
{
|
{
|
||||||
if( Acquire(timeout) )
|
if (Acquire(timeout)) {
|
||||||
{
|
|
||||||
Release();
|
Release();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -284,8 +277,7 @@ bool Threading::Mutex::Wait( const wxTimeSpan& timeout )
|
||||||
|
|
||||||
bool Threading::Mutex::WaitWithoutYield(const wxTimeSpan &timeout)
|
bool Threading::Mutex::WaitWithoutYield(const wxTimeSpan &timeout)
|
||||||
{
|
{
|
||||||
if( AcquireWithoutYield(timeout) )
|
if (AcquireWithoutYield(timeout)) {
|
||||||
{
|
|
||||||
Release();
|
Release();
|
||||||
return true;
|
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.
|
pxAssert(!m_IsLocked); // if we're already locked, changing the lock is bad mojo.
|
||||||
|
|
||||||
m_lock = const_cast<Mutex *>(locker);
|
m_lock = const_cast<Mutex *>(locker);
|
||||||
if( !m_lock ) return;
|
if (!m_lock)
|
||||||
|
return;
|
||||||
|
|
||||||
m_IsLocked = true;
|
m_IsLocked = true;
|
||||||
m_lock->Acquire();
|
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.
|
// Provides manual unlocking of a scoped lock prior to object destruction.
|
||||||
void Threading::ScopedLock::Release()
|
void Threading::ScopedLock::Release()
|
||||||
{
|
{
|
||||||
if( !m_IsLocked ) return;
|
if (!m_IsLocked)
|
||||||
|
return;
|
||||||
m_IsLocked = false;
|
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.
|
// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
|
||||||
void Threading::ScopedLock::Acquire()
|
void Threading::ScopedLock::Acquire()
|
||||||
{
|
{
|
||||||
if( m_IsLocked || !m_lock ) return;
|
if (m_IsLocked || !m_lock)
|
||||||
|
return;
|
||||||
m_lock->Acquire();
|
m_lock->Acquire();
|
||||||
m_IsLocked = true;
|
m_IsLocked = true;
|
||||||
}
|
}
|
||||||
|
@ -359,6 +355,7 @@ void Threading::ScopedLock::Acquire()
|
||||||
Threading::ScopedLock::ScopedLock(const Mutex &locker, bool isTryLock)
|
Threading::ScopedLock::ScopedLock(const Mutex &locker, bool isTryLock)
|
||||||
{
|
{
|
||||||
m_lock = const_cast<Mutex *>(&locker);
|
m_lock = const_cast<Mutex *>(&locker);
|
||||||
if( !m_lock ) return;
|
if (!m_lock)
|
||||||
|
return;
|
||||||
m_IsLocked = isTryLock ? m_lock->TryAcquire() : false;
|
m_IsLocked = isTryLock ? m_lock->TryAcquire() : false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,8 @@ wxDirName& wxDirName::MakeAbsolute( const wxString& cwd )
|
||||||
|
|
||||||
void wxDirName::Rmdir()
|
void wxDirName::Rmdir()
|
||||||
{
|
{
|
||||||
if( !Exists() ) return;
|
if (!Exists())
|
||||||
|
return;
|
||||||
wxFileName::Rmdir();
|
wxFileName::Rmdir();
|
||||||
// TODO : Throw exception if operation failed? Do we care?
|
// TODO : Throw exception if operation failed? Do we care?
|
||||||
}
|
}
|
||||||
|
@ -87,7 +88,8 @@ bool wxDirName::Mkdir()
|
||||||
#define wxS_DIR_DEFAULT 0777
|
#define wxS_DIR_DEFAULT 0777
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( Exists() ) return true;
|
if (Exists())
|
||||||
|
return true;
|
||||||
return wxFileName::Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
|
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.
|
// Returns -1 if the file does not exist.
|
||||||
s64 Path::GetFileSize(const wxString &path)
|
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();
|
return (s64)wxFileName::GetSize(path).GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,18 @@ namespace Perf
|
||||||
// Implementation of the Info object
|
// 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));
|
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);
|
snprintf(m_symbol, sizeof(m_symbol), "%s_0x%08x", symbol, pc);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +68,8 @@ namespace Perf
|
||||||
|
|
||||||
void InfoVector::print(FILE *fp)
|
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)
|
void InfoVector::map(uptr x86, u32 size, const char *symbol)
|
||||||
|
@ -75,7 +82,8 @@ namespace Perf
|
||||||
#ifdef MERGE_BLOCK_RESULT
|
#ifdef MERGE_BLOCK_RESULT
|
||||||
m_v.emplace_back(x86, size, symbol);
|
m_v.emplace_back(x86, size, symbol);
|
||||||
#else
|
#else
|
||||||
if (size < 8 * _1kb) m_v.emplace_back(x86, size, symbol);
|
if (size < 8 * _1kb)
|
||||||
|
m_v.emplace_back(x86, size, symbol);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,5 +144,4 @@ namespace Perf
|
||||||
void dump_and_reset() {}
|
void dump_and_reset() {}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,3 @@
|
||||||
#include "General.h"
|
#include "General.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,8 @@ Threading::BaseScopedReadWriteLock::~BaseScopedReadWriteLock() throw()
|
||||||
// Provides manual unlocking of a scoped lock prior to object destruction.
|
// Provides manual unlocking of a scoped lock prior to object destruction.
|
||||||
void Threading::BaseScopedReadWriteLock::Release()
|
void Threading::BaseScopedReadWriteLock::Release()
|
||||||
{
|
{
|
||||||
if( !m_IsLocked ) return;
|
if (!m_IsLocked)
|
||||||
|
return;
|
||||||
m_IsLocked = false;
|
m_IsLocked = false;
|
||||||
m_lock.Release();
|
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.
|
// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
|
||||||
void Threading::ScopedReadLock::Acquire()
|
void Threading::ScopedReadLock::Acquire()
|
||||||
{
|
{
|
||||||
if( m_IsLocked ) return;
|
if (m_IsLocked)
|
||||||
|
return;
|
||||||
m_lock.AcquireRead();
|
m_lock.AcquireRead();
|
||||||
m_IsLocked = true;
|
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.
|
// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
|
||||||
void Threading::ScopedWriteLock::Acquire()
|
void Threading::ScopedWriteLock::Acquire()
|
||||||
{
|
{
|
||||||
if( m_IsLocked ) return;
|
if (m_IsLocked)
|
||||||
|
return;
|
||||||
m_lock.AcquireWrite();
|
m_lock.AcquireWrite();
|
||||||
m_IsLocked = true;
|
m_IsLocked = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,7 @@ void Threading::Semaphore::Post( int multiple )
|
||||||
sem_post_multiple(&m_sema, multiple);
|
sem_post_multiple(&m_sema, multiple);
|
||||||
#else
|
#else
|
||||||
// Only w32pthreads has the post_multiple, but it's easy enough to fake:
|
// Only w32pthreads has the post_multiple, but it's easy enough to fake:
|
||||||
while( multiple > 0 )
|
while (multiple > 0) {
|
||||||
{
|
|
||||||
multiple--;
|
multiple--;
|
||||||
sem_post(&m_sema);
|
sem_post(&m_sema);
|
||||||
}
|
}
|
||||||
|
@ -82,17 +81,12 @@ bool Threading::Semaphore::WaitWithoutYield( const wxTimeSpan& timeout )
|
||||||
void Threading::Semaphore::Wait()
|
void Threading::Semaphore::Wait()
|
||||||
{
|
{
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
if( !wxThread::IsMain() || (wxTheApp == NULL) )
|
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
|
||||||
{
|
|
||||||
sem_wait(&m_sema);
|
sem_wait(&m_sema);
|
||||||
}
|
} else if (_WaitGui_RecursionGuard(L"Semaphore::Wait")) {
|
||||||
else if( _WaitGui_RecursionGuard( L"Semaphore::Wait" ) )
|
|
||||||
{
|
|
||||||
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
||||||
sem_wait(&m_sema);
|
sem_wait(&m_sema);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
||||||
while (!WaitWithoutYield(def_yieldgui_interval))
|
while (!WaitWithoutYield(def_yieldgui_interval))
|
||||||
YieldToMain();
|
YieldToMain();
|
||||||
|
@ -114,22 +108,18 @@ void Threading::Semaphore::Wait()
|
||||||
bool Threading::Semaphore::Wait(const wxTimeSpan &timeout)
|
bool Threading::Semaphore::Wait(const wxTimeSpan &timeout)
|
||||||
{
|
{
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
if( !wxThread::IsMain() || (wxTheApp == NULL) )
|
if (!wxThread::IsMain() || (wxTheApp == NULL)) {
|
||||||
{
|
|
||||||
return WaitWithoutYield(timeout);
|
return WaitWithoutYield(timeout);
|
||||||
}
|
} else if (_WaitGui_RecursionGuard(L"Semaphore::TimedWait")) {
|
||||||
else if( _WaitGui_RecursionGuard( L"Semaphore::TimedWait" ) )
|
|
||||||
{
|
|
||||||
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
ScopedBusyCursor hourglass(Cursor_ReallyBusy);
|
||||||
return WaitWithoutYield(timeout);
|
return WaitWithoutYield(timeout);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
//ScopedBusyCursor hourglass( Cursor_KindaBusy );
|
||||||
wxTimeSpan countdown((timeout));
|
wxTimeSpan countdown((timeout));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if( WaitWithoutYield( def_yieldgui_interval ) ) break;
|
if (WaitWithoutYield(def_yieldgui_interval))
|
||||||
|
break;
|
||||||
YieldToMain();
|
YieldToMain();
|
||||||
countdown -= def_yieldgui_interval;
|
countdown -= def_yieldgui_interval;
|
||||||
} while (countdown.GetMilliseconds() > 0);
|
} while (countdown.GetMilliseconds() > 0);
|
||||||
|
|
|
@ -93,9 +93,9 @@ void SplitString( wxArrayString& dest, const wxString& src, const wxString& deli
|
||||||
wxString JoinString(const wxArrayString &src, const wxString &separator)
|
wxString JoinString(const wxArrayString &src, const wxString &separator)
|
||||||
{
|
{
|
||||||
wxString dest;
|
wxString dest;
|
||||||
for( int i=0, len=src.GetCount(); i<len; ++i )
|
for (int i = 0, len = src.GetCount(); i < len; ++i) {
|
||||||
{
|
if (src[i].IsEmpty())
|
||||||
if( src[i].IsEmpty() ) continue;
|
continue;
|
||||||
if (!dest.IsEmpty())
|
if (!dest.IsEmpty())
|
||||||
dest += separator;
|
dest += separator;
|
||||||
dest += src[i];
|
dest += src[i];
|
||||||
|
@ -106,9 +106,9 @@ wxString JoinString( const wxArrayString& src, const wxString& separator )
|
||||||
wxString JoinString(const wxChar **src, const wxString &separator)
|
wxString JoinString(const wxChar **src, const wxString &separator)
|
||||||
{
|
{
|
||||||
wxString dest;
|
wxString dest;
|
||||||
while( *src != NULL )
|
while (*src != NULL) {
|
||||||
{
|
if (*src[0] == 0)
|
||||||
if( *src[0] == 0 ) continue;
|
continue;
|
||||||
|
|
||||||
if (!dest.IsEmpty())
|
if (!dest.IsEmpty())
|
||||||
dest += separator;
|
dest += separator;
|
||||||
|
@ -165,8 +165,10 @@ bool TryParse( wxPoint& dest, wxStringTokenizer& parts )
|
||||||
{
|
{
|
||||||
long result[2];
|
long result[2];
|
||||||
|
|
||||||
if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[0] ) ) return false;
|
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[0]))
|
||||||
if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[1] ) ) return false;
|
return false;
|
||||||
|
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[1]))
|
||||||
|
return false;
|
||||||
dest.x = result[0];
|
dest.x = result[0];
|
||||||
dest.y = result[1];
|
dest.y = result[1];
|
||||||
|
|
||||||
|
@ -177,8 +179,10 @@ bool TryParse( wxSize& dest, wxStringTokenizer& parts )
|
||||||
{
|
{
|
||||||
long result[2];
|
long result[2];
|
||||||
|
|
||||||
if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[0] ) ) return false;
|
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[0]))
|
||||||
if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[1] ) ) return false;
|
return false;
|
||||||
|
if (!parts.HasMoreTokens() || !parts.GetNextToken().ToLong(&result[1]))
|
||||||
|
return false;
|
||||||
dest.SetWidth(result[0]);
|
dest.SetWidth(result[0]);
|
||||||
dest.SetHeight(result[1]);
|
dest.SetHeight(result[1]);
|
||||||
|
|
||||||
|
@ -210,8 +214,10 @@ bool TryParse( wxRect& dest, const wxString& src, const wxRect& defval, const wx
|
||||||
wxPoint point;
|
wxPoint point;
|
||||||
wxSize size;
|
wxSize size;
|
||||||
|
|
||||||
if( !TryParse( point, parts ) ) return false;
|
if (!TryParse(point, parts))
|
||||||
if( !TryParse( size, parts ) ) return false;
|
return false;
|
||||||
|
if (!TryParse(size, parts))
|
||||||
|
return false;
|
||||||
|
|
||||||
dest = wxRect(point, size);
|
dest = wxRect(point, size);
|
||||||
return true;
|
return true;
|
||||||
|
@ -244,7 +250,8 @@ ParsedAssignmentString::ParsedAssignmentString( const wxString& src )
|
||||||
//
|
//
|
||||||
void px_fputs(FILE *fp, const char *src)
|
void px_fputs(FILE *fp, const char *src)
|
||||||
{
|
{
|
||||||
if( fp == NULL ) return;
|
if (fp == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Windows needs CR's partnered with all newlines, or else notepad.exe can't view
|
// 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;
|
const char *curchar = src;
|
||||||
bool prevcr = false;
|
bool prevcr = false;
|
||||||
while( *curchar != 0 )
|
while (*curchar != 0) {
|
||||||
{
|
if (*curchar == '\r') {
|
||||||
if( *curchar == '\r' )
|
|
||||||
{
|
|
||||||
prevcr = true;
|
prevcr = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Only write a CR/LF pair if the current LF is not prefixed nor
|
// Only write a CR/LF pair if the current LF is not prefixed nor
|
||||||
// post-fixed by a CR.
|
// post-fixed by a CR.
|
||||||
if (*curchar == '\n' && !prevcr && (*(curchar + 1) != '\r'))
|
if (*curchar == '\n' && !prevcr && (*(curchar + 1) != '\r'))
|
||||||
|
|
|
@ -38,8 +38,7 @@ ConsoleLogSource_Threading::ConsoleLogSource_Threading()
|
||||||
static const TraceLogDescriptor myDesc =
|
static const TraceLogDescriptor myDesc =
|
||||||
{
|
{
|
||||||
L"p&xThread", L"pxThread",
|
L"p&xThread", L"pxThread",
|
||||||
pxLt("Threading activity: start, detach, sync, deletion, etc.")
|
pxLt("Threading activity: start, detach, sync, deletion, etc.")};
|
||||||
};
|
|
||||||
|
|
||||||
m_Descriptor = &myDesc;
|
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.");
|
pxAssumeDev(!tkl_destructed, "total_key_lock is destroyed; program is shutting down; cannot create new thread key.");
|
||||||
|
|
||||||
ScopedLock lock(total_key_lock);
|
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 >_<)");
|
pxThreadLog.Error(thr->GetName(), L"Thread key creation failed (probably out of memory >_<)");
|
||||||
curthread_key = 0;
|
curthread_key = 0;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +89,8 @@ static void unmake_curthread_key()
|
||||||
if (!tkl_destructed)
|
if (!tkl_destructed)
|
||||||
lock.AssignAndLock(total_key_lock);
|
lock.AssignAndLock(total_key_lock);
|
||||||
|
|
||||||
if( --total_key_count > 0 ) return;
|
if (--total_key_count > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (curthread_key)
|
if (curthread_key)
|
||||||
pthread_key_delete(curthread_key);
|
pthread_key_delete(curthread_key);
|
||||||
|
@ -116,12 +116,9 @@ pxThread* Threading::pxGetCurrentThread()
|
||||||
// nor the Main/UI thread.
|
// nor the Main/UI thread.
|
||||||
wxString Threading::pxGetCurrentThreadName()
|
wxString Threading::pxGetCurrentThreadName()
|
||||||
{
|
{
|
||||||
if( pxThread* thr = pxGetCurrentThread() )
|
if (pxThread *thr = pxGetCurrentThread()) {
|
||||||
{
|
|
||||||
return thr->GetName();
|
return thr->GetName();
|
||||||
}
|
} else if (wxThread::IsMain()) {
|
||||||
else if( wxThread::IsMain() )
|
|
||||||
{
|
|
||||||
return L"Main/UI";
|
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( 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(),
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,12 +186,10 @@ Threading::pxThread::pxThread( const wxString& name )
|
||||||
// like marrying your sister, and then cheating on her with your daughter.
|
// like marrying your sister, and then cheating on her with your daughter.
|
||||||
Threading::pxThread::~pxThread() throw()
|
Threading::pxThread::~pxThread() throw()
|
||||||
{
|
{
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
pxThreadLog.Write(GetName(), L"Executing default destructor!");
|
pxThreadLog.Write(GetName(), L"Executing default destructor!");
|
||||||
|
|
||||||
if( m_running )
|
if (m_running) {
|
||||||
{
|
|
||||||
pxThreadLog.Write(GetName(), L"Waiting for running thread to end...");
|
pxThreadLog.Write(GetName(), L"Waiting for running thread to end...");
|
||||||
m_mtx_InThread.Wait();
|
m_mtx_InThread.Wait();
|
||||||
pxThreadLog.Write(GetName(), L"Thread ended gracefully.");
|
pxThreadLog.Write(GetName(), L"Thread ended gracefully.");
|
||||||
|
@ -207,7 +202,8 @@ Threading::pxThread::~pxThread() throw()
|
||||||
|
|
||||||
bool Threading::pxThread::AffinityAssert_AllowFromSelf(const DiagnosticOrigin &origin) const
|
bool Threading::pxThread::AffinityAssert_AllowFromSelf(const DiagnosticOrigin &origin) const
|
||||||
{
|
{
|
||||||
if( IsSelf() ) return true;
|
if (IsSelf())
|
||||||
|
return true;
|
||||||
|
|
||||||
if (IsDevBuild)
|
if (IsDevBuild)
|
||||||
pxOnAssert(origin, pxsFmt(L"Thread affinity violation: Call allowed from '%s' thread only.", WX_STR(GetName())));
|
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
|
bool Threading::pxThread::AffinityAssert_DisallowFromSelf(const DiagnosticOrigin &origin) const
|
||||||
{
|
{
|
||||||
if( !IsSelf() ) return true;
|
if (!IsSelf())
|
||||||
|
return true;
|
||||||
|
|
||||||
if (IsDevBuild)
|
if (IsDevBuild)
|
||||||
pxOnAssert(origin, pxsFmt(L"Thread affinity violation: Call is *not* allowed from '%s' thread.", WX_STR(GetName())));
|
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)
|
void Threading::pxThread::FrankenMutex(Mutex &mutex)
|
||||||
{
|
{
|
||||||
if( mutex.RecreateIfLocked() )
|
if (mutex.RecreateIfLocked()) {
|
||||||
{
|
|
||||||
// Our lock is bupkis, which means the previous thread probably deadlocked.
|
// Our lock is bupkis, which means the previous thread probably deadlocked.
|
||||||
// Let's create a new mutex lock to replace it.
|
// 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:
|
// Prevents sudden parallel startup, and or parallel startup + cancel:
|
||||||
ScopedLock startlock(m_mtx_start);
|
ScopedLock startlock(m_mtx_start);
|
||||||
if( m_running )
|
if (m_running) {
|
||||||
{
|
|
||||||
pxThreadLog.Write(GetName(), L"Start() called on running thread; ignorning...");
|
pxThreadLog.Write(GetName(), L"Start() called on running thread; ignorning...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -261,8 +256,7 @@ void Threading::pxThread::Start()
|
||||||
if (pthread_create(&m_thread, NULL, _internal_callback, this) != 0)
|
if (pthread_create(&m_thread, NULL, _internal_callback, this) != 0)
|
||||||
throw Exception::ThreadCreationError(this).SetDiagMsg(L"Thread creation error: " + wxString(std::strerror(errno)));
|
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();
|
RethrowException();
|
||||||
|
|
||||||
// And if the thread threw nothing of its own:
|
// And if the thread threw nothing of its own:
|
||||||
|
@ -291,17 +285,18 @@ bool Threading::pxThread::Detach()
|
||||||
{
|
{
|
||||||
AffinityAssert_DisallowFromSelf(pxDiagSpot);
|
AffinityAssert_DisallowFromSelf(pxDiagSpot);
|
||||||
|
|
||||||
if( m_detached.exchange(true) ) return false;
|
if (m_detached.exchange(true))
|
||||||
|
return false;
|
||||||
pthread_detach(m_thread);
|
pthread_detach(m_thread);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Threading::pxThread::_basecancel()
|
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.");
|
pxThreadLog.Warn(GetName(), L"Ignoring attempted cancellation of detached thread.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -331,10 +326,10 @@ void Threading::pxThread::Cancel( bool isBlocking )
|
||||||
// Prevent simultaneous startup and cancel, necessary to avoid
|
// Prevent simultaneous startup and cancel, necessary to avoid
|
||||||
ScopedLock startlock(m_mtx_start);
|
ScopedLock startlock(m_mtx_start);
|
||||||
|
|
||||||
if( !_basecancel() ) return;
|
if (!_basecancel())
|
||||||
|
return;
|
||||||
|
|
||||||
if( isBlocking )
|
if (isBlocking) {
|
||||||
{
|
|
||||||
WaitOnSelf(m_mtx_InThread);
|
WaitOnSelf(m_mtx_InThread);
|
||||||
Detach();
|
Detach();
|
||||||
}
|
}
|
||||||
|
@ -347,9 +342,11 @@ bool Threading::pxThread::Cancel( const wxTimeSpan& timespan )
|
||||||
// Prevent simultaneous startup and cancel:
|
// Prevent simultaneous startup and cancel:
|
||||||
ScopedLock startlock(m_mtx_start);
|
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();
|
Detach();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -426,18 +423,15 @@ void Threading::YieldToMain()
|
||||||
|
|
||||||
void Threading::pxThread::_selfRunningTest(const wxChar *name) const
|
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));
|
pxThreadLog.Error(GetName(), pxsFmt(L"An exception was thrown while waiting on a %s.", name));
|
||||||
RethrowException();
|
RethrowException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !m_running )
|
if (!m_running) {
|
||||||
{
|
|
||||||
throw Exception::CancelEvent(pxsFmt(
|
throw Exception::CancelEvent(pxsFmt(
|
||||||
L"Blocking thread %s was terminated while another thread was waiting on a %s.",
|
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
|
// 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
|
void Threading::pxThread::WaitOnSelf(Semaphore &sem) const
|
||||||
{
|
{
|
||||||
if( !AffinityAssert_DisallowFromSelf(pxDiagSpot) ) return;
|
if (!AffinityAssert_DisallowFromSelf(pxDiagSpot))
|
||||||
|
return;
|
||||||
|
|
||||||
while( true )
|
while (true) {
|
||||||
{
|
if (sem.WaitWithoutYield(wxTimeSpan(0, 0, 0, 333)))
|
||||||
if( sem.WaitWithoutYield( wxTimeSpan(0, 0, 0, 333) ) ) return;
|
return;
|
||||||
_selfRunningTest(L"semaphore");
|
_selfRunningTest(L"semaphore");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,11 +480,12 @@ void Threading::pxThread::WaitOnSelf( Semaphore& sem ) const
|
||||||
//
|
//
|
||||||
void Threading::pxThread::WaitOnSelf(Mutex &mutex) const
|
void Threading::pxThread::WaitOnSelf(Mutex &mutex) const
|
||||||
{
|
{
|
||||||
if( !AffinityAssert_DisallowFromSelf(pxDiagSpot) ) return;
|
if (!AffinityAssert_DisallowFromSelf(pxDiagSpot))
|
||||||
|
return;
|
||||||
|
|
||||||
while( true )
|
while (true) {
|
||||||
{
|
if (mutex.WaitWithoutYield(wxTimeSpan(0, 0, 0, 333)))
|
||||||
if( mutex.WaitWithoutYield( wxTimeSpan(0, 0, 0, 333) ) ) return;
|
return;
|
||||||
_selfRunningTest(L"mutex");
|
_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
|
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);
|
wxTimeSpan runningout(timeout);
|
||||||
|
|
||||||
while( runningout.GetMilliseconds() > 0 )
|
while (runningout.GetMilliseconds() > 0) {
|
||||||
{
|
|
||||||
const wxTimeSpan interval((SelfWaitInterval < runningout) ? SelfWaitInterval : runningout);
|
const wxTimeSpan interval((SelfWaitInterval < runningout) ? SelfWaitInterval : runningout);
|
||||||
if( sem.WaitWithoutYield( interval ) ) return true;
|
if (sem.WaitWithoutYield(interval))
|
||||||
|
return true;
|
||||||
_selfRunningTest(L"semaphore");
|
_selfRunningTest(L"semaphore");
|
||||||
runningout -= interval;
|
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
|
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);
|
wxTimeSpan runningout(timeout);
|
||||||
|
|
||||||
while( runningout.GetMilliseconds() > 0 )
|
while (runningout.GetMilliseconds() > 0) {
|
||||||
{
|
|
||||||
const wxTimeSpan interval((SelfWaitInterval < runningout) ? SelfWaitInterval : runningout);
|
const wxTimeSpan interval((SelfWaitInterval < runningout) ? SelfWaitInterval : runningout);
|
||||||
if( mutex.WaitWithoutYield( interval ) ) return true;
|
if (mutex.WaitWithoutYield(interval))
|
||||||
|
return true;
|
||||||
_selfRunningTest(L"mutex");
|
_selfRunningTest(L"mutex");
|
||||||
runningout -= interval;
|
runningout -= interval;
|
||||||
}
|
}
|
||||||
|
@ -548,14 +546,12 @@ void Threading::pxThread::_try_virtual_invoke( void (pxThread::*method)() )
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Neat repackaging for STL Runtime errors...
|
// 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()));
|
m_except = new Exception::RuntimeError(ex, WX_STR(GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
catch( Exception::RuntimeError& ex )
|
catch (Exception::RuntimeError &ex) {
|
||||||
{
|
|
||||||
BaseException *woot = ex.Clone();
|
BaseException *woot = ex.Clone();
|
||||||
woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName()));
|
woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName()));
|
||||||
m_except = woot;
|
m_except = woot;
|
||||||
|
@ -580,8 +576,7 @@ void Threading::pxThread::_try_virtual_invoke( void (pxThread::*method)() )
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// BaseException -- same deal as LogicErrors.
|
// BaseException -- same deal as LogicErrors.
|
||||||
//
|
//
|
||||||
catch( BaseException& ex )
|
catch (BaseException &ex) {
|
||||||
{
|
|
||||||
BaseException *woot = ex.Clone();
|
BaseException *woot = ex.Clone();
|
||||||
woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName()));
|
woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName()));
|
||||||
m_except = woot;
|
m_except = woot;
|
||||||
|
@ -677,7 +672,8 @@ void Threading::pxThread::OnCleanupInThread()
|
||||||
// callback function
|
// callback function
|
||||||
void *Threading::pxThread::_internal_callback(void *itsme)
|
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);
|
pxThread &owner = *((pxThread *)itsme);
|
||||||
|
|
||||||
pthread_cleanup_push(_pt_callback_cleanup, 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.
|
// Tells the thread to exit and then waits for thread termination.
|
||||||
void Threading::BaseTaskThread::Block()
|
void Threading::BaseTaskThread::Block()
|
||||||
{
|
{
|
||||||
if( !IsRunning() ) return;
|
if (!IsRunning())
|
||||||
|
return;
|
||||||
m_Done = true;
|
m_Done = true;
|
||||||
m_sem_event.Post();
|
m_sem_event.Post();
|
||||||
pxThread::Block();
|
pxThread::Block();
|
||||||
|
@ -719,7 +716,8 @@ void Threading::BaseTaskThread::PostTask()
|
||||||
// Blocks current thread execution pending the completion of the parallel task.
|
// Blocks current thread execution pending the completion of the parallel task.
|
||||||
void Threading::BaseTaskThread::WaitForResult()
|
void Threading::BaseTaskThread::WaitForResult()
|
||||||
{
|
{
|
||||||
if( m_detached || !m_running ) return;
|
if (m_detached || !m_running)
|
||||||
|
return;
|
||||||
if (m_TaskPending)
|
if (m_TaskPending)
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
m_post_TaskComplete.Wait();
|
m_post_TaskComplete.Wait();
|
||||||
|
@ -732,8 +730,7 @@ void Threading::BaseTaskThread::WaitForResult()
|
||||||
|
|
||||||
void Threading::BaseTaskThread::ExecuteTaskInThread()
|
void Threading::BaseTaskThread::ExecuteTaskInThread()
|
||||||
{
|
{
|
||||||
while( !m_Done )
|
while (!m_Done) {
|
||||||
{
|
|
||||||
// Wait for a job -- or get a pthread_cancel. I'm easy.
|
// Wait for a job -- or get a pthread_cancel. I'm easy.
|
||||||
m_sem_event.WaitWithoutYield();
|
m_sem_event.WaitWithoutYield();
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,10 @@ Threading::WaitForTaskDialog::WaitForTaskDialog( const wxString& title, const wx
|
||||||
wxString m_title(title);
|
wxString m_title(title);
|
||||||
wxString m_heading(heading);
|
wxString m_heading(heading);
|
||||||
|
|
||||||
if( m_title.IsEmpty() ) m_title = _("Waiting for task...");
|
if (m_title.IsEmpty())
|
||||||
if( m_heading.IsEmpty() ) m_heading = m_title;
|
m_title = _("Waiting for task...");
|
||||||
|
if (m_heading.IsEmpty())
|
||||||
|
m_heading = m_title;
|
||||||
|
|
||||||
Bind(pxEvt_ThreadedTaskComplete, &WaitForTaskDialog::OnTaskComplete, this);
|
Bind(pxEvt_ThreadedTaskComplete, &WaitForTaskDialog::OnTaskComplete, this);
|
||||||
|
|
||||||
|
|
|
@ -28,4 +28,3 @@ namespace Threading
|
||||||
extern void YieldToMain();
|
extern void YieldToMain();
|
||||||
extern bool AllowDeletions();
|
extern bool AllowDeletions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,8 @@ VirtualMemoryReserve& VirtualMemoryReserve::SetName( const wxString& newname )
|
||||||
|
|
||||||
VirtualMemoryReserve &VirtualMemoryReserve::SetBaseAddr(uptr newaddr)
|
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;
|
m_baseptr = (void *)newaddr;
|
||||||
return *this;
|
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."))
|
if (!pxAssertDev(m_baseptr == NULL, "(VirtualMemoryReserve) Invalid object state; object has already been reserved."))
|
||||||
return m_baseptr;
|
return m_baseptr;
|
||||||
|
|
||||||
if (!size) size = m_defsize;
|
if (!size)
|
||||||
if (!size) return NULL;
|
size = m_defsize;
|
||||||
|
if (!size)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
m_pages_reserved = (size + __pagesize - 4) / __pagesize;
|
m_pages_reserved = (size + __pagesize - 4) / __pagesize;
|
||||||
uptr reserved_bytes = m_pages_reserved * __pagesize;
|
uptr reserved_bytes = m_pages_reserved * __pagesize;
|
||||||
|
|
||||||
m_baseptr = (void *)HostSys::MmapReserve(base, reserved_bytes);
|
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...",
|
DevCon.Warning(L"%s: host memory @ %ls -> %ls is unavailable; attempting to map elsewhere...",
|
||||||
WX_STR(m_name), pxsPtr(base), pxsPtr(base + size));
|
WX_STR(m_name), pxsPtr(base), pxsPtr(base + size));
|
||||||
|
|
||||||
SafeSysMunmap(m_baseptr, reserved_bytes);
|
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
|
// Let's try again at an OS-picked memory area, and then hope it meets needed
|
||||||
// boundschecking criteria below.
|
// boundschecking criteria below.
|
||||||
m_baseptr = HostSys::MmapReserve(0, reserved_bytes);
|
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);
|
SafeSysMunmap(m_baseptr, reserved_bytes);
|
||||||
// returns null, caller should throw an exception or handle appropriately.
|
// returns null, caller should throw an exception or handle appropriately.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_baseptr) return NULL;
|
if (!m_baseptr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
FastFormatUnicode mbkb;
|
FastFormatUnicode mbkb;
|
||||||
uint mbytes = reserved_bytes / _1mb;
|
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)
|
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);
|
HostSys::MemProtect(m_baseptr, m_pages_commited * __pagesize, newmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears all committed blocks, restoring the allocation to a reserve only.
|
// Clears all committed blocks, restoring the allocation to a reserve only.
|
||||||
void VirtualMemoryReserve::Reset()
|
void VirtualMemoryReserve::Reset()
|
||||||
{
|
{
|
||||||
if (!m_pages_commited) return;
|
if (!m_pages_commited)
|
||||||
|
return;
|
||||||
|
|
||||||
ReprotectCommittedBlocks(PageAccess_None());
|
ReprotectCommittedBlocks(PageAccess_None());
|
||||||
HostSys::MmapResetPtr(m_baseptr, m_pages_commited * __pagesize);
|
HostSys::MmapResetPtr(m_baseptr, m_pages_commited * __pagesize);
|
||||||
|
@ -186,8 +189,10 @@ void VirtualMemoryReserve::Release()
|
||||||
|
|
||||||
bool VirtualMemoryReserve::Commit()
|
bool VirtualMemoryReserve::Commit()
|
||||||
{
|
{
|
||||||
if (!m_pages_reserved) return false;
|
if (!m_pages_reserved)
|
||||||
if (!pxAssert(!m_pages_commited)) return true;
|
return false;
|
||||||
|
if (!pxAssert(!m_pages_commited))
|
||||||
|
return true;
|
||||||
|
|
||||||
m_pages_commited = m_pages_reserved;
|
m_pages_commited = m_pages_reserved;
|
||||||
return HostSys::MmapCommitPtr(m_baseptr, m_pages_reserved * __pagesize, m_prot_mode);
|
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;
|
uint newPages = (newsize + __pagesize - 1) / __pagesize;
|
||||||
|
|
||||||
if (newPages > m_pages_reserved)
|
if (newPages > m_pages_reserved) {
|
||||||
{
|
|
||||||
uint toReservePages = newPages - m_pages_reserved;
|
uint toReservePages = newPages - m_pages_reserved;
|
||||||
uint toReserveBytes = toReservePages * __pagesize;
|
uint toReserveBytes = toReservePages * __pagesize;
|
||||||
|
|
||||||
|
@ -228,18 +232,16 @@ bool VirtualMemoryReserve::TryResize( uint newsize )
|
||||||
|
|
||||||
m_baseptr = (void *)HostSys::MmapReserve((uptr)GetPtrEnd(), toReserveBytes);
|
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.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);
|
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),
|
DevCon.WriteLn(Color_Gray, L"%-32s @ %08p -> %08p [%umb]", WX_STR(m_name),
|
||||||
m_baseptr, (uptr)m_baseptr + toReserveBytes, toReserveBytes / _1mb);
|
m_baseptr, (uptr)m_baseptr + toReserveBytes, toReserveBytes / _1mb);
|
||||||
}
|
} else if (newPages < m_pages_reserved) {
|
||||||
else if (newPages < m_pages_reserved)
|
if (m_pages_commited > newsize)
|
||||||
{
|
return false;
|
||||||
if (m_pages_commited > newsize) return false;
|
|
||||||
|
|
||||||
uint toRemovePages = m_pages_reserved - newPages;
|
uint toRemovePages = m_pages_reserved - newPages;
|
||||||
uint toRemoveBytes = toRemovePages * __pagesize;
|
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
|
// Depending on the operating system, this call could fail if the system is low on either
|
||||||
// physical ram or virtual memory.
|
// 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)
|
throw Exception::OutOfMemory(m_name)
|
||||||
.SetDiagMsg(pxsFmt("An additional %u blocks @ 0x%08x were requested, but could not be committed!", blocks, blockptr));
|
.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)
|
void BaseVmReserveListener::OnPageFaultEvent(const PageFaultInfo &info, bool &handled)
|
||||||
{
|
{
|
||||||
sptr offset = (info.addr - (uptr)m_baseptr) / __pagesize;
|
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(
|
pxFailRel(pxsFmt(
|
||||||
L"Memory Protection Fault @ %ls (%s)\n"
|
L"Memory Protection Fault @ %ls (%s)\n"
|
||||||
L"Modification of this reserve has been disabled (m_allow_writes == false).",
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,16 +320,11 @@ void BaseVmReserveListener::OnPageFaultEvent(const PageFaultInfo& info, bool& ha
|
||||||
handled = true;
|
handled = true;
|
||||||
|
|
||||||
#ifndef __WXMSW__
|
#ifndef __WXMSW__
|
||||||
}
|
} catch (Exception::BaseException &ex) {
|
||||||
catch (Exception::BaseException& ex)
|
|
||||||
{
|
|
||||||
handled = false;
|
handled = false;
|
||||||
if (!wxThread::IsMain())
|
if (!wxThread::IsMain()) {
|
||||||
{
|
|
||||||
pxFailRel(ex.FormatDiagnosticMessage());
|
pxFailRel(ex.FormatDiagnosticMessage());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pxTrap();
|
pxTrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,12 +338,17 @@ wxString PageProtectionMode::ToString() const
|
||||||
{
|
{
|
||||||
wxString modeStr;
|
wxString modeStr;
|
||||||
|
|
||||||
if (m_read) modeStr += L"Read";
|
if (m_read)
|
||||||
if (m_write) modeStr += L"Write";
|
modeStr += L"Read";
|
||||||
if (m_exec) modeStr += L"Exec";
|
if (m_write)
|
||||||
|
modeStr += L"Write";
|
||||||
|
if (m_exec)
|
||||||
|
modeStr += L"Exec";
|
||||||
|
|
||||||
if (modeStr.IsEmpty()) return L"NoAccess";
|
if (modeStr.IsEmpty())
|
||||||
if (modeStr.Length() <= 5) modeStr += L"Only";
|
return L"NoAccess";
|
||||||
|
if (modeStr.Length() <= 5)
|
||||||
|
modeStr += L"Only";
|
||||||
|
|
||||||
return modeStr;
|
return modeStr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// 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
|
// 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;
|
winmode = mode.CanWrite() ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ;
|
||||||
}
|
} else if (mode.CanRead()) {
|
||||||
else if (mode.CanRead())
|
|
||||||
{
|
|
||||||
winmode = mode.CanWrite() ? PAGE_READWRITE : PAGE_READONLY;
|
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)
|
bool HostSys::MmapCommitPtr(void *base, size_t size, const PageProtectionMode &mode)
|
||||||
{
|
{
|
||||||
void *result = VirtualAlloc(base, size, MEM_COMMIT, ConvertToWinApi(mode));
|
void *result = VirtualAlloc(base, size, MEM_COMMIT, ConvertToWinApi(mode));
|
||||||
if (result) return true;
|
if (result)
|
||||||
|
return true;
|
||||||
|
|
||||||
const DWORD errcode = GetLastError();
|
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);
|
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...
|
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());
|
pxFailDev(L"VirtualAlloc COMMIT failed: " + Exception::WinApiError().GetMsgFromWindows());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pxDoOutOfMemory) return false;
|
if (!pxDoOutOfMemory)
|
||||||
|
return false;
|
||||||
pxDoOutOfMemory(size);
|
pxDoOutOfMemory(size);
|
||||||
return VirtualAlloc(base, size, MEM_COMMIT, ConvertToWinApi(mode)) != NULL;
|
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)
|
void HostSys::Munmap(uptr base, size_t size)
|
||||||
{
|
{
|
||||||
if (!base) return;
|
if (!base)
|
||||||
|
return;
|
||||||
//VirtualFree((void*)base, size, MEM_DECOMMIT);
|
//VirtualFree((void*)base, size, MEM_DECOMMIT);
|
||||||
VirtualFree((void *)base, 0, MEM_RELEASE);
|
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(
|
pxAssertDev(((size & (__pagesize - 1)) == 0), pxsFmt(
|
||||||
L"Memory block size must be a multiple of the target platform's page size.\n"
|
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)",
|
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!
|
DWORD OldProtect; // enjoy my uselessness, yo!
|
||||||
if (!VirtualProtect( baseaddr, size, ConvertToWinApi(mode), &OldProtect ))
|
if (!VirtualProtect(baseaddr, size, ConvertToWinApi(mode), &OldProtect)) {
|
||||||
{
|
|
||||||
Exception::WinApiError apiError;
|
Exception::WinApiError apiError;
|
||||||
|
|
||||||
apiError.SetDiagMsg(
|
apiError.SetDiagMsg(
|
||||||
pxsFmt(L"VirtualProtect failed @ 0x%08X -> 0x%08X (mode=%s)",
|
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());
|
pxFailDev(apiError.FormatDiagnosticMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,7 @@ wxString GetOSVersionString()
|
||||||
|
|
||||||
// Test for the specific product.
|
// Test for the specific product.
|
||||||
|
|
||||||
if ( osvi.dwMajorVersion == 10 )
|
if (osvi.dwMajorVersion == 10) {
|
||||||
{
|
|
||||||
if (osvi.dwMinorVersion == 0)
|
if (osvi.dwMinorVersion == 0)
|
||||||
retval += (osvi.wProductType == VER_NT_WORKSTATION) ? L"Windows 10 " : L"Windows Server 2016 ";
|
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);
|
pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
|
||||||
|
|
||||||
switch( dwType )
|
switch (dwType) {
|
||||||
{
|
case PRODUCT_CORE:
|
||||||
case PRODUCT_CORE: retval += L"Home"; break;
|
retval += L"Home";
|
||||||
case PRODUCT_CORE_N: retval += L"Home N"; break;
|
break;
|
||||||
case PRODUCT_PROFESSIONAL: retval += L"Pro"; break;
|
case PRODUCT_CORE_N:
|
||||||
case PRODUCT_PROFESSIONAL_N: retval += L"Pro N"; break;
|
retval += L"Home N";
|
||||||
case PRODUCT_ENTERPRISE: retval += L"Enterprise"; break;
|
break;
|
||||||
case PRODUCT_ENTERPRISE_N: retval += L"Enterprise N"; break;
|
case PRODUCT_PROFESSIONAL:
|
||||||
case PRODUCT_ENTERPRISE_S: retval += L"Enterprise 2015 LTSB"; break;
|
retval += L"Pro";
|
||||||
case PRODUCT_ENTERPRISE_S_N: retval += L"Enterprise 2015 LTSB N"; break;
|
break;
|
||||||
case PRODUCT_EDUCATION: retval += L"Education"; break;
|
case PRODUCT_PROFESSIONAL_N:
|
||||||
case PRODUCT_EDUCATION_N: retval += L"Education N"; break;
|
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)
|
if (osvi.dwMinorVersion == 2)
|
||||||
retval += (osvi.wProductType == VER_NT_WORKSTATION) ? L"Windows 8 " : L"Windows Server 2012 ";
|
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);
|
pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
|
||||||
|
|
||||||
switch( dwType )
|
switch (dwType) {
|
||||||
{
|
case PRODUCT_PROFESSIONAL:
|
||||||
case PRODUCT_PROFESSIONAL: retval += L"Pro"; break;
|
retval += L"Pro";
|
||||||
case PRODUCT_PROFESSIONAL_N: retval += L"Pro N"; break;
|
break;
|
||||||
case PRODUCT_PROFESSIONAL_WMC: retval += L"Pro with Media Center"; break;
|
case PRODUCT_PROFESSIONAL_N:
|
||||||
case PRODUCT_ENTERPRISE: retval += L"Enterprise"; break;
|
retval += L"Pro N";
|
||||||
case PRODUCT_ENTERPRISE_N: retval += L"Enterprise N"; break;
|
break;
|
||||||
case PRODUCT_SERVER_FOUNDATION: retval += L"Foundation"; break;
|
case PRODUCT_PROFESSIONAL_WMC:
|
||||||
case PRODUCT_STANDARD_SERVER: retval += L"Standard"; break;
|
retval += L"Pro with Media Center";
|
||||||
case PRODUCT_STANDARD_SERVER_CORE: retval += L"Standard (core)"; break;
|
break;
|
||||||
case PRODUCT_DATACENTER_SERVER: retval += L"Datacenter"; break;
|
case PRODUCT_ENTERPRISE:
|
||||||
case PRODUCT_DATACENTER_SERVER_CORE: retval += L"Datacenter (core)"; break;
|
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)
|
if (osvi.dwMinorVersion == 0)
|
||||||
retval += (osvi.wProductType == VER_NT_WORKSTATION) ? L"Windows Vista " : L"Windows Server 2008 ";
|
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);
|
pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);
|
||||||
|
|
||||||
switch( dwType )
|
switch (dwType) {
|
||||||
{
|
case PRODUCT_ULTIMATE:
|
||||||
case PRODUCT_ULTIMATE: retval += L"Ultimate Edition"; break;
|
retval += L"Ultimate Edition";
|
||||||
case PRODUCT_HOME_PREMIUM: retval += L"Home Premium Edition"; break;
|
break;
|
||||||
case PRODUCT_HOME_BASIC: retval += L"Home Basic Edition"; break;
|
case PRODUCT_HOME_PREMIUM:
|
||||||
case PRODUCT_ENTERPRISE: retval += L"Enterprise Edition"; break;
|
retval += L"Home Premium Edition";
|
||||||
case PRODUCT_BUSINESS: retval += L"Business Edition"; break;
|
break;
|
||||||
case PRODUCT_STARTER: retval += L"Starter Edition"; break;
|
case PRODUCT_HOME_BASIC:
|
||||||
case PRODUCT_CLUSTER_SERVER: retval += L"Cluster Server Edition"; break;
|
retval += L"Home Basic Edition";
|
||||||
case PRODUCT_DATACENTER_SERVER: retval += L"Datacenter Edition"; break;
|
break;
|
||||||
case PRODUCT_DATACENTER_SERVER_CORE: retval += L"Datacenter Edition (core installation)"; break;
|
case PRODUCT_ENTERPRISE:
|
||||||
case PRODUCT_ENTERPRISE_SERVER: retval += L"Enterprise Edition"; break;
|
retval += L"Enterprise Edition";
|
||||||
case PRODUCT_ENTERPRISE_SERVER_CORE: retval += L"Enterprise Edition (core installation)"; break;
|
break;
|
||||||
case PRODUCT_SMALLBUSINESS_SERVER: retval += L"Small Business Server"; break;
|
case PRODUCT_BUSINESS:
|
||||||
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: retval += L"Small Business Server Premium Edition"; break;
|
retval += L"Business Edition";
|
||||||
case PRODUCT_STANDARD_SERVER: retval += L"Standard Edition"; break;
|
break;
|
||||||
case PRODUCT_STANDARD_SERVER_CORE: retval += L"Standard Edition (core installation)"; break;
|
case PRODUCT_STARTER:
|
||||||
case PRODUCT_WEB_SERVER: retval += L"Web Server Edition"; break;
|
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))
|
if (GetSystemMetrics(SM_SERVERR2))
|
||||||
retval += L"Windows Server 2003 R2, ";
|
retval += L"Windows Server 2003 R2, ";
|
||||||
else if (osvi.wSuiteMask == VER_SUITE_STORAGE_SERVER)
|
else if (osvi.wSuiteMask == VER_SUITE_STORAGE_SERVER)
|
||||||
|
@ -213,10 +278,8 @@ wxString GetOSVersionString()
|
||||||
retval += L"Windows Server 2003, ";
|
retval += L"Windows Server 2003, ";
|
||||||
|
|
||||||
// Test for the server type.
|
// Test for the server type.
|
||||||
if ( osvi.wProductType != VER_NT_WORKSTATION )
|
if (osvi.wProductType != VER_NT_WORKSTATION) {
|
||||||
{
|
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
|
||||||
if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
|
|
||||||
{
|
|
||||||
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
|
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
|
||||||
retval += L"Datacenter x64 Edition";
|
retval += L"Datacenter x64 Edition";
|
||||||
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
|
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
|
||||||
|
@ -225,8 +288,7 @@ wxString GetOSVersionString()
|
||||||
retval += L"Standard x64 Edition";
|
retval += L"Standard x64 Edition";
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER)
|
if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER)
|
||||||
retval += L"Compute Cluster Edition";
|
retval += L"Compute Cluster Edition";
|
||||||
else if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
|
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 += L"Windows XP ";
|
||||||
retval += (osvi.wSuiteMask & VER_SUITE_PERSONAL) ? L"Home Edition" : L"Professional";
|
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 ";
|
retval += L"Windows 2000 ";
|
||||||
|
|
||||||
if ( osvi.wProductType == VER_NT_WORKSTATION )
|
if (osvi.wProductType == VER_NT_WORKSTATION) {
|
||||||
{
|
|
||||||
retval += L"Professional";
|
retval += L"Professional";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
|
if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
|
||||||
retval += L"Datacenter Server";
|
retval += L"Datacenter Server";
|
||||||
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
|
else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
|
||||||
|
@ -273,8 +330,7 @@ wxString GetOSVersionString()
|
||||||
|
|
||||||
retval += wxsFormat(L" (build %d)", osvi.dwBuildNumber);
|
retval += wxsFormat(L" (build %d)", osvi.dwBuildNumber);
|
||||||
|
|
||||||
if ( osvi.dwMajorVersion >= 6 )
|
if (osvi.dwMajorVersion >= 6) {
|
||||||
{
|
|
||||||
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
|
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
|
||||||
retval += L", 64-bit";
|
retval += L", 64-bit";
|
||||||
else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
|
else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
|
||||||
|
@ -295,7 +351,8 @@ Exception::WinApiError::WinApiError()
|
||||||
|
|
||||||
wxString Exception::WinApiError::GetMsgFromWindows() const
|
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;
|
const DWORD BUF_LEN = 2048;
|
||||||
TCHAR t_Msg[BUF_LEN];
|
TCHAR t_Msg[BUF_LEN];
|
||||||
|
|
|
@ -75,7 +75,8 @@ u64 Threading::GetThreadTicksPerSecond()
|
||||||
|
|
||||||
u64 Threading::pxThread::GetCpuTime() const
|
u64 Threading::pxThread::GetCpuTime() const
|
||||||
{
|
{
|
||||||
if (!m_native_handle) return 0;
|
if (!m_native_handle)
|
||||||
|
return 0;
|
||||||
|
|
||||||
FileTimeSucks user, kernel;
|
FileTimeSucks user, kernel;
|
||||||
FILETIME dummy;
|
FILETIME dummy;
|
||||||
|
@ -132,9 +133,9 @@ void Threading::pxThread::_DoSetThreadName( const char* name )
|
||||||
|
|
||||||
__try {
|
__try {
|
||||||
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
|
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
|
||||||
} __except(EXCEPTION_EXECUTE_HANDLER) { }
|
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,7 @@ void pxCheckBox::Init(const wxString& label, const wxString& subtext, int flags)
|
||||||
*this += m_checkbox | pxSizerFlags::StdExpand();
|
*this += m_checkbox | pxSizerFlags::StdExpand();
|
||||||
|
|
||||||
static const int Indentation = 23;
|
static const int Indentation = 23;
|
||||||
if( !subtext.IsEmpty() )
|
if (!subtext.IsEmpty()) {
|
||||||
{
|
|
||||||
m_subtext = new pxStaticText(this, subtext, wxALIGN_LEFT);
|
m_subtext = new pxStaticText(this, subtext, wxALIGN_LEFT);
|
||||||
|
|
||||||
wxFlexGridSizer &spaced(*new wxFlexGridSizer(3));
|
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)
|
pxCheckBox &pxCheckBox::SetSubPadding(int pad)
|
||||||
{
|
{
|
||||||
m_subPadding = pad;
|
m_subPadding = pad;
|
||||||
if( m_sizerItem_subtext )
|
if (m_sizerItem_subtext) {
|
||||||
{
|
|
||||||
m_sizerItem_subtext->SetBorder(m_subPadding);
|
m_sizerItem_subtext->SetBorder(m_subPadding);
|
||||||
Fit();
|
Fit();
|
||||||
}
|
}
|
||||||
|
@ -124,7 +122,8 @@ void pxCheckBox::OnSubtextClicked( wxCommandEvent& evt )
|
||||||
|
|
||||||
void operator+=(wxSizer &target, pxCheckBox *src)
|
void operator+=(wxSizer &target, pxCheckBox *src)
|
||||||
{
|
{
|
||||||
if( src ) target.Add( src, pxExpand );
|
if (src)
|
||||||
|
target.Add(src, pxExpand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator+=(wxSizer &target, pxCheckBox &src)
|
void operator+=(wxSizer &target, pxCheckBox &src)
|
||||||
|
|
|
@ -50,10 +50,10 @@ void pxRadioPanel::Reset()
|
||||||
{
|
{
|
||||||
m_IsRealized = false;
|
m_IsRealized = false;
|
||||||
const int numbuttons = m_buttonStrings.size();
|
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].LabelObj);
|
||||||
safe_delete(m_objects[i].SubTextObj);
|
safe_delete(m_objects[i].SubTextObj);
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,10 @@ void pxRadioPanel::Reset()
|
||||||
void pxRadioPanel::Realize()
|
void pxRadioPanel::Realize()
|
||||||
{
|
{
|
||||||
const int numbuttons = m_buttonStrings.size();
|
const int numbuttons = m_buttonStrings.size();
|
||||||
if( numbuttons == 0 ) return;
|
if (numbuttons == 0)
|
||||||
if( m_IsRealized ) return;
|
return;
|
||||||
|
if (m_IsRealized)
|
||||||
|
return;
|
||||||
m_IsRealized = true;
|
m_IsRealized = true;
|
||||||
|
|
||||||
m_objects.MakeRoomFor(numbuttons);
|
m_objects.MakeRoomFor(numbuttons);
|
||||||
|
@ -80,21 +82,19 @@ void pxRadioPanel::Realize()
|
||||||
for (int i = 1; i < numbuttons; ++i)
|
for (int i = 1; i < numbuttons; ++i)
|
||||||
m_objects[i].LabelObj = new wxRadioButton(this, wxID_ANY, m_buttonStrings[i].Label);
|
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;
|
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);
|
m_objects[i].SubTextObj = new pxStaticText(this, m_buttonStrings[i].SubText, wxALIGN_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
pxAssert(GetSizer() != NULL);
|
pxAssert(GetSizer() != NULL);
|
||||||
|
|
||||||
for( int i=0; i<numbuttons; ++i )
|
for (int i = 0; i < numbuttons; ++i) {
|
||||||
{
|
|
||||||
*this += m_objects[i].LabelObj | pxSizerFlags::StdExpand();
|
*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 += subobj | pxBorder(wxLEFT, m_Indentation).Expand();
|
||||||
*this += 9 + m_padding.GetHeight();
|
*this += 9 + m_padding.GetHeight();
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,8 @@ pxRadioPanel& pxRadioPanel::SetToolTip(int idx, const wxString &tip)
|
||||||
|
|
||||||
pxRadioPanel &pxRadioPanel::SetSelection(int idx)
|
pxRadioPanel &pxRadioPanel::SetSelection(int idx)
|
||||||
{
|
{
|
||||||
if( !VerifyRealizedState() ) return *this;
|
if (!VerifyRealizedState())
|
||||||
|
return *this;
|
||||||
|
|
||||||
pxAssert(m_objects[idx].LabelObj != NULL);
|
pxAssert(m_objects[idx].LabelObj != NULL);
|
||||||
m_objects[idx].LabelObj->SetValue(true);
|
m_objects[idx].LabelObj->SetValue(true);
|
||||||
|
@ -138,8 +139,7 @@ pxRadioPanel& pxRadioPanel::SetSelection( int idx )
|
||||||
|
|
||||||
void pxRadioPanel::_RealizeDefaultOption()
|
void pxRadioPanel::_RealizeDefaultOption()
|
||||||
{
|
{
|
||||||
if( m_IsRealized && m_DefaultIdx != -1 )
|
if (m_IsRealized && m_DefaultIdx != -1) {
|
||||||
{
|
|
||||||
wxFont def(GetFont());
|
wxFont def(GetFont());
|
||||||
def.SetWeight(wxFONTWEIGHT_BOLD);
|
def.SetWeight(wxFONTWEIGHT_BOLD);
|
||||||
//def.SetStyle( wxFONTSTYLE_ITALIC );
|
//def.SetStyle( wxFONTSTYLE_ITALIC );
|
||||||
|
@ -152,10 +152,10 @@ void pxRadioPanel::_RealizeDefaultOption()
|
||||||
// Not intended for restoring default value at later time.
|
// Not intended for restoring default value at later time.
|
||||||
pxRadioPanel &pxRadioPanel::SetDefaultItem(int idx)
|
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());
|
wxFont def(GetFont());
|
||||||
m_objects[m_DefaultIdx].LabelObj->SetFont(def);
|
m_objects[m_DefaultIdx].LabelObj->SetFont(def);
|
||||||
m_objects[m_DefaultIdx].LabelObj->SetForegroundColour(GetForegroundColour());
|
m_objects[m_DefaultIdx].LabelObj->SetForegroundColour(GetForegroundColour());
|
||||||
|
@ -192,12 +192,13 @@ RadioPanelItem& pxRadioPanel::Item(int idx)
|
||||||
|
|
||||||
int pxRadioPanel::GetSelection() const
|
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 (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.
|
// 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.
|
// Returns the wxWindowID for the currently selected radio button.
|
||||||
wxWindowID pxRadioPanel::GetSelectionId() const
|
wxWindowID pxRadioPanel::GetSelectionId() const
|
||||||
{
|
{
|
||||||
if( !VerifyRealizedState() ) return 0;
|
if (!VerifyRealizedState())
|
||||||
|
return 0;
|
||||||
return m_objects[GetSelection()].LabelObj->GetId();
|
return m_objects[GetSelection()].LabelObj->GetId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pxRadioPanel::IsSelected(int idx) const
|
bool pxRadioPanel::IsSelected(int idx) const
|
||||||
{
|
{
|
||||||
if( !VerifyRealizedState() ) return false;
|
if (!VerifyRealizedState())
|
||||||
|
return false;
|
||||||
pxAssert(m_objects[idx].LabelObj != NULL);
|
pxAssert(m_objects[idx].LabelObj != NULL);
|
||||||
return m_objects[idx].LabelObj->GetValue();
|
return m_objects[idx].LabelObj->GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
pxStaticText *pxRadioPanel::GetSubText(int idx)
|
pxStaticText *pxRadioPanel::GetSubText(int idx)
|
||||||
{
|
{
|
||||||
if( !VerifyRealizedState() ) return NULL;
|
if (!VerifyRealizedState())
|
||||||
|
return NULL;
|
||||||
return m_objects[idx].SubTextObj;
|
return m_objects[idx].SubTextObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pxStaticText *pxRadioPanel::GetSubText(int idx) const
|
const pxStaticText *pxRadioPanel::GetSubText(int idx) const
|
||||||
{
|
{
|
||||||
if( !VerifyRealizedState() ) return NULL;
|
if (!VerifyRealizedState())
|
||||||
|
return NULL;
|
||||||
return m_objects[idx].SubTextObj;
|
return m_objects[idx].SubTextObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRadioButton *pxRadioPanel::GetButton(int idx)
|
wxRadioButton *pxRadioPanel::GetButton(int idx)
|
||||||
{
|
{
|
||||||
if( !VerifyRealizedState() ) return NULL;
|
if (!VerifyRealizedState())
|
||||||
|
return NULL;
|
||||||
return m_objects[idx].LabelObj;
|
return m_objects[idx].LabelObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxRadioButton *pxRadioPanel::GetButton(int idx) const
|
const wxRadioButton *pxRadioPanel::GetButton(int idx) const
|
||||||
{
|
{
|
||||||
if( !VerifyRealizedState() ) return NULL;
|
if (!VerifyRealizedState())
|
||||||
|
return NULL;
|
||||||
return m_objects[idx].LabelObj;
|
return m_objects[idx].LabelObj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,8 @@ pxStaticText& pxStaticText::SetMinHeight( int height )
|
||||||
|
|
||||||
pxStaticText &pxStaticText::SetHeight(int lines)
|
pxStaticText &pxStaticText::SetHeight(int lines)
|
||||||
{
|
{
|
||||||
if( !pxAssert(lines > 0) ) lines = 2;
|
if (!pxAssert(lines > 0))
|
||||||
|
lines = 2;
|
||||||
m_heightInLines = lines;
|
m_heightInLines = lines;
|
||||||
|
|
||||||
const int newHeight = (pxGetCharHeight(this) * m_heightInLines) + (m_paddingPix_vert * 2);
|
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;
|
double parentalFactor = 1.0;
|
||||||
const wxWindow *millrun = this;
|
const wxWindow *millrun = this;
|
||||||
|
|
||||||
while( millrun )
|
while (millrun) {
|
||||||
{
|
|
||||||
// IMPORTANT : wxWizard changes its min size and then expects everything else
|
// 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)
|
// to play nice and NOT resize according to the new min size. (wtf stupid)
|
||||||
// Anyway, this fixes it -- ignore min size specifier on wxWizard!
|
// 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);
|
int min = (int)((millrun->GetMinWidth() - parentalAdjust) * parentalFactor);
|
||||||
|
|
||||||
if( min > 0 && ((idealWidth < 0 ) || (min < idealWidth)) )
|
if (min > 0 && ((idealWidth < 0) || (min < idealWidth))) {
|
||||||
{
|
|
||||||
idealWidth = min;
|
idealWidth = min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +185,7 @@ wxSize pxStaticText::GetBestWrappedSize( const wxClientDC& dc ) const
|
||||||
millrun = millrun->GetParent();
|
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
|
// 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.
|
// the size of the user's display area.
|
||||||
|
|
||||||
|
@ -200,7 +199,8 @@ pxStaticText& pxStaticText::WrapAt( int width )
|
||||||
{
|
{
|
||||||
m_autowrap = false;
|
m_autowrap = false;
|
||||||
|
|
||||||
if( (width <= 1) || (width == m_wrappedWidth) ) return *this;
|
if ((width <= 1) || (width == m_wrappedWidth))
|
||||||
|
return *this;
|
||||||
|
|
||||||
wxString wrappedLabel;
|
wxString wrappedLabel;
|
||||||
m_wrappedWidth = width;
|
m_wrappedWidth = width;
|
||||||
|
@ -208,22 +208,19 @@ pxStaticText& pxStaticText::WrapAt( int width )
|
||||||
if (width > 1)
|
if (width > 1)
|
||||||
wrappedLabel = pxTextWrapper().Wrap(this, m_label, width).GetResult();
|
wrappedLabel = pxTextWrapper().Wrap(this, m_label, width).GetResult();
|
||||||
|
|
||||||
if(m_wrappedLabel != wrappedLabel )
|
if (m_wrappedLabel != wrappedLabel) {
|
||||||
{
|
|
||||||
m_wrappedLabel = wrappedLabel;
|
m_wrappedLabel = wrappedLabel;
|
||||||
wxSize area = wxClientDC(this).GetMultiLineTextExtent(m_wrappedLabel);
|
wxSize area = wxClientDC(this).GetMultiLineTextExtent(m_wrappedLabel);
|
||||||
SetMinSize(wxSize(
|
SetMinSize(wxSize(
|
||||||
area.GetWidth() + calcPaddingWidth(area.GetWidth()),
|
area.GetWidth() + calcPaddingWidth(area.GetWidth()),
|
||||||
area.GetHeight() + calcPaddingHeight(area.GetHeight())
|
area.GetHeight() + calcPaddingHeight(area.GetHeight())));
|
||||||
) );
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pxStaticText::_updateWrapping(bool textChanged)
|
bool pxStaticText::_updateWrapping(bool textChanged)
|
||||||
{
|
{
|
||||||
if( !m_autowrap )
|
if (!m_autowrap) {
|
||||||
{
|
|
||||||
//m_wrappedLabel = wxEmptyString;
|
//m_wrappedLabel = wxEmptyString;
|
||||||
//m_wrappedWidth = -1;
|
//m_wrappedWidth = -1;
|
||||||
return false;
|
return false;
|
||||||
|
@ -233,7 +230,8 @@ bool pxStaticText::_updateWrapping( bool textChanged )
|
||||||
int newWidth = GetSize().GetWidth();
|
int newWidth = GetSize().GetWidth();
|
||||||
newWidth -= (int)(newWidth * m_paddingPct_horiz * 2) + (m_paddingPix_horiz * 2);
|
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.
|
// 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
|
// 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)
|
if (m_wrappedWidth > 1)
|
||||||
wrappedLabel = pxTextWrapper().Wrap(this, m_label, m_wrappedWidth).GetResult();
|
wrappedLabel = pxTextWrapper().Wrap(this, m_label, m_wrappedWidth).GetResult();
|
||||||
|
|
||||||
if( m_wrappedLabel == wrappedLabel ) return false;
|
if (m_wrappedLabel == wrappedLabel)
|
||||||
|
return false;
|
||||||
m_wrappedLabel = wrappedLabel;
|
m_wrappedLabel = wrappedLabel;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -252,14 +251,14 @@ bool pxStaticText::_updateWrapping( bool textChanged )
|
||||||
|
|
||||||
void pxStaticText::UpdateWrapping(bool textChanged)
|
void pxStaticText::UpdateWrapping(bool textChanged)
|
||||||
{
|
{
|
||||||
if( _updateWrapping( textChanged ) ) Refresh();
|
if (_updateWrapping(textChanged))
|
||||||
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pxStaticText::SetLabel(const wxString &label)
|
void pxStaticText::SetLabel(const wxString &label)
|
||||||
{
|
{
|
||||||
const bool labelChanged(label != m_label);
|
const bool labelChanged(label != m_label);
|
||||||
if( labelChanged )
|
if (labelChanged) {
|
||||||
{
|
|
||||||
m_label = label;
|
m_label = label;
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -272,14 +271,14 @@ void pxStaticText::SetLabel(const wxString& label)
|
||||||
wxFont pxStaticText::GetFontOk() const
|
wxFont pxStaticText::GetFontOk() const
|
||||||
{
|
{
|
||||||
wxFont font(GetFont());
|
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;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pxStaticText::Enable(bool enabled)
|
bool pxStaticText::Enable(bool enabled)
|
||||||
{
|
{
|
||||||
if( _parent::Enable(enabled))
|
if (_parent::Enable(enabled)) {
|
||||||
{
|
|
||||||
Refresh();
|
Refresh();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +290,8 @@ void pxStaticText::paintEvent(wxPaintEvent& evt)
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
const int dcWidth = dc.GetSize().GetWidth();
|
const int dcWidth = dc.GetSize().GetWidth();
|
||||||
const int dcHeight = dc.GetSize().GetHeight();
|
const int dcHeight = dc.GetSize().GetHeight();
|
||||||
if( dcWidth < 1 ) return;
|
if (dcWidth < 1)
|
||||||
|
return;
|
||||||
dc.SetFont(GetFontOk());
|
dc.SetFont(GetFontOk());
|
||||||
|
|
||||||
if (IsEnabled())
|
if (IsEnabled())
|
||||||
|
@ -303,7 +303,8 @@ void pxStaticText::paintEvent(wxPaintEvent& evt)
|
||||||
writer.Align(m_align);
|
writer.Align(m_align);
|
||||||
|
|
||||||
const wxString &label(m_autowrap ? m_wrappedLabel : m_label);
|
const wxString &label(m_autowrap ? m_wrappedLabel : m_label);
|
||||||
if( m_autowrap ) _updateWrapping( false );
|
if (m_autowrap)
|
||||||
|
_updateWrapping(false);
|
||||||
|
|
||||||
int tWidth, tHeight;
|
int tWidth, tHeight;
|
||||||
dc.GetMultiLineTextExtent(label, &tWidth, &tHeight);
|
dc.GetMultiLineTextExtent(label, &tWidth, &tHeight);
|
||||||
|
@ -328,13 +329,10 @@ wxSize pxStaticText::DoGetBestSize() const
|
||||||
|
|
||||||
wxSize best;
|
wxSize best;
|
||||||
|
|
||||||
if( m_autowrap )
|
if (m_autowrap) {
|
||||||
{
|
|
||||||
best = GetBestWrappedSize(dc);
|
best = GetBestWrappedSize(dc);
|
||||||
//best.x = wxDefaultCoord;
|
//best.x = wxDefaultCoord;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// No autowrapping, so we can force a specific size here!
|
// No autowrapping, so we can force a specific size here!
|
||||||
best = dc.GetMultiLineTextExtent(GetLabel());
|
best = dc.GetMultiLineTextExtent(GetLabel());
|
||||||
best.x += calcPaddingWidth(best.x);
|
best.x += calcPaddingWidth(best.x);
|
||||||
|
@ -369,7 +367,8 @@ void pxStaticHeading::SetPaddingDefaults()
|
||||||
|
|
||||||
void operator+=(wxSizer &target, pxStaticText *src)
|
void operator+=(wxSizer &target, pxStaticText *src)
|
||||||
{
|
{
|
||||||
if( src ) target.Add( src, pxExpand );
|
if (src)
|
||||||
|
target.Add(src, pxExpand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator+=(wxSizer &target, pxStaticText &src)
|
void operator+=(wxSizer &target, pxStaticText &src)
|
||||||
|
|
|
@ -37,7 +37,8 @@ bool pxStreamBase::IsOk() const
|
||||||
|
|
||||||
wxFileOffset pxStreamBase::Length() const
|
wxFileOffset pxStreamBase::Length() const
|
||||||
{
|
{
|
||||||
if (!GetWxStreamBase()) return 0;
|
if (!GetWxStreamBase())
|
||||||
|
return 0;
|
||||||
return GetWxStreamBase()->GetLength();
|
return GetWxStreamBase()->GetLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +87,7 @@ void pxInputStream::SetStream( const wxString& filename, wxInputStream* stream )
|
||||||
void pxInputStream::Read(void *dest, size_t size)
|
void pxInputStream::Read(void *dest, size_t size)
|
||||||
{
|
{
|
||||||
m_stream_in->Read(dest, 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;
|
int err = errno;
|
||||||
if (!err)
|
if (!err)
|
||||||
throw Exception::BadStream(m_filename).SetDiagMsg(L"Cannot read from file (bad file handle?)");
|
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)
|
: pxStreamBase(filename)
|
||||||
, m_stream_out(std::move(output))
|
, m_stream_out(std::move(output))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pxOutputStream::pxOutputStream(const wxString &filename, wxOutputStream *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)
|
void pxOutputStream::Write(const void *src, size_t size)
|
||||||
{
|
{
|
||||||
m_stream_out->Write(src, 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;
|
int err = errno;
|
||||||
if (!err)
|
if (!err)
|
||||||
throw Exception::BadStream(m_filename).SetDiagMsg(L"Cannot write to file/stream.");
|
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();
|
dest.clear();
|
||||||
bool isUTF8 = false;
|
bool isUTF8 = false;
|
||||||
while ( true )
|
while (true) {
|
||||||
{
|
|
||||||
char c;
|
char c;
|
||||||
input.Read(&c, sizeof(c));
|
input.Read(&c, sizeof(c));
|
||||||
if( c == 0 ) break;
|
if (c == 0)
|
||||||
if( input.Eof() ) break;
|
break;
|
||||||
if( c == '\n' ) break; // eat on UNIX
|
if (input.Eof())
|
||||||
if( c == '\r' )
|
break;
|
||||||
{
|
if (c == '\n')
|
||||||
|
break; // eat on UNIX
|
||||||
|
if (c == '\r') {
|
||||||
input.Read(&c, sizeof(c));
|
input.Read(&c, sizeof(c));
|
||||||
if( c == 0 ) break;
|
if (c == 0)
|
||||||
if( input.Eof() ) break;
|
break;
|
||||||
if( c == '\n' ) break;
|
if (input.Eof())
|
||||||
|
break;
|
||||||
|
if (c == '\n')
|
||||||
|
break;
|
||||||
|
|
||||||
input.Ungetch(c);
|
input.Ungetch(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dest += c;
|
dest += c;
|
||||||
if( c & 0x80 ) isUTF8 = true;
|
if (c & 0x80)
|
||||||
|
isUTF8 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isUTF8;
|
return isUTF8;
|
||||||
|
@ -199,12 +202,12 @@ void pxReadLine( wxInputStream& input, wxString& dest, std::string& intermed )
|
||||||
dest.clear();
|
dest.clear();
|
||||||
if (pxReadLine(input, intermed))
|
if (pxReadLine(input, intermed))
|
||||||
dest = fromUTF8(intermed.c_str());
|
dest = fromUTF8(intermed.c_str());
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// Optimized ToAscii conversion.
|
// Optimized ToAscii conversion.
|
||||||
// wx3.0 : NOT COMPATIBLE!! (on linux anyway)
|
// wx3.0 : NOT COMPATIBLE!! (on linux anyway)
|
||||||
const char *ascii = intermed.c_str();
|
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)
|
void pxWriteLine(wxOutputStream &output, const wxString &text)
|
||||||
{
|
{
|
||||||
if( !text.IsEmpty() )
|
if (!text.IsEmpty()) {
|
||||||
{
|
|
||||||
pxToUTF8 utf8(text);
|
pxToUTF8 utf8(text);
|
||||||
output.Write(utf8, utf8.Length());
|
output.Write(utf8, utf8.Length());
|
||||||
}
|
}
|
||||||
|
@ -238,7 +240,8 @@ void pxWriteLine( wxOutputStream& output, const wxString& text )
|
||||||
|
|
||||||
void pxWriteMultiline(wxOutputStream &output, const wxString &src)
|
void pxWriteMultiline(wxOutputStream &output, const wxString &src)
|
||||||
{
|
{
|
||||||
if( src.IsEmpty() ) return;
|
if (src.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
wxString result(src);
|
wxString result(src);
|
||||||
result.Replace(L"\r\n", L"\n");
|
result.Replace(L"\r\n", L"\n");
|
||||||
|
|
|
@ -37,10 +37,8 @@ const wxChar* __fastcall pxExpandMsg( const wxChar* englishContent )
|
||||||
//
|
//
|
||||||
const wxChar *__fastcall pxGetTranslation(const wxChar *message)
|
const wxChar *__fastcall pxGetTranslation(const wxChar *message)
|
||||||
{
|
{
|
||||||
if( IsDevBuild )
|
if (IsDevBuild) {
|
||||||
{
|
if (wxStrlen(message) > 128) {
|
||||||
if( wxStrlen( message ) > 128 )
|
|
||||||
{
|
|
||||||
Console.Warning("pxGetTranslation: Long message detected, maybe use pxE() instead?");
|
Console.Warning("pxGetTranslation: Long message detected, maybe use pxE() instead?");
|
||||||
Console.WriteLn(Color_Green, L"Message: %s", message);
|
Console.WriteLn(Color_Green, L"Message: %s", message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,12 +93,9 @@ void pxWindowTextWriter::_DoWriteLn( const wxChar* msg )
|
||||||
|
|
||||||
wxPoint dispos(m_curpos);
|
wxPoint dispos(m_curpos);
|
||||||
|
|
||||||
if( m_align & wxALIGN_CENTER_HORIZONTAL )
|
if (m_align & wxALIGN_CENTER_HORIZONTAL) {
|
||||||
{
|
|
||||||
dispos.x = (m_dc.GetSize().GetWidth() - tWidth) / 2;
|
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;
|
dispos.x = m_dc.GetSize().GetWidth() - tWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,8 @@ static const char *upper_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
static size_t strnlen(const char *s, size_t count)
|
static size_t strnlen(const char *s, size_t count)
|
||||||
{
|
{
|
||||||
const char *sc;
|
const char *sc;
|
||||||
for (sc = s; *sc != '\0' && count--; ++sc);
|
for (sc = s; *sc != '\0' && count--; ++sc)
|
||||||
|
;
|
||||||
return sc - s;
|
return sc - s;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -78,28 +79,23 @@ static void cvt(char (&buf)[_CVTBUFSIZE], double arg, int preci, int& decpt, int
|
||||||
r2 = 0;
|
r2 = 0;
|
||||||
sign = 0;
|
sign = 0;
|
||||||
p = &buf[0];
|
p = &buf[0];
|
||||||
if (arg < 0)
|
if (arg < 0) {
|
||||||
{
|
|
||||||
sign = 1;
|
sign = 1;
|
||||||
arg = -arg;
|
arg = -arg;
|
||||||
}
|
}
|
||||||
arg = modf(arg, &fi);
|
arg = modf(arg, &fi);
|
||||||
p1 = &buf[_CVTBUFSIZE];
|
p1 = &buf[_CVTBUFSIZE];
|
||||||
|
|
||||||
if (fi != 0)
|
if (fi != 0) {
|
||||||
{
|
while (fi != 0) {
|
||||||
while (fi != 0)
|
|
||||||
{
|
|
||||||
fj = modf(fi / 10, &fi);
|
fj = modf(fi / 10, &fi);
|
||||||
*--p1 = (int)((fj + .03) * 10) + '0';
|
*--p1 = (int)((fj + .03) * 10) + '0';
|
||||||
r2++;
|
r2++;
|
||||||
}
|
}
|
||||||
while (p1 < &buf[_CVTBUFSIZE]) *p++ = *p1++;
|
while (p1 < &buf[_CVTBUFSIZE])
|
||||||
}
|
*p++ = *p1++;
|
||||||
else if (arg > 0)
|
} else if (arg > 0) {
|
||||||
{
|
while ((fj = arg * 10) < 1) {
|
||||||
while ((fj = arg * 10) < 1)
|
|
||||||
{
|
|
||||||
arg = fj;
|
arg = fj;
|
||||||
r2--;
|
r2--;
|
||||||
}
|
}
|
||||||
|
@ -107,38 +103,34 @@ static void cvt(char (&buf)[_CVTBUFSIZE], double arg, int preci, int& decpt, int
|
||||||
|
|
||||||
p1 = &buf[preci];
|
p1 = &buf[preci];
|
||||||
|
|
||||||
if (eflag == 0) p1 += r2;
|
if (eflag == 0)
|
||||||
|
p1 += r2;
|
||||||
decpt = r2;
|
decpt = r2;
|
||||||
if (p1 < &buf[0])
|
if (p1 < &buf[0]) {
|
||||||
{
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (p <= p1 && p < &buf[_CVTBUFSIZE])
|
while (p <= p1 && p < &buf[_CVTBUFSIZE]) {
|
||||||
{
|
|
||||||
arg *= 10;
|
arg *= 10;
|
||||||
arg = modf(arg, &fj);
|
arg = modf(arg, &fj);
|
||||||
*p++ = (int)fj + '0';
|
*p++ = (int)fj + '0';
|
||||||
}
|
}
|
||||||
if (p1 >= &buf[_CVTBUFSIZE])
|
if (p1 >= &buf[_CVTBUFSIZE]) {
|
||||||
{
|
|
||||||
buf[_CVTBUFSIZE - 1] = '\0';
|
buf[_CVTBUFSIZE - 1] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p = p1;
|
p = p1;
|
||||||
*p1 += 5;
|
*p1 += 5;
|
||||||
while (*p1 > '9')
|
while (*p1 > '9') {
|
||||||
{
|
|
||||||
*p1 = '0';
|
*p1 = '0';
|
||||||
if (p1 > buf)
|
if (p1 > buf)
|
||||||
++*--p1;
|
++*--p1;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
*p1 = '1';
|
*p1 = '1';
|
||||||
decpt++;
|
decpt++;
|
||||||
if (eflag == 0)
|
if (eflag == 0) {
|
||||||
{
|
if (p > buf)
|
||||||
if (p > buf) *p = '0';
|
*p = '0';
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +152,8 @@ static void fcvtbuf(char (&buf)[_CVTBUFSIZE], double arg, int preci, int& decpt,
|
||||||
static int skip_atoi(const char **s)
|
static int skip_atoi(const char **s)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (is_digit(**s)) i = i*10 + *((*s)++) - '0';
|
while (is_digit(**s))
|
||||||
|
i = i * 10 + *((*s)++) - '0';
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,34 +164,30 @@ static void number(std::string& dest, T num, int base, int size, int precision,
|
||||||
const char *dig = digits;
|
const char *dig = digits;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (type & LARGE) dig = upper_digits;
|
if (type & LARGE)
|
||||||
if (type & LEFT) type &= ~ZEROPAD;
|
dig = upper_digits;
|
||||||
if (base < 2 || base > 36) return;
|
if (type & LEFT)
|
||||||
|
type &= ~ZEROPAD;
|
||||||
|
if (base < 2 || base > 36)
|
||||||
|
return;
|
||||||
|
|
||||||
c = (type & ZEROPAD) ? '0' : ' ';
|
c = (type & ZEROPAD) ? '0' : ' ';
|
||||||
sign = 0;
|
sign = 0;
|
||||||
if (type & SIGN)
|
if (type & SIGN) {
|
||||||
{
|
if (num < 0) {
|
||||||
if (num < 0)
|
|
||||||
{
|
|
||||||
sign = '-';
|
sign = '-';
|
||||||
num = -num;
|
num = -num;
|
||||||
size--;
|
size--;
|
||||||
}
|
} else if (type & PLUS) {
|
||||||
else if (type & PLUS)
|
|
||||||
{
|
|
||||||
sign = '+';
|
sign = '+';
|
||||||
size--;
|
size--;
|
||||||
}
|
} else if (type & SPACE) {
|
||||||
else if (type & SPACE)
|
|
||||||
{
|
|
||||||
sign = ' ';
|
sign = ' ';
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type & SPECIAL)
|
if (type & SPECIAL) {
|
||||||
{
|
|
||||||
if (base == 16)
|
if (base == 16)
|
||||||
size -= 2;
|
size -= 2;
|
||||||
else if (base == 8)
|
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)
|
if (num == 0)
|
||||||
tmp[i++] = '0';
|
tmp[i++] = '0';
|
||||||
else
|
else {
|
||||||
{
|
if (base == 16) {
|
||||||
if( base == 16 )
|
while (num != 0) {
|
||||||
{
|
|
||||||
while (num != 0)
|
|
||||||
{
|
|
||||||
tmp[i++] = dig[num & 0xf];
|
tmp[i++] = dig[num & 0xf];
|
||||||
num = (uint)num >> 4;
|
num = (uint)num >> 4;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
while (num != 0) {
|
||||||
{
|
|
||||||
while (num != 0)
|
|
||||||
{
|
|
||||||
tmp[i++] = dig[num % (uint)base];
|
tmp[i++] = dig[num % (uint)base];
|
||||||
num /= (uint)base;
|
num /= (uint)base;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i > precision) precision = i;
|
if (i > precision)
|
||||||
|
precision = i;
|
||||||
size -= precision;
|
size -= precision;
|
||||||
if (!(type & (ZEROPAD | LEFT))) while (size-- > 0) dest += ' ';
|
if (!(type & (ZEROPAD | LEFT)))
|
||||||
if (sign) dest += sign;
|
while (size-- > 0)
|
||||||
|
dest += ' ';
|
||||||
|
if (sign)
|
||||||
|
dest += sign;
|
||||||
|
|
||||||
if (type & SPECIAL)
|
if (type & SPECIAL) {
|
||||||
{
|
|
||||||
if (base == 8)
|
if (base == 8)
|
||||||
dest += '0';
|
dest += '0';
|
||||||
else if (base == 16)
|
else if (base == 16) {
|
||||||
{
|
|
||||||
dest += '0';
|
dest += '0';
|
||||||
dest += digits[33];
|
dest += digits[33];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( !(type & LEFT) && size > 0) { dest.append( size, c ); size = 0; }
|
if (!(type & LEFT) && size > 0) {
|
||||||
if( i < precision ) dest.append( precision-i, '0' );
|
dest.append(size, c);
|
||||||
while (i-- > 0) dest += tmp[i];
|
size = 0;
|
||||||
if( size > 0 ) dest.append( size, ' ' );
|
}
|
||||||
|
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;
|
//if (!(type & LEFT)) while (size-- > 0) dest += c;
|
||||||
//while (i < precision--) dest += '0';
|
//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;
|
const char *dig = digits;
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
if (type & LARGE) dig = upper_digits;
|
if (type & LARGE)
|
||||||
|
dig = upper_digits;
|
||||||
len = 0;
|
len = 0;
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++) {
|
||||||
{
|
if (i != 0)
|
||||||
if (i != 0) tmp[len++] = ':';
|
tmp[len++] = ':';
|
||||||
tmp[len++] = dig[addr[i] >> 4];
|
tmp[len++] = dig[addr[i] >> 4];
|
||||||
tmp[len++] = dig[addr[i] & 0x0F];
|
tmp[len++] = dig[addr[i] & 0x0F];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(type & LEFT)) while (len < size--) dest += ' ';
|
if (!(type & LEFT))
|
||||||
for (i = 0; i < len; ++i) dest += tmp[i];
|
while (len < size--)
|
||||||
while (len < size--) dest += ' ';
|
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)
|
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;
|
int i, n, len;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++) {
|
||||||
{
|
if (i != 0)
|
||||||
if (i != 0) tmp[len++] = '.';
|
tmp[len++] = '.';
|
||||||
n = addr[i];
|
n = addr[i];
|
||||||
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
tmp[len++] = digits[0];
|
tmp[len++] = digits[0];
|
||||||
else
|
else {
|
||||||
{
|
if (n >= 100) {
|
||||||
if (n >= 100)
|
|
||||||
{
|
|
||||||
tmp[len++] = digits[n / 100];
|
tmp[len++] = digits[n / 100];
|
||||||
n = n % 100;
|
n = n % 100;
|
||||||
tmp[len++] = digits[n / 10];
|
tmp[len++] = digits[n / 10];
|
||||||
n = n % 10;
|
n = n % 10;
|
||||||
}
|
} else if (n >= 10) {
|
||||||
else if (n >= 10)
|
|
||||||
{
|
|
||||||
tmp[len++] = digits[n / 10];
|
tmp[len++] = digits[n / 10];
|
||||||
n = 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 += ' ';
|
if (!(type & LEFT))
|
||||||
for (i = 0; i < len; ++i) dest += tmp[i];
|
while (len < size--)
|
||||||
while (len < size--) dest += ' ';
|
dest += ' ';
|
||||||
|
for (i = 0; i < len; ++i)
|
||||||
|
dest += tmp[i];
|
||||||
|
while (len < size--)
|
||||||
|
dest += ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NOFLOAT
|
#ifndef NOFLOAT
|
||||||
|
@ -323,58 +319,50 @@ static void cfltcvt(double value, char *buffer, char fmt, int precision)
|
||||||
int capexp = 0;
|
int capexp = 0;
|
||||||
int magnitude;
|
int magnitude;
|
||||||
|
|
||||||
if (fmt == 'G' || fmt == 'E')
|
if (fmt == 'G' || fmt == 'E') {
|
||||||
{
|
|
||||||
capexp = 1;
|
capexp = 1;
|
||||||
fmt += 'a' - 'A';
|
fmt += 'a' - 'A';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fmt == 'g')
|
if (fmt == 'g') {
|
||||||
{
|
|
||||||
ecvtbuf(cvtbuf, value, precision, decpt, sign);
|
ecvtbuf(cvtbuf, value, precision, decpt, sign);
|
||||||
|
|
||||||
magnitude = decpt - 1;
|
magnitude = decpt - 1;
|
||||||
if (magnitude < -4 || magnitude > precision - 1)
|
if (magnitude < -4 || magnitude > precision - 1) {
|
||||||
{
|
|
||||||
fmt = 'e';
|
fmt = 'e';
|
||||||
precision -= 1;
|
precision -= 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fmt = 'f';
|
fmt = 'f';
|
||||||
precision -= decpt;
|
precision -= decpt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fmt == 'e')
|
if (fmt == 'e') {
|
||||||
{
|
|
||||||
ecvtbuf(cvtbuf, value, precision + 1, decpt, sign);
|
ecvtbuf(cvtbuf, value, precision + 1, decpt, sign);
|
||||||
|
|
||||||
const char *digits = cvtbuf;
|
const char *digits = cvtbuf;
|
||||||
|
|
||||||
if (sign) *buffer++ = '-';
|
if (sign)
|
||||||
|
*buffer++ = '-';
|
||||||
*buffer++ = *digits;
|
*buffer++ = *digits;
|
||||||
if (precision > 0) *buffer++ = '.';
|
if (precision > 0)
|
||||||
|
*buffer++ = '.';
|
||||||
memcpy(buffer, digits + 1, precision);
|
memcpy(buffer, digits + 1, precision);
|
||||||
buffer += precision;
|
buffer += precision;
|
||||||
*buffer++ = capexp ? 'E' : 'e';
|
*buffer++ = capexp ? 'E' : 'e';
|
||||||
|
|
||||||
if (decpt == 0)
|
if (decpt == 0) {
|
||||||
{
|
|
||||||
if (value == 0.0)
|
if (value == 0.0)
|
||||||
exp = 0;
|
exp = 0;
|
||||||
else
|
else
|
||||||
exp = -1;
|
exp = -1;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
exp = decpt - 1;
|
exp = decpt - 1;
|
||||||
|
|
||||||
if (exp < 0)
|
if (exp < 0) {
|
||||||
{
|
|
||||||
*buffer++ = '-';
|
*buffer++ = '-';
|
||||||
exp = -exp;
|
exp = -exp;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
*buffer++ = '+';
|
*buffer++ = '+';
|
||||||
|
|
||||||
buffer[2] = (exp % 10) + '0';
|
buffer[2] = (exp % 10) + '0';
|
||||||
|
@ -383,40 +371,35 @@ static void cfltcvt(double value, char *buffer, char fmt, int precision)
|
||||||
exp = exp / 10;
|
exp = exp / 10;
|
||||||
buffer[0] = (exp % 10) + '0';
|
buffer[0] = (exp % 10) + '0';
|
||||||
buffer += 3;
|
buffer += 3;
|
||||||
}
|
} else if (fmt == 'f') {
|
||||||
else if (fmt == 'f')
|
|
||||||
{
|
|
||||||
fcvtbuf(cvtbuf, value, precision, decpt, sign);
|
fcvtbuf(cvtbuf, value, precision, decpt, sign);
|
||||||
|
|
||||||
const char *digits = cvtbuf;
|
const char *digits = cvtbuf;
|
||||||
|
|
||||||
if (sign) *buffer++ = '-';
|
if (sign)
|
||||||
if (*digits)
|
*buffer++ = '-';
|
||||||
{
|
if (*digits) {
|
||||||
if (decpt <= 0)
|
if (decpt <= 0) {
|
||||||
{
|
|
||||||
*buffer++ = '0';
|
*buffer++ = '0';
|
||||||
*buffer++ = '.';
|
*buffer++ = '.';
|
||||||
for (pos = 0; pos < -decpt; pos++) *buffer++ = '0';
|
for (pos = 0; pos < -decpt; pos++)
|
||||||
while (*digits) *buffer++ = *digits++;
|
*buffer++ = '0';
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pos = 0;
|
|
||||||
while (*digits)
|
while (*digits)
|
||||||
{
|
*buffer++ = *digits++;
|
||||||
if (pos++ == decpt) *buffer++ = '.';
|
} else {
|
||||||
|
pos = 0;
|
||||||
|
while (*digits) {
|
||||||
|
if (pos++ == decpt)
|
||||||
|
*buffer++ = '.';
|
||||||
*buffer++ = *digits++;
|
*buffer++ = *digits++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
*buffer++ = '0';
|
*buffer++ = '0';
|
||||||
if (precision > 0)
|
if (precision > 0) {
|
||||||
{
|
|
||||||
*buffer++ = '.';
|
*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)
|
static void forcdecpt(char *buffer)
|
||||||
{
|
{
|
||||||
while (*buffer)
|
while (*buffer) {
|
||||||
{
|
if (*buffer == '.')
|
||||||
if (*buffer == '.') return;
|
return;
|
||||||
if (*buffer == 'e' || *buffer == 'E') break;
|
if (*buffer == 'e' || *buffer == 'E')
|
||||||
|
break;
|
||||||
buffer++;
|
buffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*buffer)
|
if (*buffer) {
|
||||||
{
|
|
||||||
int n = strlen(buffer);
|
int n = strlen(buffer);
|
||||||
while (n > 0)
|
while (n > 0) {
|
||||||
{
|
|
||||||
buffer[n + 1] = buffer[n];
|
buffer[n + 1] = buffer[n];
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
|
|
||||||
*buffer = '.';
|
*buffer = '.';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
*buffer++ = '.';
|
*buffer++ = '.';
|
||||||
*buffer = '\0';
|
*buffer = '\0';
|
||||||
}
|
}
|
||||||
|
@ -455,14 +435,18 @@ static void cropzeros(char *buffer)
|
||||||
{
|
{
|
||||||
char *stop;
|
char *stop;
|
||||||
|
|
||||||
while (*buffer && *buffer != '.') buffer++;
|
while (*buffer && *buffer != '.')
|
||||||
if (*buffer++)
|
buffer++;
|
||||||
{
|
if (*buffer++) {
|
||||||
while (*buffer && *buffer != 'e' && *buffer != 'E') buffer++;
|
while (*buffer && *buffer != 'e' && *buffer != 'E')
|
||||||
|
buffer++;
|
||||||
stop = buffer--;
|
stop = buffer--;
|
||||||
while (*buffer == '0') buffer--;
|
while (*buffer == '0')
|
||||||
if (*buffer == '.') buffer--;
|
buffer--;
|
||||||
while ( (*++buffer = *stop++) != 0 );
|
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;
|
int n;
|
||||||
|
|
||||||
// Left align means no zero padding
|
// Left align means no zero padding
|
||||||
if (flags & LEFT) flags &= ~ZEROPAD;
|
if (flags & LEFT)
|
||||||
|
flags &= ~ZEROPAD;
|
||||||
|
|
||||||
// Determine padding and sign char
|
// Determine padding and sign char
|
||||||
c = (flags & ZEROPAD) ? '0' : ' ';
|
c = (flags & ZEROPAD) ? '0' : ' ';
|
||||||
sign = 0;
|
sign = 0;
|
||||||
if (flags & SIGN)
|
if (flags & SIGN) {
|
||||||
{
|
if (num < 0.0) {
|
||||||
if (num < 0.0)
|
|
||||||
{
|
|
||||||
sign = '-';
|
sign = '-';
|
||||||
num = -num;
|
num = -num;
|
||||||
size--;
|
size--;
|
||||||
}
|
} else if (flags & PLUS) {
|
||||||
else if (flags & PLUS)
|
|
||||||
{
|
|
||||||
sign = '+';
|
sign = '+';
|
||||||
size--;
|
size--;
|
||||||
}
|
} else if (flags & SPACE) {
|
||||||
else if (flags & SPACE)
|
|
||||||
{
|
|
||||||
sign = ' ';
|
sign = ' ';
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
|
@ -508,21 +487,31 @@ static void flt( std::string& dest, double num, int size, int precision, char fm
|
||||||
cfltcvt(num, tmp, fmt, precision);
|
cfltcvt(num, tmp, fmt, precision);
|
||||||
|
|
||||||
// '#' and precision == 0 means force a decimal point
|
// '#' 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
|
// 'g' format means crop zero unless '#' given
|
||||||
if (fmt == 'g' && !(flags & SPECIAL)) cropzeros(tmp);
|
if (fmt == 'g' && !(flags & SPECIAL))
|
||||||
|
cropzeros(tmp);
|
||||||
|
|
||||||
n = strlen(tmp);
|
n = strlen(tmp);
|
||||||
|
|
||||||
// Output number with alignment and padding
|
// Output number with alignment and padding
|
||||||
size -= n;
|
size -= n;
|
||||||
|
|
||||||
if (!(flags & (ZEROPAD | LEFT)) && size > 0) { dest.append( size, ' ' ); size = 0; }
|
if (!(flags & (ZEROPAD | LEFT)) && size > 0) {
|
||||||
if (sign) dest += sign;
|
dest.append(size, ' ');
|
||||||
if (!(flags & LEFT) && size > 0) { dest.append( size, c ); size = 0; }
|
size = 0;
|
||||||
|
}
|
||||||
|
if (sign)
|
||||||
|
dest += sign;
|
||||||
|
if (!(flags & LEFT) && size > 0) {
|
||||||
|
dest.append(size, c);
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
dest.append(tmp, n);
|
dest.append(tmp, n);
|
||||||
if(size > 0) dest.append( size, ' ' );
|
if (size > 0)
|
||||||
|
dest.append(size, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#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 precision; // Min. # of digits for integers; max number of chars for from string
|
||||||
int qualifier; // 'h', 'l', or 'L' for integer fields
|
int qualifier; // 'h', 'l', or 'L' for integer fields
|
||||||
|
|
||||||
for( const char* fmt = format; *fmt; ++fmt )
|
for (const char *fmt = format; *fmt; ++fmt) {
|
||||||
{
|
if (*fmt != '%') {
|
||||||
if (*fmt != '%')
|
|
||||||
{
|
|
||||||
dest += *fmt;
|
dest += *fmt;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -552,25 +539,32 @@ static void vssappendf(std::string& dest, const char* format, va_list args)
|
||||||
flags = 0;
|
flags = 0;
|
||||||
repeat:
|
repeat:
|
||||||
fmt++; // This also skips first '%'
|
fmt++; // This also skips first '%'
|
||||||
switch (*fmt)
|
switch (*fmt) {
|
||||||
{
|
case '-':
|
||||||
case '-': flags |= LEFT; goto repeat;
|
flags |= LEFT;
|
||||||
case '+': flags |= PLUS; goto repeat;
|
goto repeat;
|
||||||
case ' ': flags |= SPACE; goto repeat;
|
case '+':
|
||||||
case '#': flags |= SPECIAL; goto repeat;
|
flags |= PLUS;
|
||||||
case '0': flags |= ZEROPAD; goto repeat;
|
goto repeat;
|
||||||
|
case ' ':
|
||||||
|
flags |= SPACE;
|
||||||
|
goto repeat;
|
||||||
|
case '#':
|
||||||
|
flags |= SPECIAL;
|
||||||
|
goto repeat;
|
||||||
|
case '0':
|
||||||
|
flags |= ZEROPAD;
|
||||||
|
goto repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get field width
|
// Get field width
|
||||||
field_width = -1;
|
field_width = -1;
|
||||||
if (is_digit(*fmt))
|
if (is_digit(*fmt))
|
||||||
field_width = skip_atoi(&fmt);
|
field_width = skip_atoi(&fmt);
|
||||||
else if (*fmt == '*')
|
else if (*fmt == '*') {
|
||||||
{
|
|
||||||
fmt++;
|
fmt++;
|
||||||
field_width = va_arg(args, int);
|
field_width = va_arg(args, int);
|
||||||
if (field_width < 0)
|
if (field_width < 0) {
|
||||||
{
|
|
||||||
field_width = -field_width;
|
field_width = -field_width;
|
||||||
flags |= LEFT;
|
flags |= LEFT;
|
||||||
}
|
}
|
||||||
|
@ -578,23 +572,21 @@ repeat:
|
||||||
|
|
||||||
// Get the precision
|
// Get the precision
|
||||||
precision = -1;
|
precision = -1;
|
||||||
if (*fmt == '.')
|
if (*fmt == '.') {
|
||||||
{
|
|
||||||
++fmt;
|
++fmt;
|
||||||
if (is_digit(*fmt))
|
if (is_digit(*fmt))
|
||||||
precision = skip_atoi(&fmt);
|
precision = skip_atoi(&fmt);
|
||||||
else if (*fmt == '*')
|
else if (*fmt == '*') {
|
||||||
{
|
|
||||||
++fmt;
|
++fmt;
|
||||||
precision = va_arg(args, int);
|
precision = va_arg(args, int);
|
||||||
}
|
}
|
||||||
if (precision < 0) precision = 0;
|
if (precision < 0)
|
||||||
|
precision = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the conversion qualifier
|
// Get the conversion qualifier
|
||||||
qualifier = -1;
|
qualifier = -1;
|
||||||
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' )
|
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
|
||||||
{
|
|
||||||
qualifier = *fmt;
|
qualifier = *fmt;
|
||||||
fmt++;
|
fmt++;
|
||||||
}
|
}
|
||||||
|
@ -602,39 +594,36 @@ repeat:
|
||||||
// Default base
|
// Default base
|
||||||
base = 10;
|
base = 10;
|
||||||
|
|
||||||
switch (*fmt)
|
switch (*fmt) {
|
||||||
{
|
|
||||||
case 'c':
|
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);
|
dest += (unsigned char)va_arg(args, int);
|
||||||
while (--field_width > 0) dest += ' ';
|
while (--field_width > 0)
|
||||||
|
dest += ' ';
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 's':
|
case 's': {
|
||||||
{
|
|
||||||
// let's add support for std::string as a formatted parameter! (air)
|
// let's add support for std::string as a formatted parameter! (air)
|
||||||
if( qualifier == 'h' )
|
if (qualifier == 'h') {
|
||||||
{
|
|
||||||
static const std::string nullstring("<NULL>");
|
static const std::string nullstring("<NULL>");
|
||||||
|
|
||||||
const std::string *ss = va_arg(args, std::string *);
|
const std::string *ss = va_arg(args, std::string *);
|
||||||
if( ss == NULL ) ss = &nullstring;
|
if (ss == NULL)
|
||||||
|
ss = &nullstring;
|
||||||
int len = ss->length();
|
int len = ss->length();
|
||||||
if( precision < 0 )
|
if (precision < 0) {
|
||||||
{
|
|
||||||
// no precision override so just copy the whole string.
|
// 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, ' ');
|
dest.append(field_width - len, ' ');
|
||||||
field_width = 0;
|
field_width = 0;
|
||||||
}
|
}
|
||||||
dest += *ss;
|
dest += *ss;
|
||||||
}
|
} else {
|
||||||
else
|
if (len > precision)
|
||||||
{
|
len = precision;
|
||||||
if( len > precision ) len = precision;
|
if (!(flags & LEFT) && (len < field_width)) {
|
||||||
if (!(flags & LEFT) && (len < field_width))
|
|
||||||
{
|
|
||||||
dest.append(field_width - len, ' ');
|
dest.append(field_width - len, ' ');
|
||||||
field_width = 0;
|
field_width = 0;
|
||||||
}
|
}
|
||||||
|
@ -643,33 +632,33 @@ repeat:
|
||||||
|
|
||||||
if (len < field_width)
|
if (len < field_width)
|
||||||
dest.append(field_width - len, ' ');
|
dest.append(field_width - len, ' ');
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
const char *s = va_arg(args, char *);
|
const char *s = va_arg(args, char *);
|
||||||
if (!s) s = "<NULL>";
|
if (!s)
|
||||||
|
s = "<NULL>";
|
||||||
|
|
||||||
int len = strlen(s);
|
int len = strlen(s);
|
||||||
if( precision < 0 )
|
if (precision < 0) {
|
||||||
{
|
if (!(flags & LEFT))
|
||||||
if (!(flags & LEFT)) while (len < field_width--) dest += ' ';
|
while (len < field_width--)
|
||||||
|
dest += ' ';
|
||||||
dest += s;
|
dest += s;
|
||||||
}
|
} else {
|
||||||
else
|
if (len > precision)
|
||||||
{
|
len = precision;
|
||||||
if( len > precision ) len = precision;
|
if (!(flags & LEFT))
|
||||||
if (!(flags & LEFT)) while (len < field_width--) dest += ' ';
|
while (len < field_width--)
|
||||||
|
dest += ' ';
|
||||||
dest.append(s, s + len);
|
dest.append(s, s + len);
|
||||||
}
|
}
|
||||||
while (len < field_width--) dest += ' ';
|
while (len < field_width--)
|
||||||
|
dest += ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'p':
|
case 'p': {
|
||||||
{
|
if (field_width == -1) {
|
||||||
if (field_width == -1)
|
|
||||||
{
|
|
||||||
field_width = 2 * sizeof(void *);
|
field_width = 2 * sizeof(void *);
|
||||||
flags |= ZEROPAD;
|
flags |= ZEROPAD;
|
||||||
}
|
}
|
||||||
|
@ -679,13 +668,10 @@ repeat:
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
if (qualifier == 'l')
|
if (qualifier == 'l') {
|
||||||
{
|
|
||||||
long *ip = va_arg(args, long *);
|
long *ip = va_arg(args, long *);
|
||||||
*ip = dest.length();
|
*ip = dest.length();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int *ip = va_arg(args, int *);
|
int *ip = va_arg(args, int *);
|
||||||
*ip = dest.length();
|
*ip = dest.length();
|
||||||
}
|
}
|
||||||
|
@ -734,7 +720,8 @@ repeat:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (*fmt != '%') dest += '%';
|
if (*fmt != '%')
|
||||||
|
dest += '%';
|
||||||
if (*fmt)
|
if (*fmt)
|
||||||
dest += *fmt;
|
dest += *fmt;
|
||||||
else
|
else
|
||||||
|
@ -742,13 +729,10 @@ repeat:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qualifier == 'L')
|
if (qualifier == 'L') {
|
||||||
{
|
|
||||||
// 64-bit integer support! (air)
|
// 64-bit integer support! (air)
|
||||||
number(dest, va_arg(args, s64), base, field_width, precision, flags);
|
number(dest, va_arg(args, s64), base, field_width, precision, flags);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
s32 num;
|
s32 num;
|
||||||
// Modern 32 bit compilers pass parameters into va_arg by 32 bit scale always,
|
// 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.
|
// so no point in using or checking for the 'h' parameter.
|
||||||
|
|
|
@ -32,8 +32,7 @@ ConsoleLogSource_App::ConsoleLogSource_App()
|
||||||
static const TraceLogDescriptor myDesc =
|
static const TraceLogDescriptor myDesc =
|
||||||
{
|
{
|
||||||
L"AppEvents", L"App Events",
|
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;
|
m_Descriptor = &myDesc;
|
||||||
}
|
}
|
||||||
|
@ -59,12 +58,9 @@ void SynchronousActionState::SetException( const BaseException& ex )
|
||||||
|
|
||||||
void SynchronousActionState::SetException(BaseException *ex)
|
void SynchronousActionState::SetException(BaseException *ex)
|
||||||
{
|
{
|
||||||
if( !m_posted )
|
if (!m_posted) {
|
||||||
{
|
|
||||||
m_exception = ScopedExcept(ex);
|
m_exception = ScopedExcept(ex);
|
||||||
}
|
} else if (wxTheApp) {
|
||||||
else if( wxTheApp )
|
|
||||||
{
|
|
||||||
// transport the exception to the main thread, since the message is fully
|
// transport the exception to the main thread, since the message is fully
|
||||||
// asynchronous, or has already entered an asynchronous state. Message is sent
|
// 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
|
// 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
|
void SynchronousActionState::RethrowException() const
|
||||||
{
|
{
|
||||||
if( m_exception ) m_exception->Rethrow();
|
if (m_exception)
|
||||||
|
m_exception->Rethrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynchronousActionState::WaitForResult()
|
int SynchronousActionState::WaitForResult()
|
||||||
|
@ -108,7 +105,8 @@ void SynchronousActionState::ClearResult()
|
||||||
|
|
||||||
void SynchronousActionState::PostResult()
|
void SynchronousActionState::PostResult()
|
||||||
{
|
{
|
||||||
if( m_posted ) return;
|
if (m_posted)
|
||||||
|
return;
|
||||||
m_posted = true;
|
m_posted = true;
|
||||||
m_sema.Post();
|
m_sema.Post();
|
||||||
}
|
}
|
||||||
|
@ -147,8 +145,7 @@ void pxActionEvent::SetException( BaseException* ex )
|
||||||
const wxString &prefix(pxsFmt(L"(%s) ", GetClassInfo()->GetClassName()));
|
const wxString &prefix(pxsFmt(L"(%s) ", GetClassInfo()->GetClassName()));
|
||||||
ex->DiagMsg() = prefix + ex->DiagMsg();
|
ex->DiagMsg() = prefix + ex->DiagMsg();
|
||||||
|
|
||||||
if( !m_state )
|
if (!m_state) {
|
||||||
{
|
|
||||||
ScopedExcept exptr(ex); // auto-delete it after handling.
|
ScopedExcept exptr(ex); // auto-delete it after handling.
|
||||||
ex->Rethrow();
|
ex->Rethrow();
|
||||||
}
|
}
|
||||||
|
@ -200,14 +197,14 @@ pxSynchronousCommandEvent::pxSynchronousCommandEvent( const pxSynchronousCommand
|
||||||
|
|
||||||
void pxSynchronousCommandEvent::SetException(const BaseException &ex)
|
void pxSynchronousCommandEvent::SetException(const BaseException &ex)
|
||||||
{
|
{
|
||||||
if( !m_sync ) ex.Rethrow();
|
if (!m_sync)
|
||||||
|
ex.Rethrow();
|
||||||
m_sync->SetException(ex);
|
m_sync->SetException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pxSynchronousCommandEvent::SetException(BaseException *ex)
|
void pxSynchronousCommandEvent::SetException(BaseException *ex)
|
||||||
{
|
{
|
||||||
if( !m_sync )
|
if (!m_sync) {
|
||||||
{
|
|
||||||
ScopedExcept exptr(ex); // auto-delete it after handling.
|
ScopedExcept exptr(ex); // auto-delete it after handling.
|
||||||
ex->Rethrow();
|
ex->Rethrow();
|
||||||
}
|
}
|
||||||
|
@ -261,7 +258,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void InvokeEvent()
|
void InvokeEvent()
|
||||||
{
|
{
|
||||||
if( m_Method ) m_Method();
|
if (m_Method)
|
||||||
|
m_Method();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -278,7 +276,8 @@ pxExceptionEvent::pxExceptionEvent( const BaseException& ex )
|
||||||
void pxExceptionEvent::InvokeEvent()
|
void pxExceptionEvent::InvokeEvent()
|
||||||
{
|
{
|
||||||
ScopedExcept deleteMe(m_except);
|
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)
|
bool wxAppWithHelpers::Rpc_TryInvoke(FnType_Void *method)
|
||||||
{
|
{
|
||||||
if( wxThread::IsMain() ) return false;
|
if (wxThread::IsMain())
|
||||||
|
return false;
|
||||||
|
|
||||||
SynchronousActionState sync;
|
SynchronousActionState sync;
|
||||||
PostEvent(pxRpcEvent(method, sync));
|
PostEvent(pxRpcEvent(method, sync));
|
||||||
|
@ -343,15 +343,15 @@ bool wxAppWithHelpers::Rpc_TryInvoke( FnType_Void* method )
|
||||||
//
|
//
|
||||||
bool wxAppWithHelpers::Rpc_TryInvokeAsync(FnType_Void *method)
|
bool wxAppWithHelpers::Rpc_TryInvokeAsync(FnType_Void *method)
|
||||||
{
|
{
|
||||||
if( wxThread::IsMain() ) return false;
|
if (wxThread::IsMain())
|
||||||
|
return false;
|
||||||
PostEvent(pxRpcEvent(method));
|
PostEvent(pxRpcEvent(method));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxAppWithHelpers::ProcessMethod(FnType_Void *method)
|
void wxAppWithHelpers::ProcessMethod(FnType_Void *method)
|
||||||
{
|
{
|
||||||
if( wxThread::IsMain() )
|
if (wxThread::IsMain()) {
|
||||||
{
|
|
||||||
method();
|
method();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -394,8 +394,7 @@ bool wxAppWithHelpers::ProcessEvent( pxActionEvent& evt )
|
||||||
{
|
{
|
||||||
if (wxThread::IsMain())
|
if (wxThread::IsMain())
|
||||||
return _parent::ProcessEvent(evt);
|
return _parent::ProcessEvent(evt);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
SynchronousActionState sync;
|
SynchronousActionState sync;
|
||||||
evt.SetSyncState(sync);
|
evt.SetSyncState(sync);
|
||||||
AddPendingEvent(evt);
|
AddPendingEvent(evt);
|
||||||
|
@ -406,13 +405,10 @@ bool wxAppWithHelpers::ProcessEvent( pxActionEvent& evt )
|
||||||
|
|
||||||
bool wxAppWithHelpers::ProcessEvent(pxActionEvent *evt)
|
bool wxAppWithHelpers::ProcessEvent(pxActionEvent *evt)
|
||||||
{
|
{
|
||||||
if( wxThread::IsMain() )
|
if (wxThread::IsMain()) {
|
||||||
{
|
|
||||||
std::unique_ptr<wxEvent> deleteMe(evt);
|
std::unique_ptr<wxEvent> deleteMe(evt);
|
||||||
return _parent::ProcessEvent(*deleteMe);
|
return _parent::ProcessEvent(*deleteMe);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
SynchronousActionState sync;
|
SynchronousActionState sync;
|
||||||
evt->SetSyncState(sync);
|
evt->SetSyncState(sync);
|
||||||
AddPendingEvent(*evt);
|
AddPendingEvent(*evt);
|
||||||
|
@ -444,17 +440,14 @@ void pxActionEvent::_DoInvokeEvent()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InvokeEvent();
|
InvokeEvent();
|
||||||
}
|
} catch (BaseException &ex) {
|
||||||
catch( BaseException& ex )
|
|
||||||
{
|
|
||||||
SetException(ex);
|
SetException(ex);
|
||||||
}
|
} catch (std::runtime_error &ex) {
|
||||||
catch( std::runtime_error& ex )
|
|
||||||
{
|
|
||||||
SetException(new Exception::RuntimeError(ex));
|
SetException(new Exception::RuntimeError(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_state ) m_state->PostResult();
|
if (m_state)
|
||||||
|
m_state->PostResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxAppWithHelpers::OnSynchronousCommand(pxSynchronousCommandEvent &evt)
|
void wxAppWithHelpers::OnSynchronousCommand(pxSynchronousCommandEvent &evt)
|
||||||
|
@ -466,17 +459,14 @@ void wxAppWithHelpers::OnSynchronousCommand( pxSynchronousCommandEvent& evt )
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProcessEvent(evt);
|
ProcessEvent(evt);
|
||||||
}
|
} catch (BaseException &ex) {
|
||||||
catch( BaseException& ex )
|
|
||||||
{
|
|
||||||
evt.SetException(ex);
|
evt.SetException(ex);
|
||||||
}
|
} catch (std::runtime_error &ex) {
|
||||||
catch( std::runtime_error& ex )
|
|
||||||
{
|
|
||||||
evt.SetException(new Exception::RuntimeError(ex, evt.GetClassInfo()->GetClassName()));
|
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)
|
void wxAppWithHelpers::AddIdleEvent(const wxEvent &evt)
|
||||||
|
@ -510,14 +500,12 @@ void wxAppWithHelpers::IdleEventDispatcher( const wxChar* action )
|
||||||
|
|
||||||
ScopedLock lock(m_IdleEventMutex);
|
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);
|
std::unique_ptr<wxEvent> deleteMe(*node);
|
||||||
m_IdleEventQueue.erase(node);
|
m_IdleEventQueue.erase(node);
|
||||||
|
|
||||||
lock.Release();
|
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
|
// 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
|
// 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
|
// 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.");
|
pxThreadLog.Write(((pxThread *)((wxCommandEvent *)deleteMe.get())->GetClientData())->GetName(), L"Deletion postponed due to mutex or semaphore dependency.");
|
||||||
postponed.push_back(deleteMe.release());
|
postponed.push_back(deleteMe.release());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pxAppLog.Write(L"(AppIdleQueue%s) Dispatching event '%s'", action, deleteMe->GetClassInfo()->GetClassName());
|
pxAppLog.Write(L"(AppIdleQueue%s) Dispatching event '%s'", action, deleteMe->GetClassInfo()->GetClassName());
|
||||||
ProcessEvent(*deleteMe); // dereference to prevent auto-deletion by ProcessEvent
|
ProcessEvent(*deleteMe); // dereference to prevent auto-deletion by ProcessEvent
|
||||||
}
|
}
|
||||||
|
@ -602,14 +588,12 @@ void wxAppWithHelpers::PostAction( const pxActionEvent& evt )
|
||||||
|
|
||||||
void wxAppWithHelpers::ProcessAction(pxActionEvent &evt)
|
void wxAppWithHelpers::ProcessAction(pxActionEvent &evt)
|
||||||
{
|
{
|
||||||
if( !wxThread::IsMain() )
|
if (!wxThread::IsMain()) {
|
||||||
{
|
|
||||||
SynchronousActionState sync;
|
SynchronousActionState sync;
|
||||||
evt.SetSyncState(sync);
|
evt.SetSyncState(sync);
|
||||||
AddPendingEvent(evt);
|
AddPendingEvent(evt);
|
||||||
sync.WaitForResult();
|
sync.WaitForResult();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
evt._DoInvokeEvent();
|
evt._DoInvokeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +638,8 @@ void wxAppWithHelpers::OnInvokeAction( pxActionEvent& evt )
|
||||||
|
|
||||||
void wxAppWithHelpers::OnDeleteObject(wxCommandEvent &evt)
|
void wxAppWithHelpers::OnDeleteObject(wxCommandEvent &evt)
|
||||||
{
|
{
|
||||||
if( evt.GetClientData() == NULL ) return;
|
if (evt.GetClientData() == NULL)
|
||||||
|
return;
|
||||||
delete (BaseDeletableObject *)evt.GetClientData();
|
delete (BaseDeletableObject *)evt.GetClientData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,8 +660,7 @@ wxAppTraits* wxAppWithHelpers::CreateTraits()
|
||||||
void wxAppWithHelpers::OnDeleteThread(wxCommandEvent &evt)
|
void wxAppWithHelpers::OnDeleteThread(wxCommandEvent &evt)
|
||||||
{
|
{
|
||||||
std::unique_ptr<pxThread> thr((pxThread *)evt.GetClientData());
|
std::unique_ptr<pxThread> thr((pxThread *)evt.GetClientData());
|
||||||
if( !thr )
|
if (!thr) {
|
||||||
{
|
|
||||||
pxThreadLog.Write(L"null", L"OnDeleteThread: NULL thread object received (and ignored).");
|
pxThreadLog.Write(L"null", L"OnDeleteThread: NULL thread object received (and ignored).");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -698,4 +682,3 @@ wxAppWithHelpers::wxAppWithHelpers()
|
||||||
tls_insurance = 1;
|
tls_insurance = 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,7 @@ const pxStretchType
|
||||||
|
|
||||||
wxSizerFlags pxAlignmentType::Apply(wxSizerFlags flags) const
|
wxSizerFlags pxAlignmentType::Apply(wxSizerFlags flags) const
|
||||||
{
|
{
|
||||||
switch( intval )
|
switch (intval) {
|
||||||
{
|
|
||||||
case Centre:
|
case Centre:
|
||||||
flags.Align(flags.GetFlags() | wxALIGN_CENTRE_HORIZONTAL);
|
flags.Align(flags.GetFlags() | wxALIGN_CENTRE_HORIZONTAL);
|
||||||
break;
|
break;
|
||||||
|
@ -70,8 +69,7 @@ wxSizerFlags pxAlignmentType::Apply( wxSizerFlags flags ) const
|
||||||
|
|
||||||
wxSizerFlags pxStretchType::Apply(wxSizerFlags flags) const
|
wxSizerFlags pxStretchType::Apply(wxSizerFlags flags) const
|
||||||
{
|
{
|
||||||
switch( intval )
|
switch (intval) {
|
||||||
{
|
|
||||||
case Shrink:
|
case Shrink:
|
||||||
//pxFail( "wxSHRINK is an ignored stretch flag." );
|
//pxFail( "wxSHRINK is an ignored stretch flag." );
|
||||||
break;
|
break;
|
||||||
|
@ -107,10 +105,14 @@ wxSizerFlags operator& ( const wxSizerFlags& _flgs, const wxSizerFlags& _flgs2 )
|
||||||
uint allflags = (_flgs.GetFlags() | _flgs2.GetFlags());
|
uint allflags = (_flgs.GetFlags() | _flgs2.GetFlags());
|
||||||
|
|
||||||
retval.Align(allflags & wxALIGN_MASK);
|
retval.Align(allflags & wxALIGN_MASK);
|
||||||
if( allflags & wxEXPAND ) retval.Expand();
|
if (allflags & wxEXPAND)
|
||||||
if( allflags & wxSHAPED ) retval.Shaped();
|
retval.Expand();
|
||||||
if( allflags & wxFIXED_MINSIZE ) retval.FixedMinSize();
|
if (allflags & wxSHAPED)
|
||||||
if( allflags & wxRESERVE_SPACE_EVEN_IF_HIDDEN ) retval.ReserveSpaceEvenIfHidden();
|
retval.Shaped();
|
||||||
|
if (allflags & wxFIXED_MINSIZE)
|
||||||
|
retval.FixedMinSize();
|
||||||
|
if (allflags & wxRESERVE_SPACE_EVEN_IF_HIDDEN)
|
||||||
|
retval.ReserveSpaceEvenIfHidden();
|
||||||
|
|
||||||
// Compounding borders is probably a fair approach:
|
// Compounding borders is probably a fair approach:
|
||||||
retval.Border(allflags & wxALL, _flgs.GetBorderInPixels() + _flgs2.GetBorderInPixels());
|
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)
|
void operator+=(wxWindow &target, int spacer)
|
||||||
{
|
{
|
||||||
if( !pxAssert( target.GetSizer() != NULL ) ) return;
|
if (!pxAssert(target.GetSizer() != NULL))
|
||||||
|
return;
|
||||||
target.GetSizer()->AddSpacer(spacer);
|
target.GetSizer()->AddSpacer(spacer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator+=(wxWindow &target, const pxStretchSpacer &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);
|
target.GetSizer()->AddStretchSpacer(spacer.proportion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,13 +176,15 @@ void operator+=( wxWindow& target, const pxStretchSpacer& spacer )
|
||||||
|
|
||||||
void operator+=(wxSizer *target, wxWindow &src)
|
void operator+=(wxSizer *target, wxWindow &src)
|
||||||
{
|
{
|
||||||
if( !pxAssert( target != NULL ) ) return;
|
if (!pxAssert(target != NULL))
|
||||||
|
return;
|
||||||
target->Add(&src);
|
target->Add(&src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator+=(wxSizer *target, wxSizer &src)
|
void operator+=(wxSizer *target, wxSizer &src)
|
||||||
{
|
{
|
||||||
if( !pxAssert( target != NULL ) ) return;
|
if (!pxAssert(target != NULL))
|
||||||
|
return;
|
||||||
target->Add(&src);
|
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
|
// FIXME: add range from Japanese-specific and Korean-specific section if you know the
|
||||||
// characters are used today.
|
// 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
|
return
|
||||||
// Han Ideographs: all except Supplement
|
// 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)
|
static bool no_break_after(const uint ch)
|
||||||
{
|
{
|
||||||
switch( ch )
|
// clang-format off
|
||||||
{
|
switch (ch) {
|
||||||
/**
|
/**
|
||||||
* don't break after these Japanese/Chinese characters
|
* don't break after these Japanese/Chinese characters
|
||||||
*/
|
*/
|
||||||
|
@ -341,14 +348,15 @@ static bool no_break_after(const uint ch)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool no_break_before(const uint ch)
|
static bool no_break_before(const uint ch)
|
||||||
{
|
{
|
||||||
switch(ch)
|
// clang-format off
|
||||||
{
|
switch (ch) {
|
||||||
/**
|
/**
|
||||||
* don't break before these Japanese characters
|
* 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
|
* and right side of different kinds of brackets, quotes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pxTextWrapperBase &pxTextWrapperBase::Wrap(const wxWindow &win, const wxString &text, int widthMax)
|
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;
|
const wxChar *lastSpace = NULL;
|
||||||
bool wasWrapped = false;
|
bool wasWrapped = false;
|
||||||
|
@ -392,10 +402,8 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
|
||||||
line.Alloc(text.Length() + 12);
|
line.Alloc(text.Length() + 12);
|
||||||
|
|
||||||
const wxChar *lineStart = text.wc_str();
|
const wxChar *lineStart = text.wc_str();
|
||||||
for ( const wxChar *p = lineStart; ; p++ )
|
for (const wxChar *p = lineStart;; p++) {
|
||||||
{
|
if (IsStartOfNewLine()) {
|
||||||
if ( IsStartOfNewLine() )
|
|
||||||
{
|
|
||||||
OnNewLine();
|
OnNewLine();
|
||||||
|
|
||||||
lastSpace = NULL;
|
lastSpace = NULL;
|
||||||
|
@ -407,36 +415,29 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
|
||||||
line.clear();
|
line.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *p == L'\n' || *p == L'\0' )
|
if (*p == L'\n' || *p == L'\0') {
|
||||||
{
|
|
||||||
wasWrapped = false;
|
wasWrapped = false;
|
||||||
DoOutputLine(line);
|
DoOutputLine(line);
|
||||||
|
|
||||||
if (*p == L'\0')
|
if (*p == L'\0')
|
||||||
break;
|
break;
|
||||||
}
|
} else // not EOL
|
||||||
else // not EOL
|
|
||||||
{
|
|
||||||
if (is_cjk_char(*p))
|
|
||||||
{
|
|
||||||
if (!no_break_before(*p))
|
|
||||||
{
|
{
|
||||||
|
if (is_cjk_char(*p)) {
|
||||||
|
if (!no_break_before(*p)) {
|
||||||
if (p == lineStart || !no_break_after(*(p - 1)))
|
if (p == lineStart || !no_break_after(*(p - 1)))
|
||||||
lastSpace = p;
|
lastSpace = p;
|
||||||
}
|
}
|
||||||
}
|
} else if (*p == L' ' || *p == L',' || *p == L'/')
|
||||||
else if ( *p == L' ' || *p == L',' || *p == L'/' )
|
|
||||||
lastSpace = p;
|
lastSpace = p;
|
||||||
|
|
||||||
line += *p;
|
line += *p;
|
||||||
|
|
||||||
if ( widthMax >= 0 && lastSpace )
|
if (widthMax >= 0 && lastSpace) {
|
||||||
{
|
|
||||||
int width;
|
int width;
|
||||||
win.GetTextExtent(line, &width, NULL);
|
win.GetTextExtent(line, &width, NULL);
|
||||||
|
|
||||||
if ( width > widthMax )
|
if (width > widthMax) {
|
||||||
{
|
|
||||||
wasWrapped = true;
|
wasWrapped = true;
|
||||||
|
|
||||||
// remove the last word from this line
|
// remove the last word from this line
|
||||||
|
@ -449,7 +450,6 @@ pxTextWrapperBase& pxTextWrapperBase::Wrap( const wxWindow& win, const wxString&
|
||||||
|
|
||||||
if (*p != L' ')
|
if (*p != L' ')
|
||||||
p--;
|
p--;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else: no wrapping at all or impossible to wrap
|
//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)
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,10 +524,10 @@ ScopedBusyCursor::ScopedBusyCursor( BusyCursorType busytype )
|
||||||
|
|
||||||
ScopedBusyCursor::~ScopedBusyCursor() throw()
|
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);
|
SetManualBusyCursor(m_defBusyType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -542,7 +543,8 @@ ScopedBusyCursor::~ScopedBusyCursor() throw()
|
||||||
|
|
||||||
void ScopedBusyCursor::SetDefault(BusyCursorType busytype)
|
void ScopedBusyCursor::SetDefault(BusyCursorType busytype)
|
||||||
{
|
{
|
||||||
if( busytype == m_defBusyType ) return;
|
if (busytype == m_defBusyType)
|
||||||
|
return;
|
||||||
m_defBusyType = busytype;
|
m_defBusyType = busytype;
|
||||||
|
|
||||||
if (m_cursorStack.empty())
|
if (m_cursorStack.empty())
|
||||||
|
@ -551,11 +553,16 @@ void ScopedBusyCursor::SetDefault( BusyCursorType busytype )
|
||||||
|
|
||||||
void ScopedBusyCursor::SetManualBusyCursor(BusyCursorType busytype)
|
void ScopedBusyCursor::SetManualBusyCursor(BusyCursorType busytype)
|
||||||
{
|
{
|
||||||
switch( busytype )
|
switch (busytype) {
|
||||||
{
|
case Cursor_NotBusy:
|
||||||
case Cursor_NotBusy: wxSetCursor( wxNullCursor ); break;
|
wxSetCursor(wxNullCursor);
|
||||||
case Cursor_KindaBusy: wxSetCursor( StockCursors.GetArrowWait() ); break;
|
break;
|
||||||
case Cursor_ReallyBusy: wxSetCursor( *wxHOURGLASS_CURSOR ); 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)
|
void pxSetToolTip(wxWindow *wind, const wxString &src)
|
||||||
{
|
{
|
||||||
if( wind == NULL ) return; // Silently ignore nulls
|
if (wind == NULL)
|
||||||
|
return; // Silently ignore nulls
|
||||||
wind->SetToolTip(src);
|
wind->SetToolTip(src);
|
||||||
|
|
||||||
// Make tooltips show for as long as possible on Windows. Linux (GTK) can
|
// 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(
|
return wxFont(
|
||||||
ptsize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, weight, false
|
ptsize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, weight, false
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
,L"Lucida Console" // better than courier new (win32 only)
|
,
|
||||||
|
L"Lucida Console" // better than courier new (win32 only)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,8 +133,7 @@ wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, const wxString& titl
|
||||||
: wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, cflags.GetWxWindowFlags())
|
: wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, cflags.GetWxWindowFlags())
|
||||||
{
|
{
|
||||||
m_hasContextHelp = cflags.hasContextHelp;
|
m_hasContextHelp = cflags.hasContextHelp;
|
||||||
if( (int)cflags.BoxSizerOrient != 0 )
|
if ((int)cflags.BoxSizerOrient != 0) {
|
||||||
{
|
|
||||||
SetSizer(new wxBoxSizer(cflags.BoxSizerOrient));
|
SetSizer(new wxBoxSizer(cflags.BoxSizerOrient));
|
||||||
*this += StdPadding;
|
*this += StdPadding;
|
||||||
}
|
}
|
||||||
|
@ -197,18 +196,17 @@ void wxDialogWithHelpers::DoAutoCenter()
|
||||||
// a lot since the main window is small).
|
// a lot since the main window is small).
|
||||||
|
|
||||||
bool centerfail = true;
|
bool centerfail = true;
|
||||||
if( wxWindow* parent = GetParent() )
|
if (wxWindow *parent = GetParent()) {
|
||||||
{
|
|
||||||
const wxSize parentSize(parent->GetSize());
|
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();
|
CenterOnParent();
|
||||||
centerfail = false;
|
centerfail = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( centerfail ) CenterOnScreen();
|
if (centerfail)
|
||||||
|
CenterOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDialogWithHelpers::SmartCenterFit()
|
void wxDialogWithHelpers::SmartCenterFit()
|
||||||
|
@ -216,21 +214,19 @@ void wxDialogWithHelpers::SmartCenterFit()
|
||||||
Fit();
|
Fit();
|
||||||
|
|
||||||
const wxString dlgName(GetDialogName());
|
const wxString dlgName(GetDialogName());
|
||||||
if( dlgName.IsEmpty() )
|
if (dlgName.IsEmpty()) {
|
||||||
{
|
DoAutoCenter();
|
||||||
DoAutoCenter(); return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( wxConfigBase* cfg = wxConfigBase::Get( false ) )
|
if (wxConfigBase *cfg = wxConfigBase::Get(false)) {
|
||||||
{
|
|
||||||
wxRect screenRect(GetScreenRect());
|
wxRect screenRect(GetScreenRect());
|
||||||
|
|
||||||
IniLoader loader(cfg);
|
IniLoader loader(cfg);
|
||||||
ScopedIniGroup group(loader, L"DialogPositions");
|
ScopedIniGroup group(loader, L"DialogPositions");
|
||||||
cfg->SetRecordDefaults(false);
|
cfg->SetRecordDefaults(false);
|
||||||
|
|
||||||
if( GetWindowStyle() & wxRESIZE_BORDER )
|
if (GetWindowStyle() & wxRESIZE_BORDER) {
|
||||||
{
|
|
||||||
wxSize size;
|
wxSize size;
|
||||||
loader.Entry(dlgName + L"_Size", size, screenRect.GetSize());
|
loader.Entry(dlgName + L"_Size", size, screenRect.GetSize());
|
||||||
SetSize(size);
|
SetSize(size);
|
||||||
|
@ -238,8 +234,7 @@ void wxDialogWithHelpers::SmartCenterFit()
|
||||||
|
|
||||||
if (!cfg->Exists(dlgName + L"_Pos"))
|
if (!cfg->Exists(dlgName + L"_Pos"))
|
||||||
DoAutoCenter();
|
DoAutoCenter();
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
wxPoint pos;
|
wxPoint pos;
|
||||||
loader.Entry(dlgName + L"_Pos", pos, screenRect.GetPosition());
|
loader.Entry(dlgName + L"_Pos", pos, screenRect.GetPosition());
|
||||||
SetPosition(pos);
|
SetPosition(pos);
|
||||||
|
@ -263,8 +258,7 @@ int wxDialogWithHelpers::ShowModal()
|
||||||
// 75% larger than the fitted dialog.
|
// 75% larger than the fitted dialog.
|
||||||
bool wxDialogWithHelpers::Show(bool show)
|
bool wxDialogWithHelpers::Show(bool show)
|
||||||
{
|
{
|
||||||
if( show )
|
if (show) {
|
||||||
{
|
|
||||||
SmartCenterFit();
|
SmartCenterFit();
|
||||||
m_CreatedRect = GetScreenRect();
|
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
|
// ... 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
|
// 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 wxString dlgName(GetDialogName());
|
||||||
const wxRect screenRect(GetScreenRect());
|
const wxRect screenRect(GetScreenRect());
|
||||||
if( !dlgName.IsEmpty() && ( m_CreatedRect != screenRect) )
|
if (!dlgName.IsEmpty() && (m_CreatedRect != screenRect)) {
|
||||||
{
|
|
||||||
wxPoint pos(screenRect.GetPosition());
|
wxPoint pos(screenRect.GetPosition());
|
||||||
IniSaver saver(cfg);
|
IniSaver saver(cfg);
|
||||||
ScopedIniGroup group(saver, L"DialogPositions");
|
ScopedIniGroup group(saver, L"DialogPositions");
|
||||||
|
|
||||||
if( GetWindowStyle() & wxRESIZE_BORDER )
|
if (GetWindowStyle() & wxRESIZE_BORDER) {
|
||||||
{
|
|
||||||
wxSize size(screenRect.GetSize());
|
wxSize size(screenRect.GetSize());
|
||||||
saver.Entry(dlgName + L"_Size", 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
|
#ifndef GCC_4_6_LTO_COMPILATION_ISSUE
|
||||||
// Add the context-sensitive help button on the caption for the platforms
|
// Add the context-sensitive help button on the caption for the platforms
|
||||||
// which support it (currently MSW only)
|
// which support it (currently MSW only)
|
||||||
if( m_hasContextHelp )
|
if (m_hasContextHelp) {
|
||||||
{
|
|
||||||
SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
|
SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
|
||||||
#ifndef __WXMSW__
|
#ifndef __WXMSW__
|
||||||
*m_extraButtonSizer += new wxContextHelpButton(this) | StdButton();
|
*m_extraButtonSizer += new wxContextHelpButton(this) | StdButton();
|
||||||
|
@ -365,7 +355,8 @@ void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply )
|
||||||
|
|
||||||
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);
|
pxAssert(sizer);
|
||||||
AddOkCancel(*sizer, hasApply);
|
AddOkCancel(*sizer, hasApply);
|
||||||
}
|
}
|
||||||
|
@ -469,7 +460,8 @@ wxPanelWithHelpers& wxPanelWithHelpers::SetMinWidth( int newWidth )
|
||||||
|
|
||||||
int pxGetCharHeight(const wxWindow *wind, int rows)
|
int pxGetCharHeight(const wxWindow *wind, int rows)
|
||||||
{
|
{
|
||||||
if( !wind ) return 0;
|
if (!wind)
|
||||||
|
return 0;
|
||||||
wxClientDC dc(wx_const_cast(wxWindow *, wind));
|
wxClientDC dc(wx_const_cast(wxWindow *, wind));
|
||||||
dc.SetFont(wind->GetFont());
|
dc.SetFont(wind->GetFont());
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue