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

(cherry picked from commit 5750bcb174)
This commit is contained in:
Sam Lantinga
2022-11-30 12:51:59 -08:00
parent 5c4bc807f7
commit b8d85c6939
764 changed files with 50598 additions and 54407 deletions

View File

@@ -36,30 +36,27 @@ extern "C" {
#include <Windows.h>
#endif
static void
RunThread(void *args)
static void RunThread(void *args)
{
SDL_RunThread((SDL_Thread *) args);
SDL_RunThread((SDL_Thread *)args);
}
extern "C"
int
SDL_SYS_CreateThread(SDL_Thread * thread)
extern "C" int
SDL_SYS_CreateThread(SDL_Thread *thread)
{
try {
// !!! FIXME: no way to set a thread stack size here.
std::thread cpp_thread(RunThread, thread);
thread->handle = (void *) new std::thread(std::move(cpp_thread));
thread->handle = (void *)new std::thread(std::move(cpp_thread));
return 0;
} catch (std::system_error & ex) {
} catch (std::system_error &ex) {
return SDL_SetError("unable to start a C++ thread: code=%d; %s", ex.code(), ex.what());
} catch (std::bad_alloc &) {
return SDL_OutOfMemory();
}
}
extern "C"
void
extern "C" void
SDL_SYS_SetupThread(const char *name)
{
// Make sure a thread ID gets assigned ASAP, for debugging purposes:
@@ -67,8 +64,7 @@ SDL_SYS_SetupThread(const char *name)
return;
}
extern "C"
SDL_threadID
extern "C" SDL_threadID
SDL_ThreadID(void)
{
#ifdef __WINRT__
@@ -89,8 +85,7 @@ SDL_ThreadID(void)
#endif
}
extern "C"
int
extern "C" int
SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
{
#ifdef __WINRT__
@@ -116,16 +111,15 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
#endif
}
extern "C"
void
SDL_SYS_WaitThread(SDL_Thread * thread)
extern "C" void
SDL_SYS_WaitThread(SDL_Thread *thread)
{
if ( ! thread) {
if (!thread) {
return;
}
try {
std::thread * cpp_thread = (std::thread *) thread->handle;
std::thread *cpp_thread = (std::thread *)thread->handle;
if (cpp_thread->joinable()) {
cpp_thread->join();
}
@@ -136,16 +130,15 @@ SDL_SYS_WaitThread(SDL_Thread * thread)
}
}
extern "C"
void
SDL_SYS_DetachThread(SDL_Thread * thread)
extern "C" void
SDL_SYS_DetachThread(SDL_Thread *thread)
{
if ( ! thread) {
if (!thread) {
return;
}
try {
std::thread * cpp_thread = (std::thread *) thread->handle;
std::thread *cpp_thread = (std::thread *)thread->handle;
if (cpp_thread->joinable()) {
cpp_thread->detach();
}
@@ -156,15 +149,13 @@ SDL_SYS_DetachThread(SDL_Thread * thread)
}
}
extern "C"
SDL_TLSData *
extern "C" SDL_TLSData *
SDL_SYS_GetTLSData(void)
{
return SDL_Generic_GetTLSData();
}
extern "C"
int
extern "C" int
SDL_SYS_SetTLSData(SDL_TLSData *data)
{
return SDL_Generic_SetTLSData(data);