Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d1a803

Browse filesBrowse files
danbevcodebytere
authored andcommitted
test: fix v8 Set/Get compiler warnings
PR-URL: #24246 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent 90f3f5e commit 4d1a803
Copy full SHA for 4d1a803

File tree

Expand file treeCollapse file tree

5 files changed

+17
-11
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+17
-11
lines changed
Open diff view settings
Collapse file

‎benchmark/napi/function_args/binding.cc‎

Copy file name to clipboardExpand all lines: benchmark/napi/function_args/binding.cc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ void CallWithArray(const FunctionCallbackInfo<Value>& args) {
3333
uint32_t length = array->Length();
3434
for (uint32_t i = 0; i < length; ++ i) {
3535
Local<Value> v;
36-
v = array->Get(i);
36+
v = array->Get(args.GetIsolate()->GetCurrentContext(),
37+
i).ToLocalChecked();
3738
}
3839
}
3940
}
Collapse file

‎doc/api/addons.md‎

Copy file name to clipboardExpand all lines: doc/api/addons.md
+9-5Lines changed: 9 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ to invoke such callbacks:
537537

538538
namespace demo {
539539

540+
using v8::Context;
540541
using v8::Function;
541542
using v8::FunctionCallbackInfo;
542543
using v8::Isolate;
@@ -549,13 +550,14 @@ using v8::Value;
549550

550551
void RunCallback(const FunctionCallbackInfo<Value>& args) {
551552
Isolate* isolate = args.GetIsolate();
553+
Local<Context> context = isolate->GetCurrentContext();
552554
Local<Function> cb = Local<Function>::Cast(args[0]);
553555
const unsigned argc = 1;
554556
Local<Value> argv[argc] = {
555557
String::NewFromUtf8(isolate,
556558
"hello world",
557559
NewStringType::kNormal).ToLocalChecked() };
558-
cb->Call(Null(isolate), argc, argv);
560+
cb->Call(context, Null(isolate), argc, argv).ToLocalChecked();
559561
}
560562

561563
void Init(Local<Object> exports, Local<Object> module) {
@@ -612,10 +614,12 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) {
612614
Local<Context> context = isolate->GetCurrentContext();
613615

614616
Local<Object> obj = Object::New(isolate);
615-
obj->Set(String::NewFromUtf8(isolate,
617+
obj->Set(context,
618+
String::NewFromUtf8(isolate,
616619
"msg",
617620
NewStringType::kNormal).ToLocalChecked(),
618-
args[0]->ToString(context).ToLocalChecked());
621+
args[0]->ToString(context).ToLocalChecked())
622+
.FromJust();
619623

620624
args.GetReturnValue().Set(obj);
621625
}
@@ -803,9 +807,9 @@ void MyObject::Init(Local<Object> exports) {
803807

804808
Local<Context> context = isolate->GetCurrentContext();
805809
constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
806-
exports->Set(String::NewFromUtf8(
810+
exports->Set(context, String::NewFromUtf8(
807811
isolate, "MyObject", NewStringType::kNormal).ToLocalChecked(),
808-
tpl->GetFunction(context).ToLocalChecked());
812+
tpl->GetFunction(context).ToLocalChecked()).FromJust();
809813
}
810814

811815
void MyObject::New(const FunctionCallbackInfo<Value>& args) {
Collapse file

‎test/addons/async-hello-world/binding.cc‎

Copy file name to clipboardExpand all lines: test/addons/async-hello-world/binding.cc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ void AfterAsync(uv_work_t* r) {
5353
// This should be changed to an empty handle.
5454
assert(!ret.IsEmpty());
5555
} else {
56-
callback->Call(global, 2, argv);
56+
callback->Call(isolate->GetCurrentContext(),
57+
global, 2, argv).ToLocalChecked();
5758
}
5859

5960
// cleanup
Collapse file

‎test/addons/heap-profiler/binding.cc‎

Copy file name to clipboardExpand all lines: test/addons/heap-profiler/binding.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ inline void Test(const v8::FunctionCallbackInfo<v8::Value>& args) {
1919
inline void Initialize(v8::Local<v8::Object> binding) {
2020
v8::Isolate* const isolate = binding->GetIsolate();
2121
v8::Local<v8::Context> context = isolate->GetCurrentContext();
22-
binding->Set(v8::String::NewFromUtf8(
22+
binding->Set(context, v8::String::NewFromUtf8(
2323
isolate, "test", v8::NewStringType::kNormal).ToLocalChecked(),
2424
v8::FunctionTemplate::New(isolate, Test)
2525
->GetFunction(context)
26-
.ToLocalChecked());
26+
.ToLocalChecked()).FromJust();
2727
}
2828

2929
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
Collapse file

‎test/addons/new-target/binding.cc‎

Copy file name to clipboardExpand all lines: test/addons/new-target/binding.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ inline void NewClass(const v8::FunctionCallbackInfo<v8::Value>& args) {
1212
inline void Initialize(v8::Local<v8::Object> binding) {
1313
auto isolate = binding->GetIsolate();
1414
auto context = isolate->GetCurrentContext();
15-
binding->Set(v8::String::NewFromUtf8(
15+
binding->Set(context, v8::String::NewFromUtf8(
1616
isolate, "Class", v8::NewStringType::kNormal).ToLocalChecked(),
1717
v8::FunctionTemplate::New(isolate, NewClass)
1818
->GetFunction(context)
19-
.ToLocalChecked());
19+
.ToLocalChecked()).FromJust();
2020
}
2121

2222
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.