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

Side by Side Diff: runtime/bin/main.cc

Issue 14927003: Revert 22380 to investigate windows build break. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/run_vm_tests.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_debugger_api.h" 10 #include "include/dart_debugger_api.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (strncmp(option, name, length) == 0) { 255 if (strncmp(option, name, length) == 0) {
256 return main_options[i].process(option + length); 256 return main_options[i].process(option + length);
257 } 257 }
258 i += 1; 258 i += 1;
259 name = main_options[i].option_name; 259 name = main_options[i].option_name;
260 } 260 }
261 return false; 261 return false;
262 } 262 }
263 263
264 264
265 static void* OpenFile(const char* name) {
266 File* file = File::Open(name, File::kWriteTruncate);
267 ASSERT(file != NULL);
268 return reinterpret_cast<void*>(file);
269 }
270
271
272 static void WriteFile(const void* buffer, intptr_t num_bytes, void* stream) {
273 ASSERT(stream != NULL);
274 File* file_stream = reinterpret_cast<File*>(stream);
275 bool bytes_written = file_stream->WriteFully(buffer, num_bytes);
276 ASSERT(bytes_written);
277 }
278
279
280 static void CloseFile(void* stream) {
281 delete reinterpret_cast<File*>(stream);
282 }
283
284
265 // Convert all the arguments to UTF8. On Windows, the arguments are 285 // Convert all the arguments to UTF8. On Windows, the arguments are
266 // encoded in the current code page and not UTF8. 286 // encoded in the current code page and not UTF8.
267 // 287 //
268 // Returns true if the arguments are converted. In that case 288 // Returns true if the arguments are converted. In that case
269 // each of the arguments need to be deallocated using free. 289 // each of the arguments need to be deallocated using free.
270 static bool Utf8ConvertArgv(int argc, char** argv) { 290 static bool Utf8ConvertArgv(int argc, char** argv) {
271 int unicode_argc = 0; 291 int unicode_argc = 0;
272 wchar_t** unicode_argv = ShellUtils::GetUnicodeArgv(&unicode_argc); 292 wchar_t** unicode_argv = ShellUtils::GetUnicodeArgv(&unicode_argc);
273 if (unicode_argv == NULL) return false; 293 if (unicode_argv == NULL) return false;
274 for (int i = 0; i < unicode_argc; i++) { 294 for (int i = 0; i < unicode_argc; i++) {
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } else { 725 } else {
706 PrintUsage(); 726 PrintUsage();
707 return kErrorExitCode; 727 return kErrorExitCode;
708 } 728 }
709 } 729 }
710 730
711 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 731 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
712 732
713 // Initialize the Dart VM. 733 // Initialize the Dart VM.
714 if (!Dart_Initialize(CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, 734 if (!Dart_Initialize(CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate,
715 DartUtils::OpenFile, 735 OpenFile, WriteFile, CloseFile)) {
716 DartUtils::ReadFile,
717 DartUtils::WriteFile,
718 DartUtils::CloseFile)) {
719 fprintf(stderr, "%s", "VM initialization failed\n"); 736 fprintf(stderr, "%s", "VM initialization failed\n");
720 fflush(stderr); 737 fflush(stderr);
721 return kErrorExitCode; 738 return kErrorExitCode;
722 } 739 }
723 740
724 DartUtils::SetOriginalWorkingDirectory(); 741 DartUtils::SetOriginalWorkingDirectory();
725 742
726 // Start the debugger wire protocol handler if necessary. 743 // Start the debugger wire protocol handler if necessary.
727 if (start_debugger) { 744 if (start_debugger) {
728 ASSERT(debug_port != 0); 745 ASSERT(debug_port != 0);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 864
848 return Process::GlobalExitCode(); 865 return Process::GlobalExitCode();
849 } 866 }
850 867
851 } // namespace bin 868 } // namespace bin
852 } // namespace dart 869 } // namespace dart
853 870
854 int main(int argc, char** argv) { 871 int main(int argc, char** argv) {
855 return dart::bin::main(argc, argv); 872 return dart::bin::main(argc, argv);
856 } 873 }
OLDNEW
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/run_vm_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698