diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-08 21:40:46 +0300 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2019-11-21 08:29:26 +0300 |
commit | 1a92c884185bc3e01c6d64aae55ea5a947d82840 (patch) | |
tree | df5f0a195866bf94bf0f7d90827817adfb859f1e /src/node_buffer.cc | |
parent | f17c794faf7892ee385d10bba8c11c9df4b45778 (diff) |
src: migrate off ArrayBuffer::GetContents
V8 deprecates `GetContents()` in favour of `GetBackingStore()`.
Update our code to reflect that.
V8 also deprecates `Externalize()` and `IsExternal()`; we should
be able to remove all usage of this once V8 8.0 is there.
PR-URL: https://github.com/nodejs/node/pull/30339
Refs: https://github.com/v8/v8/commit/bfe3d6bce734e596e312465e207bcfd55a59fe34
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/node_buffer.cc')
-rw-r--r-- | src/node_buffer.cc | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 3aa1ea2535a..2dbdd61923f 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -192,16 +192,13 @@ bool HasInstance(Local<Object> obj) { char* Data(Local<Value> val) { CHECK(val->IsArrayBufferView()); Local<ArrayBufferView> ui = val.As<ArrayBufferView>(); - ArrayBuffer::Contents ab_c = ui->Buffer()->GetContents(); - return static_cast<char*>(ab_c.Data()) + ui->ByteOffset(); + return static_cast<char*>(ui->Buffer()->GetBackingStore()->Data()) + + ui->ByteOffset(); } char* Data(Local<Object> obj) { - CHECK(obj->IsArrayBufferView()); - Local<ArrayBufferView> ui = obj.As<ArrayBufferView>(); - ArrayBuffer::Contents ab_c = ui->Buffer()->GetContents(); - return static_cast<char*>(ab_c.Data()) + ui->ByteOffset(); + return Data(obj.As<Value>()); } @@ -1060,13 +1057,13 @@ static void EncodeInto(const FunctionCallbackInfo<Value>& args) { Local<Uint8Array> dest = args[1].As<Uint8Array>(); Local<ArrayBuffer> buf = dest->Buffer(); char* write_result = - static_cast<char*>(buf->GetContents().Data()) + dest->ByteOffset(); + static_cast<char*>(buf->GetBackingStore()->Data()) + dest->ByteOffset(); size_t dest_length = dest->ByteLength(); // results = [ read, written ] Local<Uint32Array> result_arr = args[2].As<Uint32Array>(); uint32_t* results = reinterpret_cast<uint32_t*>( - static_cast<char*>(result_arr->Buffer()->GetContents().Data()) + + static_cast<char*>(result_arr->Buffer()->GetBackingStore()->Data()) + result_arr->ByteOffset()); int nchars; |