@@ -19,7 +19,7 @@ static volatile v8wrap_callback ___go_v8_callback = NULL;
19
19
20
20
static std::string
21
21
to_json (v8::Handle<v8::Value> value) {
22
- v8::HandleScope scope;
22
+ v8::HandleScope scope ( v8::Isolate::GetCurrent ()) ;
23
23
v8::TryCatch try_catch;
24
24
v8::Handle<v8::Object> json = v8::Handle<v8::Object>::Cast (
25
25
v8::Context::GetCurrent ()->Global ()->Get (v8::String::New (" JSON" )));
@@ -34,7 +34,7 @@ to_json(v8::Handle<v8::Value> value) {
34
34
35
35
v8::Handle<v8::Value>
36
36
from_json (std::string str) {
37
- v8::HandleScope scope;
37
+ v8::HandleScope scope ( v8::Isolate::GetCurrent ()) ;
38
38
v8::TryCatch try_catch;
39
39
40
40
v8::Handle<v8::Object> json = v8::Handle<v8::Object>::Cast (
@@ -51,8 +51,8 @@ v8_get_array_item(v8data* array, int index) {
51
51
return array[index];
52
52
}
53
53
54
- v8::Handle<v8::Value>
55
- _go_call (const v8::Arguments & args) {
54
+ void
55
+ _go_call (const v8::FunctionCallbackInfo<v8::Value> & args) {
56
56
v8::Locker v8Locker;
57
57
uint32_t id = args[0 ]->ToUint32 ()->Value ();
58
58
v8::String::Utf8Value name (args[1 ]);
@@ -106,33 +106,34 @@ _go_call(const v8::Arguments& args) {
106
106
if (retv != NULL ) {
107
107
v8::Handle<v8::Value> ret = from_json (retv);
108
108
free (retv);
109
- return ret;
109
+ args. GetReturnValue (). Set ( ret) ;
110
110
}
111
- return v8::Undefined ();
111
+ args. GetReturnValue (). Set ( v8::Undefined () );
112
112
}
113
113
114
114
class V8Context {
115
115
public:
116
116
V8Context () : err_(" " ) {
117
117
v8::Locker v8Locker;
118
- v8::HandleScope scope;
119
- global_ = v8::Persistent<v8::ObjectTemplate>::New (v8::ObjectTemplate::New ());
120
- global_->Set (v8::String::New (" _go_call" ),
118
+ v8::Isolate* isolate = v8::Isolate::GetCurrent ();
119
+ v8::HandleScope scope (isolate);
120
+ v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New ();
121
+ global->Set (v8::String::New (" _go_call" ),
121
122
v8::FunctionTemplate::New (_go_call));
122
- v8::Handle<v8::Context> context = v8::Context::New (NULL , global_);
123
- context_ = v8::Persistent<v8::Context>::New (context);
123
+
124
+ v8::Local<v8::Context> context = v8::Context::New (isolate, NULL , global);
125
+ context_.Reset (isolate, context);
126
+
124
127
};
125
128
126
129
virtual ~V8Context () {
127
130
context_.Dispose ();
128
- global_.Dispose ();
129
131
};
130
- v8::Handle<v8::Context> context () { return context_; };
132
+ v8::Handle<v8::Context> context () { return v8::Handle<v8::Context>:: New ( v8::Isolate::GetCurrent (), context_) ; };
131
133
const char * err () const { return err_.c_str (); };
132
134
void err (const char * e) { this ->err_ = std::string (e); }
133
135
134
136
private:
135
- v8::Persistent<v8::ObjectTemplate> global_;
136
137
v8::Persistent<v8::Context> context_;
137
138
std::string err_;
138
139
};
@@ -197,7 +198,7 @@ char*
197
198
v8_execute (void *ctx, char * source) {
198
199
v8::Locker v8Locker;
199
200
V8Context *context = static_cast <V8Context *>(ctx);
200
- v8::HandleScope scope;
201
+ v8::HandleScope scope ( v8::Isolate::GetCurrent ()) ;
201
202
v8::TryCatch try_catch;
202
203
203
204
v8::Context::Scope context_scope (context->context ());
0 commit comments