-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
doc: document AliasedBuffers usage scope in style guide #24724
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,6 +21,7 @@ | |||||
* [Use explicit pointer comparisons](#use-explicit-pointer-comparisons) | ||||||
* [Ownership and Smart Pointers](#ownership-and-smart-pointers) | ||||||
* [Avoid non-const references](#avoid-non-const-references) | ||||||
* [Use AliasedBuffers to manipulate TypedArrays](#use-aliasedbuffers-to-manipulate-typedarrays) | ||||||
* [Others](#others) | ||||||
* [Type casting](#type-casting) | ||||||
* [Using `auto`](#using-auto) | ||||||
|
@@ -257,6 +258,21 @@ class ExampleClass { | |||||
}; | ||||||
``` | ||||||
|
||||||
### Use AliasedBuffers to manipulate TypedArrays | ||||||
|
||||||
When working with typed arrays that involves direct data modification | ||||||
from C++, use an AliasedBuffer when possible. The API abstraction and | ||||||
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.
Suggested change
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. fixed |
||||||
the usage scope of AliasedBuffer is documented in [aliased_buffer.h][]. | ||||||
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.
Suggested change
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. fixed |
||||||
|
||||||
```c++ | ||||||
// Create an AliasedBuffer | ||||||
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.
Suggested change
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. done. |
||||||
AliasedBuffer<uint32_t, v8::Uint32Array> data; | ||||||
... | ||||||
|
||||||
// Modify the data through natural operator semantics. | ||||||
data[0] = 12345; | ||||||
``` | ||||||
|
||||||
## Others | ||||||
|
||||||
### Type casting | ||||||
|
@@ -382,3 +398,4 @@ even `try` and `catch` **will** break. | |||||
[Run Time Type Information]: https://en.wikipedia.org/wiki/Run-time_type_information | ||||||
[cppref_auto_ptr]: https://en.cppreference.com/w/cpp/memory/auto_ptr | ||||||
[without C++ exception handling]: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html#intro.using.exception.no | ||||||
[aliased_buffer.h]: https://github.com/nodejs/node/blob/master/src/aliased_buffer.h#L12 |
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.
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.
changed, thanks.