-
Notifications
You must be signed in to change notification settings - Fork 30k
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
[DO NOT LAND] src: run clang-format on LINT_CPP_FILES #21998
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
Language: Cpp | ||
# BasedOnStyle: Google | ||
AccessModifierOffset: -1 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: Right | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: Inline | ||
AllowShortIfStatementsOnASingleLine: true | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: true | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BraceWrapping: | ||
AfterClass: false | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Attach | ||
BreakBeforeInheritanceComma: false | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeColon | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 80 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^<ext/.*\.h>' | ||
Priority: 2 | ||
- Regex: '^<.*\.h>' | ||
Priority: 1 | ||
- Regex: '^<.*' | ||
Priority: 2 | ||
- Regex: '.*' | ||
Priority: 3 | ||
IncludeIsMainRegex: '([-_](test|unittest))?$' | ||
IndentCaseLabels: true | ||
IndentPPDirectives: None | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: false | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 1 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
PointerAlignment: Left | ||
ReflowComments: true | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 2 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Auto | ||
TabWidth: 8 | ||
UseTab: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include <v8.h> | ||
#include <node.h> | ||
#include <v8.h> | ||
|
||
static int c = 0; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
#ifndef SRC_ALIASED_BUFFER_H_ | ||
#define SRC_ALIASED_BUFFER_H_ | ||
|
||
#include "v8.h" | ||
#include "util-inl.h" | ||
#include "v8.h" | ||
|
||
namespace node { | ||
|
||
|
@@ -25,10 +25,7 @@ template <class NativeT, class V8T> | |
class AliasedBuffer { | ||
public: | ||
AliasedBuffer(v8::Isolate* isolate, const size_t count) | ||
: isolate_(isolate), | ||
count_(count), | ||
byte_offset_(0), | ||
free_buffer_(true) { | ||
: isolate_(isolate), count_(count), byte_offset_(0), free_buffer_(true) { | ||
CHECK_GT(count, 0); | ||
const v8::HandleScope handle_scope(isolate_); | ||
|
||
|
@@ -38,8 +35,8 @@ class AliasedBuffer { | |
buffer_ = Calloc<NativeT>(count); | ||
|
||
// allocate v8 ArrayBuffer | ||
v8::Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New( | ||
isolate_, buffer_, sizeInBytes); | ||
v8::Local<v8::ArrayBuffer> ab = | ||
v8::ArrayBuffer::New(isolate_, buffer_, sizeInBytes); | ||
|
||
// allocate v8 TypedArray | ||
v8::Local<V8T> js_array = V8T::New(ab, byte_offset_, count); | ||
|
@@ -57,8 +54,7 @@ class AliasedBuffer { | |
AliasedBuffer(v8::Isolate* isolate, | ||
const size_t byte_offset, | ||
const size_t count, | ||
const AliasedBuffer<uint8_t, | ||
v8::Uint8Array>& backing_buffer) | ||
const AliasedBuffer<uint8_t, v8::Uint8Array>& backing_buffer) | ||
: isolate_(isolate), | ||
count_(count), | ||
byte_offset_(byte_offset), | ||
|
@@ -70,7 +66,7 @@ class AliasedBuffer { | |
// validate that the byte_offset is aligned with sizeof(NativeT) | ||
CHECK_EQ(byte_offset & (sizeof(NativeT) - 1), 0); | ||
// validate this fits inside the backing buffer | ||
CHECK_LE(sizeof(NativeT) * count, ab->ByteLength() - byte_offset); | ||
CHECK_LE(sizeof(NativeT) * count, ab->ByteLength() - byte_offset); | ||
|
||
buffer_ = reinterpret_cast<NativeT*>( | ||
const_cast<uint8_t*>(backing_buffer.GetNativeBuffer() + byte_offset)); | ||
|
@@ -117,14 +113,10 @@ class AliasedBuffer { | |
class Reference { | ||
public: | ||
Reference(AliasedBuffer<NativeT, V8T>* aliased_buffer, size_t index) | ||
: aliased_buffer_(aliased_buffer), | ||
index_(index) { | ||
} | ||
: aliased_buffer_(aliased_buffer), index_(index) {} | ||
|
||
Reference(const Reference& that) | ||
: aliased_buffer_(that.aliased_buffer_), | ||
index_(that.index_) { | ||
} | ||
: aliased_buffer_(that.aliased_buffer_), index_(that.index_) {} | ||
|
||
inline Reference& operator=(const NativeT& val) { | ||
aliased_buffer_->SetValue(index_, val); | ||
|
@@ -135,9 +127,7 @@ class AliasedBuffer { | |
return *this = static_cast<NativeT>(val); | ||
} | ||
|
||
operator NativeT() const { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we have return always on a new line? |
||
return aliased_buffer_->GetValue(index_); | ||
} | ||
operator NativeT() const { return aliased_buffer_->GetValue(index_); } | ||
|
||
inline Reference& operator+=(const NativeT& val) { | ||
const NativeT current = aliased_buffer_->GetValue(index_); | ||
|
@@ -163,14 +153,12 @@ class AliasedBuffer { | |
/** | ||
* Get the underlying v8 TypedArray overlayed on top of the native buffer | ||
*/ | ||
v8::Local<V8T> GetJSArray() const { | ||
return js_array_.Get(isolate_); | ||
} | ||
v8::Local<V8T> GetJSArray() const { return js_array_.Get(isolate_); } | ||
|
||
/** | ||
* Get the underlying v8::ArrayBuffer underlying the TypedArray and | ||
* overlaying the native buffer | ||
*/ | ||
* Get the underlying v8::ArrayBuffer underlying the TypedArray and | ||
* overlaying the native buffer | ||
*/ | ||
v8::Local<v8::ArrayBuffer> GetArrayBuffer() const { | ||
return GetJSArray()->Buffer(); | ||
} | ||
|
@@ -179,16 +167,12 @@ class AliasedBuffer { | |
* Get the underlying native buffer. Note that all reads/writes should occur | ||
* through the GetValue/SetValue/operator[] methods | ||
*/ | ||
inline const NativeT* GetNativeBuffer() const { | ||
return buffer_; | ||
} | ||
inline const NativeT* GetNativeBuffer() const { return buffer_; } | ||
|
||
/** | ||
* Synonym for GetBuffer() | ||
*/ | ||
inline const NativeT* operator * () const { | ||
return GetNativeBuffer(); | ||
} | ||
inline const NativeT* operator*() const { return GetNativeBuffer(); } | ||
|
||
/** | ||
* Set position index to given value. | ||
|
@@ -213,17 +197,11 @@ class AliasedBuffer { | |
/** | ||
* Effectively, a synonym for GetValue/SetValue | ||
*/ | ||
Reference operator[](size_t index) { | ||
return Reference(this, index); | ||
} | ||
Reference operator[](size_t index) { return Reference(this, index); } | ||
|
||
NativeT operator[](size_t index) const { | ||
return GetValue(index); | ||
} | ||
NativeT operator[](size_t index) const { return GetValue(index); } | ||
|
||
size_t Length() const { | ||
return count_; | ||
} | ||
size_t Length() const { return count_; } | ||
|
||
private: | ||
v8::Isolate* isolate_; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like this was more readable before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is
ConstructorInitializerAllOnOneLineOrOnePerLine
. There is apparently no option to force one per line.