Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/nodejs/src/aliased_struct.h
$ cat -n /usr/include/nodejs/src/aliased_struct.h 1 #ifndef SRC_ALIASED_STRUCT_H_ 2 #define SRC_ALIASED_STRUCT_H_ 3 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 5 6 #include "node_internals.h" 7 #include "v8.h" 8 #include
9 10 namespace node { 11 12 // AliasedStruct is a utility that allows uses a V8 Backing Store 13 // to be exposed to the C++/C side as a struct and to the 14 // JavaScript side as an ArrayBuffer to efficiently share 15 // data without marshalling. It is similar in nature to 16 // AliasedBuffer. 17 // 18 // struct Foo { int x; } 19 // 20 // AliasedStruct
foo; 21 // foo->x = 1; 22 // 23 // Local
ab = foo.GetArrayBuffer(); 24 template
25 class AliasedStruct final { 26 public: 27 template
28 explicit AliasedStruct(v8::Isolate* isolate, Args&&... args); 29 30 inline AliasedStruct(const AliasedStruct& that); 31 32 inline ~AliasedStruct(); 33 34 inline AliasedStruct& operator=(AliasedStruct&& that) noexcept; 35 36 v8::Local
GetArrayBuffer() const { 37 return buffer_.Get(isolate_); 38 } 39 40 const T* Data() const { return ptr_; } 41 42 T* Data() { return ptr_; } 43 44 const T& operator*() const { return *ptr_; } 45 46 T& operator*() { return *ptr_; } 47 48 const T* operator->() const { return ptr_; } 49 50 T* operator->() { return ptr_; } 51 52 private: 53 v8::Isolate* isolate_; 54 std::shared_ptr
store_; 55 T* ptr_; 56 v8::Global
buffer_; 57 }; 58 59 } // namespace node 60 61 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 62 63 #endif // SRC_ALIASED_STRUCT_H_
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™