Skip to content

Commit fa50a30

Browse files
authored
Formatting (#19)
1 parent 2d465f0 commit fa50a30

18 files changed

+2127
-2320
lines changed

.clang-format

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
AccessModifierOffset: -2
2+
AlignAfterOpenBracket: BlockIndent
3+
AlignConsecutiveAssignments: false
4+
AlignConsecutiveDeclarations: true
5+
AlignEscapedNewlines: Left
6+
AlignOperands: DontAlign
7+
AlignTrailingComments: false
8+
AllowAllArgumentsOnNextLine: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: None
13+
AllowShortIfStatementsOnASingleLine: WithoutElse
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterDefinitionReturnType: None
16+
AlwaysBreakAfterReturnType: None
17+
AlwaysBreakBeforeMultilineStrings: true
18+
AlwaysBreakTemplateDeclarations: Yes
19+
BinPackArguments: false
20+
BinPackParameters: false
21+
BraceWrapping:
22+
AfterClass: false
23+
AfterControlStatement: false
24+
AfterEnum: false
25+
AfterFunction: false
26+
AfterNamespace: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
AfterExternBlock: false
30+
BeforeCatch: false
31+
BeforeElse: false
32+
IndentBraces: false
33+
SplitEmptyFunction: false
34+
SplitEmptyRecord: false
35+
SplitEmptyNamespace: false
36+
BreakAfterJavaFieldAnnotations: false
37+
BreakBeforeBinaryOperators: None
38+
BreakBeforeBraces: Custom
39+
BreakBeforeInheritanceComma: false
40+
BreakBeforeTernaryOperators: true
41+
BreakConstructorInitializers: BeforeComma
42+
BreakConstructorInitializersBeforeComma: false
43+
BreakStringLiterals: true
44+
ColumnLimit: 80
45+
CompactNamespaces: false
46+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
47+
ConstructorInitializerIndentWidth: 2
48+
ContinuationIndentWidth: 2
49+
Cpp11BracedListStyle: true
50+
DerivePointerAlignment: false
51+
DisableFormat: false
52+
ExperimentalAutoDetectBinPacking: false
53+
FixNamespaceComments: true
54+
IncludeBlocks: Preserve
55+
IncludeIsMainRegex: "(Test)?$"
56+
IndentCaseLabels: true
57+
IndentPPDirectives: AfterHash
58+
IndentWidth: 2
59+
IndentWrappedFunctionNames: false
60+
InsertBraces: true
61+
JavaScriptQuotes: Leave
62+
JavaScriptWrapImports: true
63+
KeepEmptyLinesAtTheStartOfBlocks: false
64+
MacroBlockBegin: ""
65+
MacroBlockEnd: ""
66+
MaxEmptyLinesToKeep: 1
67+
NamespaceIndentation: None
68+
PackConstructorInitializers: NextLine
69+
PenaltyBreakAssignment: 10
70+
PenaltyBreakBeforeFirstCallParameter: 30
71+
PenaltyBreakComment: 10
72+
PenaltyBreakFirstLessLess: 0
73+
PenaltyBreakString: 10
74+
PenaltyExcessCharacter: 400
75+
PenaltyReturnTypeOnItsOwnLine: 350
76+
PointerAlignment: Left
77+
ReflowComments: true
78+
RequiresClausePosition: OwnLine
79+
SortIncludes: false
80+
SortUsingDeclarations: true
81+
SpaceAfterCStyleCast: false
82+
SpaceAfterLogicalNot: false
83+
SpaceAfterTemplateKeyword: false
84+
SpaceBeforeAssignmentOperators: true
85+
SpaceBeforeCtorInitializerColon: true
86+
SpaceBeforeInheritanceColon: true
87+
SpaceBeforeParens: Never
88+
SpaceBeforeRangeBasedForLoopColon: true
89+
SpaceInEmptyParentheses: false
90+
SpacesBeforeTrailingComments: 1
91+
SpacesInAngles: Never
92+
SpacesInContainerLiterals: false
93+
SpacesInCStyleCastParentheses: false
94+
SpacesInParentheses: false
95+
SpacesInSquareBrackets: false
96+
SeparateDefinitionBlocks: Always
97+
Standard: Latest
98+
TabWidth: 2
99+
UseTab: ForContinuationAndIndentation

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14+
formatting-check:
15+
name: Formatting Check
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: jidicula/[email protected]
20+
with: { clang-format-version: "15" }
1421
test-windows:
1522
runs-on: windows-latest
1623
steps:

.vscode/settings.json

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
{
2-
"[starlark]": {
3-
"editor.formatOnSave": true,
4-
"editor.defaultFormatter": "BazelBuild.vscode-bazel"
5-
},
6-
"lldb.launch.sourceMap": {
7-
"/proc/self/cwd": "${workspaceFolder}"
8-
},
2+
"editor.formatOnSave": true,
93
"files.insertFinalNewline": true,
104
"files.eol": "\n",
115
"editor.insertSpaces": false,
12-
"C_Cpp.default.compileCommands": "${workspaceFolder}/compile_commands.json"
6+
"files.associations": {},
7+
"editor.wordWrap": "wordWrapColumn",
8+
"C_Cpp.autocomplete": "default",
9+
"C_Cpp.autoAddFileAssociations": false,
10+
"C_Cpp.default.compileCommands": "${workspaceFolder}/compile_commands.json",
11+
"lldb.launch.sourceMap": {
12+
"/proc/self/cwd": "${workspaceFolder}"
13+
},
14+
"[json]": {
15+
"editor.defaultFormatter": "vscode.json-language-features"
16+
},
17+
"[jsonc]": {
18+
"editor.defaultFormatter": "vscode.json-language-features"
19+
},
20+
"[markdown]": {
21+
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
22+
},
23+
"[cpp]": {
24+
"editor.detectIndentation": false,
25+
"editor.defaultFormatter": "xaver.clang-format"
26+
},
27+
"[starlark]": {
28+
"editor.defaultFormatter": "BazelBuild.vscode-bazel",
29+
"editor.insertSpaces": true,
30+
"editor.detectIndentation": false
31+
}
1332
}

ecsact/entt/detail/entt_util.hh

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,17 @@
33
#include <entt/entt.hpp>
44

55
namespace ecsact_entt_rt {
6-
inline void ensure_entity
7-
( entt::registry& registry
8-
, entt::entity entity
9-
)
10-
{
11-
if(!registry.valid(entity)) {
12-
static_cast<void>(registry.create(entity));
13-
assert(registry.valid(entity));
14-
}
15-
}
166

17-
template<typename C>
18-
bool has_entity_and_component
19-
( entt::registry& registry
20-
, entt::entity entity
21-
)
22-
{
23-
return registry.valid(entity) && registry.all_of<C>(entity);
24-
}
7+
inline void ensure_entity(entt::registry& registry, entt::entity entity) {
8+
if(!registry.valid(entity)) {
9+
static_cast<void>(registry.create(entity));
10+
assert(registry.valid(entity));
11+
}
12+
}
2513

14+
template<typename C>
15+
bool has_entity_and_component(entt::registry& registry, entt::entity entity) {
16+
return registry.valid(entity) && registry.all_of<C>(entity);
2617
}
18+
19+
} // namespace ecsact_entt_rt

ecsact/entt/detail/execution_events_collector.hh

Lines changed: 81 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -4,112 +4,93 @@
44
#include "ecsact/runtime/core.h"
55

66
namespace ecsact_entt_rt {
7-
struct execution_events_collector {
8-
const ecsact_execution_events_collector* target;
97

10-
inline bool has_init_callback() const {
11-
return target->init_callback != nullptr;
12-
}
8+
struct execution_events_collector {
9+
const ecsact_execution_events_collector* target;
1310

14-
inline bool has_update_callback() const {
15-
return target->update_callback != nullptr;
16-
}
11+
inline bool has_init_callback() const {
12+
return target->init_callback != nullptr;
13+
}
1714

18-
inline bool has_remove_callback() const {
19-
return target->remove_callback != nullptr;
20-
}
15+
inline bool has_update_callback() const {
16+
return target->update_callback != nullptr;
17+
}
2118

22-
template<typename C>
23-
requires(!std::is_empty_v<C>)
24-
void invoke_init_callback
25-
( ecsact_entity_id entity
26-
, const C& component
27-
)
28-
{
29-
target->init_callback(
30-
ECSACT_EVENT_INIT_COMPONENT,
31-
static_cast<ecsact_entity_id>(entity),
32-
static_cast<ecsact_component_id>(C::id),
33-
static_cast<const void*>(&component),
34-
target->init_callback_user_data
35-
);
36-
}
19+
inline bool has_remove_callback() const {
20+
return target->remove_callback != nullptr;
21+
}
3722

38-
template<typename C>
39-
requires(std::is_empty_v<C>)
40-
void invoke_init_callback
41-
( ecsact_entity_id entity
42-
)
43-
{
44-
target->init_callback(
45-
ECSACT_EVENT_INIT_COMPONENT,
46-
static_cast<ecsact_entity_id>(entity),
47-
static_cast<ecsact_component_id>(C::id),
48-
nullptr,
49-
target->init_callback_user_data
50-
);
51-
}
23+
template<typename C>
24+
requires(!std::is_empty_v<C>)
25+
void invoke_init_callback(ecsact_entity_id entity, const C& component) {
26+
target->init_callback(
27+
ECSACT_EVENT_INIT_COMPONENT,
28+
static_cast<ecsact_entity_id>(entity),
29+
static_cast<ecsact_component_id>(C::id),
30+
static_cast<const void*>(&component),
31+
target->init_callback_user_data
32+
);
33+
}
5234

53-
template<typename C>
54-
requires(!std::is_empty_v<C>)
55-
void invoke_update_callback
56-
( ecsact_entity_id entity
57-
, const C& component
58-
)
59-
{
60-
target->update_callback(
61-
ECSACT_EVENT_UPDATE_COMPONENT,
62-
static_cast<ecsact_entity_id>(entity),
63-
static_cast<ecsact_component_id>(C::id),
64-
static_cast<const void*>(&component),
65-
target->update_callback_user_data
66-
);
67-
}
35+
template<typename C>
36+
requires(std::is_empty_v<C>)
37+
void invoke_init_callback(ecsact_entity_id entity) {
38+
target->init_callback(
39+
ECSACT_EVENT_INIT_COMPONENT,
40+
static_cast<ecsact_entity_id>(entity),
41+
static_cast<ecsact_component_id>(C::id),
42+
nullptr,
43+
target->init_callback_user_data
44+
);
45+
}
6846

69-
template<typename C>
70-
requires(std::is_empty_v<C>)
71-
void invoke_update_callback
72-
( ecsact_entity_id entity
73-
)
74-
{
75-
target->update_callback(
76-
ECSACT_EVENT_UPDATE_COMPONENT,
77-
static_cast<ecsact_entity_id>(entity),
78-
static_cast<ecsact_component_id>(C::id),
79-
nullptr,
80-
target->update_callback_user_data
81-
);
82-
}
47+
template<typename C>
48+
requires(!std::is_empty_v<C>)
49+
void invoke_update_callback(ecsact_entity_id entity, const C& component) {
50+
target->update_callback(
51+
ECSACT_EVENT_UPDATE_COMPONENT,
52+
static_cast<ecsact_entity_id>(entity),
53+
static_cast<ecsact_component_id>(C::id),
54+
static_cast<const void*>(&component),
55+
target->update_callback_user_data
56+
);
57+
}
8358

84-
template<typename C>
85-
requires(!std::is_empty_v<C>)
86-
void invoke_remove_callback
87-
( ecsact_entity_id entity
88-
, const C& component
89-
)
90-
{
91-
target->remove_callback(
92-
ECSACT_EVENT_REMOVE_COMPONENT,
93-
static_cast<ecsact_entity_id>(entity),
94-
static_cast<ecsact_component_id>(C::id),
95-
static_cast<const void*>(&component),
96-
target->remove_callback_user_data
97-
);
98-
}
59+
template<typename C>
60+
requires(std::is_empty_v<C>)
61+
void invoke_update_callback(ecsact_entity_id entity) {
62+
target->update_callback(
63+
ECSACT_EVENT_UPDATE_COMPONENT,
64+
static_cast<ecsact_entity_id>(entity),
65+
static_cast<ecsact_component_id>(C::id),
66+
nullptr,
67+
target->update_callback_user_data
68+
);
69+
}
9970

100-
template<typename C>
101-
requires(std::is_empty_v<C>)
102-
void invoke_remove_callback
103-
( ecsact_entity_id entity
104-
)
105-
{
106-
target->remove_callback(
107-
ECSACT_EVENT_REMOVE_COMPONENT,
108-
static_cast<ecsact_entity_id>(entity),
109-
static_cast<ecsact_component_id>(C::id),
110-
nullptr,
111-
target->remove_callback_user_data
112-
);
113-
}
114-
};
115-
}
71+
template<typename C>
72+
requires(!std::is_empty_v<C>)
73+
void invoke_remove_callback(ecsact_entity_id entity, const C& component) {
74+
target->remove_callback(
75+
ECSACT_EVENT_REMOVE_COMPONENT,
76+
static_cast<ecsact_entity_id>(entity),
77+
static_cast<ecsact_component_id>(C::id),
78+
static_cast<const void*>(&component),
79+
target->remove_callback_user_data
80+
);
81+
}
82+
83+
template<typename C>
84+
requires(std::is_empty_v<C>)
85+
void invoke_remove_callback(ecsact_entity_id entity) {
86+
target->remove_callback(
87+
ECSACT_EVENT_REMOVE_COMPONENT,
88+
static_cast<ecsact_entity_id>(entity),
89+
static_cast<ecsact_component_id>(C::id),
90+
nullptr,
91+
target->remove_callback_user_data
92+
);
93+
}
94+
};
95+
96+
} // namespace ecsact_entt_rt

0 commit comments

Comments
 (0)