Skip to content

Commit

Permalink
test: drop Isolate::GetCurrent() from addon tests
Browse files Browse the repository at this point in the history
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 <trev.norris@gmail.com>
  • Loading branch information
bnoordhuis authored and Fishrock123 committed Aug 19, 2015
1 parent 46cdb2f commit 194eeb8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 5 additions & 3 deletions test/addons/async-hello-world/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ struct async_req {
uv_work_t req;
int input;
int output;
v8::Isolate* isolate;
v8::Persistent<v8::Function> callback;
};

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

void AfterAsync(uv_work_t* r) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
async_req* req = reinterpret_cast<async_req*>(r->data);
v8::Isolate* isolate = req->isolate;
v8::HandleScope scope(isolate);

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

void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);

async_req* req = new async_req;
req->req.data = req;

req->input = args[0]->IntegerValue();
req->output = 0;
req->isolate = isolate;

v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(args[1]);
req->callback.Reset(isolate, callback);
Expand Down
6 changes: 2 additions & 4 deletions test/addons/at-exit/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ static int at_exit_cb1_called = 0;
static int at_exit_cb2_called = 0;

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

void init(Handle<Object> target) {
AtExit(at_exit_cb1);
AtExit(at_exit_cb1, target->CreationContext()->GetIsolate());
AtExit(at_exit_cb2, cookie);
AtExit(at_exit_cb2, cookie);
atexit(sanity_check);
Expand Down
2 changes: 1 addition & 1 deletion test/addons/hello-world-function-export/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <v8.h>

void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, "world"));
}
Expand Down
2 changes: 1 addition & 1 deletion test/addons/hello-world/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <v8.h>

void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, "world"));
}
Expand Down

0 comments on commit 194eeb8

Please sign in to comment.