diff options
author | Trevor Norris <trev.norris@gmail.com> | 2013-03-18 13:49:34 -0700 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-03-20 01:11:01 +0100 |
commit | 83261e789eb903da39f279cb5a161611482e7df5 (patch) | |
tree | 4133b5ca9f53bed4365e1a94544a227d68a0cf12 /deps/v8/samples/lineprocessor.cc | |
parent | a05f973f82d2be8527aad4c371d40d3c7e4c564e (diff) | |
download | android-node-v8-83261e789eb903da39f279cb5a161611482e7df5.tar.gz android-node-v8-83261e789eb903da39f279cb5a161611482e7df5.tar.bz2 android-node-v8-83261e789eb903da39f279cb5a161611482e7df5.zip |
deps: update v8 to 3.17.13
Diffstat (limited to 'deps/v8/samples/lineprocessor.cc')
-rw-r--r-- | deps/v8/samples/lineprocessor.cc | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/deps/v8/samples/lineprocessor.cc b/deps/v8/samples/lineprocessor.cc index 26e787f2b7..b5b63675e5 100644 --- a/deps/v8/samples/lineprocessor.cc +++ b/deps/v8/samples/lineprocessor.cc @@ -98,13 +98,14 @@ enum MainCycleType { }; const char* ToCString(const v8::String::Utf8Value& value); -void ReportException(v8::TryCatch* handler); +void ReportException(v8::Isolate* isolate, v8::TryCatch* handler); v8::Handle<v8::String> ReadFile(const char* name); v8::Handle<v8::String> ReadLine(); v8::Handle<v8::Value> Print(const v8::Arguments& args); v8::Handle<v8::Value> ReadLine(const v8::Arguments& args); -bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context, +bool RunCppCycle(v8::Handle<v8::Script> script, + v8::Local<v8::Context> context, bool report_exceptions); @@ -132,7 +133,8 @@ void DispatchDebugMessages() { int RunMain(int argc, char* argv[]) { v8::V8::SetFlagsFromCommandLine(&argc, argv, true); - v8::HandleScope handle_scope; + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope handle_scope(isolate); v8::Handle<v8::String> script_source(NULL); v8::Handle<v8::Value> script_name(NULL); @@ -212,9 +214,10 @@ int RunMain(int argc, char* argv[]) { v8::Context::Scope context_scope(context); #ifdef ENABLE_DEBUGGER_SUPPORT - debug_message_context = v8::Persistent<v8::Context>::New(context); + debug_message_context = + v8::Persistent<v8::Context>::New(isolate, context); - v8::Locker locker; + v8::Locker locker(isolate); if (support_callback) { v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true); @@ -235,7 +238,7 @@ int RunMain(int argc, char* argv[]) { if (script.IsEmpty()) { // Print errors that happened during compilation. if (report_exceptions) - ReportException(&try_catch); + ReportException(isolate, &try_catch); return 1; } } @@ -246,13 +249,14 @@ int RunMain(int argc, char* argv[]) { script->Run(); if (try_catch.HasCaught()) { if (report_exceptions) - ReportException(&try_catch); + ReportException(isolate, &try_catch); return 1; } } if (cycle_type == CycleInCpp) { - bool res = RunCppCycle(script, v8::Context::GetCurrent(), + bool res = RunCppCycle(script, + v8::Context::GetCurrent(), report_exceptions); return !res; } else { @@ -262,15 +266,16 @@ int RunMain(int argc, char* argv[]) { } -bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context, +bool RunCppCycle(v8::Handle<v8::Script> script, + v8::Local<v8::Context> context, bool report_exceptions) { + v8::Isolate* isolate = context->GetIsolate(); #ifdef ENABLE_DEBUGGER_SUPPORT - v8::Locker lock; + v8::Locker lock(isolate); #endif // ENABLE_DEBUGGER_SUPPORT v8::Handle<v8::String> fun_name = v8::String::New("ProcessLine"); - v8::Handle<v8::Value> process_val = - v8::Context::GetCurrent()->Global()->Get(fun_name); + v8::Handle<v8::Value> process_val = context->Global()->Get(fun_name); // If there is no Process function, or if it is not a function, // bail out @@ -285,7 +290,7 @@ bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context, while (!feof(stdin)) { - v8::HandleScope handle_scope; + v8::HandleScope handle_scope(isolate); v8::Handle<v8::String> input_line = ReadLine(); if (input_line == v8::Undefined()) { @@ -302,7 +307,7 @@ bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context, argc, argv); if (try_catch.HasCaught()) { if (report_exceptions) - ReportException(&try_catch); + ReportException(isolate, &try_catch); return false; } } @@ -349,8 +354,8 @@ v8::Handle<v8::String> ReadFile(const char* name) { } -void ReportException(v8::TryCatch* try_catch) { - v8::HandleScope handle_scope; +void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) { + v8::HandleScope handle_scope(isolate); v8::String::Utf8Value exception(try_catch->Exception()); const char* exception_string = ToCString(exception); v8::Handle<v8::Message> message = try_catch->Message(); @@ -388,7 +393,7 @@ void ReportException(v8::TryCatch* try_catch) { v8::Handle<v8::Value> Print(const v8::Arguments& args) { bool first = true; for (int i = 0; i < args.Length(); i++) { - v8::HandleScope handle_scope; + v8::HandleScope handle_scope(args.GetIsolate()); if (first) { first = false; } else { @@ -420,7 +425,7 @@ v8::Handle<v8::String> ReadLine() { char* res; { #ifdef ENABLE_DEBUGGER_SUPPORT - v8::Unlocker unlocker; + v8::Unlocker unlocker(v8::Isolate::GetCurrent()); #endif // ENABLE_DEBUGGER_SUPPORT res = fgets(buffer, kBufferSize, stdin); } |