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

Side by Side Diff: samples/shell.cc

Issue 24538002: add isolate parameter to ThrowException (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/lineprocessor.cc ('k') | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 printf("\n"); 133 printf("\n");
134 fflush(stdout); 134 fflush(stdout);
135 } 135 }
136 136
137 137
138 // The callback that is invoked by v8 whenever the JavaScript 'read' 138 // The callback that is invoked by v8 whenever the JavaScript 'read'
139 // function is called. This function loads the content of the file named in 139 // function is called. This function loads the content of the file named in
140 // the argument into a JavaScript string. 140 // the argument into a JavaScript string.
141 void Read(const v8::FunctionCallbackInfo<v8::Value>& args) { 141 void Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
142 if (args.Length() != 1) { 142 if (args.Length() != 1) {
143 v8::ThrowException(v8::String::New("Bad parameters")); 143 args.GetIsolate()->ThrowException(
144 v8::String::New("Bad parameters"));
144 return; 145 return;
145 } 146 }
146 v8::String::Utf8Value file(args[0]); 147 v8::String::Utf8Value file(args[0]);
147 if (*file == NULL) { 148 if (*file == NULL) {
148 v8::ThrowException(v8::String::New("Error loading file")); 149 args.GetIsolate()->ThrowException(
150 v8::String::New("Error loading file"));
149 return; 151 return;
150 } 152 }
151 v8::Handle<v8::String> source = ReadFile(*file); 153 v8::Handle<v8::String> source = ReadFile(*file);
152 if (source.IsEmpty()) { 154 if (source.IsEmpty()) {
153 v8::ThrowException(v8::String::New("Error loading file")); 155 args.GetIsolate()->ThrowException(
156 v8::String::New("Error loading file"));
154 return; 157 return;
155 } 158 }
156 args.GetReturnValue().Set(source); 159 args.GetReturnValue().Set(source);
157 } 160 }
158 161
159 162
160 // The callback that is invoked by v8 whenever the JavaScript 'load' 163 // The callback that is invoked by v8 whenever the JavaScript 'load'
161 // function is called. Loads, compiles and executes its argument 164 // function is called. Loads, compiles and executes its argument
162 // JavaScript file. 165 // JavaScript file.
163 void Load(const v8::FunctionCallbackInfo<v8::Value>& args) { 166 void Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
164 for (int i = 0; i < args.Length(); i++) { 167 for (int i = 0; i < args.Length(); i++) {
165 v8::HandleScope handle_scope(args.GetIsolate()); 168 v8::HandleScope handle_scope(args.GetIsolate());
166 v8::String::Utf8Value file(args[i]); 169 v8::String::Utf8Value file(args[i]);
167 if (*file == NULL) { 170 if (*file == NULL) {
168 v8::ThrowException(v8::String::New("Error loading file")); 171 args.GetIsolate()->ThrowException(
172 v8::String::New("Error loading file"));
169 return; 173 return;
170 } 174 }
171 v8::Handle<v8::String> source = ReadFile(*file); 175 v8::Handle<v8::String> source = ReadFile(*file);
172 if (source.IsEmpty()) { 176 if (source.IsEmpty()) {
173 v8::ThrowException(v8::String::New("Error loading file")); 177 args.GetIsolate()->ThrowException(
178 v8::String::New("Error loading file"));
174 return; 179 return;
175 } 180 }
176 if (!ExecuteString(args.GetIsolate(), 181 if (!ExecuteString(args.GetIsolate(),
177 source, 182 source,
178 v8::String::New(*file), 183 v8::String::New(*file),
179 false, 184 false,
180 false)) { 185 false)) {
181 v8::ThrowException(v8::String::New("Error executing file")); 186 args.GetIsolate()->ThrowException(
187 v8::String::New("Error executing file"));
182 return; 188 return;
183 } 189 }
184 } 190 }
185 } 191 }
186 192
187 193
188 // The callback that is invoked by v8 whenever the JavaScript 'quit' 194 // The callback that is invoked by v8 whenever the JavaScript 'quit'
189 // function is called. Quits. 195 // function is called. Quits.
190 void Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { 196 void Quit(const v8::FunctionCallbackInfo<v8::Value>& args) {
191 // If not arguments are given args[0] will yield undefined which 197 // If not arguments are given args[0] will yield undefined which
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 fprintf(stderr, "^"); 352 fprintf(stderr, "^");
347 } 353 }
348 fprintf(stderr, "\n"); 354 fprintf(stderr, "\n");
349 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); 355 v8::String::Utf8Value stack_trace(try_catch->StackTrace());
350 if (stack_trace.length() > 0) { 356 if (stack_trace.length() > 0) {
351 const char* stack_trace_string = ToCString(stack_trace); 357 const char* stack_trace_string = ToCString(stack_trace);
352 fprintf(stderr, "%s\n", stack_trace_string); 358 fprintf(stderr, "%s\n", stack_trace_string);
353 } 359 }
354 } 360 }
355 } 361 }
OLDNEW
« no previous file with comments | « samples/lineprocessor.cc ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698