| 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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) { | 38 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) { |
| 39 Dart_SetReturnValue(args, DartUtils::NewString(hostname)); | 39 Dart_SetReturnValue(args, DartUtils::NewString(hostname)); |
| 40 } else { | 40 } else { |
| 41 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 41 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) { | 46 void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) { |
| 47 ASSERT(Platform::GetExecutableName() != NULL); | 47 ASSERT(Platform::GetExecutableName() != NULL); |
| 48 if (Dart_IsRunningPrecompiledCode()) { |
| 49 // This is a work-around to be able to use most of the existing test suite |
| 50 // for precompilation. Many tests do something like Process.run( |
| 51 // Platform.executable, some_other_script.dart). But with precompilation |
| 52 // the script is already fixed, so the spawned process runs the same script |
| 53 // again and we have a fork-bomb. |
| 54 Dart_ThrowException(Dart_NewStringFromCString( |
| 55 "Platform.executable not supported under precompilation")); |
| 56 UNREACHABLE(); |
| 57 } |
| 48 Dart_SetReturnValue( | 58 Dart_SetReturnValue( |
| 49 args, Dart_NewStringFromCString(Platform::GetExecutableName())); | 59 args, Dart_NewStringFromCString(Platform::GetExecutableName())); |
| 50 } | 60 } |
| 51 | 61 |
| 52 | 62 |
| 53 void FUNCTION_NAME(Platform_ResolvedExecutableName)(Dart_NativeArguments args) { | 63 void FUNCTION_NAME(Platform_ResolvedExecutableName)(Dart_NativeArguments args) { |
| 64 if (Dart_IsRunningPrecompiledCode()) { |
| 65 Dart_ThrowException(Dart_NewStringFromCString( |
| 66 "Platform.resolvedExecutable not supported under precompilation")); |
| 67 UNREACHABLE(); |
| 68 } |
| 69 |
| 54 if (Platform::GetResolvedExecutableName() != NULL) { | 70 if (Platform::GetResolvedExecutableName() != NULL) { |
| 55 Dart_SetReturnValue( | 71 Dart_SetReturnValue( |
| 56 args, Dart_NewStringFromCString(Platform::GetResolvedExecutableName())); | 72 args, Dart_NewStringFromCString(Platform::GetResolvedExecutableName())); |
| 57 } else { | 73 } else { |
| 58 Dart_SetReturnValue(args, Dart_Null()); | 74 Dart_SetReturnValue(args, Dart_Null()); |
| 59 } | 75 } |
| 60 } | 76 } |
| 61 | 77 |
| 62 | 78 |
| 63 void FUNCTION_NAME(Platform_ExecutableArguments)(Dart_NativeArguments args) { | 79 void FUNCTION_NAME(Platform_ExecutableArguments)(Dart_NativeArguments args) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 122 } |
| 107 } | 123 } |
| 108 | 124 |
| 109 | 125 |
| 110 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { | 126 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { |
| 111 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); | 127 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); |
| 112 } | 128 } |
| 113 | 129 |
| 114 } // namespace bin | 130 } // namespace bin |
| 115 } // namespace dart | 131 } // namespace dart |
| OLD | NEW |