diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2014-03-31 15:13:37 +0200 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-04-02 00:05:25 +0400 |
commit | c7214fe355596543d92d7c10b38d78ca65b4abfe (patch) | |
tree | 185d2795e28bc92d2f0f1fbb45799012ec578ca7 /src | |
parent | 5e24adbb90d085e6ac0e37ad6f016b1c94ce01d6 (diff) | |
download | android-node-v8-c7214fe355596543d92d7c10b38d78ca65b4abfe.tar.gz android-node-v8-c7214fe355596543d92d7c10b38d78ca65b4abfe.tar.bz2 android-node-v8-c7214fe355596543d92d7c10b38d78ca65b4abfe.zip |
src: fix up after v8 upgrade
The two biggest changes are that v8::Script::New() has been removed and
that a v8::Script object now has to be explicitly bound to a context if
you want to run it from another context.
We can accommodate both changes without breaking the vm module's public
API or even the internal JS API.
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 2 | ||||
-rw-r--r-- | src/node_contextify.cc | 18 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/node.cc b/src/node.cc index 65de300159..31c77c0b3b 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1491,7 +1491,7 @@ static void ReportException(Environment* env, const TryCatch& try_catch) { // Executes a str within the current v8 context. static Local<Value> ExecuteString(Environment* env, Handle<String> source, - Handle<Value> filename) { + Handle<String> filename) { EscapableHandleScope scope(env->isolate()); TryCatch try_catch; diff --git a/src/node_contextify.cc b/src/node_contextify.cc index f552387ed2..0f07e57d4f 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -51,8 +51,11 @@ using v8::ObjectTemplate; using v8::Persistent; using v8::PropertyCallbackInfo; using v8::Script; +using v8::ScriptCompiler; +using v8::ScriptOrigin; using v8::String; using v8::TryCatch; +using v8::UnboundScript; using v8::V8; using v8::Value; using v8::WeakCallbackData; @@ -430,7 +433,7 @@ class ContextifyContext { class ContextifyScript : public BaseObject { private: - Persistent<Script> script_; + Persistent<UnboundScript> script_; public: static void Init(Environment* env, Local<Object> target) { @@ -473,10 +476,10 @@ class ContextifyScript : public BaseObject { return; } - Local<Context> context = env->context(); - Context::Scope context_scope(context); - - Local<Script> v8_script = Script::New(code, filename); + ScriptOrigin origin(filename); + ScriptCompiler::Source source(code, origin); + Local<UnboundScript> v8_script = + ScriptCompiler::CompileUnbound(env->isolate(), &source); if (v8_script.IsEmpty()) { if (display_errors) { @@ -639,8 +642,9 @@ class ContextifyScript : public BaseObject { ContextifyScript* wrapped_script = Unwrap<ContextifyScript>(args.This()); - Local<Script> script = PersistentToLocal(env->isolate(), - wrapped_script->script_); + Local<UnboundScript> unbound_script = + PersistentToLocal(env->isolate(), wrapped_script->script_); + Local<Script> script = unbound_script->BindToCurrentContext(); Local<Value> result; if (timeout != -1) { |