Skip to content

Fix clang-format warnings #7

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,4 @@ SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never

2 changes: 2 additions & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
utils/*

24 changes: 17 additions & 7 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
name: Clang Format Checker
on: [push]
name: clang-format Check
on: [push, pull_request]
jobs:
clang-format-checking:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
strategy:
matrix:
path:
- check: 'ef_lib'
exclude: '(utils)' # Exclude file paths containing "hello" or "world"
steps:
- uses: actions/checkout@v2
- uses: RafikFarhad/clang-format-github-action@v4
with:
sources: "ef_lib/**/*.h,ef_lib/**/*.c,ef_lib/**/*.c"
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.14.0
with:
clang-format-version: '14'
check-path: ${{ matrix.path['check'] }}
exclude-regex: ${{ matrix.path['exclude'] }}
fallback-style: 'Mozilla' # optional
109 changes: 109 additions & 0 deletions ef_lib/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4 # -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true # false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true # false
AfterControlStatement: true # false
AfterEnum: true # false
AfterFunction: true # false
AfterNamespace: true # false
AfterObjCDeclaration: true # false
AfterStruct: true # false
AfterUnion: true # false
AfterExternBlock: true # false
BeforeCatch: true # false
BeforeElse: true # false
IndentBraces: true # false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman # Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: ".*"
Priority: 1
IncludeIsMainRegex: "(Test)?$"
IndentCaseLabels: true # false
IndentPPDirectives: None
IndentWidth: 4 #2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left # Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never

2 changes: 2 additions & 0 deletions ef_lib/.clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
utils/*

41 changes: 23 additions & 18 deletions ef_lib/GameAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,44 @@
#ifdef __cplusplus

#include <bitset>
#include <string>
#include <filesystem>
#include <vector>
#include <queue>
#include <string>
#include <vector>

#endif


typedef void (*debug_log_t)(int level, const char *fmt, ...);
typedef void (*debug_log_t)(int level, const char* fmt, ...);

#define GAMEAI_MAX_BUTTONS 16
#define GAMEAI_SKIPFRAMES 4


#ifdef __cplusplus

class GameAI {
class GameAI
{
public:
virtual void Init(void * ram_ptr, int ram_size) {};
virtual void Think(bool buttons[GAMEAI_MAX_BUTTONS], int player, const void *frame_data, unsigned int frame_width, unsigned int frame_height, unsigned int frame_pitch, unsigned int pixel_format) {};
void SetShowDebug(const bool show){ this->showDebug = show; };
void SetDebugLog(debug_log_t func){debugLogFunc = func;};
virtual void Init(void* ram_ptr, int ram_size){};
virtual void Think(bool buttons[GAMEAI_MAX_BUTTONS], int player,
const void* frame_data, unsigned int frame_width,
unsigned int frame_height, unsigned int frame_pitch,
unsigned int pixel_format){};
void SetShowDebug(const bool show) { this->showDebug = show; };
void SetDebugLog(debug_log_t func) { debugLogFunc = func; };

private:
bool showDebug;
debug_log_t debugLogFunc;
bool showDebug;
debug_log_t debugLogFunc;
};

#endif

typedef void * (*create_game_ai_t)(const char *);
typedef void (*destroy_game_ai_t)(void * obj_ptr);
typedef void (*game_ai_lib_init_t)(void * obj_ptr, void * ram_ptr, int ram_size);
typedef void (*game_ai_lib_think_t)(void * obj_ptr, bool buttons[GAMEAI_MAX_BUTTONS], int player, const void *frame_data, unsigned int frame_width, unsigned int frame_height, unsigned int frame_pitch, unsigned int pixel_format);
typedef void (*game_ai_lib_set_show_debug_t)(void * obj_ptr, const bool show);
typedef void (*game_ai_lib_set_debug_log_t)(void * obj_ptr, debug_log_t func);
typedef void* (*create_game_ai_t)(const char*);
typedef void (*destroy_game_ai_t)(void* obj_ptr);
typedef void (*game_ai_lib_init_t)(void* obj_ptr, void* ram_ptr, int ram_size);
typedef void (*game_ai_lib_think_t)(
void* obj_ptr, bool buttons[GAMEAI_MAX_BUTTONS], int player,
const void* frame_data, unsigned int frame_width, unsigned int frame_height,
unsigned int frame_pitch, unsigned int pixel_format);
typedef void (*game_ai_lib_set_show_debug_t)(void* obj_ptr, const bool show);
typedef void (*game_ai_lib_set_debug_log_t)(void* obj_ptr, debug_log_t func);
Loading
Loading