Add .clang-format

Co-authored-by: Maschell <Maschell@gmx.de>
This commit is contained in:
GaryOderNichts 2024-10-02 21:12:23 +02:00 committed by Dave Murphy
parent fa650f92c4
commit 2b66122422
12 changed files with 144 additions and 42 deletions

90
.clang-format Normal file
View File

@ -0,0 +1,90 @@
---
BasedOnStyle: LLVM
AccessModifierOffset: -3
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: AcrossEmptyLinesAndComments
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: All
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- asm
- WUT_FORMAT_PRINTF
BinPackParameters: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterExternBlock: false
AfterStruct: true
AfterFunction: true
AfterNamespace: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ConstructorInitializerIndentWidth: 3
ContinuationIndentWidth: 3
FixNamespaceComments: true
IncludeBlocks: Preserve
IncludeCategories:
# Include wut headers first
- Regex: '^[<|"]wut'
Priority: 1
- Regex: '^<'
Priority: 2
- Regex: '^"'
Priority: 3
IndentAccessModifiers: false
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 3
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PointerAlignment: Right
ReflowComments: false
SeparateDefinitionBlocks: Leave
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
TypenameMacros:
- BOOL
- RPLWRAP
UseTab: Never

View File

@ -11,8 +11,10 @@
extern "C" { extern "C" {
#endif #endif
// clang-format off
void void
RPLWRAP(exit)(int code); RPLWRAP(exit)(int code);
// clang-format on
void void
_Exit(int code); _Exit(int code);

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <wut.h>
#include "wut.h"
#include "filesystem.h" #include "filesystem.h"
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -249,9 +249,11 @@ ACPGetTitleIdOfMainApplication(ACPTitleId* titleId);
* @param metaXml must be aligned to 0x40 * @param metaXml must be aligned to 0x40
* @return ACP_RESULT_SUCCESS on success * @return ACP_RESULT_SUCCESS on success
*/ */
// clang-format off
ACPResult ACPResult
RPLWRAP(ACPGetTitleMetaXml)(ACPTitleId titleId, RPLWRAP(ACPGetTitleMetaXml)(ACPTitleId titleId,
ACPMetaXml *metaXml); ACPMetaXml *metaXml);
// clang-format on
/** /**
* Gets the MetaXML for a given title id * Gets the MetaXML for a given title id
@ -269,10 +271,12 @@ ACPGetTitleMetaXml(ACPTitleId titleId,
return RPLWRAP(ACPGetTitleMetaXml)(titleId, metaXml); return RPLWRAP(ACPGetTitleMetaXml)(titleId, metaXml);
} }
// clang-format off
ACPResult ACPResult
RPLWRAP(ACPGetTitleSaveMetaXml)(uint64_t titleId, RPLWRAP(ACPGetTitleSaveMetaXml)(uint64_t titleId,
ACPMetaXml* metaXml, ACPMetaXml* metaXml,
ACPDeviceType deviceType); ACPDeviceType deviceType);
// clang-format on
/** /**
* Gets the save dir MetaXML for a given title id * Gets the save dir MetaXML for a given title id

View File

@ -176,10 +176,12 @@ HPADShutdown(void);
* \return * \return
* The amount of buffers read or a negative value on error. * The amount of buffers read or a negative value on error.
*/ */
// clang-format off
int32_t int32_t
RPLWRAP(HPADRead)(HPADChan chan, RPLWRAP(HPADRead)(HPADChan chan,
HPADStatus *buffers, HPADStatus *buffers,
int32_t count); int32_t count);
// clang-format on
/** /**
* Reads status buffers from a specified HPAD channel. * Reads status buffers from a specified HPAD channel.

View File

@ -57,11 +57,13 @@ somemopt(SOMemOptRequest request,
uint32_t size, uint32_t size,
SOMemOptFlags flags); SOMemOptFlags flags);
// clang-format off
int int
RPLWRAP(somemopt)(SOMemOptRequest request, RPLWRAP(somemopt)(SOMemOptRequest request,
void *buffer, void *buffer,
uint32_t size, uint32_t size,
SOMemOptFlags flags); SOMemOptFlags flags);
// clang-format on
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -11,6 +11,8 @@
extern "C" { extern "C" {
#endif #endif
// clang-format off
struct hostent * struct hostent *
RPLWRAP(gethostbyaddr)(const void *addr, RPLWRAP(gethostbyaddr)(const void *addr,
size_t len, size_t len,
@ -50,6 +52,8 @@ RPLWRAP(get_h_errno)(void);
const char * const char *
RPLWRAP(gai_strerror)(int ecode); RPLWRAP(gai_strerror)(int ecode);
// clang-format on
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -47,6 +47,8 @@ socket_lib_init();
void void
socket_lib_finish(); socket_lib_finish();
// clang-format off
int int
RPLWRAP(accept)(int sockfd, RPLWRAP(accept)(int sockfd,
struct sockaddr *addr, struct sockaddr *addr,
@ -151,6 +153,8 @@ RPLWRAP(inet_pton)(int af,
int int
RPLWRAP(socketlasterr)(); RPLWRAP(socketlasterr)();
// clang-format on
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include <wut.h> #include <wut.h>
#include <wut_rplwrap.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>

View File

@ -1,35 +1,33 @@
#include "devoptab_fsa.h" #include "devoptab_fsa.h"
#include <cstdio> #include <cstdio>
static devoptab_t static devoptab_t __wut_fsa_devoptab = {
__wut_fsa_devoptab = .name = "fs",
{ .structSize = sizeof(__wut_fsa_file_t),
.name = "fs", .open_r = __wut_fsa_open,
.structSize = sizeof(__wut_fsa_file_t), .close_r = __wut_fsa_close,
.open_r = __wut_fsa_open, .write_r = __wut_fsa_write,
.close_r = __wut_fsa_close, .read_r = __wut_fsa_read,
.write_r = __wut_fsa_write, .seek_r = __wut_fsa_seek,
.read_r = __wut_fsa_read, .fstat_r = __wut_fsa_fstat,
.seek_r = __wut_fsa_seek, .stat_r = __wut_fsa_stat,
.fstat_r = __wut_fsa_fstat, .unlink_r = __wut_fsa_unlink,
.stat_r = __wut_fsa_stat, .chdir_r = __wut_fsa_chdir,
.unlink_r = __wut_fsa_unlink, .rename_r = __wut_fsa_rename,
.chdir_r = __wut_fsa_chdir, .mkdir_r = __wut_fsa_mkdir,
.rename_r = __wut_fsa_rename, .dirStateSize = sizeof(__wut_fsa_dir_t),
.mkdir_r = __wut_fsa_mkdir, .diropen_r = __wut_fsa_diropen,
.dirStateSize = sizeof(__wut_fsa_dir_t), .dirreset_r = __wut_fsa_dirreset,
.diropen_r = __wut_fsa_diropen, .dirnext_r = __wut_fsa_dirnext,
.dirreset_r = __wut_fsa_dirreset, .dirclose_r = __wut_fsa_dirclose,
.dirnext_r = __wut_fsa_dirnext, .statvfs_r = __wut_fsa_statvfs,
.dirclose_r = __wut_fsa_dirclose, .ftruncate_r = __wut_fsa_ftruncate,
.statvfs_r = __wut_fsa_statvfs, .fsync_r = __wut_fsa_fsync,
.ftruncate_r = __wut_fsa_ftruncate, .deviceData = nullptr,
.fsync_r = __wut_fsa_fsync, .chmod_r = __wut_fsa_chmod,
.deviceData = nullptr, .rmdir_r = __wut_fsa_rmdir,
.chmod_r = __wut_fsa_chmod, .lstat_r = __wut_fsa_stat,
.rmdir_r = __wut_fsa_rmdir, };
.lstat_r = __wut_fsa_stat,
};
__wut_fsa_device_t __wut_fsa_device_data = {}; __wut_fsa_device_t __wut_fsa_device_data = {};

View File

@ -5,9 +5,7 @@
int h_errno; int h_errno;
static devoptab_t static devoptab_t __wut_socket_devoptab = {
__wut_socket_devoptab =
{
.name = "soc", .name = "soc",
.structSize = sizeof(int), .structSize = sizeof(int),
.open_r = __wut_socket_open, .open_r = __wut_socket_open,
@ -16,9 +14,7 @@ __wut_socket_devoptab =
.read_r = __wut_socket_read, .read_r = __wut_socket_read,
}; };
static unsigned char static unsigned char __wut_nsysnet_error_code_map[] = {
__wut_nsysnet_error_code_map[] =
{
0, // 0 0, // 0
ENOBUFS, ENOBUFS,
ETIMEDOUT, ETIMEDOUT,

View File

@ -18,18 +18,20 @@
#include <coreinit/thread.h> #include <coreinit/thread.h>
#include <coreinit/time.h> #include <coreinit/time.h>
static const float sPositionData[] = static const float sPositionData[] = {
{ // clang-format off
1.0f, -1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f,
// clang-format on
}; };
static const float sColourData[] = static const float sColourData[] = {
{ // clang-format off
1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
// clang-format on
}; };
int main(int argc, char **argv) int main(int argc, char **argv)