internal: fix some editor indentation rules (#9289)

* internal: fix some editor indentation rules

* internal: update CODE_STYLE.md
This commit is contained in:
Eliza
2025-10-03 11:38:01 -07:00
committed by GitHub
parent 7fe1ee3fd5
commit a6c9922d33
3 changed files with 26 additions and 10 deletions

View File

@@ -65,4 +65,6 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never
PackConstructorInitializers: Never
PackConstructorInitializers: Never
ConstructorInitializerIndentWidth: 8
IndentWrappedFunctionNames: true

View File

@@ -20,7 +20,7 @@ The guiding principles of the filament code style and code formatting can be res
- class access modifiers are not indented
- last line of `.cpp` or `.h` file must be an empty line
```
```c++
for (int i = 0; i < max; i++) {
}
@@ -73,12 +73,24 @@ src/data.inc
- `public` class attributes *are not* prefixed
- class attributes and methods are lower camelcase
```
```c++
extern int gGlobalWarming;
class FooBar {
public:
void methodName();
FooBar(int attributeName, int sizeInBytes)
: mAttributeName(attributeName),
sizeInBytes(sizeInBytes) {}
void reallyLongMethodNameWithLotsOfArguments(bool argument1,
int someSecondArgument, int bestArgument) {
std::pair<bool, int> pair = {
argument1,
argument2,
};
// etc
}
int sizeInBytes;
private:
int mAttributeName;
@@ -97,7 +109,7 @@ private:
- always include the copyright notice at the top of every file
- make sure the date is correct
```
```c++
/*
* Copyright (C) 2018 The Android Open Source Project
*
@@ -139,7 +151,7 @@ conversely containers and algorithms are not allowed. There are exceptions such
*Sorting the headers is important to help catching missing `#include` directives.*
```
```c++
/*
* Copyright (C) 2018 The Android Open Source Project
*
@@ -183,7 +195,7 @@ conversely containers and algorithms are not allowed. There are exceptions such
### Misc
- Use `auto` only when the type appears on the same line or with iterators and lambdas.
```
```c++
auto foo = new Foo();
for (auto& i : collection) { }
```

View File

@@ -34,13 +34,14 @@ position (or nil if there is none)."
c-basic-offset
(if (assq 'arglist-cont-nonempty c-syntactic-context)
(- c-basic-offset)
(* 2 c-basic-offset))))))
c-basic-offset)))))
(defun c-filament-style-lineup-brace-list-entry (_langelem)
"Indent following lines in braced lists in the Filament style.
This properly indents doubled-up arglists + lists, e.g. ({."
(if (assq 'arglist-cont-nonempty c-syntactic-context)
;; Un-indent closing brace line.
(- (* c-basic-offset 2))
0))
@@ -67,13 +68,14 @@ nil if there is none)."
(arglist-cont . 0)
(arglist-cont-nonempty . c-filament-style-lineup-arglist)
(arglist-close . c-filament-style-lineup-arglist)
(statement-cont . ++)
(case-label . +)
(brace-list-intro . c-filament-style-lineup-brace-list-intro)
(brace-list-entry . c-filament-style-lineup-brace-list-entry)
(brace-list-close . c-filament-style-lineup-brace-list-entry)
(label . [0])
(member-init-intro . ++))))
(statement-cont . ++)
(member-init-intro . ++)
(topmost-intro-cont . ++))))
(provide 'c-filament-style)