mirror of
https://github.com/ARMSX2/ARMSX2.git
synced 2026-08-24 16:50:16 -07:00
Everything: Remove a **lot** of wx, and px nonsense
- common has no wx left except for Path. - pcsx2core only has it in a few places (memory cards and path related stuff).
This commit is contained in:
committed by
refractionpcsx2
parent
c07c942659
commit
893b3c629d
@@ -33,25 +33,6 @@
|
||||
#define pxUSE_SECURE_MALLOC 0
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Safe deallocation macros -- checks pointer validity (non-null) when needed, and sets
|
||||
// pointer to null after deallocation.
|
||||
|
||||
#define safe_delete(ptr) \
|
||||
((void)(delete (ptr)), (ptr) = NULL)
|
||||
|
||||
#define safe_delete_array(ptr) \
|
||||
((void)(delete[](ptr)), (ptr) = NULL)
|
||||
|
||||
// No checks for NULL -- wxWidgets says it's safe to skip NULL checks and it runs on
|
||||
// just about every compiler and libc implementation of any recentness.
|
||||
#define safe_free(ptr) \
|
||||
((void)(free(ptr), !!0), (ptr) = NULL)
|
||||
//((void) (( ( (ptr) != NULL ) && (free( ptr ), !!0) ), (ptr) = NULL))
|
||||
|
||||
#define safe_fclose(ptr) \
|
||||
((void)((((ptr) != NULL) && (fclose(ptr), !!0)), (ptr) = NULL))
|
||||
|
||||
// Implementation note: all known implementations of _aligned_free check the pointer for
|
||||
// NULL status (our implementation under GCC, and microsoft's under MSVC), so no need to
|
||||
// do it here.
|
||||
@@ -68,27 +49,6 @@ extern void _aligned_free(void* pmem);
|
||||
_aligned_realloc(handle, new_size, align)
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// pxDoOutOfMemory
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
typedef void FnType_OutOfMemory(uptr blocksize);
|
||||
typedef FnType_OutOfMemory* Fnptr_OutOfMemory;
|
||||
|
||||
// This method is meant to be assigned by applications that link against pxWex. It is called
|
||||
// (invoked) prior to most pxWex built-in memory/array classes throwing exceptions, and can be
|
||||
// used by an application to remove unneeded memory allocations and/or reduce internal cache
|
||||
// reserves.
|
||||
//
|
||||
// Example: PCSX2 uses several bloated recompiler code caches. Larger caches improve performance,
|
||||
// however a rouge cache growth could cause memory constraints in the operating system. If an out-
|
||||
// of-memory error occurs, PCSX2's implementation of this function attempts to reset all internal
|
||||
// recompiler caches. This can typically free up 100-150 megs of memory, and will allow the app
|
||||
// to continue running without crashing or hanging the operating system, etc.
|
||||
//
|
||||
extern Fnptr_OutOfMemory pxDoOutOfMemory;
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// AlignedBuffer
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
+13
-36
@@ -15,9 +15,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wx/string.h>
|
||||
#include "common/Pcsx2Defs.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef __pxFUNCTION__
|
||||
#if defined(__GNUG__)
|
||||
#define __pxFUNCTION__ __PRETTY_FUNCTION__
|
||||
@@ -26,25 +27,17 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef wxNullChar
|
||||
#define wxNullChar ((wxChar*)NULL)
|
||||
#endif
|
||||
|
||||
// FnChar_t - function name char type; typedef'd in case it ever changes between compilers
|
||||
// (ie, a compiler decides to wchar_t it instead of char/UTF8).
|
||||
typedef char FnChar_t;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// DiagnosticOrigin
|
||||
// --------------------------------------------------------------------------------------
|
||||
struct DiagnosticOrigin
|
||||
{
|
||||
const wxChar* srcfile;
|
||||
const FnChar_t* function;
|
||||
const wxChar* condition;
|
||||
const char* srcfile;
|
||||
const char* function;
|
||||
const char* condition;
|
||||
int line;
|
||||
|
||||
DiagnosticOrigin(const wxChar* _file, int _line, const FnChar_t* _func, const wxChar* _cond = NULL)
|
||||
DiagnosticOrigin(const char* _file, int _line, const char* _func, const char* _cond = nullptr)
|
||||
: srcfile(_file)
|
||||
, function(_func)
|
||||
, condition(_cond)
|
||||
@@ -52,12 +45,12 @@ struct DiagnosticOrigin
|
||||
{
|
||||
}
|
||||
|
||||
wxString ToString(const wxChar* msg = NULL) const;
|
||||
std::string ToString(const char* msg = nullptr) const;
|
||||
};
|
||||
|
||||
// Returns ture if the assertion is to trap into the debugger, or false if execution
|
||||
// of the program should continue unimpeded.
|
||||
typedef bool pxDoAssertFnType(const DiagnosticOrigin& origin, const wxChar* msg);
|
||||
typedef bool pxDoAssertFnType(const DiagnosticOrigin& origin, const char* msg);
|
||||
|
||||
extern pxDoAssertFnType pxAssertImpl_LogIt;
|
||||
|
||||
@@ -100,8 +93,8 @@ extern pxDoAssertFnType* pxDoAssert;
|
||||
// it can lead to the compiler optimizing out code and leading to crashes in dev/release
|
||||
// builds. To have code optimized, explicitly use pxAssume(false) or pxAssumeDev(false,msg);
|
||||
|
||||
#define pxDiagSpot DiagnosticOrigin(__TFILE__, __LINE__, __pxFUNCTION__)
|
||||
#define pxAssertSpot(cond) DiagnosticOrigin(__TFILE__, __LINE__, __pxFUNCTION__, _T(#cond))
|
||||
#define pxDiagSpot DiagnosticOrigin(__FILE__, __LINE__, __pxFUNCTION__)
|
||||
#define pxAssertSpot(cond) DiagnosticOrigin(__FILE__, __LINE__, __pxFUNCTION__, #cond)
|
||||
|
||||
// pxAssertRel ->
|
||||
// Special release-mode assertion. Limited use since stack traces in release mode builds
|
||||
@@ -170,28 +163,12 @@ extern pxDoAssertFnType* pxDoAssert;
|
||||
|
||||
#endif
|
||||
|
||||
#define pxAssert(cond) pxAssertMsg(cond, wxNullChar)
|
||||
#define pxAssume(cond) pxAssumeMsg(cond, wxNullChar)
|
||||
#define pxAssert(cond) pxAssertMsg(cond, nullptr)
|
||||
#define pxAssume(cond) pxAssumeMsg(cond, nullptr)
|
||||
|
||||
#define pxAssertRelease(cond, msg)
|
||||
|
||||
// Performs an unsigned index bounds check, and generates a debug assertion if the check fails.
|
||||
// For stricter checking in Devel builds as well as debug builds (but possibly slower), use
|
||||
// IndexBoundsCheckDev.
|
||||
|
||||
#define IndexBoundsCheck(objname, idx, sze) pxAssertMsg((uint)(idx) < (uint)(sze), \
|
||||
pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze)))
|
||||
|
||||
#define IndexBoundsCheckDev(objname, idx, sze) pxAssertDev((uint)(idx) < (uint)(sze), \
|
||||
pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze)))
|
||||
|
||||
#define IndexBoundsAssume(objname, idx, sze) pxAssumeMsg((uint)(idx) < (uint)(sze), \
|
||||
pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze)))
|
||||
|
||||
#define IndexBoundsAssumeDev(objname, idx, sze) pxAssumeDev((uint)(idx) < (uint)(sze), \
|
||||
pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze)))
|
||||
|
||||
extern void pxOnAssert(const DiagnosticOrigin& origin, const wxString& msg);
|
||||
extern void pxOnAssert(const DiagnosticOrigin& origin, const char* msg);
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// jNO_DEFAULT -- disables the default case in a switch, which improves switch optimization
|
||||
|
||||
@@ -17,7 +17,6 @@ target_sources(common PRIVATE
|
||||
CrashHandler.cpp
|
||||
EventSource.cpp
|
||||
Exceptions.cpp
|
||||
FastFormatString.cpp
|
||||
FastJmp.cpp
|
||||
FileSystem.cpp
|
||||
Misc.cpp
|
||||
@@ -26,10 +25,8 @@ target_sources(common PRIVATE
|
||||
PrecompiledHeader.cpp
|
||||
Perf.cpp
|
||||
ProgressCallback.cpp
|
||||
pxTranslate.cpp
|
||||
Semaphore.cpp
|
||||
SettingsWrapper.cpp
|
||||
StringHelpers.cpp
|
||||
StringUtil.cpp
|
||||
Timer.cpp
|
||||
WindowInfo.cpp
|
||||
@@ -64,7 +61,6 @@ target_sources(common PRIVATE
|
||||
boost_spsc_queue.hpp
|
||||
Console.h
|
||||
CrashHandler.h
|
||||
Dependencies.h
|
||||
EnumOps.h
|
||||
EventSource.h
|
||||
Exceptions.h
|
||||
@@ -80,13 +76,11 @@ target_sources(common PRIVATE
|
||||
PageFaultSource.h
|
||||
PrecompiledHeader.h
|
||||
ProgressCallback.h
|
||||
pxForwardDefs.h
|
||||
RedtapeWindows.h
|
||||
SafeArray.h
|
||||
ScopedGuard.h
|
||||
SettingsInterface.h
|
||||
SettingsWrapper.h
|
||||
StringHelpers.h
|
||||
StringUtil.h
|
||||
Timer.h
|
||||
Threading.h
|
||||
@@ -262,7 +256,15 @@ if (USE_GCC AND CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
||||
set_source_files_properties(FastJmp.cpp PROPERTIES COMPILE_FLAGS -fno-lto)
|
||||
endif()
|
||||
|
||||
target_link_libraries(common PRIVATE ${LIBC_LIBRARIES} PUBLIC wxWidgets::all)
|
||||
target_link_libraries(common PRIVATE
|
||||
${LIBC_LIBRARIES}
|
||||
)
|
||||
|
||||
target_link_libraries(common PUBLIC
|
||||
wxWidgets::all
|
||||
fmt::fmt
|
||||
)
|
||||
|
||||
target_compile_features(common PUBLIC cxx_std_17)
|
||||
target_include_directories(common PUBLIC ../3rdparty/include ../)
|
||||
target_compile_definitions(common PUBLIC "${PCSX2_DEFS}")
|
||||
|
||||
+61
-151
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "common/Threading.h"
|
||||
#include "common/TraceLog.h"
|
||||
#include "common/Assertions.h"
|
||||
#include "common/RedtapeWindows.h" // OutputDebugString
|
||||
|
||||
using namespace Threading;
|
||||
@@ -73,14 +74,14 @@ void Console_SetActiveHandler(const IConsoleWriter& writer, FILE* flushfp)
|
||||
|
||||
// Writes text to the Visual Studio Output window (Microsoft Windows only).
|
||||
// On all other platforms this pipes to Stdout instead.
|
||||
void MSW_OutputDebugString(const wxString& text)
|
||||
static void MSW_OutputDebugString(const char* text)
|
||||
{
|
||||
#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
|
||||
static bool hasDebugger = wxIsDebuggerRunning();
|
||||
#ifdef _WIN32
|
||||
static bool hasDebugger = IsDebuggerPresent();
|
||||
if (hasDebugger)
|
||||
OutputDebugString(text);
|
||||
OutputDebugStringA(text);
|
||||
#else
|
||||
fputs(text.utf8_str(), stdout_fp);
|
||||
fputs(text, stdout_fp);
|
||||
fflush(stdout_fp);
|
||||
#endif
|
||||
}
|
||||
@@ -90,11 +91,11 @@ void MSW_OutputDebugString(const wxString& text)
|
||||
// ConsoleNull
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
static void ConsoleNull_SetTitle(const wxString& title) {}
|
||||
static void ConsoleNull_SetTitle(const char* title) {}
|
||||
static void ConsoleNull_DoSetColor(ConsoleColors color) {}
|
||||
static void ConsoleNull_Newline() {}
|
||||
static void ConsoleNull_DoWrite(const wxString& fmt) {}
|
||||
static void ConsoleNull_DoWriteLn(const wxString& fmt) {}
|
||||
static void ConsoleNull_DoWrite(const char* fmt) {}
|
||||
static void ConsoleNull_DoWriteLn(const char* fmt) {}
|
||||
|
||||
const IConsoleWriter ConsoleWriter_Null =
|
||||
{
|
||||
@@ -172,20 +173,21 @@ static __fi const char* GetLinuxConsoleColor(ConsoleColors color)
|
||||
#endif
|
||||
|
||||
// One possible default write action at startup and shutdown is to use the stdout.
|
||||
static void ConsoleStdout_DoWrite(const wxString& fmt)
|
||||
static void ConsoleStdout_DoWrite(const char* fmt)
|
||||
{
|
||||
MSW_OutputDebugString(fmt);
|
||||
}
|
||||
|
||||
// Default write action at startup and shutdown is to use the stdout.
|
||||
static void ConsoleStdout_DoWriteLn(const wxString& fmt)
|
||||
static void ConsoleStdout_DoWriteLn(const char* fmt)
|
||||
{
|
||||
MSW_OutputDebugString(fmt + L"\n");
|
||||
MSW_OutputDebugString(fmt);
|
||||
MSW_OutputDebugString("\n");
|
||||
}
|
||||
|
||||
static void ConsoleStdout_Newline()
|
||||
{
|
||||
MSW_OutputDebugString(L"\n");
|
||||
MSW_OutputDebugString("\n");
|
||||
}
|
||||
|
||||
static void ConsoleStdout_DoSetColor(ConsoleColors color)
|
||||
@@ -198,12 +200,12 @@ static void ConsoleStdout_DoSetColor(ConsoleColors color)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ConsoleStdout_SetTitle(const wxString& title)
|
||||
static void ConsoleStdout_SetTitle(const char* title)
|
||||
{
|
||||
#if defined(__POSIX__)
|
||||
if (supports_color)
|
||||
fputs("\033]0;", stdout_fp);
|
||||
fputs(title.utf8_str(), stdout_fp);
|
||||
fputs(title, stdout_fp);
|
||||
if (supports_color)
|
||||
fputs("\007", stdout_fp);
|
||||
#endif
|
||||
@@ -225,14 +227,14 @@ const IConsoleWriter ConsoleWriter_Stdout =
|
||||
// ConsoleAssert
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
static void ConsoleAssert_DoWrite(const wxString& fmt)
|
||||
static void ConsoleAssert_DoWrite(const char* fmt)
|
||||
{
|
||||
pxFail(L"Console class has not been initialized; Message written:\n\t" + fmt);
|
||||
pxFailRel("Console class has not been initialized");
|
||||
}
|
||||
|
||||
static void ConsoleAssert_DoWriteLn(const wxString& fmt)
|
||||
static void ConsoleAssert_DoWriteLn(const char* fmt)
|
||||
{
|
||||
pxFail(L"Console class has not been initialized; Message written:\n\t" + fmt);
|
||||
pxFailRel("Console class has not been initialized");
|
||||
}
|
||||
|
||||
const IConsoleWriter ConsoleWriter_Assert =
|
||||
@@ -258,16 +260,27 @@ const IConsoleWriter ConsoleWriter_Assert =
|
||||
// glob_indent - this parameter is used to specify a global indentation setting. It is used by
|
||||
// WriteLn function, but defaults to 0 for Warning and Error calls. Local indentation always
|
||||
// applies to all writes.
|
||||
wxString IConsoleWriter::_addIndentation(const wxString& src, int glob_indent = 0) const
|
||||
std::string IConsoleWriter::_addIndentation(const std::string& src, int glob_indent = 0) const
|
||||
{
|
||||
const int indent = glob_indent + _imm_indentation;
|
||||
if (indent == 0)
|
||||
return src;
|
||||
|
||||
wxString result(src);
|
||||
const wxString indentStr(L'\t', indent);
|
||||
result.Replace(L"\n", L"\n" + indentStr);
|
||||
return indentStr + result;
|
||||
std::string indentStr;
|
||||
for (int i = 0; i < indent; i++)
|
||||
indentStr += '\t';
|
||||
|
||||
std::string result;
|
||||
result.reserve(src.length() + 16 * indent);
|
||||
result.append(indentStr);
|
||||
result.append(src);
|
||||
|
||||
std::string::size_type pos = result.find('\n');
|
||||
while (pos != std::string::npos)
|
||||
{
|
||||
result.insert(pos + 1, indentStr);
|
||||
pos = result.find('\n', pos + 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sets the indentation to be applied to all WriteLn's. The indentation is added to the
|
||||
@@ -324,7 +337,16 @@ const IConsoleWriter& IConsoleWriter::ClearColor() const
|
||||
|
||||
bool IConsoleWriter::FormatV(const char* fmt, va_list args) const
|
||||
{
|
||||
DoWriteLn(_addIndentation(pxsFmtV(fmt, args), conlog_Indent));
|
||||
// TODO: Make this less rubbish
|
||||
if ((_imm_indentation + conlog_Indent) > 0)
|
||||
{
|
||||
DoWriteLn(_addIndentation(StringUtil::StdStringFromFormatV(fmt, args), conlog_Indent).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
DoWriteLn(StringUtil::StdStringFromFormatV(fmt, args).c_str());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -371,105 +393,6 @@ bool IConsoleWriter::Warning(const char* fmt, ...) const
|
||||
return false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Write Variants - Unicode/UTF16 style
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
bool IConsoleWriter::FormatV(const wxChar* fmt, va_list args) const
|
||||
{
|
||||
DoWriteLn(_addIndentation(pxsFmtV(fmt, args), conlog_Indent));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IConsoleWriter::WriteLn(const wxChar* fmt, ...) const
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
FormatV(fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IConsoleWriter::WriteLn(ConsoleColors color, const wxChar* fmt, ...) const
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ConsoleColorScope cs(color);
|
||||
FormatV(fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IConsoleWriter::Error(const wxChar* fmt, ...) const
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ConsoleColorScope cs(Color_StrongRed);
|
||||
FormatV(fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IConsoleWriter::Warning(const wxChar* fmt, ...) const
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ConsoleColorScope cs(Color_StrongOrange);
|
||||
FormatV(fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Write Variants - Unknown style
|
||||
// --------------------------------------------------------------------------------------
|
||||
bool IConsoleWriter::WriteLn(const wxString fmt, ...) const
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
FormatV(fmt.wx_str(), args);
|
||||
va_end(args);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IConsoleWriter::WriteLn(ConsoleColors color, const wxString fmt, ...) const
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ConsoleColorScope cs(color);
|
||||
FormatV(fmt.wx_str(), args);
|
||||
va_end(args);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IConsoleWriter::Error(const wxString fmt, ...) const
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ConsoleColorScope cs(Color_StrongRed);
|
||||
FormatV(fmt.wx_str(), args);
|
||||
va_end(args);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IConsoleWriter::Warning(const wxString fmt, ...) const
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ConsoleColorScope cs(Color_StrongOrange);
|
||||
FormatV(fmt.wx_str(), args);
|
||||
va_end(args);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IConsoleWriter::WriteLn(ConsoleColors color, const std::string& str) const
|
||||
{
|
||||
ConsoleColorScope cs(color);
|
||||
@@ -478,7 +401,15 @@ bool IConsoleWriter::WriteLn(ConsoleColors color, const std::string& str) const
|
||||
|
||||
bool IConsoleWriter::WriteLn(const std::string& str) const
|
||||
{
|
||||
DoWriteLn(_addIndentation(fromUTF8(str), conlog_Indent));
|
||||
// TODO: Make this less rubbish
|
||||
if ((_imm_indentation + conlog_Indent) > 0)
|
||||
{
|
||||
DoWriteLn(_addIndentation(str, conlog_Indent).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
DoWriteLn(str.c_str());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -533,11 +464,7 @@ ConsoleIndentScope::ConsoleIndentScope(int tabs)
|
||||
|
||||
ConsoleIndentScope::~ConsoleIndentScope()
|
||||
{
|
||||
try
|
||||
{
|
||||
LeaveScope();
|
||||
}
|
||||
DESTRUCTOR_CATCHALL
|
||||
LeaveScope();
|
||||
}
|
||||
|
||||
void ConsoleIndentScope::EnterScope()
|
||||
@@ -560,12 +487,8 @@ ConsoleAttrScope::ConsoleAttrScope(ConsoleColors newcolor, int indent)
|
||||
|
||||
ConsoleAttrScope::~ConsoleAttrScope()
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.SetColor(m_old_color);
|
||||
Console.SetIndent(-m_tabsize);
|
||||
}
|
||||
DESTRUCTOR_CATCHALL
|
||||
Console.SetColor(m_old_color);
|
||||
Console.SetIndent(-m_tabsize);
|
||||
}
|
||||
|
||||
|
||||
@@ -599,14 +522,7 @@ NullConsoleWriter NullCon = {};
|
||||
bool ConsoleLogSource::WriteV(ConsoleColors color, const char* fmt, va_list list) const
|
||||
{
|
||||
ConsoleColorScope cs(color);
|
||||
DoWrite(pxsFmtV(fmt, list).c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConsoleLogSource::WriteV(ConsoleColors color, const wxChar* fmt, va_list list) const
|
||||
{
|
||||
ConsoleColorScope cs(color);
|
||||
DoWrite(pxsFmtV(fmt, list).c_str());
|
||||
Console.WriteLn(StringUtil::StdStringFromFormatV(fmt, list));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -618,9 +534,3 @@ bool ConsoleLogSource::WriteV(const char* fmt, va_list list) const
|
||||
WriteV(DefaultColor, fmt, list);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConsoleLogSource::WriteV(const wxChar* fmt, va_list list) const
|
||||
{
|
||||
WriteV(DefaultColor, fmt, list);
|
||||
return false;
|
||||
}
|
||||
|
||||
+12
-32
@@ -15,7 +15,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/StringHelpers.h"
|
||||
#include "Pcsx2Defs.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
enum ConsoleColors
|
||||
{
|
||||
@@ -70,11 +72,11 @@ struct IConsoleWriter
|
||||
{
|
||||
// A direct console write, without tabbing or newlines. Useful to devs who want to do quick
|
||||
// logging of various junk; but should *not* be used in production code due.
|
||||
void(* WriteRaw)(const wxString& fmt);
|
||||
void(* WriteRaw)(const char* fmt);
|
||||
|
||||
// WriteLn implementation for internal use only. Bypasses tabbing, prefixing, and other
|
||||
// formatting.
|
||||
void(* DoWriteLn)(const wxString& fmt);
|
||||
void(* DoWriteLn)(const char* fmt);
|
||||
|
||||
// SetColor implementation for internal use only.
|
||||
void(* DoSetColor)(ConsoleColors color);
|
||||
@@ -82,16 +84,16 @@ struct IConsoleWriter
|
||||
// Special implementation of DoWrite that's pretty much for MSVC use only.
|
||||
// All implementations should map to DoWrite, except Stdio which should map to Null.
|
||||
// (This avoids circular/recursive stdio output)
|
||||
void(* DoWriteFromStdout)(const wxString& fmt);
|
||||
void(* DoWriteFromStdout)(const char* fmt);
|
||||
|
||||
void(* Newline)();
|
||||
void(* SetTitle)(const wxString& title);
|
||||
void(* SetTitle)(const char* title);
|
||||
|
||||
// internal value for indentation of individual lines. Use the Indent() member to invoke.
|
||||
int _imm_indentation;
|
||||
|
||||
// For internal use only.
|
||||
wxString _addIndentation(const wxString& src, int glob_indent) const;
|
||||
std::string _addIndentation(const std::string& src, int glob_indent) const;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Public members; call these to print stuff to console!
|
||||
@@ -112,17 +114,6 @@ struct IConsoleWriter
|
||||
bool Error(const char* fmt, ...) const;
|
||||
bool Warning(const char* fmt, ...) const;
|
||||
|
||||
bool FormatV(const wxChar* fmt, va_list args) const;
|
||||
bool WriteLn(ConsoleColors color, const wxChar* fmt, ...) const;
|
||||
bool WriteLn(const wxChar* fmt, ...) const;
|
||||
bool Error(const wxChar* fmt, ...) const;
|
||||
bool Warning(const wxChar* fmt, ...) const;
|
||||
|
||||
bool WriteLn(ConsoleColors color, const wxString fmt, ...) const;
|
||||
bool WriteLn(const wxString fmt, ...) const;
|
||||
bool Error(const wxString fmt, ...) const;
|
||||
bool Warning(const wxString fmt, ...) const;
|
||||
|
||||
bool WriteLn(ConsoleColors color, const std::string& str) const;
|
||||
bool WriteLn(const std::string& str) const;
|
||||
bool Error(const std::string& str) const;
|
||||
@@ -136,12 +127,12 @@ struct IConsoleWriter
|
||||
//
|
||||
struct NullConsoleWriter
|
||||
{
|
||||
void WriteRaw(const wxString& fmt) {}
|
||||
void DoWriteLn(const wxString& fmt) {}
|
||||
void WriteRaw(const char* fmt) {}
|
||||
void DoWriteLn(const char* fmt) {}
|
||||
void DoSetColor(ConsoleColors color) {}
|
||||
void DoWriteFromStdout(const wxString& fmt) {}
|
||||
void DoWriteFromStdout(const char* fmt) {}
|
||||
void Newline() {}
|
||||
void SetTitle(const wxString& title) {}
|
||||
void SetTitle(const char* title) {}
|
||||
|
||||
|
||||
ConsoleColors GetColor() const { return Color_Current; }
|
||||
@@ -156,17 +147,6 @@ struct NullConsoleWriter
|
||||
bool WriteLn(const char* fmt, ...) const { return false; }
|
||||
bool Error(const char* fmt, ...) const { return false; }
|
||||
bool Warning(const char* fmt, ...) const { return false; }
|
||||
|
||||
bool FormatV(const wxChar* fmt, va_list args) const { return false; }
|
||||
bool WriteLn(ConsoleColors color, const wxChar* fmt, ...) const { return false; }
|
||||
bool WriteLn(const wxChar* fmt, ...) const { return false; }
|
||||
bool Error(const wxChar* fmt, ...) const { return false; }
|
||||
bool Warning(const wxChar* fmt, ...) const { return false; }
|
||||
|
||||
bool WriteLn(ConsoleColors color, const wxString fmt, ...) const { return false; }
|
||||
bool WriteLn(const wxString fmt, ...) const { return false; }
|
||||
bool Error(const wxString fmt, ...) const { return false; }
|
||||
bool Warning(const wxString fmt, ...) const { return false; }
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <wx/string.h>
|
||||
|
||||
#include "common/Pcsx2Types.h"
|
||||
#include "common/General.h"
|
||||
|
||||
// Darwin (OSX) is a bit different from Linux when requesting properties of
|
||||
// the OS because of its BSD/Mach heritage. Helpfully, most of this code
|
||||
@@ -85,7 +86,7 @@ static std::string sysctl_str(int category, int name)
|
||||
return std::string(buf, len > 0 ? len - 1 : 0);
|
||||
}
|
||||
|
||||
wxString GetOSVersionString()
|
||||
std::string GetOSVersionString()
|
||||
{
|
||||
std::string type = sysctl_str(CTL_KERN, KERN_OSTYPE);
|
||||
std::string release = sysctl_str(CTL_KERN, KERN_OSRELEASE);
|
||||
|
||||
@@ -1,240 +0,0 @@
|
||||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Dependencies.h : Contains classes required by all Utilities headers.
|
||||
// This file is included by most .h files provided by the Utilities class.
|
||||
|
||||
#include "pxForwardDefs.h"
|
||||
|
||||
// This should prove useful....
|
||||
#define wxsFormat wxString::Format
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// ImplementEnumOperators (macro)
|
||||
// --------------------------------------------------------------------------------------
|
||||
// This macro implements ++/-- operators for any conforming enumeration. In order for an
|
||||
// enum to conform, it must have _FIRST and _COUNT members defined, and must have a full
|
||||
// compliment of sequential members (no custom assignments) --- looking like so:
|
||||
//
|
||||
// enum Dummy {
|
||||
// Dummy_FIRST,
|
||||
// Dummy_Item = Dummy_FIRST,
|
||||
// Dummy_Crap,
|
||||
// Dummy_COUNT
|
||||
// };
|
||||
//
|
||||
// The macro also defines utility functions for bounds checking enumerations:
|
||||
// EnumIsValid(value); // returns TRUE if the enum value is between FIRST and COUNT.
|
||||
// EnumAssert(value);
|
||||
//
|
||||
// It also defines a *prototype* for converting the enumeration to a string. Note that this
|
||||
// method is not implemented! You must implement it yourself if you want to use it:
|
||||
// EnumToString(value);
|
||||
//
|
||||
#define ImplementEnumOperators(enumName) \
|
||||
static __fi enumName& operator++(enumName& src) \
|
||||
{ \
|
||||
src = (enumName)((int)src + 1); \
|
||||
return src; \
|
||||
} \
|
||||
\
|
||||
static __fi enumName& operator--(enumName& src) \
|
||||
{ \
|
||||
src = (enumName)((int)src - 1); \
|
||||
return src; \
|
||||
} \
|
||||
\
|
||||
static __fi enumName operator++(enumName& src, int) \
|
||||
{ \
|
||||
enumName orig = src; \
|
||||
src = (enumName)((int)src + 1); \
|
||||
return orig; \
|
||||
} \
|
||||
\
|
||||
static __fi enumName operator--(enumName& src, int) \
|
||||
{ \
|
||||
enumName orig = src; \
|
||||
src = (enumName)((int)src - 1); \
|
||||
return orig; \
|
||||
} \
|
||||
\
|
||||
static __fi bool operator<(const enumName& left, const pxEnumEnd_t&) { return (int)left < enumName##_COUNT; } \
|
||||
static __fi bool operator!=(const enumName& left, const pxEnumEnd_t&) { return (int)left != enumName##_COUNT; } \
|
||||
static __fi bool operator==(const enumName& left, const pxEnumEnd_t&) { return (int)left == enumName##_COUNT; } \
|
||||
\
|
||||
static __fi bool EnumIsValid(enumName id) \
|
||||
{ \
|
||||
return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); \
|
||||
} \
|
||||
\
|
||||
static __fi void EnumAssert(enumName id) \
|
||||
{ \
|
||||
pxAssert(EnumIsValid(id)); \
|
||||
} \
|
||||
\
|
||||
extern const char* EnumToString(enumName id)
|
||||
|
||||
class pxEnumEnd_t
|
||||
{
|
||||
};
|
||||
static const pxEnumEnd_t pxEnumEnd = {};
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// DeclareNoncopyableObject
|
||||
// --------------------------------------------------------------------------------------
|
||||
// This macro provides an easy and clean method for ensuring objects are not copyable.
|
||||
// Simply add the macro to the head or tail of your class declaration, and attempts to
|
||||
// copy the class will give you a moderately obtuse compiler error that will have you
|
||||
// scratching your head for 20 minutes.
|
||||
//
|
||||
// (... but that's probably better than having a weird invalid object copy having you
|
||||
// scratch your head for a day).
|
||||
//
|
||||
// Programmer's notes:
|
||||
// * We intentionally do NOT provide implementations for these methods, which should
|
||||
// never be referenced anyway.
|
||||
|
||||
// * I've opted for macro form over multi-inherited class form (Boost style), because
|
||||
// the errors generated by the macro are considerably less voodoo. The Boost-style
|
||||
// The macro reports the exact class that causes the copy failure, while Boost's class
|
||||
// approach just reports an error in whatever "NoncopyableObject" is inherited.
|
||||
//
|
||||
// * This macro is the same as wxWidgets' DECLARE_NO_COPY_CLASS macro. This one is free
|
||||
// of wx dependencies though, and has a nicer typeset. :)
|
||||
//
|
||||
#ifndef DeclareNoncopyableObject
|
||||
#define DeclareNoncopyableObject(classname) \
|
||||
public: \
|
||||
classname(const classname&) = delete; \
|
||||
classname& operator=(const classname&) = delete
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// _(x) / _t(x) / _d(x) / pxL(x) / pxLt(x) [macros]
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Define pxWex's own i18n helpers. These override the wxWidgets helpers and provide
|
||||
// additional functionality. Define them FIRST THING, to make sure that wx's own gettext
|
||||
// macros aren't in place.
|
||||
//
|
||||
// _ is for standard translations
|
||||
// _t is for tertiary low priority translations
|
||||
// _d is for debug/devel build translations
|
||||
|
||||
#define WXINTL_NO_GETTEXT_MACRO
|
||||
|
||||
#ifndef _
|
||||
#define _(s) pxGetTranslation(_T(s))
|
||||
#endif
|
||||
|
||||
#ifndef _t
|
||||
#define _t(s) pxGetTranslation(_T(s))
|
||||
#endif
|
||||
|
||||
#ifndef _d
|
||||
#define _d(s) pxGetTranslation(_T(s))
|
||||
#endif
|
||||
|
||||
// pxL / pxLt / pxDt -- macros provided for tagging translation strings, without actually running
|
||||
// them through the translator (which the _() does automatically, and sometimes we don't
|
||||
// want that). This is a shorthand replacement for wxTRANSLATE. pxL is a standard translation
|
||||
// moniker. pxLt is for tertiary strings that have a very low translation priority. pxDt is for
|
||||
// debug/devel specific translations.
|
||||
//
|
||||
#ifndef pxL
|
||||
#define pxL(a) wxT(a)
|
||||
#endif
|
||||
|
||||
#ifndef pxLt
|
||||
#define pxLt(a) wxT(a)
|
||||
#endif
|
||||
|
||||
#ifndef pxDt
|
||||
#define pxDt(a) wxT(a)
|
||||
#endif
|
||||
|
||||
|
||||
#include <wx/string.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/log.h>
|
||||
#include <wx/crt.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
// This deals with a mode_t redefinition conflict. The mode_t doesn't seem to be
|
||||
// used anywhere in w32pthreads, so I've chosen to use the wxWidgets mode_t
|
||||
// (I think it's unsigned int vs signed int)
|
||||
#include <wx/filefn.h>
|
||||
#define HAVE_MODE_T
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cstring> // string.h under c++
|
||||
#include <cstdio> // stdio.h under c++
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
#include "Pcsx2Defs.h"
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Handy Human-readable constants for common immediate values (_16kb -> _4gb)
|
||||
|
||||
static const sptr _1kb = 1024 * 1;
|
||||
static const sptr _4kb = _1kb * 4;
|
||||
static const sptr _16kb = _1kb * 16;
|
||||
static const sptr _32kb = _1kb * 32;
|
||||
static const sptr _64kb = _1kb * 64;
|
||||
static const sptr _128kb = _1kb * 128;
|
||||
static const sptr _256kb = _1kb * 256;
|
||||
|
||||
static const s64 _1mb = 1024 * 1024;
|
||||
static const s64 _8mb = _1mb * 8;
|
||||
static const s64 _16mb = _1mb * 16;
|
||||
static const s64 _32mb = _1mb * 32;
|
||||
static const s64 _64mb = _1mb * 64;
|
||||
static const s64 _256mb = _1mb * 256;
|
||||
static const s64 _1gb = _1mb * 1024;
|
||||
static const s64 _4gb = _1gb * 4;
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// pxE(msg) and pxEt(msg) [macros] => now same as _/_t/_d
|
||||
// --------------------------------------------------------------------------------------
|
||||
#define pxE(english) pxExpandMsg((english))
|
||||
|
||||
// For use with tertiary translations (low priority).
|
||||
#define pxEt(english) pxExpandMsg((english))
|
||||
|
||||
// For use with Dev/debug build translations (low priority).
|
||||
#define pxE_dev(english) pxExpandMsg((english))
|
||||
|
||||
|
||||
extern const wxChar* pxExpandMsg(const wxChar* message);
|
||||
extern const wxChar* pxGetTranslation(const wxChar* message);
|
||||
extern bool pxIsEnglish(int id);
|
||||
|
||||
extern wxString fromUTF8(const std::string& str);
|
||||
extern wxString fromUTF8(const char* src);
|
||||
extern wxString fromAscii(const char* src);
|
||||
|
||||
|
||||
#include "common/Assertions.h"
|
||||
#include "common/Exceptions.h"
|
||||
#include "common/AlignedMalloc.h"
|
||||
@@ -17,7 +17,4 @@
|
||||
#include "EventSource.h"
|
||||
#include "EventSource.inl"
|
||||
|
||||
#include <wx/event.h>
|
||||
|
||||
//template class EventSource< wxCommandEvent >;
|
||||
//template class EventSource< int >;
|
||||
|
||||
@@ -75,21 +75,21 @@ __fi void EventSource<ListenerType>::_DispatchRaw(ListenerIterator iter, const L
|
||||
{
|
||||
if (IsDevBuild)
|
||||
{
|
||||
pxFailDev(L"Ignoring runtime error thrown from event listener (event listeners should not throw exceptions!): " + ex.FormatDiagnosticMessage());
|
||||
pxFailDev(("Ignoring runtime error thrown from event listener (event listeners should not throw exceptions!): " + ex.FormatDiagnosticMessage()).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error(L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage());
|
||||
Console.Error("Ignoring runtime error thrown from event listener: %s", ex.FormatDiagnosticMessage().c_str());
|
||||
}
|
||||
}
|
||||
catch (BaseException& ex)
|
||||
{
|
||||
if (IsDevBuild)
|
||||
{
|
||||
ex.DiagMsg() = L"Non-runtime BaseException thrown from event listener .. " + ex.DiagMsg();
|
||||
ex.DiagMsg() = "Non-runtime BaseException thrown from event listener .. " + ex.DiagMsg();
|
||||
throw;
|
||||
}
|
||||
Console.Error(L"Ignoring non-runtime BaseException thrown from event listener: " + ex.FormatDiagnosticMessage());
|
||||
Console.Error("Ignoring non-runtime BaseException thrown from event listener: %s", ex.FormatDiagnosticMessage().c_str());
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
|
||||
+138
-141
File diff suppressed because it is too large
Load Diff
+60
-60
@@ -16,9 +16,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <wx/string.h>
|
||||
#include <stdexcept>
|
||||
#include "common/Assertions.h"
|
||||
#include "common/Dependencies.h"
|
||||
#include "common/Pcsx2Defs.h"
|
||||
|
||||
// Because wxTrap isn't available on Linux builds of wxWidgets (non-Debug, typically)
|
||||
void pxTrap();
|
||||
@@ -69,7 +69,7 @@ namespace Exception
|
||||
class BaseException;
|
||||
|
||||
int MakeNewType();
|
||||
BaseException* FromErrno(const wxString& streamname, int errcode);
|
||||
BaseException* FromErrno(std::string streamname, int errcode);
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// BaseException
|
||||
@@ -91,29 +91,29 @@ namespace Exception
|
||||
class BaseException
|
||||
{
|
||||
protected:
|
||||
wxString m_message_diag; // (untranslated) a "detailed" message of what disastrous thing has occurred!
|
||||
wxString m_message_user; // (translated) a "detailed" message of what disastrous thing has occurred!
|
||||
std::string m_message_diag; // (untranslated) a "detailed" message of what disastrous thing has occurred!
|
||||
std::string m_message_user; // (translated) a "detailed" message of what disastrous thing has occurred!
|
||||
|
||||
public:
|
||||
virtual ~BaseException() = default;
|
||||
|
||||
const wxString& DiagMsg() const { return m_message_diag; }
|
||||
const wxString& UserMsg() const { return m_message_user; }
|
||||
const std::string& DiagMsg() const { return m_message_diag; }
|
||||
const std::string& UserMsg() const { return m_message_user; }
|
||||
|
||||
wxString& DiagMsg() { return m_message_diag; }
|
||||
wxString& UserMsg() { return m_message_user; }
|
||||
std::string& DiagMsg() { return m_message_diag; }
|
||||
std::string& UserMsg() { return m_message_user; }
|
||||
|
||||
BaseException& SetBothMsgs(const wxChar* msg_diag);
|
||||
BaseException& SetDiagMsg(const wxString& msg_diag);
|
||||
BaseException& SetUserMsg(const wxString& msg_user);
|
||||
BaseException& SetBothMsgs(const char* msg_diag);
|
||||
BaseException& SetDiagMsg(std::string msg_diag);
|
||||
BaseException& SetUserMsg(std::string msg_user);
|
||||
|
||||
// Returns a message suitable for diagnostic / logging purposes.
|
||||
// This message is always in English, and includes a full stack trace.
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
|
||||
// Returns a message suitable for end-user display.
|
||||
// This message is usually meant for display in a user popup or such.
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
|
||||
virtual void Rethrow() const = 0;
|
||||
virtual BaseException* Clone() const = 0;
|
||||
@@ -135,14 +135,14 @@ namespace Exception
|
||||
class Ps2Generic
|
||||
{
|
||||
protected:
|
||||
wxString m_message; // a "detailed" message of what disastrous thing has occurred!
|
||||
std::string m_message; // a "detailed" message of what disastrous thing has occurred!
|
||||
|
||||
public:
|
||||
virtual ~Ps2Generic() = default;
|
||||
|
||||
virtual u32 GetPc() const = 0;
|
||||
virtual bool IsDelaySlot() const = 0;
|
||||
virtual wxString& Message() { return m_message; }
|
||||
virtual std::string& Message() { return m_message; }
|
||||
|
||||
virtual void Rethrow() const = 0;
|
||||
virtual Ps2Generic* Clone() const = 0;
|
||||
@@ -181,21 +181,21 @@ public: \
|
||||
|
||||
#define DEFINE_EXCEPTION_MESSAGES(classname) \
|
||||
public: \
|
||||
classname& SetBothMsgs(const wxChar* msg_diag) \
|
||||
classname& SetBothMsgs(const char* msg_diag) \
|
||||
{ \
|
||||
BaseException::SetBothMsgs(msg_diag); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
classname& SetDiagMsg(const wxString& msg_diag) \
|
||||
classname& SetDiagMsg(std::string msg_diag) \
|
||||
{ \
|
||||
m_message_diag = msg_diag; \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
classname& SetUserMsg(const wxString& msg_user) \
|
||||
classname& SetUserMsg(std::string msg_user) \
|
||||
{ \
|
||||
m_message_user = msg_user; \
|
||||
m_message_user = std::move(msg_user); \
|
||||
return *this; \
|
||||
}
|
||||
|
||||
@@ -221,8 +221,8 @@ public: \
|
||||
bool IsSilent;
|
||||
|
||||
RuntimeError() { IsSilent = false; }
|
||||
RuntimeError(const std::runtime_error& ex, const wxString& prefix = wxEmptyString);
|
||||
RuntimeError(const std::exception& ex, const wxString& prefix = wxEmptyString);
|
||||
RuntimeError(const std::runtime_error& ex, const char* prefix = nullptr);
|
||||
RuntimeError(const std::exception& ex, const char* prefix = nullptr);
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
@@ -236,17 +236,17 @@ public: \
|
||||
// an App message loop we'll still want it to be handled in a reasonably graceful manner.
|
||||
class CancelEvent : public RuntimeError
|
||||
{
|
||||
DEFINE_RUNTIME_EXCEPTION(CancelEvent, RuntimeError, pxLt("No reason given."))
|
||||
DEFINE_RUNTIME_EXCEPTION(CancelEvent, RuntimeError, "No reason given.")
|
||||
|
||||
public:
|
||||
explicit CancelEvent(const wxString& logmsg)
|
||||
explicit CancelEvent(std::string logmsg)
|
||||
{
|
||||
m_message_diag = logmsg;
|
||||
m_message_diag = std::move(logmsg);
|
||||
// overridden message formatters only use the diagnostic version...
|
||||
}
|
||||
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
@@ -261,21 +261,21 @@ public: \
|
||||
//
|
||||
class OutOfMemory : public RuntimeError
|
||||
{
|
||||
DEFINE_RUNTIME_EXCEPTION(OutOfMemory, RuntimeError, wxEmptyString)
|
||||
DEFINE_RUNTIME_EXCEPTION(OutOfMemory, RuntimeError, "")
|
||||
|
||||
public:
|
||||
wxString AllocDescription;
|
||||
std::string AllocDescription;
|
||||
|
||||
public:
|
||||
OutOfMemory(const wxString& allocdesc);
|
||||
OutOfMemory(std::string allocdesc);
|
||||
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
};
|
||||
|
||||
class ParseError : public RuntimeError
|
||||
{
|
||||
DEFINE_RUNTIME_EXCEPTION(ParseError, RuntimeError, pxL("Parse error"));
|
||||
DEFINE_RUNTIME_EXCEPTION(ParseError, RuntimeError, "Parse error");
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
@@ -288,18 +288,18 @@ public: \
|
||||
// we'd really like to have access to.
|
||||
class VirtualMemoryMapConflict : public OutOfMemory
|
||||
{
|
||||
DEFINE_RUNTIME_EXCEPTION(VirtualMemoryMapConflict, OutOfMemory, wxEmptyString)
|
||||
DEFINE_RUNTIME_EXCEPTION(VirtualMemoryMapConflict, OutOfMemory, "")
|
||||
|
||||
VirtualMemoryMapConflict(const wxString& allocdesc);
|
||||
VirtualMemoryMapConflict(std::string allocdesc);
|
||||
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
};
|
||||
|
||||
class HardwareDeficiency : public RuntimeError
|
||||
{
|
||||
public:
|
||||
DEFINE_RUNTIME_EXCEPTION(HardwareDeficiency, RuntimeError, pxL("Your machine's hardware is incapable of running PCSX2. Sorry dood."));
|
||||
DEFINE_RUNTIME_EXCEPTION(HardwareDeficiency, RuntimeError, "Your machine's hardware is incapable of running PCSX2. Sorry dood.");
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
@@ -308,21 +308,21 @@ public: \
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
#define DEFINE_STREAM_EXCEPTION_ACCESSORS(classname) \
|
||||
virtual classname& SetStreamName(const wxString& name) \
|
||||
virtual classname& SetStreamName(std::string name) \
|
||||
{ \
|
||||
StreamName = name; \
|
||||
StreamName = std::move(name); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
virtual classname& SetStreamName(const char* name) \
|
||||
{ \
|
||||
StreamName = fromUTF8(name); \
|
||||
StreamName = name; \
|
||||
return *this; \
|
||||
}
|
||||
|
||||
#define DEFINE_STREAM_EXCEPTION(classname, parent) \
|
||||
DEFINE_RUNTIME_EXCEPTION(classname, parent, wxEmptyString) \
|
||||
classname(const wxString& filename) \
|
||||
DEFINE_RUNTIME_EXCEPTION(classname, parent, "") \
|
||||
classname(std::string filename) \
|
||||
{ \
|
||||
StreamName = filename; \
|
||||
} \
|
||||
@@ -337,14 +337,14 @@ public: \
|
||||
DEFINE_STREAM_EXCEPTION(BadStream, RuntimeError)
|
||||
|
||||
public:
|
||||
wxString StreamName; // name of the stream (if applicable)
|
||||
std::string StreamName; // name of the stream (if applicable)
|
||||
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
|
||||
protected:
|
||||
void _formatDiagMsg(FastFormatUnicode& dest) const;
|
||||
void _formatUserMsg(FastFormatUnicode& dest) const;
|
||||
void _formatDiagMsg(std::string& dest) const;
|
||||
void _formatUserMsg(std::string& dest) const;
|
||||
};
|
||||
|
||||
// A generic exception for odd-ball stream creation errors.
|
||||
@@ -353,8 +353,8 @@ public: \
|
||||
{
|
||||
DEFINE_STREAM_EXCEPTION(CannotCreateStream, BadStream)
|
||||
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
};
|
||||
|
||||
// Exception thrown when an attempt to open a non-existent file is made.
|
||||
@@ -365,8 +365,8 @@ public: \
|
||||
public:
|
||||
DEFINE_STREAM_EXCEPTION(FileNotFound, CannotCreateStream)
|
||||
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
};
|
||||
|
||||
class AccessDenied : public CannotCreateStream
|
||||
@@ -374,8 +374,8 @@ public: \
|
||||
public:
|
||||
DEFINE_STREAM_EXCEPTION(AccessDenied, CannotCreateStream)
|
||||
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
};
|
||||
|
||||
// EndOfStream can be used either as an error, or used just as a shortcut for manual
|
||||
@@ -386,11 +386,11 @@ public: \
|
||||
public:
|
||||
DEFINE_STREAM_EXCEPTION(EndOfStream, BadStream)
|
||||
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
};
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#ifdef _WIN32
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Exception::WinApiError
|
||||
// --------------------------------------------------------------------------------------
|
||||
@@ -405,9 +405,9 @@ public: \
|
||||
public:
|
||||
WinApiError();
|
||||
|
||||
wxString GetMsgFromWindows() const;
|
||||
virtual wxString FormatDisplayMessage() const;
|
||||
virtual wxString FormatDiagnosticMessage() const;
|
||||
std::string GetMsgFromWindows() const;
|
||||
virtual std::string FormatDisplayMessage() const;
|
||||
virtual std::string FormatDiagnosticMessage() const;
|
||||
};
|
||||
#endif
|
||||
} // namespace Exception
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#ifdef __APPLE__
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#include "common/Console.h"
|
||||
#include "ContextEGL.h"
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <wx/string.h>
|
||||
#include <string>
|
||||
#include "common/Pcsx2Defs.h"
|
||||
|
||||
// This macro is actually useful for about any and every possible application of C++
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
bool CanExecute() const { return m_exec && m_read; }
|
||||
bool IsNone() const { return !m_read && !m_write; }
|
||||
|
||||
wxString ToString() const;
|
||||
std::string ToString() const;
|
||||
};
|
||||
|
||||
static __fi PageProtectionMode PageAccess_None()
|
||||
@@ -161,6 +161,6 @@ extern u32 ShortSpin();
|
||||
/// Number of ns to spin for before sleeping a thread
|
||||
extern const u32 SPIN_TIME_NS;
|
||||
|
||||
extern wxString GetOSVersionString();
|
||||
extern std::string GetOSVersionString();
|
||||
|
||||
void ScreensaverAllow(bool allow);
|
||||
|
||||
+19
-36
@@ -14,15 +14,18 @@
|
||||
*/
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <cstdio>
|
||||
#include <sys/mman.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fmt/core.h"
|
||||
|
||||
#include "common/PageFaultSource.h"
|
||||
#include "common/Assertions.h"
|
||||
#include "common/Console.h"
|
||||
#include "common/Exceptions.h"
|
||||
#include "common/StringHelpers.h"
|
||||
|
||||
// Apple uses the MAP_ANON define instead of MAP_ANONYMOUS, but they mean
|
||||
// the same thing.
|
||||
@@ -66,10 +69,8 @@ static void SysPageFaultSignalFilter(int signal, siginfo_t* siginfo, void*)
|
||||
if (Source_PageFault->WasHandled())
|
||||
return;
|
||||
|
||||
if (!wxThread::IsMain())
|
||||
{
|
||||
pxFailRel(pxsFmt("Unhandled page fault @ 0x%08x", siginfo->si_addr));
|
||||
}
|
||||
std::fprintf(stderr, "Unhandled page fault @ 0x%08x", siginfo->si_addr);
|
||||
pxFailRel("Unhandled page fault");
|
||||
|
||||
// Bad mojo! Completely invalid address.
|
||||
// Instigate a trap if we're in a debugger, and if not then do a SIGKILL.
|
||||
@@ -95,25 +96,12 @@ void _platform_InstallSignalHandler()
|
||||
#endif
|
||||
}
|
||||
|
||||
static __ri void PageSizeAssertionTest(size_t size)
|
||||
{
|
||||
pxAssertMsg((__pagesize == getpagesize()), pxsFmt(
|
||||
"Internal system error: Operating system pagesize does not match compiled pagesize.\n\t"
|
||||
L"\tOS Page Size: 0x%x (%d), Compiled Page Size: 0x%x (%u)",
|
||||
getpagesize(), getpagesize(), __pagesize, __pagesize));
|
||||
|
||||
pxAssertDev((size & (__pagesize - 1)) == 0, pxsFmt(
|
||||
L"Memory block size must be a multiple of the target platform's page size.\n"
|
||||
L"\tPage Size: 0x%x (%u), Block Size: 0x%x (%u)",
|
||||
__pagesize, __pagesize, size, size));
|
||||
}
|
||||
|
||||
// returns FALSE if the mprotect call fails with an ENOMEM.
|
||||
// Raises assertions on other types of POSIX errors (since those typically reflect invalid object
|
||||
// or memory states).
|
||||
static bool _memprotect(void* baseaddr, size_t size, const PageProtectionMode& mode)
|
||||
{
|
||||
PageSizeAssertionTest(size);
|
||||
pxAssertDev((size & (__pagesize - 1)) == 0, "Size is page aligned");
|
||||
|
||||
uint lnxmode = 0;
|
||||
|
||||
@@ -132,13 +120,13 @@ static bool _memprotect(void* baseaddr, size_t size, const PageProtectionMode& m
|
||||
switch (errno)
|
||||
{
|
||||
case EINVAL:
|
||||
pxFailDev(pxsFmt(L"mprotect returned EINVAL @ 0x%08X -> 0x%08X (mode=%s)",
|
||||
baseaddr, (uptr)baseaddr + size, WX_STR(mode.ToString())));
|
||||
pxFailDev(fmt::format("mprotect returned EINVAL @ 0x{:X} -> 0x{:X} (mode={})",
|
||||
baseaddr, (uptr)baseaddr + size, mode.ToString()).c_str());
|
||||
break;
|
||||
|
||||
case EACCES:
|
||||
pxFailDev(pxsFmt(L"mprotect returned EACCES @ 0x%08X -> 0x%08X (mode=%s)",
|
||||
baseaddr, (uptr)baseaddr + size, WX_STR(mode.ToString())));
|
||||
pxFailDev(fmt::format("mprotect returned EACCES @ 0x{:X} -> 0x{:X} (mode={})",
|
||||
baseaddr, (uptr)baseaddr + size, mode.ToString()).c_str());
|
||||
break;
|
||||
|
||||
case ENOMEM:
|
||||
@@ -150,7 +138,7 @@ static bool _memprotect(void* baseaddr, size_t size, const PageProtectionMode& m
|
||||
|
||||
void* HostSys::MmapReservePtr(void* base, size_t size)
|
||||
{
|
||||
PageSizeAssertionTest(size);
|
||||
pxAssertDev((size & (__pagesize - 1)) == 0, "Size is page aligned");
|
||||
|
||||
// On linux a reserve-without-commit is performed by using mmap on a read-only
|
||||
// or anonymous source, with PROT_NONE (no-access) permission. Since the mapping
|
||||
@@ -172,21 +160,16 @@ bool HostSys::MmapCommitPtr(void* base, size_t size, const PageProtectionMode& m
|
||||
if (_memprotect(base, size, mode))
|
||||
return true;
|
||||
|
||||
if (!pxDoOutOfMemory)
|
||||
return false;
|
||||
pxDoOutOfMemory(size);
|
||||
return _memprotect(base, size, mode);
|
||||
return false;
|
||||
}
|
||||
|
||||
void HostSys::MmapResetPtr(void* base, size_t size)
|
||||
{
|
||||
PageSizeAssertionTest(size);
|
||||
pxAssertDev((size & (__pagesize - 1)) == 0, "Size is page aligned");
|
||||
|
||||
void* result = mmap(base, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
|
||||
|
||||
pxAssertRel((uptr)result == (uptr)base, pxsFmt(
|
||||
"Virtual memory decommit failed: memory at 0x%08X -> 0x%08X could not be remapped.",
|
||||
base, (uptr)base + size));
|
||||
pxAssertRel((uptr)result == (uptr)base, "Virtual memory decommit failed");
|
||||
}
|
||||
|
||||
void* HostSys::MmapReserve(uptr base, size_t size)
|
||||
@@ -206,7 +189,7 @@ void HostSys::MmapReset(uptr base, size_t size)
|
||||
|
||||
void* HostSys::Mmap(uptr base, size_t size)
|
||||
{
|
||||
PageSizeAssertionTest(size);
|
||||
pxAssertDev((size & (__pagesize - 1)) == 0, "Size is page aligned");
|
||||
|
||||
// MAP_ANONYMOUS - means we have no associated file handle (or device).
|
||||
|
||||
@@ -224,9 +207,9 @@ void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode&
|
||||
{
|
||||
if (!_memprotect(baseaddr, size, mode))
|
||||
{
|
||||
throw Exception::OutOfMemory(L"MemProtect")
|
||||
.SetDiagMsg(pxsFmt(L"mprotect failed @ 0x%08X -> 0x%08X (mode=%s)",
|
||||
baseaddr, (uptr)baseaddr + size, WX_STR(mode.ToString())));
|
||||
throw Exception::OutOfMemory("MemProtect")
|
||||
.SetDiagMsg(fmt::format("mprotect failed @ 0x{:X} -> 0x{:X} (mode={})",
|
||||
baseaddr, (uptr)baseaddr + size, mode.ToString()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <wx/utils.h>
|
||||
|
||||
#include "common/Pcsx2Types.h"
|
||||
#include "common/General.h"
|
||||
|
||||
// Returns 0 on failure (not supported by the operating system).
|
||||
u64 GetPhysicalMemory()
|
||||
@@ -51,12 +51,12 @@ u64 GetCPUTicks()
|
||||
return (static_cast<u64>(ts.tv_sec) * 1000000000ULL) + ts.tv_nsec;
|
||||
}
|
||||
|
||||
wxString GetOSVersionString()
|
||||
std::string GetOSVersionString()
|
||||
{
|
||||
#if defined(__linux__)
|
||||
return wxGetLinuxDistributionInfo().Description;
|
||||
return "Linux";
|
||||
#else // freebsd
|
||||
return wxGetOsDescription();
|
||||
return "Other Unix";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,10 @@
|
||||
#include "EventSource.h"
|
||||
#include "General.h"
|
||||
#include "Assertions.h"
|
||||
#include "Dependencies.h"
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
struct PageFaultInfo
|
||||
{
|
||||
@@ -135,7 +136,7 @@ class VirtualMemoryManager
|
||||
{
|
||||
DeclareNoncopyableObject(VirtualMemoryManager);
|
||||
|
||||
wxString m_name;
|
||||
std::string m_name;
|
||||
|
||||
uptr m_baseptr;
|
||||
|
||||
@@ -149,7 +150,7 @@ public:
|
||||
// If upper_bounds is nonzero and the OS fails to allocate memory that is below it,
|
||||
// calls to IsOk() will return false and Alloc() will always return null pointers
|
||||
// strict indicates that the allocation should quietly fail if the memory can't be mapped at `base`
|
||||
VirtualMemoryManager(const wxString& name, uptr base, size_t size, uptr upper_bounds = 0, bool strict = false);
|
||||
VirtualMemoryManager(std::string name, uptr base, size_t size, uptr upper_bounds = 0, bool strict = false);
|
||||
~VirtualMemoryManager();
|
||||
|
||||
void* GetBase() const { return (void*)m_baseptr; }
|
||||
@@ -195,7 +196,7 @@ class VirtualMemoryReserve
|
||||
DeclareNoncopyableObject(VirtualMemoryReserve);
|
||||
|
||||
protected:
|
||||
wxString m_name;
|
||||
std::string m_name;
|
||||
|
||||
// Where the memory came from (so we can return it)
|
||||
VirtualMemoryManagerPtr m_allocator;
|
||||
@@ -228,7 +229,7 @@ protected:
|
||||
virtual size_t GetSize(size_t requestedSize);
|
||||
|
||||
public:
|
||||
VirtualMemoryReserve(const wxString& name, size_t size = 0);
|
||||
VirtualMemoryReserve(std::string name, size_t size = 0);
|
||||
virtual ~VirtualMemoryReserve()
|
||||
{
|
||||
Release();
|
||||
@@ -260,7 +261,7 @@ public:
|
||||
virtual void AllowModification();
|
||||
|
||||
bool IsOk() const { return m_baseptr != NULL; }
|
||||
const wxString& GetName() const { return m_name; }
|
||||
const std::string& GetName() const { return m_name; }
|
||||
|
||||
uptr GetReserveSizeInBytes() const { return m_pages_reserved * __pagesize; }
|
||||
uptr GetReserveSizeInPages() const { return m_pages_reserved; }
|
||||
|
||||
+5
-4
@@ -15,8 +15,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/Pcsx2Defs.h"
|
||||
|
||||
#include <wx/filename.h>
|
||||
#include "common/StringHelpers.h"
|
||||
|
||||
#include "ghc/filesystem.h"
|
||||
|
||||
@@ -43,7 +44,7 @@ public:
|
||||
: wxFileName(src)
|
||||
{
|
||||
}
|
||||
explicit wxDirName(const char* src) { Assign(fromUTF8(src)); }
|
||||
explicit wxDirName(const char* src) { Assign(wxString(src, wxMBConvUTF8())); }
|
||||
explicit wxDirName(const wxString& src) { Assign(src); }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -187,14 +188,14 @@ public:
|
||||
}
|
||||
wxDirName& operator=(const char* dirname)
|
||||
{
|
||||
Assign(fromUTF8(dirname));
|
||||
Assign(wxString(dirname, wxMBConvUTF8()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxFileName operator+(const wxFileName& right) const { return Combine(right); }
|
||||
wxDirName operator+(const wxDirName& right) const { return Combine(right); }
|
||||
wxFileName operator+(const wxString& right) const { return Combine(wxFileName(right)); }
|
||||
wxFileName operator+(const char* right) const { return Combine(wxFileName(fromUTF8(right))); }
|
||||
wxFileName operator+(const char* right) const { return Combine(wxFileName(wxString(right, wxMBConvUTF8()))); }
|
||||
|
||||
bool operator==(const wxDirName& filename) const { return SameAs(filename); }
|
||||
bool operator!=(const wxDirName& filename) const { return !SameAs(filename); }
|
||||
|
||||
+10
-8
@@ -14,6 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "common/Path.h"
|
||||
#include "common/Assertions.h"
|
||||
#include "common/Exceptions.h"
|
||||
|
||||
#include <wx/file.h>
|
||||
#include <wx/utils.h>
|
||||
@@ -24,7 +26,7 @@
|
||||
|
||||
wxFileName wxDirName::Combine(const wxFileName& right) const
|
||||
{
|
||||
pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wxDirName concatenation.");
|
||||
pxAssertMsg(IsDir(), "Warning: Malformed directory name detected during wxDirName concatenation.");
|
||||
if (right.IsAbsolute())
|
||||
return right;
|
||||
|
||||
@@ -39,7 +41,7 @@ wxFileName wxDirName::Combine(const wxFileName& right) const
|
||||
|
||||
wxDirName wxDirName::Combine(const wxDirName& right) const
|
||||
{
|
||||
pxAssertMsg(IsDir() && right.IsDir(), L"Warning: Malformed directory name detected during wDirName concatenation.");
|
||||
pxAssertMsg(IsDir() && right.IsDir(), "Warning: Malformed directory name detected during wDirName concatenation.");
|
||||
|
||||
wxDirName result(right);
|
||||
result.Normalize(wxPATH_NORM_ENV_VARS | wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE, GetPath());
|
||||
@@ -48,25 +50,25 @@ wxDirName wxDirName::Combine(const wxDirName& right) const
|
||||
|
||||
wxDirName& wxDirName::Normalize(int flags, const wxString& cwd)
|
||||
{
|
||||
pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wDirName normalization.");
|
||||
pxAssertMsg(IsDir(), "Warning: Malformed directory name detected during wDirName normalization.");
|
||||
if (!wxFileName::Normalize(flags, cwd))
|
||||
throw Exception::ParseError().SetDiagMsg(L"wxDirName::Normalize operation failed.");
|
||||
throw Exception::ParseError().SetDiagMsg("wxDirName::Normalize operation failed.");
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDirName& wxDirName::MakeRelativeTo(const wxString& pathBase)
|
||||
{
|
||||
pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wDirName normalization.");
|
||||
pxAssertMsg(IsDir(), "Warning: Malformed directory name detected during wDirName normalization.");
|
||||
if (!wxFileName::MakeRelativeTo(pathBase))
|
||||
throw Exception::ParseError().SetDiagMsg(L"wxDirName::MakeRelativeTo operation failed.");
|
||||
throw Exception::ParseError().SetDiagMsg("wxDirName::MakeRelativeTo operation failed.");
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDirName& wxDirName::MakeAbsolute(const wxString& cwd)
|
||||
{
|
||||
pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wDirName normalization.");
|
||||
pxAssertMsg(IsDir(), "Warning: Malformed directory name detected during wDirName normalization.");
|
||||
if (!wxFileName::MakeAbsolute(cwd))
|
||||
throw Exception::ParseError().SetDiagMsg(L"wxDirName::MakeAbsolute operation failed.");
|
||||
throw Exception::ParseError().SetDiagMsg("wxDirName::MakeAbsolute operation failed.");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,3 +188,144 @@ static const int __pagesize = PCSX2_PAGESIZE;
|
||||
#endif
|
||||
|
||||
#define ASSERT assert
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Safe deallocation macros -- checks pointer validity (non-null) when needed, and sets
|
||||
// pointer to null after deallocation.
|
||||
|
||||
#define safe_delete(ptr) \
|
||||
((void)(delete (ptr)), (ptr) = NULL)
|
||||
|
||||
#define safe_delete_array(ptr) \
|
||||
((void)(delete[](ptr)), (ptr) = NULL)
|
||||
|
||||
// No checks for NULL -- wxWidgets says it's safe to skip NULL checks and it runs on
|
||||
// just about every compiler and libc implementation of any recentness.
|
||||
#define safe_free(ptr) \
|
||||
((void)(free(ptr), !!0), (ptr) = NULL)
|
||||
//((void) (( ( (ptr) != NULL ) && (free( ptr ), !!0) ), (ptr) = NULL))
|
||||
|
||||
#define safe_fclose(ptr) \
|
||||
((void)((((ptr) != NULL) && (fclose(ptr), !!0)), (ptr) = NULL))
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// ImplementEnumOperators (macro)
|
||||
// --------------------------------------------------------------------------------------
|
||||
// This macro implements ++/-- operators for any conforming enumeration. In order for an
|
||||
// enum to conform, it must have _FIRST and _COUNT members defined, and must have a full
|
||||
// compliment of sequential members (no custom assignments) --- looking like so:
|
||||
//
|
||||
// enum Dummy {
|
||||
// Dummy_FIRST,
|
||||
// Dummy_Item = Dummy_FIRST,
|
||||
// Dummy_Crap,
|
||||
// Dummy_COUNT
|
||||
// };
|
||||
//
|
||||
// The macro also defines utility functions for bounds checking enumerations:
|
||||
// EnumIsValid(value); // returns TRUE if the enum value is between FIRST and COUNT.
|
||||
// EnumAssert(value);
|
||||
//
|
||||
// It also defines a *prototype* for converting the enumeration to a string. Note that this
|
||||
// method is not implemented! You must implement it yourself if you want to use it:
|
||||
// EnumToString(value);
|
||||
//
|
||||
#define ImplementEnumOperators(enumName) \
|
||||
static __fi enumName& operator++(enumName& src) \
|
||||
{ \
|
||||
src = (enumName)((int)src + 1); \
|
||||
return src; \
|
||||
} \
|
||||
\
|
||||
static __fi enumName& operator--(enumName& src) \
|
||||
{ \
|
||||
src = (enumName)((int)src - 1); \
|
||||
return src; \
|
||||
} \
|
||||
\
|
||||
static __fi enumName operator++(enumName& src, int) \
|
||||
{ \
|
||||
enumName orig = src; \
|
||||
src = (enumName)((int)src + 1); \
|
||||
return orig; \
|
||||
} \
|
||||
\
|
||||
static __fi enumName operator--(enumName& src, int) \
|
||||
{ \
|
||||
enumName orig = src; \
|
||||
src = (enumName)((int)src - 1); \
|
||||
return orig; \
|
||||
} \
|
||||
\
|
||||
static __fi bool operator<(const enumName& left, const pxEnumEnd_t&) { return (int)left < enumName##_COUNT; } \
|
||||
static __fi bool operator!=(const enumName& left, const pxEnumEnd_t&) { return (int)left != enumName##_COUNT; } \
|
||||
static __fi bool operator==(const enumName& left, const pxEnumEnd_t&) { return (int)left == enumName##_COUNT; } \
|
||||
\
|
||||
static __fi bool EnumIsValid(enumName id) \
|
||||
{ \
|
||||
return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); \
|
||||
} \
|
||||
\
|
||||
extern const char* EnumToString(enumName id)
|
||||
|
||||
class pxEnumEnd_t
|
||||
{
|
||||
};
|
||||
static const pxEnumEnd_t pxEnumEnd = {};
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// DeclareNoncopyableObject
|
||||
// --------------------------------------------------------------------------------------
|
||||
// This macro provides an easy and clean method for ensuring objects are not copyable.
|
||||
// Simply add the macro to the head or tail of your class declaration, and attempts to
|
||||
// copy the class will give you a moderately obtuse compiler error that will have you
|
||||
// scratching your head for 20 minutes.
|
||||
//
|
||||
// (... but that's probably better than having a weird invalid object copy having you
|
||||
// scratch your head for a day).
|
||||
//
|
||||
// Programmer's notes:
|
||||
// * We intentionally do NOT provide implementations for these methods, which should
|
||||
// never be referenced anyway.
|
||||
|
||||
// * I've opted for macro form over multi-inherited class form (Boost style), because
|
||||
// the errors generated by the macro are considerably less voodoo. The Boost-style
|
||||
// The macro reports the exact class that causes the copy failure, while Boost's class
|
||||
// approach just reports an error in whatever "NoncopyableObject" is inherited.
|
||||
//
|
||||
// * This macro is the same as wxWidgets' DECLARE_NO_COPY_CLASS macro. This one is free
|
||||
// of wx dependencies though, and has a nicer typeset. :)
|
||||
//
|
||||
#ifndef DeclareNoncopyableObject
|
||||
#define DeclareNoncopyableObject(classname) \
|
||||
public: \
|
||||
classname(const classname&) = delete; \
|
||||
classname& operator=(const classname&) = delete
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Handy Human-readable constants for common immediate values (_16kb -> _4gb)
|
||||
|
||||
static constexpr sptr _1kb = 1024 * 1;
|
||||
static constexpr sptr _4kb = _1kb * 4;
|
||||
static constexpr sptr _16kb = _1kb * 16;
|
||||
static constexpr sptr _32kb = _1kb * 32;
|
||||
static constexpr sptr _64kb = _1kb * 64;
|
||||
static constexpr sptr _128kb = _1kb * 128;
|
||||
static constexpr sptr _256kb = _1kb * 256;
|
||||
|
||||
static constexpr s64 _1mb = 1024 * 1024;
|
||||
static constexpr s64 _8mb = _1mb * 8;
|
||||
static constexpr s64 _16mb = _1mb * 16;
|
||||
static constexpr s64 _32mb = _1mb * 32;
|
||||
static constexpr s64 _64mb = _1mb * 64;
|
||||
static constexpr s64 _256mb = _1mb * 256;
|
||||
static constexpr s64 _1gb = _1mb * 1024;
|
||||
static constexpr s64 _4gb = _1gb * 4;
|
||||
|
||||
// Disable some spammy warnings which wx appeared to disable.
|
||||
// We probably should fix these at some point.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4244) // warning C4244: 'initializing': conversion from 'uptr' to 'uint', possible loss of data
|
||||
#pragma warning(disable: 4267) // warning C4267: 'initializing': conversion from 'size_t' to 'uint', possible loss of data
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user