diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..da339488 --- /dev/null +++ b/.clang-format @@ -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 diff --git a/include/coreinit/exit.h b/include/coreinit/exit.h index 5dc00879..f57bec62 100644 --- a/include/coreinit/exit.h +++ b/include/coreinit/exit.h @@ -11,8 +11,10 @@ extern "C" { #endif +// clang-format off void RPLWRAP(exit)(int code); +// clang-format on void _Exit(int code); diff --git a/include/coreinit/filesystem_fsa.h b/include/coreinit/filesystem_fsa.h index 52c65bd7..fd05e2af 100644 --- a/include/coreinit/filesystem_fsa.h +++ b/include/coreinit/filesystem_fsa.h @@ -1,6 +1,5 @@ #pragma once - -#include "wut.h" +#include #include "filesystem.h" #ifdef __cplusplus diff --git a/include/nn/acp/title.h b/include/nn/acp/title.h index 26770c40..3be9db0e 100644 --- a/include/nn/acp/title.h +++ b/include/nn/acp/title.h @@ -249,9 +249,11 @@ ACPGetTitleIdOfMainApplication(ACPTitleId* titleId); * @param metaXml must be aligned to 0x40 * @return ACP_RESULT_SUCCESS on success */ +// clang-format off ACPResult RPLWRAP(ACPGetTitleMetaXml)(ACPTitleId titleId, ACPMetaXml *metaXml); +// clang-format on /** * Gets the MetaXML for a given title id @@ -269,10 +271,12 @@ ACPGetTitleMetaXml(ACPTitleId titleId, return RPLWRAP(ACPGetTitleMetaXml)(titleId, metaXml); } +// clang-format off ACPResult RPLWRAP(ACPGetTitleSaveMetaXml)(uint64_t titleId, ACPMetaXml* metaXml, ACPDeviceType deviceType); +// clang-format on /** * Gets the save dir MetaXML for a given title id diff --git a/include/nn/hpad/hpad.h b/include/nn/hpad/hpad.h index 0a2936ce..9dfc6010 100644 --- a/include/nn/hpad/hpad.h +++ b/include/nn/hpad/hpad.h @@ -176,10 +176,12 @@ HPADShutdown(void); * \return * The amount of buffers read or a negative value on error. */ +// clang-format off int32_t RPLWRAP(HPADRead)(HPADChan chan, HPADStatus *buffers, int32_t count); +// clang-format on /** * Reads status buffers from a specified HPAD channel. diff --git a/include/nn/nets2/somemopt.h b/include/nn/nets2/somemopt.h index 7105c3eb..18d9f900 100644 --- a/include/nn/nets2/somemopt.h +++ b/include/nn/nets2/somemopt.h @@ -57,11 +57,13 @@ somemopt(SOMemOptRequest request, uint32_t size, SOMemOptFlags flags); +// clang-format off int RPLWRAP(somemopt)(SOMemOptRequest request, void *buffer, uint32_t size, SOMemOptFlags flags); +// clang-format on #ifdef __cplusplus } diff --git a/include/nsysnet/_netdb.h b/include/nsysnet/_netdb.h index d0f406f4..d5f1e8a5 100644 --- a/include/nsysnet/_netdb.h +++ b/include/nsysnet/_netdb.h @@ -11,6 +11,8 @@ extern "C" { #endif +// clang-format off + struct hostent * RPLWRAP(gethostbyaddr)(const void *addr, size_t len, @@ -50,6 +52,8 @@ RPLWRAP(get_h_errno)(void); const char * RPLWRAP(gai_strerror)(int ecode); +// clang-format on + #ifdef __cplusplus } #endif diff --git a/include/nsysnet/_socket.h b/include/nsysnet/_socket.h index 03ac0383..cde9cf70 100644 --- a/include/nsysnet/_socket.h +++ b/include/nsysnet/_socket.h @@ -47,6 +47,8 @@ socket_lib_init(); void socket_lib_finish(); +// clang-format off + int RPLWRAP(accept)(int sockfd, struct sockaddr *addr, @@ -151,6 +153,8 @@ RPLWRAP(inet_pton)(int af, int RPLWRAP(socketlasterr)(); +// clang-format on + #ifdef __cplusplus } #endif diff --git a/include/nsysnet/netconfig.h b/include/nsysnet/netconfig.h index b29d6df8..1e5b83d9 100644 --- a/include/nsysnet/netconfig.h +++ b/include/nsysnet/netconfig.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include #include diff --git a/libraries/wutdevoptab/devoptab_fsa.cpp b/libraries/wutdevoptab/devoptab_fsa.cpp index 97bd9445..0f467edc 100644 --- a/libraries/wutdevoptab/devoptab_fsa.cpp +++ b/libraries/wutdevoptab/devoptab_fsa.cpp @@ -1,35 +1,33 @@ #include "devoptab_fsa.h" #include -static devoptab_t - __wut_fsa_devoptab = - { - .name = "fs", - .structSize = sizeof(__wut_fsa_file_t), - .open_r = __wut_fsa_open, - .close_r = __wut_fsa_close, - .write_r = __wut_fsa_write, - .read_r = __wut_fsa_read, - .seek_r = __wut_fsa_seek, - .fstat_r = __wut_fsa_fstat, - .stat_r = __wut_fsa_stat, - .unlink_r = __wut_fsa_unlink, - .chdir_r = __wut_fsa_chdir, - .rename_r = __wut_fsa_rename, - .mkdir_r = __wut_fsa_mkdir, - .dirStateSize = sizeof(__wut_fsa_dir_t), - .diropen_r = __wut_fsa_diropen, - .dirreset_r = __wut_fsa_dirreset, - .dirnext_r = __wut_fsa_dirnext, - .dirclose_r = __wut_fsa_dirclose, - .statvfs_r = __wut_fsa_statvfs, - .ftruncate_r = __wut_fsa_ftruncate, - .fsync_r = __wut_fsa_fsync, - .deviceData = nullptr, - .chmod_r = __wut_fsa_chmod, - .rmdir_r = __wut_fsa_rmdir, - .lstat_r = __wut_fsa_stat, - }; +static devoptab_t __wut_fsa_devoptab = { + .name = "fs", + .structSize = sizeof(__wut_fsa_file_t), + .open_r = __wut_fsa_open, + .close_r = __wut_fsa_close, + .write_r = __wut_fsa_write, + .read_r = __wut_fsa_read, + .seek_r = __wut_fsa_seek, + .fstat_r = __wut_fsa_fstat, + .stat_r = __wut_fsa_stat, + .unlink_r = __wut_fsa_unlink, + .chdir_r = __wut_fsa_chdir, + .rename_r = __wut_fsa_rename, + .mkdir_r = __wut_fsa_mkdir, + .dirStateSize = sizeof(__wut_fsa_dir_t), + .diropen_r = __wut_fsa_diropen, + .dirreset_r = __wut_fsa_dirreset, + .dirnext_r = __wut_fsa_dirnext, + .dirclose_r = __wut_fsa_dirclose, + .statvfs_r = __wut_fsa_statvfs, + .ftruncate_r = __wut_fsa_ftruncate, + .fsync_r = __wut_fsa_fsync, + .deviceData = nullptr, + .chmod_r = __wut_fsa_chmod, + .rmdir_r = __wut_fsa_rmdir, + .lstat_r = __wut_fsa_stat, +}; __wut_fsa_device_t __wut_fsa_device_data = {}; diff --git a/libraries/wutsocket/wut_socket_common.c b/libraries/wutsocket/wut_socket_common.c index 9e630ec3..a0232fbc 100644 --- a/libraries/wutsocket/wut_socket_common.c +++ b/libraries/wutsocket/wut_socket_common.c @@ -5,9 +5,7 @@ int h_errno; -static devoptab_t -__wut_socket_devoptab = -{ +static devoptab_t __wut_socket_devoptab = { .name = "soc", .structSize = sizeof(int), .open_r = __wut_socket_open, @@ -16,9 +14,7 @@ __wut_socket_devoptab = .read_r = __wut_socket_read, }; -static unsigned char -__wut_nsysnet_error_code_map[] = -{ +static unsigned char __wut_nsysnet_error_code_map[] = { 0, // 0 ENOBUFS, ETIMEDOUT, diff --git a/samples/cmake/gx2_triangle/main.c b/samples/cmake/gx2_triangle/main.c index 5f43a4d6..001c7683 100644 --- a/samples/cmake/gx2_triangle/main.c +++ b/samples/cmake/gx2_triangle/main.c @@ -18,18 +18,20 @@ #include #include -static const float sPositionData[] = -{ +static const float sPositionData[] = { +// clang-format off 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.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, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, +// clang-format on }; int main(int argc, char **argv)