Skip to content

Commit 8e1b7e2

Browse files
kvakilruyadorno
authored andcommitted
src: remove usages of GetBackingStore in node-api
This removes all usages of GetBackingStore in `node-api`. See the linked issue for an explanation. Refs: #32226 Refs: #43921 PR-URL: #44075 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Feng Yu <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent cddf3ed commit 8e1b7e2

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/js_native_api_v8.cc

+8-11
Original file line numberDiff line numberDiff line change
@@ -2780,7 +2780,7 @@ napi_status NAPI_CDECL napi_create_arraybuffer(napi_env env,
27802780
// Optionally return a pointer to the buffer's data, to avoid another call to
27812781
// retrieve it.
27822782
if (data != nullptr) {
2783-
*data = buffer->GetBackingStore()->Data();
2783+
*data = buffer->Data();
27842784
}
27852785

27862786
*result = v8impl::JsValueFromV8LocalValue(buffer);
@@ -2814,15 +2814,14 @@ napi_status NAPI_CDECL napi_get_arraybuffer_info(napi_env env,
28142814
v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(arraybuffer);
28152815
RETURN_STATUS_IF_FALSE(env, value->IsArrayBuffer(), napi_invalid_arg);
28162816

2817-
std::shared_ptr<v8::BackingStore> backing_store =
2818-
value.As<v8::ArrayBuffer>()->GetBackingStore();
2817+
v8::Local<v8::ArrayBuffer> ab = value.As<v8::ArrayBuffer>();
28192818

28202819
if (data != nullptr) {
2821-
*data = backing_store->Data();
2820+
*data = ab->Data();
28222821
}
28232822

28242823
if (byte_length != nullptr) {
2825-
*byte_length = backing_store->ByteLength();
2824+
*byte_length = ab->ByteLength();
28262825
}
28272826

28282827
return napi_clear_last_error(env);
@@ -2963,8 +2962,7 @@ napi_status NAPI_CDECL napi_get_typedarray_info(napi_env env,
29632962
}
29642963

29652964
if (data != nullptr) {
2966-
*data = static_cast<uint8_t*>(buffer->GetBackingStore()->Data()) +
2967-
array->ByteOffset();
2965+
*data = static_cast<uint8_t*>(buffer->Data()) + array->ByteOffset();
29682966
}
29692967

29702968
if (arraybuffer != nullptr) {
@@ -3044,8 +3042,7 @@ napi_status NAPI_CDECL napi_get_dataview_info(napi_env env,
30443042
}
30453043

30463044
if (data != nullptr) {
3047-
*data = static_cast<uint8_t*>(buffer->GetBackingStore()->Data()) +
3048-
array->ByteOffset();
3045+
*data = static_cast<uint8_t*>(buffer->Data()) + array->ByteOffset();
30493046
}
30503047

30513048
if (arraybuffer != nullptr) {
@@ -3255,8 +3252,8 @@ napi_status NAPI_CDECL napi_is_detached_arraybuffer(napi_env env,
32553252

32563253
v8::Local<v8::Value> value = v8impl::V8LocalValueFromJsValue(arraybuffer);
32573254

3258-
*result = value->IsArrayBuffer() &&
3259-
value.As<v8::ArrayBuffer>()->GetBackingStore()->Data() == nullptr;
3255+
*result =
3256+
value->IsArrayBuffer() && value.As<v8::ArrayBuffer>()->Data() == nullptr;
32603257

32613258
return napi_clear_last_error(env);
32623259
}

0 commit comments

Comments
 (0)