GeezerVison is showing github.com — src: replace uses of deprecated v8::External APIs · nodejs/node@5334433
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/crypto/crypto_context.cc +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2409,7 +2409,8 @@ int SecureContext::TicketCompatibilityCallback(SSL* ssl, | 2409 | 2409 | void SecureContext::CtxGetter(const FunctionCallbackInfo<Value>& info) { | 2410 | 2410 | SecureContext* sc; | 2411 | 2411 | ASSIGN_OR_RETURN_UNWRAP(&sc, info.This()); | 2412 | | - Local<External> ext = External::New(info.GetIsolate(), sc->ctx_.get()); | | 2412 | + Local<External> ext = External::New( | | 2413 | + info.GetIsolate(), sc->ctx_.get(), v8::kExternalPointerTypeTagDefault); | 2413 | 2414 | info.GetReturnValue().Set(ext); | 2414 | 2415 | } | 2415 | 2416 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/js_native_api_v8.cc +15-9Lines changed: 15 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -355,8 +355,8 @@ inline napi_status Unwrap(napi_env env, | 355 | 355 | auto val = obj->GetPrivate(context, NAPI_PRIVATE_KEY(context, wrapper)) | 356 | 356 | .ToLocalChecked(); | 357 | 357 | RETURN_STATUS_IF_FALSE(env, val->IsExternal(), napi_invalid_arg); | 358 | | - Reference* reference = | 359 | | - static_cast<v8impl::Reference*>(val.As<v8::External>()->Value()); | | 358 | + Reference* reference = static_cast<v8impl::Reference*>( | | 359 | + val.As<v8::External>()->Value(v8::kExternalPointerTypeTagDefault)); | 360 | 360 |
| 361 | 361 | if (result) { | 362 | 362 | *result = reference->Data(); | @@ -395,14 +395,16 @@ class CallbackBundle { | 395 | 395 | bundle->cb_data = data; | 396 | 396 | bundle->env = env; | 397 | 397 |
| 398 | | - v8::Local<v8::Value> cbdata = v8::External::New(env->isolate, bundle); | | 398 | + v8::Local<v8::Value> cbdata = v8::External::New( | | 399 | + env->isolate, bundle, v8::kExternalPointerTypeTagDefault); | 399 | 400 | ReferenceWithFinalizer::New( | 400 | 401 | env, cbdata, 0, ReferenceOwnership::kRuntime, Delete, bundle, nullptr); | 401 | 402 | return cbdata; | 402 | 403 | } | 403 | 404 |
| 404 | 405 | static CallbackBundle* FromCallbackData(v8::Local<v8::Value> data) { | 405 | | - return reinterpret_cast<CallbackBundle*>(data.As<v8::External>()->Value()); | | 406 | + return reinterpret_cast<CallbackBundle*>( | | 407 | + data.As<v8::External>()->Value(v8::kExternalPointerTypeTagDefault)); | 406 | 408 | } | 407 | 409 |
| 408 | 410 | public: | @@ -573,9 +575,11 @@ inline napi_status Wrap(napi_env env, | 573 | 575 | env, obj, 0, v8impl::ReferenceOwnership::kRuntime, native_object); | 574 | 576 | } | 575 | 577 |
| 576 | | - CHECK(obj->SetPrivate(context, | 577 | | - NAPI_PRIVATE_KEY(context, wrapper), | 578 | | - v8::External::New(env->isolate, reference)) | | 578 | + CHECK(obj->SetPrivate( | | 579 | + context, | | 580 | + NAPI_PRIVATE_KEY(context, wrapper), | | 581 | + v8::External::New( | | 582 | + env->isolate, reference, v8::kExternalPointerTypeTagDefault)) | 579 | 583 | .FromJust()); | 580 | 584 |
| 581 | 585 | return GET_RETURN_STATUS(env); | @@ -842,7 +846,8 @@ class ExternalWrapper { | 842 | 846 | public: | 843 | 847 | static v8::Local<v8::External> New(napi_env env, void* data) { | 844 | 848 | ExternalWrapper* wrapper = new ExternalWrapper(data); | 845 | | - v8::Local<v8::External> external = v8::External::New(env->isolate, wrapper); | | 849 | + v8::Local<v8::External> external = v8::External::New( | | 850 | + env->isolate, wrapper, v8::kExternalPointerTypeTagDefault); | 846 | 851 | wrapper->persistent_.Reset(env->isolate, external); | 847 | 852 | wrapper->persistent_.SetWeak( | 848 | 853 | wrapper, WeakCallback, v8::WeakCallbackType::kParameter); | @@ -851,7 +856,8 @@ class ExternalWrapper { | 851 | 856 | } | 852 | 857 |
| 853 | 858 | static ExternalWrapper* From(v8::Local<v8::External> external) { | 854 | | - return static_cast<ExternalWrapper*>(external->Value()); | | 859 | + return static_cast<ExternalWrapper*>( | | 860 | + external->Value(v8::kExternalPointerTypeTagDefault)); | 855 | 861 | } | 856 | 862 |
| 857 | 863 | void* Data() { return data_; } | |
Collapse file Copy file name to clipboardExpand all lines: src/node_modules.cc +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -552,8 +552,10 @@ void GetCompileCacheEntry(const FunctionCallbackInfo<Value>& args) { | 552 | 552 |
| 553 | 553 | v8::LocalVector<v8::Name> names(isolate, | 554 | 554 | {FIXED_ONE_BYTE_STRING(isolate, "external")}); | 555 | | - v8::LocalVector<v8::Value> values(isolate, | 556 | | - {v8::External::New(isolate, cache_entry)}); | | 555 | + v8::LocalVector<v8::Value> values( | | 556 | + isolate, | | 557 | + {v8::External::New( | | 558 | + isolate, cache_entry, v8::kExternalPointerTypeTagDefault)}); | 557 | 559 | if (cache_entry->cache != nullptr) { | 558 | 560 | Debug(env, | 559 | 561 | DebugCategory::COMPILE_CACHE, | @@ -592,8 +594,8 @@ void SaveCompileCacheEntry(const FunctionCallbackInfo<Value>& args) { | 592 | 594 | DCHECK(env->use_compile_cache()); | 593 | 595 | CHECK(args[0]->IsExternal()); | 594 | 596 | CHECK(args[1]->IsString()); // TODO(joyeecheung): accept buffer. | 595 | | - auto* cache_entry = | 596 | | - static_cast<CompileCacheEntry*>(args[0].As<External>()->Value()); | | 597 | + auto* cache_entry = static_cast<CompileCacheEntry*>( | | 598 | + args[0].As<External>()->Value(v8::kExternalPointerTypeTagDefault)); | 597 | 599 | Utf8Value utf8(isolate, args[1].As<String>()); | 598 | 600 | env->compile_cache_handler()->MaybeSave(cache_entry, utf8.ToStringView()); | 599 | 601 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/node_util.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -93,7 +93,7 @@ static void GetExternalValue( | 93 | 93 | Isolate* isolate = args.GetIsolate(); | 94 | 94 | Local<External> external = args[0].As<External>(); | 95 | 95 |
| 96 | | - void* ptr = external->Value(); | | 96 | + void* ptr = external->Value(v8::kExternalPointerTypeTagDefault); | 97 | 97 | uint64_t value = reinterpret_cast<uint64_t>(ptr); | 98 | 98 | Local<BigInt> ret = BigInt::NewFromUnsigned(isolate, value); | 99 | 99 | args.GetReturnValue().Set(ret); | |
Collapse file Copy file name to clipboardExpand all lines: src/stream_base.cc +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -653,7 +653,8 @@ void StreamBase::GetExternal(const FunctionCallbackInfo<Value>& args) { | 653 | 653 | StreamBase* wrap = StreamBase::FromObject(args.This().As<Object>()); | 654 | 654 | if (wrap == nullptr) return; | 655 | 655 |
| 656 | | - Local<External> ext = External::New(args.GetIsolate(), wrap); | | 656 | + Local<External> ext = External::New( | | 657 | + args.GetIsolate(), wrap, v8::kExternalPointerTypeTagDefault); | 657 | 658 | args.GetReturnValue().Set(ext); | 658 | 659 | } | 659 | 660 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/cctest/test_environment.cc +12-8Lines changed: 12 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -700,14 +700,18 @@ TEST_F(EnvironmentTest, NestedMicrotaskQueue) { | 700 | 700 |
| 701 | 701 | using IntVec = std::vector<int>; | 702 | 702 | IntVec callback_calls; | 703 | | - v8::Local<v8::Function> must_call = v8::Function::New( | 704 | | - context, | 705 | | - [](const v8::FunctionCallbackInfo<v8::Value>& info) { | 706 | | - IntVec* callback_calls = static_cast<IntVec*>( | 707 | | - info.Data().As<v8::External>()->Value()); | 708 | | - callback_calls->push_back(info[0].As<v8::Int32>()->Value()); | 709 | | - }, | 710 | | - v8::External::New(isolate_, static_cast<void*>(&callback_calls))) | | 703 | + v8::Local<v8::Function> must_call = | | 704 | + v8::Function::New( | | 705 | + context, | | 706 | + [](const v8::FunctionCallbackInfo<v8::Value>& info) { | | 707 | + IntVec* callback_calls = | | 708 | + static_cast<IntVec*>(info.Data().As<v8::External>()->Value( | | 709 | + v8::kExternalPointerTypeTagDefault)); | | 710 | + callback_calls->push_back(info[0].As<v8::Int32>()->Value()); | | 711 | + }, | | 712 | + v8::External::New(isolate_, | | 713 | + static_cast<void*>(&callback_calls), | | 714 | + v8::kExternalPointerTypeTagDefault)) | 711 | 715 | .ToLocalChecked(); | 712 | 716 | context->Global()->Set( | 713 | 717 | context, | |
|