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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
6 | 6 |
7 #include "bin/platform.h" | 7 #include "bin/platform.h" |
8 | 8 |
9 #include "bin/file.h" | 9 #include "bin/file.h" |
10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 char hostname[HOSTNAME_LENGTH]; | 33 char hostname[HOSTNAME_LENGTH]; |
34 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) { | 34 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) { |
35 Dart_SetReturnValue(args, DartUtils::NewString(hostname)); | 35 Dart_SetReturnValue(args, DartUtils::NewString(hostname)); |
36 } else { | 36 } else { |
37 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 37 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) { | 42 void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) { |
43 ASSERT(Platform::GetExecutableName() != NULL); | |
44 if (Dart_IsRunningPrecompiledCode()) { | 43 if (Dart_IsRunningPrecompiledCode()) { |
45 // This is a work-around to be able to use most of the existing test suite | 44 // This is a work-around to be able to use most of the existing test suite |
46 // for precompilation. Many tests do something like Process.run( | 45 // for precompilation. Many tests do something like Process.run( |
47 // Platform.executable, some_other_script.dart). But with precompilation | 46 // Platform.executable, some_other_script.dart). But with precompilation |
48 // the script is already fixed, so the spawned process runs the same script | 47 // the script is already fixed, so the spawned process runs the same script |
49 // again and we have a fork-bomb. | 48 // again and we have a fork-bomb. |
50 Dart_ThrowException(Dart_NewStringFromCString( | 49 Dart_ThrowException(Dart_NewStringFromCString( |
51 "Platform.executable not supported under precompilation")); | 50 "Platform.executable not supported under precompilation")); |
52 UNREACHABLE(); | 51 UNREACHABLE(); |
53 } | 52 } |
54 Dart_SetReturnValue( | 53 if (Platform::GetExecutableName() != NULL) { |
55 args, Dart_NewStringFromCString(Platform::GetExecutableName())); | 54 Dart_SetReturnValue( |
| 55 args, Dart_NewStringFromCString(Platform::GetExecutableName())); |
| 56 } else { |
| 57 Dart_SetReturnValue(args, Dart_Null()); |
| 58 } |
56 } | 59 } |
57 | 60 |
58 | 61 |
59 void FUNCTION_NAME(Platform_ResolvedExecutableName)(Dart_NativeArguments args) { | 62 void FUNCTION_NAME(Platform_ResolvedExecutableName)(Dart_NativeArguments args) { |
60 if (Dart_IsRunningPrecompiledCode()) { | 63 if (Dart_IsRunningPrecompiledCode()) { |
61 Dart_ThrowException(Dart_NewStringFromCString( | 64 Dart_ThrowException(Dart_NewStringFromCString( |
62 "Platform.resolvedExecutable not supported under precompilation")); | 65 "Platform.resolvedExecutable not supported under precompilation")); |
63 UNREACHABLE(); | 66 UNREACHABLE(); |
64 } | 67 } |
65 | 68 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 119 |
117 | 120 |
118 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { | 121 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { |
119 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); | 122 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); |
120 } | 123 } |
121 | 124 |
122 } // namespace bin | 125 } // namespace bin |
123 } // namespace dart | 126 } // namespace dart |
124 | 127 |
125 #endif // !defined(DART_IO_DISABLED) | 128 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |