| OLD | NEW |
| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 if (script_param_counter != 1) { | 197 if (script_param_counter != 1) { |
| 198 printf("Only one script may be specified\n"); | 198 printf("Only one script may be specified\n"); |
| 199 return 1; | 199 return 1; |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Create a template for the global object. | 202 // Create a template for the global object. |
| 203 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); | 203 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); |
| 204 | 204 |
| 205 // Bind the global 'print' function to the C++ Print callback. | 205 // Bind the global 'print' function to the C++ Print callback. |
| 206 global->Set(v8::String::NewFromUtf8(isolate, "print"), | 206 global->Set(v8::String::NewFromUtf8(isolate, "print"), |
| 207 v8::FunctionTemplate::New(Print)); | 207 v8::FunctionTemplate::New(isolate, Print)); |
| 208 | 208 |
| 209 if (cycle_type == CycleInJs) { | 209 if (cycle_type == CycleInJs) { |
| 210 // Bind the global 'read_line' function to the C++ Print callback. | 210 // Bind the global 'read_line' function to the C++ Print callback. |
| 211 global->Set(v8::String::NewFromUtf8(isolate, "read_line"), | 211 global->Set(v8::String::NewFromUtf8(isolate, "read_line"), |
| 212 v8::FunctionTemplate::New(ReadLine)); | 212 v8::FunctionTemplate::New(isolate, ReadLine)); |
| 213 } | 213 } |
| 214 | 214 |
| 215 // Create a new execution environment containing the built-in | 215 // Create a new execution environment containing the built-in |
| 216 // functions | 216 // functions |
| 217 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global); | 217 v8::Handle<v8::Context> context = v8::Context::New(isolate, NULL, global); |
| 218 // Enter the newly created execution environment. | 218 // Enter the newly created execution environment. |
| 219 v8::Context::Scope context_scope(context); | 219 v8::Context::Scope context_scope(context); |
| 220 | 220 |
| 221 #ifdef ENABLE_DEBUGGER_SUPPORT | 221 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 222 debug_message_context.Reset(isolate, context); | 222 debug_message_context.Reset(isolate, context); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 } | 446 } |
| 447 // Remove newline char | 447 // Remove newline char |
| 448 for (char* pos = buffer; *pos != '\0'; pos++) { | 448 for (char* pos = buffer; *pos != '\0'; pos++) { |
| 449 if (*pos == '\n') { | 449 if (*pos == '\n') { |
| 450 *pos = '\0'; | 450 *pos = '\0'; |
| 451 break; | 451 break; |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 return v8::String::NewFromUtf8(isolate, buffer); | 454 return v8::String::NewFromUtf8(isolate, buffer); |
| 455 } | 455 } |
| OLD | NEW |