File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 2121 * [ Use explicit pointer comparisons] ( #use-explicit-pointer-comparisons )
2222 * [ Ownership and Smart Pointers] ( #ownership-and-smart-pointers )
2323 * [ Avoid non-const references] ( #avoid-non-const-references )
24+ * [ Use AliasedBuffers to manipulate TypedArrays] ( #use-aliasedbuffers-to-manipulate-typedarrays )
2425* [ Others] ( #others )
2526 * [ Type casting] ( #type-casting )
2627 * [ Using ` auto ` ] ( #using-auto )
@@ -257,6 +258,21 @@ class ExampleClass {
257258};
258259```
259260
261+ ### Use AliasedBuffers to manipulate TypedArrays
262+
263+ When working with typed arrays that involves direct data modification
264+ from C++, use an AliasedBuffer when possible. The API abstraction and
265+ the usage scope of AliasedBuffer is documented in [ aliased_buffer.h] [ ] .
266+
267+ ``` c++
268+ // Create an AliasedBuffer
269+ AliasedBuffer<uint32_t , v8::Uint32Array> data;
270+ ...
271+
272+ // Modify the data through natural operator semantics.
273+ data[0 ] = 12345 ;
274+ ```
275+
260276## Others
261277
262278### Type casting
@@ -382,3 +398,4 @@ even `try` and `catch` **will** break.
382398[ Run Time Type Information ] : https://en.wikipedia.org/wiki/Run-time_type_information
383399[ cppref_auto_ptr ] : https://en.cppreference.com/w/cpp/memory/auto_ptr
384400[ without C++ exception handling ] : https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html#intro.using.exception.no
401+ [ aliased_buffer.h ] : https://github.com/nodejs/node/blob/master/src/aliased_buffer.h#L12
You can’t perform that action at this time.
0 commit comments