Skip to content

Commit 194eeb8

Browse files
bnoordhuisFishrock123
authored andcommitted
test: drop Isolate::GetCurrent() from addon tests
v8::Isolate::GetCurrent() is not exactly deprecated at this point but its use is strongly discouraged. Update the addon tests so they no longer use it. PR-URL: #2427 Reviewed-By: Trevor Norris <[email protected]>
1 parent 46cdb2f commit 194eeb8

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ struct async_req {
77
uv_work_t req;
88
int input;
99
int output;
10+
v8::Isolate* isolate;
1011
v8::Persistent<v8::Function> callback;
1112
};
1213

@@ -17,9 +18,9 @@ void DoAsync(uv_work_t* r) {
1718
}
1819

1920
void AfterAsync(uv_work_t* r) {
20-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
21-
v8::HandleScope scope(isolate);
2221
async_req* req = reinterpret_cast<async_req*>(r->data);
22+
v8::Isolate* isolate = req->isolate;
23+
v8::HandleScope scope(isolate);
2324

2425
v8::Handle<v8::Value> argv[2] = {
2526
v8::Null(isolate),
@@ -42,14 +43,15 @@ void AfterAsync(uv_work_t* r) {
4243
}
4344

4445
void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
45-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
46+
v8::Isolate* isolate = args.GetIsolate();
4647
v8::HandleScope scope(isolate);
4748

4849
async_req* req = new async_req;
4950
req->req.data = req;
5051

5152
req->input = args[0]->IntegerValue();
5253
req->output = 0;
54+
req->isolate = isolate;
5355

5456
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(args[1]);
5557
req->callback.Reset(isolate, callback);

test/addons/at-exit/binding.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ static int at_exit_cb1_called = 0;
1616
static int at_exit_cb2_called = 0;
1717

1818
static void at_exit_cb1(void* arg) {
19-
// FIXME(bnoordhuis) Isolate::GetCurrent() is on its way out.
20-
Isolate* isolate = Isolate::GetCurrent();
19+
Isolate* isolate = static_cast<Isolate*>(arg);
2120
HandleScope handle_scope(isolate);
22-
assert(arg == 0);
2321
Local<Object> obj = Object::New(isolate);
2422
assert(!obj.IsEmpty()); // Assert VM is still alive.
2523
assert(obj->IsObject());
@@ -37,7 +35,7 @@ static void sanity_check(void) {
3735
}
3836

3937
void init(Handle<Object> target) {
40-
AtExit(at_exit_cb1);
38+
AtExit(at_exit_cb1, target->CreationContext()->GetIsolate());
4139
AtExit(at_exit_cb2, cookie);
4240
AtExit(at_exit_cb2, cookie);
4341
atexit(sanity_check);

test/addons/hello-world-function-export/binding.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <v8.h>
33

44
void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
5-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
5+
v8::Isolate* isolate = args.GetIsolate();
66
v8::HandleScope scope(isolate);
77
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, "world"));
88
}

test/addons/hello-world/binding.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <v8.h>
33

44
void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
5-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
5+
v8::Isolate* isolate = args.GetIsolate();
66
v8::HandleScope scope(isolate);
77
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, "world"));
88
}

0 commit comments

Comments
 (0)