Skip to content

Commit 641cf0f

Browse files
committed
Apply clang format
1 parent 694652d commit 641cf0f

File tree

7 files changed

+296
-152
lines changed

7 files changed

+296
-152
lines changed

.clang-format

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveMacros: true
7+
AlignConsecutiveAssignments: true
8+
AlignConsecutiveBitFields: true
9+
AlignConsecutiveDeclarations: true
10+
AlignEscapedNewlines: Right
11+
AlignOperands: Align
12+
AlignTrailingComments: true
13+
AllowAllArgumentsOnNextLine: true
14+
AllowAllConstructorInitializersOnNextLine: true
15+
AllowAllParametersOfDeclarationOnNextLine: true
16+
AllowShortEnumsOnASingleLine: true
17+
AllowShortBlocksOnASingleLine: Never
18+
AllowShortCaseLabelsOnASingleLine: true
19+
AllowShortFunctionsOnASingleLine: All
20+
AllowShortLambdasOnASingleLine: All
21+
AllowShortIfStatementsOnASingleLine: Never
22+
AllowShortLoopsOnASingleLine: false
23+
AlwaysBreakAfterDefinitionReturnType: None
24+
AlwaysBreakAfterReturnType: None
25+
AlwaysBreakBeforeMultilineStrings: false
26+
AlwaysBreakTemplateDeclarations: MultiLine
27+
BinPackArguments: true
28+
BinPackParameters: true
29+
BraceWrapping:
30+
AfterCaseLabel: false
31+
AfterClass: false
32+
AfterControlStatement: Never
33+
AfterEnum: false
34+
AfterFunction: false
35+
AfterNamespace: false
36+
AfterObjCDeclaration: false
37+
AfterStruct: false
38+
AfterUnion: false
39+
AfterExternBlock: false
40+
BeforeCatch: false
41+
BeforeElse: false
42+
BeforeLambdaBody: false
43+
BeforeWhile: false
44+
IndentBraces: false
45+
SplitEmptyFunction: true
46+
SplitEmptyRecord: true
47+
SplitEmptyNamespace: true
48+
BreakBeforeBinaryOperators: None
49+
BreakBeforeBraces: Attach
50+
BreakBeforeInheritanceComma: false
51+
BreakInheritanceList: BeforeColon
52+
BreakBeforeTernaryOperators: true
53+
BreakConstructorInitializersBeforeComma: false
54+
BreakConstructorInitializers: BeforeColon
55+
BreakAfterJavaFieldAnnotations: false
56+
BreakStringLiterals: true
57+
ColumnLimit: 120
58+
CommentPragmas: '^ IWYU pragma:'
59+
CompactNamespaces: false
60+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
61+
ConstructorInitializerIndentWidth: 4
62+
ContinuationIndentWidth: 4
63+
Cpp11BracedListStyle: true
64+
DeriveLineEnding: true
65+
DerivePointerAlignment: false
66+
DisableFormat: false
67+
ExperimentalAutoDetectBinPacking: false
68+
FixNamespaceComments: true
69+
ForEachMacros:
70+
- foreach
71+
- Q_FOREACH
72+
- BOOST_FOREACH
73+
IncludeBlocks: Preserve
74+
IncludeCategories:
75+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
76+
Priority: 2
77+
SortPriority: 0
78+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
79+
Priority: 3
80+
SortPriority: 0
81+
- Regex: '.*'
82+
Priority: 1
83+
SortPriority: 0
84+
IncludeIsMainRegex: '(Test)?$'
85+
IncludeIsMainSourceRegex: ''
86+
IndentCaseLabels: true
87+
IndentCaseBlocks: false
88+
IndentGotoLabels: true
89+
IndentPPDirectives: None
90+
IndentExternBlock: AfterExternBlock
91+
IndentWidth: 4
92+
IndentWrappedFunctionNames: false
93+
InsertTrailingCommas: None
94+
JavaScriptQuotes: Leave
95+
JavaScriptWrapImports: true
96+
KeepEmptyLinesAtTheStartOfBlocks: true
97+
MacroBlockBegin: ''
98+
MacroBlockEnd: ''
99+
MaxEmptyLinesToKeep: 1
100+
NamespaceIndentation: None
101+
ObjCBinPackProtocolList: Auto
102+
ObjCBlockIndentWidth: 2
103+
ObjCBreakBeforeNestedBlockParam: true
104+
ObjCSpaceAfterProperty: false
105+
ObjCSpaceBeforeProtocolList: true
106+
PenaltyBreakAssignment: 2
107+
PenaltyBreakBeforeFirstCallParameter: 19
108+
PenaltyBreakComment: 300
109+
PenaltyBreakFirstLessLess: 120
110+
PenaltyBreakString: 1000
111+
PenaltyBreakTemplateDeclaration: 10
112+
PenaltyExcessCharacter: 1000000
113+
PenaltyReturnTypeOnItsOwnLine: 60
114+
PointerAlignment: Right
115+
ReflowComments: true
116+
SortIncludes: true
117+
SortUsingDeclarations: true
118+
SpaceAfterCStyleCast: false
119+
SpaceAfterLogicalNot: false
120+
SpaceAfterTemplateKeyword: true
121+
SpaceBeforeAssignmentOperators: true
122+
SpaceBeforeCpp11BracedList: false
123+
SpaceBeforeCtorInitializerColon: true
124+
SpaceBeforeInheritanceColon: true
125+
SpaceBeforeParens: ControlStatements
126+
SpaceBeforeRangeBasedForLoopColon: true
127+
SpaceInEmptyBlock: false
128+
SpaceInEmptyParentheses: false
129+
SpacesBeforeTrailingComments: 1
130+
SpacesInAngles: false
131+
SpacesInConditionalStatement: false
132+
SpacesInContainerLiterals: true
133+
SpacesInCStyleCastParentheses: false
134+
SpacesInParentheses: false
135+
SpacesInSquareBrackets: false
136+
SpaceBeforeSquareBrackets: false
137+
Standard: Latest
138+
StatementMacros:
139+
- Q_UNUSED
140+
- QT_REQUIRE_VERSION
141+
TabWidth: 8
142+
UseCRLF: false
143+
UseTab: Never
144+
WhitespaceSensitiveMacros:
145+
- STRINGIZE
146+
- PP_STRINGIZE
147+
- BOOST_PP_STRINGIZE
148+
...
149+

src/cubie.c

Lines changed: 65 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -3,84 +3,76 @@
33
#include "definitions.h"
44
#include "move_tables.h"
55

6-
cube_cubie* init_cubie_cube() {
7-
cube_cubie* cube = (cube_cubie*)malloc(sizeof(cube_cubie));
6+
cube_cubie *init_cubie_cube() {
7+
cube_cubie *cube = (cube_cubie *)malloc(sizeof(cube_cubie));
88

9-
for (int i = 0; i < 8; i++) {
10-
cube->corner_permutations[i] = i;
11-
cube->corner_orientations[i] = 0;
12-
}
9+
for (int i = 0; i < 8; i++) {
10+
cube->corner_permutations[i] = i;
11+
cube->corner_orientations[i] = 0;
12+
}
1313

14-
for (int i = 0; i < 12; i++) {
15-
cube->edge_permutations[i] = i;
16-
cube->edge_orientations[i] = 0;
17-
}
14+
for (int i = 0; i < 12; i++) {
15+
cube->edge_permutations[i] = i;
16+
cube->edge_orientations[i] = 0;
17+
}
1818

19-
return cube;
19+
return cube;
2020
}
2121

22-
cube_cubie* build_cubie_cube(move base_move) {
23-
cube_cubie* cube = init_cubie_cube();
24-
25-
switch (base_move) {
26-
case MOVE_U1:
27-
case MOVE_U2:
28-
case MOVE_U3:
29-
apply_basic_move(cube, corner_permutation_U, edge_permutation_U,
30-
corner_orientation_U, edge_orientation_U);
31-
break;
32-
33-
case MOVE_R1:
34-
case MOVE_R2:
35-
case MOVE_R3:
36-
apply_basic_move(cube, corner_permutation_R, edge_permutation_R,
37-
corner_orientation_R, edge_orientation_R);
38-
break;
39-
40-
case MOVE_F1:
41-
case MOVE_F2:
42-
case MOVE_F3:
43-
apply_basic_move(cube, corner_permutation_F, edge_permutation_F,
44-
corner_orientation_F, edge_orientation_F);
45-
break;
46-
47-
case MOVE_D1:
48-
case MOVE_D2:
49-
case MOVE_D3:
50-
apply_basic_move(cube, corner_permutation_D, edge_permutation_D,
51-
corner_orientation_D, edge_orientation_D);
52-
break;
53-
54-
case MOVE_L1:
55-
case MOVE_L2:
56-
case MOVE_L3:
57-
apply_basic_move(cube, corner_permutation_L, edge_permutation_L,
58-
corner_orientation_L, edge_orientation_L);
59-
break;
60-
61-
case MOVE_B1:
62-
case MOVE_B2:
63-
case MOVE_B3:
64-
apply_basic_move(cube, corner_permutation_B, edge_permutation_B,
65-
corner_orientation_B, edge_orientation_B);
66-
break;
67-
68-
case MOVE_NULL:
69-
break;
70-
}
71-
72-
return cube;
22+
cube_cubie *build_cubie_cube(move base_move) {
23+
cube_cubie *cube = init_cubie_cube();
24+
25+
switch (base_move) {
26+
case MOVE_U1:
27+
case MOVE_U2:
28+
case MOVE_U3:
29+
apply_basic_move(cube, corner_permutation_U, edge_permutation_U, corner_orientation_U, edge_orientation_U);
30+
break;
31+
32+
case MOVE_R1:
33+
case MOVE_R2:
34+
case MOVE_R3:
35+
apply_basic_move(cube, corner_permutation_R, edge_permutation_R, corner_orientation_R, edge_orientation_R);
36+
break;
37+
38+
case MOVE_F1:
39+
case MOVE_F2:
40+
case MOVE_F3:
41+
apply_basic_move(cube, corner_permutation_F, edge_permutation_F, corner_orientation_F, edge_orientation_F);
42+
break;
43+
44+
case MOVE_D1:
45+
case MOVE_D2:
46+
case MOVE_D3:
47+
apply_basic_move(cube, corner_permutation_D, edge_permutation_D, corner_orientation_D, edge_orientation_D);
48+
break;
49+
50+
case MOVE_L1:
51+
case MOVE_L2:
52+
case MOVE_L3:
53+
apply_basic_move(cube, corner_permutation_L, edge_permutation_L, corner_orientation_L, edge_orientation_L);
54+
break;
55+
56+
case MOVE_B1:
57+
case MOVE_B2:
58+
case MOVE_B3:
59+
apply_basic_move(cube, corner_permutation_B, edge_permutation_B, corner_orientation_B, edge_orientation_B);
60+
break;
61+
62+
case MOVE_NULL: break;
63+
}
64+
65+
return cube;
7366
}
7467

75-
void apply_basic_move(cube_cubie* cube, corner cp[], edge ep[], int co[],
76-
int eo[]) {
77-
for (int i = 0; i < 8; i++) {
78-
cube->corner_permutations[i] = cp[i];
79-
cube->corner_orientations[i] = co[i];
80-
}
81-
82-
for (int i = 0; i < 12; i++) {
83-
cube->edge_permutations[i] = ep[i];
84-
cube->edge_orientations[i] = eo[i];
85-
}
68+
void apply_basic_move(cube_cubie *cube, corner cp[], edge ep[], int co[], int eo[]) {
69+
for (int i = 0; i < 8; i++) {
70+
cube->corner_permutations[i] = cp[i];
71+
cube->corner_orientations[i] = co[i];
72+
}
73+
74+
for (int i = 0; i < 12; i++) {
75+
cube->edge_permutations[i] = ep[i];
76+
cube->edge_orientations[i] = eo[i];
77+
}
8678
}

src/cubie.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77

88
// Represents the cube at the cubie level, as a series of permutations
99
typedef struct {
10-
corner corner_permutations[8];
11-
edge edge_permutations[12];
10+
corner corner_permutations[8];
11+
edge edge_permutations[12];
1212

13-
int corner_orientations[8];
14-
int edge_orientations[8];
13+
int corner_orientations[8];
14+
int edge_orientations[8];
1515
} cube_cubie;
1616

17-
cube_cubie* init_cubie_cube();
18-
cube_cubie* build_cubie_cube(move base_move);
19-
void apply_basic_move(cube_cubie* cube, corner cp[], edge ep[], int co[],
20-
int eo[]);
17+
cube_cubie *init_cubie_cube();
18+
cube_cubie *build_cubie_cube(move base_move);
19+
void apply_basic_move(cube_cubie *cube, corner cp[], edge ep[], int co[], int eo[]);
2120

2221
#endif /* end of include guard */

src/definitions.h

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#ifndef _DEFINITIONS
22
#define _DEFINITIONS
33

4-
54
typedef enum {
65
ROT_URF3 = 0,
7-
ROT_F2 = 1,
8-
ROT_U4 = 2,
6+
ROT_F2 = 1,
7+
ROT_U4 = 2,
98
MIRR_LR2 = 3,
109
} base_symmetry;
1110

12-
1311
typedef enum {
1412
CORNER_URF = 0,
1513
CORNER_UFL = 1,
@@ -21,7 +19,6 @@ typedef enum {
2119
CORNER_DRB = 7,
2220
} corner;
2321

24-
2522
typedef enum {
2623
EDGE_UR = 0,
2724
EDGE_UF = 1,
@@ -37,30 +34,28 @@ typedef enum {
3734
EDGE_BR = 11,
3835
} edge;
3936

40-
4137
typedef enum {
42-
MOVE_U1 = 0,
43-
MOVE_U2 = 1,
44-
MOVE_U3 = 2,
45-
MOVE_R1 = 3,
46-
MOVE_R2 = 4,
47-
MOVE_R3 = 5,
48-
MOVE_F1 = 6,
49-
MOVE_F2 = 7,
50-
MOVE_F3 = 8,
51-
MOVE_D1 = 9,
52-
MOVE_D2 = 10,
53-
MOVE_D3 = 11,
54-
MOVE_L1 = 12,
55-
MOVE_L2 = 13,
56-
MOVE_L3 = 14,
57-
MOVE_B1 = 15,
58-
MOVE_B2 = 16,
59-
MOVE_B3 = 17,
38+
MOVE_U1 = 0,
39+
MOVE_U2 = 1,
40+
MOVE_U3 = 2,
41+
MOVE_R1 = 3,
42+
MOVE_R2 = 4,
43+
MOVE_R3 = 5,
44+
MOVE_F1 = 6,
45+
MOVE_F2 = 7,
46+
MOVE_F3 = 8,
47+
MOVE_D1 = 9,
48+
MOVE_D2 = 10,
49+
MOVE_D3 = 11,
50+
MOVE_L1 = 12,
51+
MOVE_L2 = 13,
52+
MOVE_L3 = 14,
53+
MOVE_B1 = 15,
54+
MOVE_B2 = 16,
55+
MOVE_B3 = 17,
6056
MOVE_NULL = 18,
6157
} move;
6258

63-
6459
typedef enum {
6560
FACELET_U1 = 0,
6661
FACELET_U2 = 1,

0 commit comments

Comments
 (0)