Merge pull request #3277 from IntelOrca/refactor-twitch

Refactor and clean up twitch.cpp
This commit is contained in:
Ted John 2016-04-20 22:12:57 +01:00
commit 60ac228c51
8 changed files with 1659 additions and 1491 deletions

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,8 @@
<ClCompile Include="src\cmdline_sprite.c" />
<ClCompile Include="src\config.c" />
<ClCompile Include="src\core\Console.cpp" />
<ClCompile Include="src\core\Diagnostics.cpp" />
<ClCompile Include="src\core\Guard.cpp" />
<ClCompile Include="src\core\Json.cpp" />
<ClCompile Include="src\core\Path.cpp" />
<ClCompile Include="src\core\Stopwatch.cpp" />
@ -394,4 +396,4 @@
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
</Project>

View File

@ -576,6 +576,12 @@
<ClCompile Include="src\core\textinputbuffer.c">
<Filter>Source\Core</Filter>
</ClCompile>
<ClCompile Include="src\core\Diagnostics.cpp">
<Filter>Source\Core</Filter>
</ClCompile>
<ClCompile Include="src\core\Guard.cpp">
<Filter>Source\Core</Filter>
</ClCompile>
<ClCompile Include="src\platform\crash.cpp">
<Filter>Source\Platform</Filter>
</ClCompile>
@ -583,7 +589,7 @@
<Filter>Source\Core</Filter>
</ClCompile>
<ClCompile Include="src\windows\themes.c">
<Filter>Source\Interface</Filter>
<Filter>Source\Windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>

22
src/core/Diagnostics.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <SDL_platform.h>
#if defined(DEBUG) && defined(__WINDOWS__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include "Diagnostics.hpp"
namespace Debug
{
void Break()
{
#if DEBUG
#if __WINDOWS__
if (IsDebuggerPresent()) {
DebugBreak();
}
#endif
#endif
}
}

View File

@ -1,22 +1,9 @@
#pragma once
#if _WIN32
#include <debugapi.h>
#endif
/**
* Utility methods for asserting and logging.
*/
namespace Debug
{
void Break()
{
#if DEBUG
#if _WIN32
if (IsDebuggerPresent()) {
DebugBreak();
}
#endif
#endif
}
void Break();
}

24
src/core/Guard.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <cassert>
#include <stdio.h>
#include "Console.hpp"
#include "Diagnostics.hpp"
#include "Guard.hpp"
namespace Guard
{
void Assert(bool expression, const char * message)
{
if (expression) return;
if (message != nullptr)
{
Console::Error::WriteLine(message);
}
#if DEBUG
Debug::Break();
#endif
assert(false);
}
}

View File

@ -1,30 +1,11 @@
#pragma once
#include <cassert>
#include <stdio.h>
#include "Console.hpp"
#include "Diagnostics.hpp"
/**
* Utility methods for asserting function parameters.
*/
namespace Guard
{
void Assert(bool expression, const char * message = nullptr)
{
if (expression) return;
if (message != nullptr)
{
Console::Error::WriteLine(message);
}
#if DEBUG
Debug::Break();
#endif
assert(false);
}
void Assert(bool expression, const char * message = nullptr);
template<typename T>
void ArgumentNotNull(T * argument, const char * message = nullptr)

File diff suppressed because it is too large Load Diff