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
781 changed files with 51659 additions and 55763 deletions

View File

@@ -24,7 +24,6 @@
#include <e32std.h>
#define SDL_MUTEX_TIMEOUT -2
struct SDL_semaphore
@@ -35,18 +34,17 @@ struct SDL_semaphore
struct TInfo
{
TInfo(TInt aTime, TInt aHandle) :
iTime(aTime), iHandle(aHandle), iVal(0) {}
TInfo(TInt aTime, TInt aHandle) : iTime(aTime), iHandle(aHandle), iVal(0) {}
TInt iTime;
TInt iHandle;
TInt iVal;
};
extern TInt CreateUnique(TInt (*aFunc)(const TDesC& aName, TAny*, TAny*), TAny*, TAny*);
extern TInt CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *, TAny *);
static TBool RunThread(TAny* aInfo)
static TBool RunThread(TAny *aInfo)
{
TInfo* info = STATIC_CAST(TInfo*, aInfo);
TInfo *info = STATIC_CAST(TInfo *, aInfo);
User::After(info->iTime);
RSemaphore sema;
sema.SetHandle(info->iHandle);
@@ -55,15 +53,14 @@ static TBool RunThread(TAny* aInfo)
return 0;
}
static TInt
NewThread(const TDesC& aName, TAny* aPtr1, TAny* aPtr2)
static TInt NewThread(const TDesC &aName, TAny *aPtr1, TAny *aPtr2)
{
return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2);
}
static TInt NewSema(const TDesC& aName, TAny* aPtr1, TAny* aPtr2)
static TInt NewSema(const TDesC &aName, TAny *aPtr1, TAny *aPtr2)
{
TInt value = *((TInt*) aPtr2);
TInt value = *((TInt *)aPtr2);
return ((RSemaphore *)aPtr1)->CreateGlobal(aName, value);
}
@@ -85,14 +82,13 @@ SDL_CreateSemaphore(Uint32 initial_value)
if (status != KErrNone) {
SDL_SetError("Couldn't create semaphore");
}
SDL_semaphore* sem = new /*(ELeave)*/ SDL_semaphore;
SDL_semaphore *sem = new /*(ELeave)*/ SDL_semaphore;
sem->handle = s.Handle();
sem->count = initial_value;
return sem;
}
void
SDL_DestroySemaphore(SDL_sem * sem)
void SDL_DestroySemaphore(SDL_sem *sem)
{
if (sem != NULL) {
RSemaphore sema;
@@ -104,8 +100,7 @@ SDL_DestroySemaphore(SDL_sem * sem)
}
}
int
SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
{
if (sem == NULL) {
return SDL_InvalidParamError("sem");
@@ -117,8 +112,8 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
}
RThread thread;
TInfo* info = new (ELeave)TInfo(timeout, sem->handle);
TInt status = CreateUnique(NewThread, &thread, info);
TInfo *info = new (ELeave) TInfo(timeout, sem->handle);
TInt status = CreateUnique(NewThread, &thread, info);
if (status != KErrNone) {
return status;
@@ -135,8 +130,7 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
return info->iVal;
}
int
SDL_SemTryWait(SDL_sem *sem)
int SDL_SemTryWait(SDL_sem *sem)
{
if (sem == NULL) {
return SDL_InvalidParamError("sem");
@@ -148,14 +142,13 @@ SDL_SemTryWait(SDL_sem *sem)
return SDL_MUTEX_TIMEOUT;
}
int
SDL_SemWait(SDL_sem * sem)
int SDL_SemWait(SDL_sem *sem)
{
return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
}
Uint32
SDL_SemValue(SDL_sem * sem)
SDL_SemValue(SDL_sem *sem)
{
if (sem == NULL) {
SDL_InvalidParamError("sem");
@@ -164,8 +157,7 @@ SDL_SemValue(SDL_sem * sem)
return sem->count;
}
int
SDL_SemPost(SDL_sem * sem)
int SDL_SemPost(SDL_sem *sem)
{
if (sem == NULL) {
return SDL_InvalidParamError("sem");