Code-style consistency improvement:

Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
erwincoumans
2018-09-23 14:17:31 -07:00
parent b73b05e9fb
commit ab8f16961e
1773 changed files with 1081087 additions and 474249 deletions

View File

@@ -9,76 +9,74 @@
#ifdef _WIN32
#include <windows.h>
#include <mmsystem.h>
#pragma comment( lib, "winmm.lib" )
#pragma comment(lib, "winmm.lib")
using namespace Gwen;
using namespace Gwen::Platform;
#ifdef UNICODE
static LPWSTR iCursorConvertion[] =
static LPWSTR iCursorConvertion[] =
#else
static LPSTR iCursorConvertion[] =
static LPSTR iCursorConvertion[] =
#endif
{
IDC_ARROW,
IDC_IBEAM,
IDC_SIZENS,
IDC_SIZEWE,
IDC_SIZENWSE,
IDC_SIZENESW,
IDC_SIZEALL,
IDC_NO,
IDC_WAIT,
IDC_HAND
};
{
IDC_ARROW,
IDC_IBEAM,
IDC_SIZENS,
IDC_SIZEWE,
IDC_SIZENWSE,
IDC_SIZENESW,
IDC_SIZEALL,
IDC_NO,
IDC_WAIT,
IDC_HAND};
void Gwen::Platform::SetCursor( unsigned char iCursor )
void Gwen::Platform::SetCursor(unsigned char iCursor)
{
// Todo.. Properly.
::SetCursor( LoadCursor( NULL, iCursorConvertion[iCursor] ) );
::SetCursor(LoadCursor(NULL, iCursorConvertion[iCursor]));
}
Gwen::UnicodeString Gwen::Platform::GetClipboardText()
{
if ( !OpenClipboard( NULL ) ) return L"";
if (!OpenClipboard(NULL)) return L"";
HANDLE hData = GetClipboardData( CF_UNICODETEXT );
HANDLE hData = GetClipboardData(CF_UNICODETEXT);
if ( hData == NULL )
if (hData == NULL)
{
CloseClipboard();
return L"";
}
wchar_t* buffer = (wchar_t *)GlobalLock( hData );
UnicodeString str = buffer;
GlobalUnlock( hData );
wchar_t* buffer = (wchar_t*)GlobalLock(hData);
UnicodeString str = buffer;
GlobalUnlock(hData);
CloseClipboard();
return str;
}
bool Gwen::Platform::SetClipboardText( const Gwen::UnicodeString& str )
bool Gwen::Platform::SetClipboardText(const Gwen::UnicodeString& str)
{
if ( !OpenClipboard( NULL ) ) return false;
if (!OpenClipboard(NULL)) return false;
EmptyClipboard();
// Create a buffer to hold the string
size_t iDataSize = (str.length()+1) * sizeof(wchar_t);
HGLOBAL clipbuffer = GlobalAlloc( GMEM_DDESHARE, iDataSize );
size_t iDataSize = (str.length() + 1) * sizeof(wchar_t);
HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, iDataSize);
// Copy the string into the buffer
wchar_t* buffer = (wchar_t*) GlobalLock( clipbuffer );
//wcscpy_s( buffer, iDataSize, str.c_str() );
memcpy( buffer, str.c_str() ,iDataSize);
wchar_t* buffer = (wchar_t*)GlobalLock(clipbuffer);
//wcscpy_s( buffer, iDataSize, str.c_str() );
memcpy(buffer, str.c_str(), iDataSize);
GlobalUnlock(clipbuffer);
// Place it on the clipboard
SetClipboardData( CF_UNICODETEXT, clipbuffer );
SetClipboardData(CF_UNICODETEXT, clipbuffer);
CloseClipboard();
return true;
@@ -88,10 +86,10 @@ double GetPerformanceFrequency()
{
static double Frequency = 0.0f;
if ( Frequency == 0.0f )
if (Frequency == 0.0f)
{
__int64 perfFreq;
QueryPerformanceFrequency( (LARGE_INTEGER*)&perfFreq );
QueryPerformanceFrequency((LARGE_INTEGER*)&perfFreq);
Frequency = 1.0 / (double)perfFreq;
}
@@ -106,10 +104,10 @@ float Gwen::Platform::GetTimeInSeconds()
static __int64 iLastTime = 0;
__int64 thistime;
QueryPerformanceCounter( (LARGE_INTEGER*)&thistime );
QueryPerformanceCounter((LARGE_INTEGER*)&thistime);
float fSecondsDifference = (double)( thistime - iLastTime ) * GetPerformanceFrequency();
if ( fSecondsDifference > 0.1f ) fSecondsDifference = 0.1f;
float fSecondsDifference = (double)(thistime - iLastTime) * GetPerformanceFrequency();
if (fSecondsDifference > 0.1f) fSecondsDifference = 0.1f;
fCurrentTime += fSecondsDifference;
@@ -118,24 +116,24 @@ float Gwen::Platform::GetTimeInSeconds()
return fCurrentTime;
#else
return timeGetTime() / 1000.0;
#endif
}
bool Gwen::Platform::FileOpen( const String& Name, const String& StartPath, const String& Extension, Gwen::Event::Handler* pHandler, Event::Handler::FunctionStr fnCallback )
bool Gwen::Platform::FileOpen(const String& Name, const String& StartPath, const String& Extension, Gwen::Event::Handler* pHandler, Event::Handler::FunctionStr fnCallback)
{
char Filestring[256];
String returnstring;
char FilterBuffer[512];
{
memset( FilterBuffer, 0, sizeof(FilterBuffer) );
memcpy( FilterBuffer, Extension.c_str(), GwenUtil_Min( Extension.size(), 512 ) );
for (int i=0; i<512; i++)
memset(FilterBuffer, 0, sizeof(FilterBuffer));
memcpy(FilterBuffer, Extension.c_str(), GwenUtil_Min(Extension.size(), 512));
for (int i = 0; i < 512; i++)
{
if ( FilterBuffer[i] == '|' )
if (FilterBuffer[i] == '|')
FilterBuffer[i] = 0;
}
}
@@ -150,7 +148,7 @@ bool Gwen::Platform::FileOpen( const String& Name, const String& StartPath, cons
opf.lpstrFile[0] = '\0';
opf.nMaxFile = 256;
opf.lpstrFileTitle = 0;
opf.nMaxFileTitle=50;
opf.nMaxFileTitle = 50;
opf.lpstrInitialDir = StartPath.c_str();
opf.lpstrTitle = Name.c_str();
opf.nFileOffset = 0;
@@ -161,36 +159,36 @@ bool Gwen::Platform::FileOpen( const String& Name, const String& StartPath, cons
opf.Flags = (OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR) & ~OFN_ALLOWMULTISELECT;
opf.lStructSize = sizeof(OPENFILENAME);
if ( GetOpenFileNameA( &opf ) )
if (GetOpenFileNameA(&opf))
{
if ( pHandler && fnCallback )
if (pHandler && fnCallback)
{
(pHandler->*fnCallback)( opf.lpstrFile );
(pHandler->*fnCallback)(opf.lpstrFile);
}
}
else
{
if ( pHandler && fnCallback )
if (pHandler && fnCallback)
{
(pHandler->*fnCallback)( "" );
(pHandler->*fnCallback)("");
}
}
return true;
}
bool Gwen::Platform::FileSave( const String& Name, const String& StartPath, const String& Extension, Gwen::Event::Handler* pHandler, Gwen::Event::Handler::FunctionStr fnCallback )
bool Gwen::Platform::FileSave(const String& Name, const String& StartPath, const String& Extension, Gwen::Event::Handler* pHandler, Gwen::Event::Handler::FunctionStr fnCallback)
{
char Filestring[256];
String returnstring;
char FilterBuffer[512];
{
memset( FilterBuffer, 0, sizeof(FilterBuffer) );
memcpy( FilterBuffer, Extension.c_str(), GwenUtil_Min( Extension.size(), 512 ) );
for (int i=0; i<512; i++)
memset(FilterBuffer, 0, sizeof(FilterBuffer));
memcpy(FilterBuffer, Extension.c_str(), GwenUtil_Min(Extension.size(), 512));
for (int i = 0; i < 512; i++)
{
if ( FilterBuffer[i] == '|' )
if (FilterBuffer[i] == '|')
FilterBuffer[i] = 0;
}
}
@@ -205,7 +203,7 @@ bool Gwen::Platform::FileSave( const String& Name, const String& StartPath, cons
opf.lpstrFile[0] = '\0';
opf.nMaxFile = 256;
opf.lpstrFileTitle = 0;
opf.nMaxFileTitle=50;
opf.nMaxFileTitle = 50;
opf.lpstrInitialDir = StartPath.c_str();
opf.lpstrTitle = Name.c_str();
opf.nFileOffset = 0;
@@ -216,22 +214,22 @@ bool Gwen::Platform::FileSave( const String& Name, const String& StartPath, cons
opf.Flags = (OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR) & ~OFN_ALLOWMULTISELECT;
opf.lStructSize = sizeof(OPENFILENAME);
if ( GetSaveFileNameA( &opf ) )
if (GetSaveFileNameA(&opf))
{
if ( pHandler && fnCallback )
if (pHandler && fnCallback)
{
(pHandler->*fnCallback)( opf.lpstrFile );
(pHandler->*fnCallback)(opf.lpstrFile);
}
}
else
{
if ( pHandler && fnCallback )
if (pHandler && fnCallback)
{
(pHandler->*fnCallback)( "" );
(pHandler->*fnCallback)("");
}
}
return true;
}
#endif // WIN32
#endif // WIN32