mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-31 21:01:57 +00:00
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:
@@ -30,17 +30,15 @@ extern "C" {
|
||||
#include "SDL_sysmutex_c.h"
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
/* Create a mutex */
|
||||
extern "C"
|
||||
SDL_mutex *
|
||||
extern "C" SDL_mutex *
|
||||
SDL_CreateMutex(void)
|
||||
{
|
||||
/* Allocate and initialize the mutex */
|
||||
try {
|
||||
SDL_mutex * mutex = new SDL_mutex;
|
||||
SDL_mutex *mutex = new SDL_mutex;
|
||||
return mutex;
|
||||
} catch (std::system_error & ex) {
|
||||
} catch (std::system_error &ex) {
|
||||
SDL_SetError("unable to create a C++ mutex: code=%d; %s", ex.code(), ex.what());
|
||||
return NULL;
|
||||
} catch (std::bad_alloc &) {
|
||||
@@ -50,9 +48,8 @@ SDL_CreateMutex(void)
|
||||
}
|
||||
|
||||
/* Free the mutex */
|
||||
extern "C"
|
||||
void
|
||||
SDL_DestroyMutex(SDL_mutex * mutex)
|
||||
extern "C" void
|
||||
SDL_DestroyMutex(SDL_mutex *mutex)
|
||||
{
|
||||
if (mutex != NULL) {
|
||||
delete mutex;
|
||||
@@ -60,9 +57,8 @@ SDL_DestroyMutex(SDL_mutex * mutex)
|
||||
}
|
||||
|
||||
/* Lock the semaphore */
|
||||
extern "C"
|
||||
int
|
||||
SDL_mutexP(SDL_mutex * mutex)
|
||||
extern "C" int
|
||||
SDL_mutexP(SDL_mutex *mutex)
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
return SDL_InvalidParamError("mutex");
|
||||
@@ -71,14 +67,13 @@ SDL_mutexP(SDL_mutex * mutex)
|
||||
try {
|
||||
mutex->cpp_mutex.lock();
|
||||
return 0;
|
||||
} catch (std::system_error & ex) {
|
||||
} catch (std::system_error &ex) {
|
||||
return SDL_SetError("unable to lock a C++ mutex: code=%d; %s", ex.code(), ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
/* TryLock the mutex */
|
||||
int
|
||||
SDL_TryLockMutex(SDL_mutex * mutex)
|
||||
int SDL_TryLockMutex(SDL_mutex *mutex)
|
||||
{
|
||||
int retval = 0;
|
||||
if (mutex == NULL) {
|
||||
@@ -92,9 +87,8 @@ SDL_TryLockMutex(SDL_mutex * mutex)
|
||||
}
|
||||
|
||||
/* Unlock the mutex */
|
||||
extern "C"
|
||||
int
|
||||
SDL_mutexV(SDL_mutex * mutex)
|
||||
extern "C" int
|
||||
SDL_mutexV(SDL_mutex *mutex)
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
return SDL_InvalidParamError("mutex");
|
||||
|
||||
Reference in New Issue
Block a user