Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: samples/lineprocessor.cc

Issue 12716010: Added a version of the v8::HandleScope constructor with an Isolate and use that consistently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed rest Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | samples/process.cc » ('j') | samples/shell.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/lineprocessor.cc
diff --git a/samples/lineprocessor.cc b/samples/lineprocessor.cc
index 6549f4c260b803d89fc217853ac5775b799f5b75..b5b63675e593d30badcb021f3cf4e203963ceef9 100644
--- a/samples/lineprocessor.cc
+++ b/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);
@@ -213,9 +215,9 @@ int RunMain(int argc, char* argv[]) {
#ifdef ENABLE_DEBUGGER_SUPPORT
debug_message_context =
- v8::Persistent<v8::Context>::New(context->GetIsolate(), context);
+ v8::Persistent<v8::Context>::New(isolate, context);
- v8::Locker locker(context->GetIsolate());
+ v8::Locker locker(isolate);
if (support_callback) {
v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true);
@@ -236,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;
}
}
@@ -247,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 {
@@ -263,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::Isolate::GetCurrent());
+ 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
@@ -286,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()) {
@@ -303,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;
}
}
@@ -350,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();
@@ -389,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 {
« no previous file with comments | « include/v8.h ('k') | samples/process.cc » ('j') | samples/shell.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698