Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code format #14

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Clang Format Check

on: [push, pull_request]

jobs:
format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all tags and branches

- name: Install clang-format
run: sudo apt-get install -y clang-format

- name: Check code formatting
run: |
cd src
# Find all C/C++ files, format them and check for differences
find . -regex '.*\.\(cpp\|hpp\|c\|h\)' | while read file; do
clang-format -style=file "$file" | diff -u "$file" -
if [ $? -ne 0 ]; then
echo "::error file=$file::File is not formatted correctly"
FORMAT_STATUS=1
fi
done
# Fail the job if any files were not formatted correctly
if [ $FORMAT_STATUS -ne 0 ]; then
exit 1
fi
113 changes: 113 additions & 0 deletions src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 4
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Never
...

8 changes: 4 additions & 4 deletions src/ahidsound.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern void ahi_updatesound(int force);
extern uae_u32 REGPARAM2 ahi_demux (TrapContext*);
extern int ahi_open_sound (void);
extern void ahi_close_sound (void);
extern void ahi_finish_sound_buffer (void);
extern uae_u32 REGPARAM2 ahi_demux(TrapContext*);
extern int ahi_open_sound(void);
extern void ahi_close_sound(void);
extern void ahi_finish_sound_buffer(void);

extern int ahi_on;
extern int ahi_pollrate;
6 changes: 3 additions & 3 deletions src/ahidsound_new.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
extern void init_ahi_v2 (void);
extern void free_ahi_v2 (void);
extern void ahi2_pause_sound (int);
extern void init_ahi_v2(void);
extern void free_ahi_v2(void);
extern void ahi2_pause_sound(int);
6 changes: 3 additions & 3 deletions src/avioutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern TCHAR avioutput_filename_auto[MAX_DPATH];
extern TCHAR avioutput_filename_inuse[MAX_DPATH];

extern void AVIOutput_Toggle(int mode, bool immediate);
extern bool AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize);
extern bool AVIOutput_WriteAudio(uae_u8* sndbuffer, int sndbufsize);
extern int AVIOutput_ChooseAudioCodec(HWND hwnd, TCHAR*, int);
extern int AVIOutput_GetAudioCodec(TCHAR*, int);
extern int AVIOutput_ChooseVideoCodec(HWND hwnd, TCHAR*, int);
Expand All @@ -31,11 +31,11 @@ extern void AVIOutput_End(void);
extern void AVIOutput_Begin(bool);
extern void AVIOutput_Release(void);
extern void AVIOutput_Initialize(void);
extern void AVIOutput_RGBinfo(int,int,int,int,int,int,int,int);
extern void AVIOutput_RGBinfo(int, int, int, int, int, int, int, int);
extern void AVIOutput_GetSettings(void);
extern void AVIOutput_SetSettings(void);

extern void Screenshot_RGBinfo(int,int,int,int,int,int,int,int);
extern void Screenshot_RGBinfo(int, int, int, int, int, int, int, int);

#define AVIAUDIO_AVI 1
#define AVIAUDIO_WAV 2
Loading