Skip to content

Commit d253625

Browse files
committed
Reformat sources
1 parent a598ee0 commit d253625

File tree

4 files changed

+71
-68
lines changed

4 files changed

+71
-68
lines changed

src/.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ root = true
44
# 4 space indentation
55
[*.{cpp,h,hpp}]
66
indent_style = space
7-
indent_size = 4
7+
indent_size = 4
8+
9+
# newline ending every file
10+
insert_final_newline = true

src/xrCore/Threading/ScopeLock.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
#include "Threading/Lock.hpp"
55
#include "xrDebug.h"
66

7-
class ScopeLock: Noncopyable
7+
class ScopeLock : Noncopyable
88
{
99
public:
10-
ScopeLock(Lock* SyncObject);
10+
ScopeLock(Lock *SyncObject);
1111
~ScopeLock();
1212

1313
private:
14-
Lock * m_SyncObject;
14+
Lock *syncObject;
1515
};
1616

17-
ScopeLock::ScopeLock(Lock* SyncObject): m_SyncObject(SyncObject)
17+
ScopeLock::ScopeLock(Lock *SyncObject) : syncObject(SyncObject)
1818
{
19-
VERIFY(m_SyncObject);
19+
VERIFY(syncObject);
2020

21-
m_SyncObject->Enter();
21+
syncObject->Enter();
2222
}
2323

2424
ScopeLock::~ScopeLock()
2525
{
26-
m_SyncObject->Leave();
26+
syncObject->Leave();
2727
}

src/xrCore/xrDebug.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ xrDebug::DialogHandler xrDebug::OnDialog = nullptr;
7878
string_path xrDebug::BugReportFile;
7979
bool xrDebug::ErrorAfterDialog = false;
8080

81-
bool xrDebug::m_SymEngineInitialized = false;
82-
Lock xrDebug::m_DbgHelpLock;
81+
bool xrDebug::symEngineInitialized = false;
82+
Lock xrDebug::dbgHelpLock;
8383

84-
void xrDebug::SetBugReportFile(const char* fileName) { strcpy_s(BugReportFile, fileName); }
84+
void xrDebug::SetBugReportFile(const char *fileName) { strcpy_s(BugReportFile, fileName); }
8585

86-
bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string& frameStr)
86+
bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string &frameStr)
8787
{
8888
BOOL result = StackWalk(MACHINE_TYPE, GetCurrentProcess(), GetCurrentThread(), stackFrame, threadCtx, nullptr,
8989
SymFunctionTableAccess, SymGetModuleBase, nullptr);
@@ -140,7 +140,7 @@ bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCt
140140
/// Source info
141141
///
142142
DWORD dwLineOffset;
143-
IMAGEHLP_LINE sourceInfo = { 0 };
143+
IMAGEHLP_LINE sourceInfo = {};
144144
sourceInfo.SizeOfStruct = sizeof(sourceInfo);
145145

146146
result = SymGetLineFromAddr(GetCurrentProcess(), stackFrame->AddrPC.Offset, &dwLineOffset, &sourceInfo);
@@ -164,36 +164,36 @@ bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCt
164164

165165
bool xrDebug::InitializeSymbolEngine()
166166
{
167-
if (!m_SymEngineInitialized)
167+
if (!symEngineInitialized)
168168
{
169169
DWORD dwOptions = SymGetOptions();
170170
SymSetOptions(dwOptions | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
171171

172172
if (SymInitialize(GetCurrentProcess(), nullptr, TRUE))
173173
{
174-
m_SymEngineInitialized = true;
174+
symEngineInitialized = true;
175175
}
176176
}
177177

178-
return m_SymEngineInitialized;
178+
return symEngineInitialized;
179179
}
180180

181181
void xrDebug::DeinitializeSymbolEngine(void)
182182
{
183-
if (m_SymEngineInitialized)
183+
if (symEngineInitialized)
184184
{
185185
SymCleanup(GetCurrentProcess());
186186

187-
m_SymEngineInitialized = false;
187+
symEngineInitialized = false;
188188
}
189189
}
190190

191191
xr_vector<xr_string> xrDebug::BuildStackTrace(PCONTEXT threadCtx, u16 maxFramesCount)
192192
{
193-
ScopeLock Lock(&m_DbgHelpLock);
193+
ScopeLock Lock(&dbgHelpLock);
194194

195195
SStringVec traceResult;
196-
STACKFRAME stackFrame = { 0 };
196+
STACKFRAME stackFrame = {};
197197
xr_string frameStr;
198198

199199
if (!InitializeSymbolEngine())
@@ -234,28 +234,28 @@ xr_vector<xr_string> xrDebug::BuildStackTrace(PCONTEXT threadCtx, u16 maxFramesC
234234

235235
SStringVec xrDebug::BuildStackTrace(u16 maxFramesCount)
236236
{
237-
CONTEXT currentThreadCtx = { 0 };
237+
CONTEXT currentThreadCtx = {};
238238

239239
RtlCaptureContext(&currentThreadCtx); /// GetThreadContext cann't be used on the current thread
240240
currentThreadCtx.ContextFlags = CONTEXT_FULL;
241241

242242
return BuildStackTrace(&currentThreadCtx, maxFramesCount);
243243
}
244244

245-
void xrDebug::LogStackTrace(const char* header)
245+
void xrDebug::LogStackTrace(const char *header)
246246
{
247247
SStringVec stackTrace = BuildStackTrace();
248248
Msg("%s", header);
249-
for(const auto& frame : stackTrace)
249+
for (const auto &frame : stackTrace)
250250
{
251251
Msg("%s", frame.c_str());
252252
}
253253
}
254254

255-
void xrDebug::GatherInfo(char* assertionInfo, const ErrorLocation& loc, const char* expr, const char* desc,
256-
const char* arg1, const char* arg2)
255+
void xrDebug::GatherInfo(char *assertionInfo, const ErrorLocation &loc, const char *expr, const char *desc,
256+
const char *arg1, const char *arg2)
257257
{
258-
char* buffer = assertionInfo;
258+
char *buffer = assertionInfo;
259259
if (!expr)
260260
expr = "<no expression>";
261261
bool extendedDesc = desc && strchr(desc, '\n');
@@ -317,7 +317,7 @@ void xrDebug::GatherInfo(char* assertionInfo, const ErrorLocation& loc, const ch
317317
os_clipboard::copy_to_clipboard(assertionInfo);
318318
}
319319

320-
void xrDebug::Fatal(const ErrorLocation& loc, const char* format, ...)
320+
void xrDebug::Fatal(const ErrorLocation &loc, const char *format, ...)
321321
{
322322
string1024 desc;
323323
va_list args;
@@ -328,14 +328,14 @@ void xrDebug::Fatal(const ErrorLocation& loc, const char* format, ...)
328328
Fail(ignoreAlways, loc, nullptr, "fatal error", desc);
329329
}
330330

331-
void xrDebug::Fail(
332-
bool& ignoreAlways, const ErrorLocation& loc, const char* expr, long hresult, const char* arg1, const char* arg2)
331+
void xrDebug::Fail(bool &ignoreAlways, const ErrorLocation &loc, const char *expr, long hresult, const char *arg1,
332+
const char *arg2)
333333
{
334334
Fail(ignoreAlways, loc, expr, xrDebug::ErrorToString(hresult), arg1, arg2);
335335
}
336336

337-
void xrDebug::Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* expr, const char* desc, const char* arg1,
338-
const char* arg2)
337+
void xrDebug::Fail(bool &ignoreAlways, const ErrorLocation &loc, const char *expr, const char *desc, const char *arg1,
338+
const char *arg2)
339339
{
340340
#ifdef PROFILE_CRITICAL_SECTIONS
341341
static Lock lock(MUTEX_PROFILE_ID(xrDebug::Backend));
@@ -393,13 +393,13 @@ void xrDebug::Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* exp
393393
lock.Leave();
394394
}
395395

396-
void xrDebug::Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* expr, const std::string& desc,
397-
const char* arg1, const char* arg2)
396+
void xrDebug::Fail(bool &ignoreAlways, const ErrorLocation &loc, const char *expr, const std::string &desc,
397+
const char *arg1, const char *arg2)
398398
{
399399
Fail(ignoreAlways, loc, expr, desc.c_str(), arg1, arg2);
400400
}
401401

402-
void xrDebug::DoExit(const std::string& message)
402+
void xrDebug::DoExit(const std::string &message)
403403
{
404404
FlushLog();
405405
MessageBox(NULL, message.c_str(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
@@ -408,7 +408,7 @@ void xrDebug::DoExit(const std::string& message)
408408

409409
LPCSTR xrDebug::ErrorToString(long code)
410410
{
411-
const char* result = nullptr;
411+
const char *result = nullptr;
412412
static string1024 descStorage;
413413
DXGetErrorDescription(code, descStorage, sizeof(descStorage));
414414
if (!result)
@@ -476,7 +476,7 @@ void WINAPI xrDebug::PreErrorHandler(INT_PTR)
476476
BT_SaveSnapshot(nullptr);
477477
}
478478

479-
void xrDebug::SetupExceptionHandler(const bool& dedicated)
479+
void xrDebug::SetupExceptionHandler(const bool &dedicated)
480480
{
481481
// disable 'appname has stopped working' popup dialog
482482
UINT prevMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
@@ -516,7 +516,7 @@ void xrDebug::SetupExceptionHandler(const bool& dedicated)
516516
#endif // USE_BUG_TRAP
517517

518518
#ifdef USE_OWN_MINI_DUMP
519-
void xrDebug::SaveMiniDump(EXCEPTION_POINTERS* exPtrs)
519+
void xrDebug::SaveMiniDump(EXCEPTION_POINTERS *exPtrs)
520520
{
521521
string64 dateStr;
522522
timestamp(dateStr);
@@ -537,23 +537,23 @@ void xrDebug::SaveMiniDump(EXCEPTION_POINTERS* exPtrs)
537537
}
538538
#endif
539539

540-
void xrDebug::FormatLastError(char* buffer, const size_t& bufferSize)
540+
void xrDebug::FormatLastError(char *buffer, const size_t &bufferSize)
541541
{
542542
int lastErr = GetLastError();
543543
if (lastErr == ERROR_SUCCESS)
544544
{
545545
*buffer = 0;
546546
return;
547547
}
548-
void* msg = nullptr;
548+
void *msg = nullptr;
549549
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, lastErr,
550550
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&msg, 0, nullptr);
551551
// XXX nitrocaster: check buffer overflow
552552
sprintf(buffer, "[error][%8d]: %s", lastErr, (char*)msg);
553553
LocalFree(msg);
554554
}
555555

556-
LONG WINAPI xrDebug::UnhandledFilter(EXCEPTION_POINTERS* exPtrs)
556+
LONG WINAPI xrDebug::UnhandledFilter(EXCEPTION_POINTERS *exPtrs)
557557
{
558558
string256 errMsg;
559559
FormatLastError(errMsg, sizeof(errMsg));
@@ -628,14 +628,14 @@ void _terminate()
628628
}
629629
#endif // USE_BUG_TRAP
630630

631-
static void handler_base(const char* reason)
631+
static void handler_base(const char *reason)
632632
{
633633
bool ignoreAlways = false;
634634
xrDebug::Fail(ignoreAlways, DEBUG_INFO, nullptr, reason, nullptr, nullptr);
635635
}
636636

637-
static void invalid_parameter_handler(
638-
const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t reserved)
637+
static void invalid_parameter_handler(const wchar_t *expression, const wchar_t *function, const wchar_t *file,
638+
unsigned int line, uintptr_t reserved)
639639
{
640640
bool ignoreAlways = false;
641641
string4096 mbExpression;
@@ -657,7 +657,7 @@ static void invalid_parameter_handler(
657657
line = __LINE__;
658658
xr_strcpy(mbFile, __FILE__);
659659
}
660-
xrDebug::Fail(ignoreAlways, { mbFile, int(line), mbFunction }, mbExpression, "invalid parameter");
660+
xrDebug::Fail(ignoreAlways, {mbFile, int(line), mbFunction}, mbExpression, "invalid parameter");
661661
}
662662

663663
static void pure_call_handler() { handler_base("pure virtual function call"); }
@@ -692,7 +692,7 @@ void xrDebug::OnThreadSpawn()
692692
#endif
693693
}
694694

695-
void xrDebug::Initialize(const bool& dedicated)
695+
void xrDebug::Initialize(const bool &dedicated)
696696
{
697697
*BugReportFile = 0;
698698
OnThreadSpawn();

src/xrCore/xrDebug.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ class ErrorLocation
1818
int Line = -1;
1919
const char* Function = nullptr;
2020

21-
ErrorLocation(const char* file, int line, const char* function)
21+
ErrorLocation(const char* file, int line, const char *function)
2222
{
2323
File = file;
2424
Line = line;
2525
Function = function;
2626
}
2727

28-
ErrorLocation& operator=(const ErrorLocation& rhs)
28+
ErrorLocation& operator=(const ErrorLocation &rhs)
2929
{
3030
File = rhs.File;
3131
Line = rhs.Line;
@@ -40,7 +40,7 @@ class XRCORE_API xrDebug
4040
using OutOfMemoryCallbackFunc = void(*)();
4141
using CrashHandler = void(*)();
4242
using DialogHandler = void(*)(bool);
43-
using UnhandledExceptionFilter = LONG(WINAPI*)(EXCEPTION_POINTERS* exPtrs);
43+
using UnhandledExceptionFilter = LONG(WINAPI*)(EXCEPTION_POINTERS *exPtrs);
4444

4545
private:
4646
static const u16 MaxFramesCountDefault = 512;
@@ -64,41 +64,41 @@ class XRCORE_API xrDebug
6464
static DialogHandler GetDialogHandler() { return OnDialog; }
6565
static void SetDialogHandler(DialogHandler handler) { OnDialog = handler; }
6666
static const char* ErrorToString(long code);
67-
static void SetBugReportFile(const char* fileName);
68-
static void GatherInfo(char* assertionInfo, const ErrorLocation& loc, const char* expr, const char* desc,
69-
const char* arg1 = nullptr, const char* arg2 = nullptr);
70-
static void Fatal(const ErrorLocation& loc, const char* format, ...);
71-
static void Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* expr, long hresult,
72-
const char* arg1 = nullptr, const char* arg2 = nullptr);
73-
static void Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* expr,
74-
const char* desc = "assertion failed", const char* arg1 = nullptr, const char* arg2 = nullptr);
75-
static void Fail(bool& ignoreAlways, const ErrorLocation& loc, const char* expr, const std::string& desc,
76-
const char* arg1 = nullptr, const char* arg2 = nullptr);
77-
static void DoExit(const std::string& message);
67+
static void SetBugReportFile(const char *fileName);
68+
static void GatherInfo(char *assertionInfo, const ErrorLocation &loc, const char *expr, const char *desc,
69+
const char *arg1 = nullptr, const char *arg2 = nullptr);
70+
static void Fatal(const ErrorLocation &loc, const char *format, ...);
71+
static void Fail(bool &ignoreAlways, const ErrorLocation &loc, const char *expr, long hresult,
72+
const char *arg1 = nullptr, const char *arg2 = nullptr);
73+
static void Fail(bool &ignoreAlways, const ErrorLocation &loc, const char *expr,
74+
const char *desc = "assertion failed", const char *arg1 = nullptr, const char *arg2 = nullptr);
75+
static void Fail(bool &ignoreAlways, const ErrorLocation &loc, const char *expr, const std::string &desc,
76+
const char *arg1 = nullptr, const char *arg2 = nullptr);
77+
static void DoExit(const std::string &message);
7878

79-
static void LogStackTrace(const char* header);
79+
static void LogStackTrace(const char *header);
8080
static xr_vector<xr_string> BuildStackTrace(u16 maxFramesCount = MaxFramesCountDefault);
8181
private:
82-
static void FormatLastError(char* buffer, const size_t& bufferSize);
83-
static void SetupExceptionHandler(const bool& dedicated);
84-
static LONG WINAPI UnhandledFilter(EXCEPTION_POINTERS* exPtrs);
82+
static void FormatLastError(char *buffer, const size_t &bufferSize);
83+
static void SetupExceptionHandler(const bool &dedicated);
84+
static LONG WINAPI UnhandledFilter(EXCEPTION_POINTERS *exPtrs);
8585
static void WINAPI PreErrorHandler(INT_PTR);
86-
static void SaveMiniDump(EXCEPTION_POINTERS* exPtrs);
86+
static void SaveMiniDump(EXCEPTION_POINTERS *exPtrs);
8787

8888
///
8989
/// Next members relates to stack tracing
9090
///
91-
static bool m_SymEngineInitialized;
92-
static Lock m_DbgHelpLock;
91+
static bool symEngineInitialized;
92+
static Lock dbgHelpLock;
9393

9494
static xr_vector<xr_string> BuildStackTrace(PCONTEXT threadCtx, u16 maxFramesCount);
95-
static bool GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string& frameStr);
95+
static bool GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string &frameStr);
9696
static bool InitializeSymbolEngine();
9797
static void DeinitializeSymbolEngine(void);
9898
};
9999

100100
// for debug purposes only
101-
inline std::string make_string(const char* format, ...)
101+
inline std::string make_string(const char *format, ...)
102102
{
103103
va_list args;
104104
va_start(args, format);

0 commit comments

Comments
 (0)