Skip to content

Commit

Permalink
Cleanup formatting with clang-format. (#558)
Browse files Browse the repository at this point in the history
Bring in .clang-format file from zeldaret/mm.

Include other clang format changes.

Per review adjustments from @Kewlan and @HylianFreddy

Update clang format for short enums.

Update trickNameTable with custom formatting.
  • Loading branch information
PhlexPlexico committed Nov 22, 2022
1 parent 0fda313 commit 152ac39
Show file tree
Hide file tree
Showing 239 changed files with 39,692 additions and 35,135 deletions.
28 changes: 28 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Respectfully taken from https://github.com/zeldaret/mm/blob/master/.clang-format
# This is to ensure parity between Zelda projects.
IndentWidth: 4
Language: Cpp
UseTab: Never
ColumnLimit: 120
PointerAlignment: Left
BreakBeforeBraces: Attach
SpaceAfterCStyleCast: false
Cpp11BracedListStyle: false
IndentCaseLabels: true
BinPackArguments: true
BinPackParameters: true
AlignAfterOpenBracket: Align
AlignOperands: true
BreakBeforeTernaryOperators: true
BreakBeforeBinaryOperators: None
AllowShortBlocksOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AlignEscapedNewlines: Left
AlignTrailingComments: true
SortIncludes: false
IndentPPDirectives: BeforeHash
AlignConsecutiveAssignments: true
AllowShortEnumsOnASingleLine: false
35 changes: 35 additions & 0 deletions .github/workflows/clang_format_code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Code Linting On Push To Main and Development


on:
push:
branches:
- main
- development

jobs:
auto-formatter-on-main:
name: Auto Format Code and Commit If Any Changes
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: DoozyX/[email protected]
with:
source: "./code ./source"
extensions: 'h,cpp,c,hpp'
clangFormatVersion: 14
style: file
inplace: True

- uses: EndBug/[email protected]
with:
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
message: |
Run automatic format script as code does not match clang format rules.
Developers please rebase to avoid merge conflicts!
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 14 additions & 14 deletions code/include/3ds/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

/// System run-flags.
enum {
RUNFLAG_APTWORKAROUND = BIT(0), ///< Use APT workaround.
RUNFLAG_APTREINIT = BIT(1), ///< Reinitialize APT.
RUNFLAG_APTCHAINLOAD = BIT(2), ///< Chainload APT on return.
RUNFLAG_APTWORKAROUND = BIT(0), ///< Use APT workaround.
RUNFLAG_APTREINIT = BIT(1), ///< Reinitialize APT.
RUNFLAG_APTCHAINLOAD = BIT(2), ///< Chainload APT on return.
};

#define __service_ptr NULL
Expand All @@ -20,7 +20,7 @@ enum {
* @return Whether the application was launched from a homebrew environment.
*/
static inline bool envIsHomebrew(void) {
return __service_ptr != NULL;
return __service_ptr != NULL;
}

/**
Expand All @@ -35,42 +35,42 @@ Handle envGetHandle(const char* name);
* @return The APT app ID.
*/
static inline u32 envGetAptAppId(void) {
extern u32 __apt_appid;
return __apt_appid;
extern u32 __apt_appid;
return __apt_appid;
}

/**
* @brief Gets the size of the application heap.
* @return The application heap size.
*/
static inline u32 envGetHeapSize(void) {
extern u32 __ctru_heap_size;
return __ctru_heap_size;
extern u32 __ctru_heap_size;
return __ctru_heap_size;
}

/**
* @brief Gets the size of the linear heap.
* @return The linear heap size.
*/
static inline u32 envGetLinearHeapSize(void) {
extern u32 __ctru_linear_heap_size;
return __ctru_linear_heap_size;
extern u32 __ctru_linear_heap_size;
return __ctru_linear_heap_size;
}

/**
* @brief Gets the environment argument list.
* @return The argument list.
*/
static inline const char* envGetSystemArgList(void) {
extern const char* __system_arglist;
return __system_arglist;
extern const char* __system_arglist;
return __system_arglist;
}

/**
* @brief Gets the environment run flags.
* @return The run flags.
*/
static inline u32 envGetSystemRunFlags(void) {
extern u32 __system_runflags;
return __system_runflags;
extern u32 __system_runflags;
return __system_runflags;
}
17 changes: 9 additions & 8 deletions code/include/3ds/extdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Result extDataInit();
* @brief Mounts the extData archive. Creates it first if it does not exist yet.
* @param out Pointer to output the archive handle to.
*/
Result extDataMount(FS_Archive *out);
Result extDataMount(FS_Archive* out);

/**
* @brief Creates a file in extdata with the given size and opens it. Fails if the file already exists.
Expand All @@ -24,7 +24,7 @@ Result extDataMount(FS_Archive *out);
* @param filename The path to the file to create in the extData.
* @param filesize The size of the file to create
*/
Result extDataCreateFile(Handle *out, FS_Archive fsa, char *filename, u64 filesize);
Result extDataCreateFile(Handle* out, FS_Archive fsa, char* filename, u64 filesize);

/**
* @brief Opens a file from extData. If it does not exist yet, creates it with the given size.
Expand All @@ -33,7 +33,7 @@ Result extDataCreateFile(Handle *out, FS_Archive fsa, char *filename, u64 filesi
* @param filename The path to the file to create in the extData.
* @param filesize The size of the file to create
*/
Result extDataOpenOrCreateFile(Handle *out, FS_Archive fsa, char *filename, u64 filesize);
Result extDataOpenOrCreateFile(Handle* out, FS_Archive fsa, char* filename, u64 filesize);

/**
* @brief Reads data from an extData file.
Expand All @@ -43,7 +43,7 @@ Result extDataOpenOrCreateFile(Handle *out, FS_Archive fsa, char *filename, u64
* @param count Number of bytes to read.
* @return The number of bytes read.
*/
u32 extDataReadFile(Handle handle, void *buf_out, u64 offset, u32 count);
u32 extDataReadFile(Handle handle, void* buf_out, u64 offset, u32 count);

/**
* @brief Reads data from an extData file directly without having to open or close it manually.
Expand All @@ -54,7 +54,7 @@ u32 extDataReadFile(Handle handle, void *buf_out, u64 offset, u32 count);
* @param count Number of bytes to read.
* @return The number of bytes read. <0 indicates an error.
*/
u32 extDataReadFileDirectly(FS_Archive fsa, char *filename, void *buf_out, u64 offset, u32 count);
u32 extDataReadFileDirectly(FS_Archive fsa, char* filename, void* buf_out, u64 offset, u32 count);

/**
* @brief Writes data to an extData file.
Expand All @@ -64,7 +64,7 @@ u32 extDataReadFileDirectly(FS_Archive fsa, char *filename, void *buf_out, u64 o
* @param count Number of bytes to write.
* @return The number of bytes written. <0 indicates an error.
*/
u32 extDataWriteFile(Handle handle, void *buf, u64 offset, u32 count);
u32 extDataWriteFile(Handle handle, void* buf, u64 offset, u32 count);

/**
* @brief Reads data from an extData file directly without having to open or close it manually.
Expand All @@ -76,7 +76,7 @@ u32 extDataWriteFile(Handle handle, void *buf, u64 offset, u32 count);
* @param count Number of bytes to read.
* @return The number of bytes read. <0 indicates an error.
*/
u32 extDataWriteFileDirectly(FS_Archive fsa, char *filename, void *buf, u64 offset, u32 count);
u32 extDataWriteFileDirectly(FS_Archive fsa, char* filename, void* buf, u64 offset, u32 count);

/**
* @brief Unmounts the extData archive.
Expand All @@ -97,7 +97,8 @@ u32 extDataWriteFileDirectly(FS_Archive fsa, char *filename, void *buf, u64 offs
* @param fsa FS_Archive : The archive obtained from extDataMount.
* @param filename char* : The path to the file to open in the extData.
*/
#define extDataOpen(out, fsa, filename) FSUSER_OpenFile(out, fsa, fsMakePath(PATH_ASCII, filename), FS_OPEN_WRITE | FS_OPEN_READ, 0)
#define extDataOpen(out, fsa, filename) \
FSUSER_OpenFile(out, fsa, fsMakePath(PATH_ASCII, filename), FS_OPEN_WRITE | FS_OPEN_READ, 0)

/**
* @brief Closes a file opened from extdata.
Expand Down
Loading

0 comments on commit 152ac39

Please sign in to comment.