Skip to content

Commit 28d515a

Browse files
authored
Index Typedef (#161)
* Refactor ID types from long to index_t across the codebase * Update clang-format action to v4.15.0 and version to 20 * Update clang-format
1 parent 63494e3 commit 28d515a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+468
-174
lines changed

.clang-format

Lines changed: 271 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,148 @@
1-
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
2-
BasedOnStyle: WebKit
3-
ColumnLimit: 80
4-
AlignTrailingComments: true
5-
FixNamespaceComments: true
6-
ReflowComments: true
7-
BinPackParameters: false
8-
AllowAllParametersOfDeclarationOnNextLine: true
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -4
94
AlignAfterOpenBracket: AlwaysBreak
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveAssignments:
7+
Enabled: false
8+
AcrossEmptyLines: false
9+
AcrossComments: false
10+
AlignCompound: false
11+
AlignFunctionDeclarations: false
12+
AlignFunctionPointers: false
13+
PadOperators: true
14+
AlignConsecutiveBitFields:
15+
Enabled: false
16+
AcrossEmptyLines: false
17+
AcrossComments: false
18+
AlignCompound: false
19+
AlignFunctionDeclarations: false
20+
AlignFunctionPointers: false
21+
PadOperators: false
22+
AlignConsecutiveDeclarations:
23+
Enabled: false
24+
AcrossEmptyLines: false
25+
AcrossComments: false
26+
AlignCompound: false
27+
AlignFunctionDeclarations: true
28+
AlignFunctionPointers: false
29+
PadOperators: false
30+
AlignConsecutiveMacros:
31+
Enabled: false
32+
AcrossEmptyLines: false
33+
AcrossComments: false
34+
AlignCompound: false
35+
AlignFunctionDeclarations: false
36+
AlignFunctionPointers: false
37+
PadOperators: false
38+
AlignConsecutiveShortCaseStatements:
39+
Enabled: false
40+
AcrossEmptyLines: false
41+
AcrossComments: false
42+
AlignCaseArrows: false
43+
AlignCaseColons: false
44+
AlignConsecutiveTableGenBreakingDAGArgColons:
45+
Enabled: false
46+
AcrossEmptyLines: false
47+
AcrossComments: false
48+
AlignCompound: false
49+
AlignFunctionDeclarations: false
50+
AlignFunctionPointers: false
51+
PadOperators: false
52+
AlignConsecutiveTableGenCondOperatorColons:
53+
Enabled: false
54+
AcrossEmptyLines: false
55+
AcrossComments: false
56+
AlignCompound: false
57+
AlignFunctionDeclarations: false
58+
AlignFunctionPointers: false
59+
PadOperators: false
60+
AlignConsecutiveTableGenDefinitionColons:
61+
Enabled: false
62+
AcrossEmptyLines: false
63+
AcrossComments: false
64+
AlignCompound: false
65+
AlignFunctionDeclarations: false
66+
AlignFunctionPointers: false
67+
PadOperators: false
68+
AlignEscapedNewlines: Right
69+
AlignOperands: DontAlign
70+
AlignTrailingComments:
71+
Kind: Always
72+
OverEmptyLines: 0
73+
AllowAllArgumentsOnNextLine: true
74+
AllowAllParametersOfDeclarationOnNextLine: true
75+
AllowBreakBeforeNoexceptSpecifier: Never
76+
AllowShortBlocksOnASingleLine: Always
77+
AllowShortCaseExpressionOnASingleLine: true
78+
AllowShortCaseLabelsOnASingleLine: false
79+
AllowShortCompoundRequirementOnASingleLine: true
80+
AllowShortEnumsOnASingleLine: true
81+
AllowShortFunctionsOnASingleLine: All
82+
AllowShortIfStatementsOnASingleLine: Never
83+
AllowShortLambdasOnASingleLine: All
84+
AllowShortLoopsOnASingleLine: false
85+
AllowShortNamespacesOnASingleLine: false
86+
AlwaysBreakAfterDefinitionReturnType: None
87+
AlwaysBreakBeforeMultilineStrings: false
88+
AttributeMacros:
89+
- __capability
90+
BinPackArguments: true
91+
BinPackParameters: false
92+
BitFieldColonSpacing: Both
93+
BraceWrapping:
94+
AfterCaseLabel: false
95+
AfterClass: false
96+
AfterControlStatement: Never
97+
AfterEnum: false
98+
AfterExternBlock: false
99+
AfterFunction: true
100+
AfterNamespace: false
101+
AfterObjCDeclaration: false
102+
AfterStruct: false
103+
AfterUnion: false
104+
BeforeCatch: false
105+
BeforeElse: false
106+
BeforeLambdaBody: false
107+
BeforeWhile: false
108+
IndentBraces: false
109+
SplitEmptyFunction: true
110+
SplitEmptyRecord: true
111+
SplitEmptyNamespace: true
112+
BreakAdjacentStringLiterals: true
113+
BreakAfterAttributes: Leave
114+
BreakAfterJavaFieldAnnotations: false
115+
BreakAfterReturnType: None
116+
BreakArrays: false
10117
BreakBeforeBinaryOperators: NonAssignment
11-
SortIncludes: true
12-
CommentPragmas: '^@.+'
118+
BreakBeforeConceptDeclarations: Always
119+
BreakBeforeBraces: Custom
120+
BreakBeforeInlineASMColon: OnlyMultiline
121+
BreakBeforeTernaryOperators: true
122+
BreakBinaryOperations: Never
123+
BreakConstructorInitializers: BeforeComma
124+
BreakFunctionDefinitionParameters: false
125+
BreakInheritanceList: BeforeColon
13126
BreakStringLiterals: false
14-
PackConstructorInitializers: CurrentLine
15-
# Regroup includes with a priority system
16-
IncludeBlocks: Regroup
127+
BreakTemplateDeclarations: MultiLine
128+
ColumnLimit: 80
129+
CommentPragmas: '^@.+'
130+
CompactNamespaces: false
131+
ConstructorInitializerIndentWidth: 4
132+
ContinuationIndentWidth: 4
133+
Cpp11BracedListStyle: false
134+
DerivePointerAlignment: false
135+
DisableFormat: false
136+
EmptyLineAfterAccessModifier: Never
137+
EmptyLineBeforeAccessModifier: LogicalBlock
138+
ExperimentalAutoDetectBinPacking: false
139+
FixNamespaceComments: true
140+
ForEachMacros:
141+
- RANGES_FOR
142+
- FOREACH
143+
IfMacros:
144+
- IF
145+
IncludeBlocks: Regroup
17146
IncludeCategories:
18147
# by default, the main header of a cpp will get priority 0
19148
# regex here are sorted by search pattern, not by sort priority
@@ -36,4 +165,132 @@ IncludeCategories:
36165
- Regex: ".*" # catch-all for internal files
37166
Priority: 1 # internal file group
38167
SortPriority: 1
39-
CaseSensitive: true
168+
CaseSensitive: true
169+
IncludeIsMainRegex: '(Test)?$'
170+
IncludeIsMainSourceRegex: ''
171+
IndentAccessModifiers: false
172+
IndentCaseBlocks: false
173+
IndentCaseLabels: false
174+
IndentExportBlock: true
175+
IndentExternBlock: AfterExternBlock
176+
IndentGotoLabels: true
177+
IndentPPDirectives: None
178+
IndentRequiresClause: true
179+
IndentWidth: 4
180+
IndentWrappedFunctionNames: false
181+
InsertBraces: false
182+
InsertNewlineAtEOF: false
183+
InsertTrailingCommas: None
184+
IntegerLiteralSeparator:
185+
Binary: 0
186+
BinaryMinDigits: 0
187+
Decimal: 0
188+
DecimalMinDigits: 0
189+
Hex: 0
190+
HexMinDigits: 0
191+
JavaScriptQuotes: Leave
192+
JavaScriptWrapImports: true
193+
KeepEmptyLines:
194+
AtEndOfFile: false
195+
AtStartOfBlock: true
196+
AtStartOfFile: true
197+
KeepFormFeed: false
198+
LambdaBodyIndentation: Signature
199+
LineEnding: DeriveLF
200+
MacroBlockBegin: ''
201+
MacroBlockEnd: ''
202+
MainIncludeChar: Quote
203+
MaxEmptyLinesToKeep: 1
204+
NamespaceIndentation: Inner
205+
ObjCBinPackProtocolList: Auto
206+
ObjCBlockIndentWidth: 4
207+
ObjCBreakBeforeNestedBlockParam: true
208+
ObjCSpaceAfterProperty: true
209+
ObjCSpaceBeforeProtocolList: true
210+
PackConstructorInitializers: CurrentLine
211+
PenaltyBreakAssignment: 2
212+
PenaltyBreakBeforeFirstCallParameter: 19
213+
PenaltyBreakBeforeMemberAccess: 150
214+
PenaltyBreakComment: 300
215+
PenaltyBreakFirstLessLess: 120
216+
PenaltyBreakOpenParenthesis: 0
217+
PenaltyBreakScopeResolution: 500
218+
PenaltyBreakString: 1000
219+
PenaltyBreakTemplateDeclaration: 10
220+
PenaltyExcessCharacter: 1000000
221+
PenaltyIndentedWhitespace: 0
222+
PenaltyReturnTypeOnItsOwnLine: 60
223+
PointerAlignment: Left
224+
PPIndentWidth: -1
225+
QualifierAlignment: Leave
226+
ReferenceAlignment: Pointer
227+
ReflowComments: Always
228+
RemoveBracesLLVM: false
229+
RemoveEmptyLinesInUnwrappedLines: true
230+
RemoveParentheses: Leave
231+
RemoveSemicolon: false
232+
RequiresClausePosition: OwnLine
233+
RequiresExpressionIndentation: OuterScope
234+
SeparateDefinitionBlocks: Leave
235+
ShortNamespaceLines: 1
236+
SkipMacroDefinitionBody: false
237+
SortIncludes: CaseInsensitive
238+
SortJavaStaticImport: Before
239+
SortUsingDeclarations: LexicographicNumeric
240+
SpaceAfterCStyleCast: false
241+
SpaceAfterLogicalNot: false
242+
SpaceAfterTemplateKeyword: true
243+
SpaceAroundPointerQualifiers: Default
244+
SpaceBeforeAssignmentOperators: true
245+
SpaceBeforeCaseColon: false
246+
SpaceBeforeCpp11BracedList: true
247+
SpaceBeforeCtorInitializerColon: true
248+
SpaceBeforeInheritanceColon: true
249+
SpaceBeforeJsonColon: false
250+
SpaceBeforeParens: ControlStatements
251+
SpaceBeforeParensOptions:
252+
AfterControlStatements: true
253+
AfterForeachMacros: true
254+
AfterFunctionDefinitionName: false
255+
AfterFunctionDeclarationName: false
256+
AfterIfMacros: true
257+
AfterOverloadedOperator: false
258+
AfterPlacementOperator: true
259+
AfterRequiresInClause: false
260+
AfterRequiresInExpression: false
261+
BeforeNonEmptyParentheses: false
262+
SpaceBeforeRangeBasedForLoopColon: true
263+
SpaceBeforeSquareBrackets: false
264+
SpaceInEmptyBlock: true
265+
SpacesBeforeTrailingComments: 1
266+
SpacesInAngles: Never
267+
SpacesInContainerLiterals: true
268+
SpacesInLineCommentPrefix:
269+
Minimum: 1
270+
Maximum: -1
271+
SpacesInParens: Never
272+
SpacesInParensOptions:
273+
ExceptDoubleParentheses: false
274+
InCStyleCasts: false
275+
InConditionalStatements: false
276+
InEmptyParentheses: false
277+
Other: false
278+
SpacesInSquareBrackets: false
279+
Standard: Latest
280+
StatementAttributeLikeMacros:
281+
- Q_EMIT
282+
StatementMacros:
283+
- Q_UNUSED
284+
- QT_REQUIRE_VERSION
285+
TableGenBreakInsideDAGArg: DontBreak
286+
TabWidth: 8
287+
UseTab: Never
288+
VerilogBreakBetweenInstancePorts: true
289+
WhitespaceSensitiveMacros:
290+
- BOOST_PP_STRINGIZE
291+
- CF_SWIFT_NAME
292+
- NS_SWIFT_NAME
293+
- PP_STRINGIZE
294+
- STRINGIZE
295+
WrapNamespaceBodyWithEmptyLines: Leave
296+
...

.github/workflows/clang-format-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@v4
2929
- name: clang-format style check
30-
uses: jidicula/clang-format-action@v4.13.0
30+
uses: jidicula/clang-format-action@v4.15.0
3131
with:
32-
clang-format-version: '18'
32+
clang-format-version: '20'
3333
check-path: ${{ matrix.path }}

python/src/barrier/adaptive_stiffness.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ void define_adaptive_stiffness(py::module_& m)
7272
m.def(
7373
"semi_implicit_stiffness",
7474
static_cast<double (*)(
75-
const CollisionStencil&, const std::array<long, 4>&,
76-
Eigen::ConstRef<VectorMax12d>, Eigen::ConstRef<VectorMax4d>,
77-
Eigen::ConstRef<MatrixMax12d>, const double)>(
78-
&semi_implicit_stiffness),
75+
const CollisionStencil&, Eigen::ConstRef<VectorMax12d>,
76+
Eigen::ConstRef<VectorMax4d>, Eigen::ConstRef<MatrixMax12d>,
77+
const double)>(&semi_implicit_stiffness),
7978
R"ipc_Qu8mg5v7(
8079
Compute the semi-implicit stiffness for a single collision.
8180
@@ -92,8 +91,8 @@ void define_adaptive_stiffness(py::module_& m)
9291
Returns:
9392
The semi-implicit stiffness.
9493
)ipc_Qu8mg5v7",
95-
py::arg("stencil"), py::arg("vertex_ids"), py::arg("vertices"),
96-
py::arg("mass"), py::arg("local_hess"), py::arg("dmin"));
94+
py::arg("stencil"), py::arg("vertices"), py::arg("mass"),
95+
py::arg("local_hess"), py::arg("dmin"));
9796

9897
m.def(
9998
"semi_implicit_stiffness",

python/src/candidates/edge_edge.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ using namespace ipc;
88
void define_edge_edge_candidate(py::module_& m)
99
{
1010
py::class_<EdgeEdgeCandidate, CollisionStencil>(m, "EdgeEdgeCandidate")
11-
.def(py::init<long, long>(), py::arg("edge0_id"), py::arg("edge1_id"))
1211
.def(
13-
py::init([](std::tuple<long, long> edge_ids) {
12+
py::init<index_t, index_t>(), py::arg("edge0_id"),
13+
py::arg("edge1_id"))
14+
.def(
15+
py::init([](std::tuple<index_t, index_t> edge_ids) {
1416
return std::make_unique<EdgeEdgeCandidate>(
1517
std::get<0>(edge_ids), std::get<1>(edge_ids));
1618
}),
@@ -37,5 +39,6 @@ void define_edge_edge_candidate(py::module_& m)
3739
.def_readwrite(
3840
"edge1_id", &EdgeEdgeCandidate::edge1_id, "ID of the second edge.");
3941

40-
py::implicitly_convertible<std::tuple<long, long>, EdgeEdgeCandidate>();
42+
py::implicitly_convertible<
43+
std::tuple<index_t, index_t>, EdgeEdgeCandidate>();
4144
}

python/src/candidates/edge_face.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ using namespace ipc;
99
void define_edge_face_candidate(py::module_& m)
1010
{
1111
py::class_<EdgeFaceCandidate>(m, "EdgeFaceCandidate")
12-
.def(py::init<long, long>(), py::arg("edge_id"), py::arg("face_id"))
1312
.def(
14-
py::init([](std::tuple<long, long> edge_and_face_id) {
13+
py::init<index_t, index_t>(), py::arg("edge_id"),
14+
py::arg("face_id"))
15+
.def(
16+
py::init([](std::tuple<index_t, index_t> edge_and_face_id) {
1517
return std::make_unique<EdgeFaceCandidate>(
1618
std::get<0>(edge_and_face_id),
1719
std::get<1>(edge_and_face_id));
@@ -37,5 +39,6 @@ void define_edge_face_candidate(py::module_& m)
3739
.def_readwrite(
3840
"face_id", &EdgeFaceCandidate::face_id, "ID of the face");
3941

40-
py::implicitly_convertible<std::tuple<long, long>, EdgeFaceCandidate>();
42+
py::implicitly_convertible<
43+
std::tuple<index_t, index_t>, EdgeFaceCandidate>();
4144
}

python/src/candidates/edge_vertex.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ using namespace ipc;
88
void define_edge_vertex_candidate(py::module_& m)
99
{
1010
py::class_<EdgeVertexCandidate, CollisionStencil>(m, "EdgeVertexCandidate")
11-
.def(py::init<long, long>(), py::arg("edge_id"), py::arg("vertex_id"))
1211
.def(
13-
py::init([](std::tuple<long, long> edge_and_vertex_id) {
12+
py::init<index_t, index_t>(), py::arg("edge_id"),
13+
py::arg("vertex_id"))
14+
.def(
15+
py::init([](std::tuple<index_t, index_t> edge_and_vertex_id) {
1416
return std::make_unique<EdgeVertexCandidate>(
1517
std::get<0>(edge_and_vertex_id),
1618
std::get<1>(edge_and_vertex_id));
@@ -39,5 +41,6 @@ void define_edge_vertex_candidate(py::module_& m)
3941
.def_readwrite(
4042
"vertex_id", &EdgeVertexCandidate::vertex_id, "ID of the vertex");
4143

42-
py::implicitly_convertible<std::tuple<long, long>, EdgeVertexCandidate>();
44+
py::implicitly_convertible<
45+
std::tuple<index_t, index_t>, EdgeVertexCandidate>();
4346
}

0 commit comments

Comments
 (0)