10
10
11
11
namespace node {
12
12
13
- typedef size_t AliasedBufferInfo ;
13
+ typedef size_t AliasedBufferIndex ;
14
14
15
15
/* *
16
16
* Do not use this class directly when creating instances of it - use the
@@ -37,10 +37,10 @@ class AliasedBufferBase {
37
37
public:
38
38
AliasedBufferBase (v8::Isolate* isolate,
39
39
const size_t count,
40
- const AliasedBufferInfo* info = nullptr )
41
- : isolate_(isolate), count_(count), byte_offset_(0 ), info_(info ) {
40
+ const AliasedBufferIndex* index = nullptr )
41
+ : isolate_(isolate), count_(count), byte_offset_(0 ), index_(index ) {
42
42
CHECK_GT (count, 0 );
43
- if (info != nullptr ) {
43
+ if (index != nullptr ) {
44
44
// Will be deserialized later.
45
45
return ;
46
46
}
@@ -72,12 +72,12 @@ class AliasedBufferBase {
72
72
const size_t byte_offset,
73
73
const size_t count,
74
74
const AliasedBufferBase<uint8_t , v8::Uint8Array>& backing_buffer,
75
- const AliasedBufferInfo* info = nullptr )
75
+ const AliasedBufferIndex* index = nullptr )
76
76
: isolate_(isolate),
77
77
count_ (count),
78
78
byte_offset_(byte_offset),
79
- info_(info ) {
80
- if (info != nullptr ) {
79
+ index_(index ) {
80
+ if (index != nullptr ) {
81
81
// Will be deserialized later.
82
82
return ;
83
83
}
@@ -102,20 +102,20 @@ class AliasedBufferBase {
102
102
count_(that.count_),
103
103
byte_offset_(that.byte_offset_),
104
104
buffer_(that.buffer_) {
105
- DCHECK_NULL (info_ );
105
+ DCHECK_NULL (index_ );
106
106
js_array_ = v8::Global<V8T>(that.isolate_ , that.GetJSArray ());
107
107
}
108
108
109
- AliasedBufferInfo Serialize (v8::Local<v8::Context> context,
109
+ AliasedBufferIndex Serialize (v8::Local<v8::Context> context,
110
110
v8::SnapshotCreator* creator) {
111
- DCHECK_NULL (info_ );
111
+ DCHECK_NULL (index_ );
112
112
return creator->AddData (context, GetJSArray ());
113
113
}
114
114
115
115
inline void Deserialize (v8::Local<v8::Context> context) {
116
- DCHECK_NOT_NULL (info_ );
116
+ DCHECK_NOT_NULL (index_ );
117
117
v8::Local<V8T> arr =
118
- context->GetDataFromSnapshotOnce <V8T>(*info_ ).ToLocalChecked ();
118
+ context->GetDataFromSnapshotOnce <V8T>(*index_ ).ToLocalChecked ();
119
119
// These may not hold true for AliasedBuffers that have grown, so should
120
120
// be removed when we expand the snapshot support.
121
121
DCHECK_EQ (count_, arr->Length ());
@@ -124,11 +124,11 @@ class AliasedBufferBase {
124
124
static_cast <uint8_t *>(arr->Buffer ()->GetBackingStore ()->Data ());
125
125
buffer_ = reinterpret_cast <NativeT*>(raw + byte_offset_);
126
126
js_array_.Reset (isolate_, arr);
127
- info_ = nullptr ;
127
+ index_ = nullptr ;
128
128
}
129
129
130
130
AliasedBufferBase& operator =(AliasedBufferBase&& that) noexcept {
131
- DCHECK_NULL (info_ );
131
+ DCHECK_NULL (index_ );
132
132
this ->~AliasedBufferBase ();
133
133
isolate_ = that.isolate_ ;
134
134
count_ = that.count_ ;
@@ -194,7 +194,7 @@ class AliasedBufferBase {
194
194
* Get the underlying v8 TypedArray overlayed on top of the native buffer
195
195
*/
196
196
v8::Local<V8T> GetJSArray () const {
197
- DCHECK_NULL (info_ );
197
+ DCHECK_NULL (index_ );
198
198
return js_array_.Get (isolate_);
199
199
}
200
200
@@ -211,7 +211,7 @@ class AliasedBufferBase {
211
211
* through the GetValue/SetValue/operator[] methods
212
212
*/
213
213
inline const NativeT* GetNativeBuffer () const {
214
- DCHECK_NULL (info_ );
214
+ DCHECK_NULL (index_ );
215
215
return buffer_;
216
216
}
217
217
@@ -227,15 +227,15 @@ class AliasedBufferBase {
227
227
*/
228
228
inline void SetValue (const size_t index, NativeT value) {
229
229
DCHECK_LT (index , count_);
230
- DCHECK_NULL (info_ );
230
+ DCHECK_NULL (index_ );
231
231
buffer_[index ] = value;
232
232
}
233
233
234
234
/* *
235
235
* Get value at position index
236
236
*/
237
237
inline const NativeT GetValue (const size_t index) const {
238
- DCHECK_NULL (info_ );
238
+ DCHECK_NULL (index_ );
239
239
DCHECK_LT (index , count_);
240
240
return buffer_[index ];
241
241
}
@@ -244,7 +244,7 @@ class AliasedBufferBase {
244
244
* Effectively, a synonym for GetValue/SetValue
245
245
*/
246
246
Reference operator [](size_t index) {
247
- DCHECK_NULL (info_ );
247
+ DCHECK_NULL (index_ );
248
248
return Reference (this , index );
249
249
}
250
250
@@ -260,7 +260,7 @@ class AliasedBufferBase {
260
260
// Should only be used on an owning array, not one created as a sub array of
261
261
// an owning `AliasedBufferBase`.
262
262
void reserve (size_t new_capacity) {
263
- DCHECK_NULL (info_ );
263
+ DCHECK_NULL (index_ );
264
264
DCHECK_GE (new_capacity, count_);
265
265
DCHECK_EQ (byte_offset_, 0 );
266
266
const v8::HandleScope handle_scope (isolate_);
@@ -296,7 +296,7 @@ class AliasedBufferBase {
296
296
v8::Global<V8T> js_array_;
297
297
298
298
// Deserialize data
299
- const AliasedBufferInfo* info_ = nullptr ;
299
+ const AliasedBufferIndex* index_ = nullptr ;
300
300
};
301
301
302
302
typedef AliasedBufferBase<int32_t , v8::Int32Array> AliasedInt32Array;
0 commit comments