| OLD | NEW |
| 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_tools_api.h" | 10 #include "include/dart_tools_api.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 return true; | 397 return true; |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 i += 1; | 400 i += 1; |
| 401 name = main_options[i].option_name; | 401 name = main_options[i].option_name; |
| 402 } | 402 } |
| 403 return false; | 403 return false; |
| 404 } | 404 } |
| 405 | 405 |
| 406 | 406 |
| 407 // Convert all the arguments to UTF8. On Windows, the arguments are | |
| 408 // encoded in the current code page and not UTF8. | |
| 409 // | |
| 410 // Returns true if the arguments are converted. In that case | |
| 411 // each of the arguments need to be deallocated using free. | |
| 412 static bool Utf8ConvertArgv(int argc, char** argv) { | |
| 413 int unicode_argc = 0; | |
| 414 wchar_t** unicode_argv = ShellUtils::GetUnicodeArgv(&unicode_argc); | |
| 415 if (unicode_argv == NULL) return false; | |
| 416 for (int i = 0; i < unicode_argc; i++) { | |
| 417 wchar_t* arg = unicode_argv[i]; | |
| 418 argv[i] = StringUtils::WideToUtf8(arg); | |
| 419 } | |
| 420 ShellUtils::FreeUnicodeArgv(unicode_argv); | |
| 421 return true; | |
| 422 } | |
| 423 | |
| 424 | |
| 425 // Parse out the command line arguments. Returns -1 if the arguments | 407 // Parse out the command line arguments. Returns -1 if the arguments |
| 426 // are incorrect, 0 otherwise. | 408 // are incorrect, 0 otherwise. |
| 427 static int ParseArguments(int argc, | 409 static int ParseArguments(int argc, |
| 428 char** argv, | 410 char** argv, |
| 429 CommandLineOptions* vm_options, | 411 CommandLineOptions* vm_options, |
| 430 char** script_name, | 412 char** script_name, |
| 431 CommandLineOptions* dart_options, | 413 CommandLineOptions* dart_options, |
| 432 bool* print_flags_seen, | 414 bool* print_flags_seen, |
| 433 bool* verbose_debug_seen) { | 415 bool* verbose_debug_seen) { |
| 434 const char* kPrefix = "--"; | 416 const char* kPrefix = "--"; |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 bool verbose_debug_seen = false; | 868 bool verbose_debug_seen = false; |
| 887 | 869 |
| 888 vm_options.AddArgument("--no_write_protect_code"); | 870 vm_options.AddArgument("--no_write_protect_code"); |
| 889 // Perform platform specific initialization. | 871 // Perform platform specific initialization. |
| 890 if (!Platform::Initialize()) { | 872 if (!Platform::Initialize()) { |
| 891 Log::PrintErr("Initialization failed\n"); | 873 Log::PrintErr("Initialization failed\n"); |
| 892 } | 874 } |
| 893 | 875 |
| 894 // On Windows, the argv strings are code page encoded and not | 876 // On Windows, the argv strings are code page encoded and not |
| 895 // utf8. We need to convert them to utf8. | 877 // utf8. We need to convert them to utf8. |
| 896 bool argv_converted = Utf8ConvertArgv(argc, argv); | 878 bool argv_converted = ShellUtils::GetUtf8Argv(argc, argv); |
| 897 | 879 |
| 898 // Parse command line arguments. | 880 // Parse command line arguments. |
| 899 if (ParseArguments(argc, | 881 if (ParseArguments(argc, |
| 900 argv, | 882 argv, |
| 901 &vm_options, | 883 &vm_options, |
| 902 &script_name, | 884 &script_name, |
| 903 &dart_options, | 885 &dart_options, |
| 904 &print_flags_seen, | 886 &print_flags_seen, |
| 905 &verbose_debug_seen) < 0) { | 887 &verbose_debug_seen) < 0) { |
| 906 if (has_help_option) { | 888 if (has_help_option) { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 exit(Process::GlobalExitCode()); | 1084 exit(Process::GlobalExitCode()); |
| 1103 } | 1085 } |
| 1104 | 1086 |
| 1105 } // namespace bin | 1087 } // namespace bin |
| 1106 } // namespace dart | 1088 } // namespace dart |
| 1107 | 1089 |
| 1108 int main(int argc, char** argv) { | 1090 int main(int argc, char** argv) { |
| 1109 dart::bin::main(argc, argv); | 1091 dart::bin::main(argc, argv); |
| 1110 UNREACHABLE(); | 1092 UNREACHABLE(); |
| 1111 } | 1093 } |
| OLD | NEW |