File tree 4 files changed +9
-9
lines changed
hello-world-function-export
4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ struct async_req {
7
7
uv_work_t req;
8
8
int input;
9
9
int output;
10
+ v8::Isolate* isolate;
10
11
v8::Persistent<v8::Function> callback;
11
12
};
12
13
@@ -17,9 +18,9 @@ void DoAsync(uv_work_t* r) {
17
18
}
18
19
19
20
void AfterAsync (uv_work_t * r) {
20
- v8::Isolate* isolate = v8::Isolate::GetCurrent ();
21
- v8::HandleScope scope (isolate);
22
21
async_req* req = reinterpret_cast <async_req*>(r->data );
22
+ v8::Isolate* isolate = req->isolate ;
23
+ v8::HandleScope scope (isolate);
23
24
24
25
v8::Handle <v8::Value> argv[2 ] = {
25
26
v8::Null (isolate),
@@ -42,14 +43,15 @@ void AfterAsync(uv_work_t* r) {
42
43
}
43
44
44
45
void Method (const v8::FunctionCallbackInfo<v8::Value>& args) {
45
- v8::Isolate* isolate = v8::Isolate::GetCurrent ();
46
+ v8::Isolate* isolate = args. GetIsolate ();
46
47
v8::HandleScope scope (isolate);
47
48
48
49
async_req* req = new async_req;
49
50
req->req .data = req;
50
51
51
52
req->input = args[0 ]->IntegerValue ();
52
53
req->output = 0 ;
54
+ req->isolate = isolate;
53
55
54
56
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast (args[1 ]);
55
57
req->callback .Reset (isolate, callback);
Original file line number Diff line number Diff line change @@ -16,10 +16,8 @@ static int at_exit_cb1_called = 0;
16
16
static int at_exit_cb2_called = 0 ;
17
17
18
18
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);
21
20
HandleScope handle_scope (isolate);
22
- assert (arg == 0 );
23
21
Local<Object> obj = Object::New (isolate);
24
22
assert (!obj.IsEmpty ()); // Assert VM is still alive.
25
23
assert (obj->IsObject ());
@@ -37,7 +35,7 @@ static void sanity_check(void) {
37
35
}
38
36
39
37
void init (Handle <Object> target) {
40
- AtExit (at_exit_cb1);
38
+ AtExit (at_exit_cb1, target-> CreationContext ()-> GetIsolate () );
41
39
AtExit (at_exit_cb2, cookie);
42
40
AtExit (at_exit_cb2, cookie);
43
41
atexit (sanity_check);
Original file line number Diff line number Diff line change 2
2
#include < v8.h>
3
3
4
4
void Method (const v8::FunctionCallbackInfo<v8::Value>& args) {
5
- v8::Isolate* isolate = v8::Isolate::GetCurrent ();
5
+ v8::Isolate* isolate = args. GetIsolate ();
6
6
v8::HandleScope scope (isolate);
7
7
args.GetReturnValue ().Set (v8::String::NewFromUtf8 (isolate, " world" ));
8
8
}
Original file line number Diff line number Diff line change 2
2
#include < v8.h>
3
3
4
4
void Method (const v8::FunctionCallbackInfo<v8::Value>& args) {
5
- v8::Isolate* isolate = v8::Isolate::GetCurrent ();
5
+ v8::Isolate* isolate = args. GetIsolate ();
6
6
v8::HandleScope scope (isolate);
7
7
args.GetReturnValue ().Set (v8::String::NewFromUtf8 (isolate, " world" ));
8
8
}
You can’t perform that action at this time.
0 commit comments