Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: remove usages of GetBackingStore in node-api #44075

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2780,7 +2780,7 @@ napi_status NAPI_CDECL napi_create_arraybuffer(napi_env env,
// Optionally return a pointer to the buffer's data, to avoid another call to
// retrieve it.
if (data != nullptr) {
*data = buffer->GetBackingStore()->Data();
*data = buffer->Data();
}

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

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

if (data != nullptr) {
*data = backing_store->Data();
*data = ab->Data();
}

if (byte_length != nullptr) {
*byte_length = backing_store->ByteLength();
*byte_length = ab->ByteLength();
}

return napi_clear_last_error(env);
Expand Down Expand Up @@ -2963,8 +2962,7 @@ napi_status NAPI_CDECL napi_get_typedarray_info(napi_env env,
}

if (data != nullptr) {
*data = static_cast<uint8_t*>(buffer->GetBackingStore()->Data()) +
array->ByteOffset();
*data = static_cast<uint8_t*>(buffer->Data()) + array->ByteOffset();
}

if (arraybuffer != nullptr) {
Expand Down Expand Up @@ -3044,8 +3042,7 @@ napi_status NAPI_CDECL napi_get_dataview_info(napi_env env,
}

if (data != nullptr) {
*data = static_cast<uint8_t*>(buffer->GetBackingStore()->Data()) +
array->ByteOffset();
*data = static_cast<uint8_t*>(buffer->Data()) + array->ByteOffset();
}

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

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

*result = value->IsArrayBuffer() &&
value.As<v8::ArrayBuffer>()->GetBackingStore()->Data() == nullptr;
*result =
value->IsArrayBuffer() && value.As<v8::ArrayBuffer>()->Data() == nullptr;

return napi_clear_last_error(env);
}