| 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 "bin/platform.h" | 5 #include "bin/platform.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "bin/file.h" | 9 #include "bin/file.h" |
| 10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 namespace bin { | 13 namespace bin { |
| 14 | 14 |
| 15 const char* Platform::executable_name_ = NULL; | 15 const char* Platform::executable_name_ = NULL; |
| 16 bool Platform::executable_name_resolved_ = false; | 16 const char* Platform::resolved_executable_name_ = NULL; |
| 17 const char* Platform::package_root_ = NULL; | 17 const char* Platform::package_root_ = NULL; |
| 18 int Platform::script_index_ = 1; | 18 int Platform::script_index_ = 1; |
| 19 char** Platform::argv_ = NULL; | 19 char** Platform::argv_ = NULL; |
| 20 | 20 |
| 21 void FUNCTION_NAME(Platform_NumberOfProcessors)(Dart_NativeArguments args) { | 21 void FUNCTION_NAME(Platform_NumberOfProcessors)(Dart_NativeArguments args) { |
| 22 Dart_SetReturnValue(args, Dart_NewInteger(Platform::NumberOfProcessors())); | 22 Dart_SetReturnValue(args, Dart_NewInteger(Platform::NumberOfProcessors())); |
| 23 } | 23 } |
| 24 | 24 |
| 25 | 25 |
| 26 void FUNCTION_NAME(Platform_OperatingSystem)(Dart_NativeArguments args) { | 26 void FUNCTION_NAME(Platform_OperatingSystem)(Dart_NativeArguments args) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) { | 47 void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) { |
| 48 ASSERT(Platform::GetExecutableName() != NULL); | 48 ASSERT(Platform::GetExecutableName() != NULL); |
| 49 Dart_SetReturnValue( | 49 Dart_SetReturnValue( |
| 50 args, Dart_NewStringFromCString(Platform::GetExecutableName())); | 50 args, Dart_NewStringFromCString(Platform::GetExecutableName())); |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 void FUNCTION_NAME(Platform_ResolvedExecutableName)(Dart_NativeArguments args) { |
| 55 if (Platform::GetResolvedExecutableName() != NULL) { |
| 56 Dart_SetReturnValue( |
| 57 args, Dart_NewStringFromCString(Platform::GetResolvedExecutableName())); |
| 58 } else { |
| 59 Dart_SetReturnValue(args, Dart_Null()); |
| 60 } |
| 61 } |
| 62 |
| 63 |
| 54 void FUNCTION_NAME(Platform_ExecutableArguments)(Dart_NativeArguments args) { | 64 void FUNCTION_NAME(Platform_ExecutableArguments)(Dart_NativeArguments args) { |
| 55 int end = Platform::GetScriptIndex(); | 65 int end = Platform::GetScriptIndex(); |
| 56 char** argv = Platform::GetArgv(); | 66 char** argv = Platform::GetArgv(); |
| 57 Dart_Handle result = Dart_NewList(end - 1); | 67 Dart_Handle result = Dart_NewList(end - 1); |
| 58 for (intptr_t i = 1; i < end; i++) { | 68 for (intptr_t i = 1; i < end; i++) { |
| 59 Dart_Handle str = DartUtils::NewString(argv[i]); | 69 Dart_Handle str = DartUtils::NewString(argv[i]); |
| 60 Dart_Handle error = Dart_ListSetAt(result, i - 1, str); | 70 Dart_Handle error = Dart_ListSetAt(result, i - 1, str); |
| 61 if (Dart_IsError(error)) { | 71 if (Dart_IsError(error)) { |
| 62 Dart_PropagateError(error); | 72 Dart_PropagateError(error); |
| 63 } | 73 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 116 } |
| 107 } | 117 } |
| 108 | 118 |
| 109 | 119 |
| 110 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { | 120 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { |
| 111 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); | 121 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); |
| 112 } | 122 } |
| 113 | 123 |
| 114 } // namespace bin | 124 } // namespace bin |
| 115 } // namespace dart | 125 } // namespace dart |
| OLD | NEW |