| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 v8::String::Utf8Value str(result); | 246 v8::String::Utf8Value str(result); |
| 247 const char* cstr = ToCString(str); | 247 const char* cstr = ToCString(str); |
| 248 printf("%s\n", cstr); | 248 printf("%s\n", cstr); |
| 249 } | 249 } |
| 250 | 250 |
| 251 return true; | 251 return true; |
| 252 } | 252 } |
| 253 | 253 |
| 254 | 254 |
| 255 int main(int argc, char* argv[]) { | 255 int main(int argc, char* argv[]) { |
| 256 v8::V8::PerformPerThreadSetup(); |
| 256 v8::V8::InitializeICU(); | 257 v8::V8::InitializeICU(); |
| 257 int result = RunMain(argc, argv); | 258 int result = RunMain(argc, argv); |
| 258 v8::V8::Dispose(); | 259 v8::V8::Dispose(); |
| 259 return result; | 260 return result; |
| 260 } | 261 } |
| 261 | 262 |
| 262 | 263 |
| 263 // Extracts a C string from a V8 Utf8Value. | 264 // Extracts a C string from a V8 Utf8Value. |
| 264 const char* ToCString(const v8::String::Utf8Value& value) { | 265 const char* ToCString(const v8::String::Utf8Value& value) { |
| 265 return *value ? *value : "<string conversion failed>"; | 266 return *value ? *value : "<string conversion failed>"; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 371 } |
| 371 // Remove newline char | 372 // Remove newline char |
| 372 for (char* pos = buffer; *pos != '\0'; pos++) { | 373 for (char* pos = buffer; *pos != '\0'; pos++) { |
| 373 if (*pos == '\n') { | 374 if (*pos == '\n') { |
| 374 *pos = '\0'; | 375 *pos = '\0'; |
| 375 break; | 376 break; |
| 376 } | 377 } |
| 377 } | 378 } |
| 378 return v8::String::NewFromUtf8(isolate, buffer); | 379 return v8::String::NewFromUtf8(isolate, buffer); |
| 379 } | 380 } |
| OLD | NEW |