Update for SDL3 coding style (#6717)

I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
This commit is contained in:
Sam Lantinga 2022-11-30 12:51:59 -08:00 committed by GitHub
parent 14b902faca
commit 5750bcb174
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
781 changed files with 51659 additions and 55763 deletions

View file

@ -21,7 +21,7 @@
#include "SDL_internal.h"
/* TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all
*/
*/
#ifdef __WINRT__
@ -39,55 +39,55 @@ extern "C" const wchar_t *
SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
{
switch (pathType) {
case SDL_WINRT_PATH_INSTALLED_LOCATION:
{
static wstring path;
if (path.empty()) {
case SDL_WINRT_PATH_INSTALLED_LOCATION:
{
static wstring path;
if (path.empty()) {
#if defined(NTDDI_WIN10_19H1) && (NTDDI_VERSION >= NTDDI_WIN10_19H1) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) /* Only PC supports mods */
/* Windows 1903 supports mods, via the EffectiveLocation API */
if (Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8, 0)) {
path = Windows::ApplicationModel::Package::Current->EffectiveLocation->Path->Data();
} else {
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
}
#else
/* Windows 1903 supports mods, via the EffectiveLocation API */
if (Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8, 0)) {
path = Windows::ApplicationModel::Package::Current->EffectiveLocation->Path->Data();
} else {
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
}
#else
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
#endif
}
return path.c_str();
}
return path.c_str();
}
case SDL_WINRT_PATH_LOCAL_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->LocalFolder->Path->Data();
}
return path.c_str();
case SDL_WINRT_PATH_LOCAL_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->LocalFolder->Path->Data();
}
return path.c_str();
}
#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8)
case SDL_WINRT_PATH_ROAMING_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->RoamingFolder->Path->Data();
}
return path.c_str();
case SDL_WINRT_PATH_ROAMING_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->RoamingFolder->Path->Data();
}
return path.c_str();
}
case SDL_WINRT_PATH_TEMP_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->TemporaryFolder->Path->Data();
}
return path.c_str();
case SDL_WINRT_PATH_TEMP_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->TemporaryFolder->Path->Data();
}
return path.c_str();
}
#endif
default:
break;
default:
break;
}
SDL_Unsupported();
@ -105,12 +105,12 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
return searchResult->second.c_str();
}
const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
const wchar_t *ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
if (ucs2Path == NULL) {
return NULL;
}
char * utf8Path = WIN_StringToUTF8(ucs2Path);
char *utf8Path = WIN_StringToUTF8(ucs2Path);
utf8Paths[pathType] = utf8Path;
SDL_free(utf8Path);
return utf8Paths[pathType].c_str();
@ -119,9 +119,9 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
extern "C" char *
SDL_GetBasePath(void)
{
const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION);
const char *srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION);
size_t destPathLen;
char * destPath = NULL;
char *destPath = NULL;
if (srcPath == NULL) {
SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
@ -129,7 +129,7 @@ SDL_GetBasePath(void)
}
destPathLen = SDL_strlen(srcPath) + 2;
destPath = (char *) SDL_malloc(destPathLen);
destPath = (char *)SDL_malloc(destPathLen);
if (destPath == NULL) {
SDL_OutOfMemory();
return NULL;
@ -148,11 +148,11 @@ SDL_GetPrefPath(const char *org, const char *app)
* without violating Microsoft's app-store requirements.
*/
const WCHAR * srcPath = NULL;
const WCHAR *srcPath = NULL;
WCHAR path[MAX_PATH];
char *retval = NULL;
WCHAR* worg = NULL;
WCHAR* wapp = NULL;
WCHAR *worg = NULL;
WCHAR *wapp = NULL;
size_t new_wpath_len = 0;
BOOL api_result = FALSE;