| 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; |
| 16 |
| 15 void FUNCTION_NAME(Platform_NumberOfProcessors)(Dart_NativeArguments args) { | 17 void FUNCTION_NAME(Platform_NumberOfProcessors)(Dart_NativeArguments args) { |
| 16 Dart_SetReturnValue(args, Dart_NewInteger(Platform::NumberOfProcessors())); | 18 Dart_SetReturnValue(args, Dart_NewInteger(Platform::NumberOfProcessors())); |
| 17 } | 19 } |
| 18 | 20 |
| 19 | 21 |
| 20 void FUNCTION_NAME(Platform_OperatingSystem)(Dart_NativeArguments args) { | 22 void FUNCTION_NAME(Platform_OperatingSystem)(Dart_NativeArguments args) { |
| 21 Dart_SetReturnValue(args, DartUtils::NewString(Platform::OperatingSystem())); | 23 Dart_SetReturnValue(args, DartUtils::NewString(Platform::OperatingSystem())); |
| 22 } | 24 } |
| 23 | 25 |
| 24 | 26 |
| 25 void FUNCTION_NAME(Platform_PathSeparator)(Dart_NativeArguments args) { | 27 void FUNCTION_NAME(Platform_PathSeparator)(Dart_NativeArguments args) { |
| 26 Dart_SetReturnValue(args, DartUtils::NewString(File::PathSeparator())); | 28 Dart_SetReturnValue(args, DartUtils::NewString(File::PathSeparator())); |
| 27 } | 29 } |
| 28 | 30 |
| 29 | 31 |
| 30 void FUNCTION_NAME(Platform_LocalHostname)(Dart_NativeArguments args) { | 32 void FUNCTION_NAME(Platform_LocalHostname)(Dart_NativeArguments args) { |
| 31 const intptr_t HOSTNAME_LENGTH = 256; | 33 const intptr_t HOSTNAME_LENGTH = 256; |
| 32 char hostname[HOSTNAME_LENGTH]; | 34 char hostname[HOSTNAME_LENGTH]; |
| 33 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) { | 35 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) { |
| 34 Dart_SetReturnValue(args, DartUtils::NewString(hostname)); | 36 Dart_SetReturnValue(args, DartUtils::NewString(hostname)); |
| 35 } else { | 37 } else { |
| 36 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); | 38 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); |
| 37 } | 39 } |
| 38 } | 40 } |
| 39 | 41 |
| 40 | 42 |
| 43 void FUNCTION_NAME(Platform_ExecutableName)(Dart_NativeArguments args) { |
| 44 ASSERT(Platform::GetExecutableName() != NULL); |
| 45 Dart_SetReturnValue( |
| 46 args, Dart_NewStringFromCString(Platform::GetExecutableName())); |
| 47 } |
| 48 |
| 41 void FUNCTION_NAME(Platform_Environment)(Dart_NativeArguments args) { | 49 void FUNCTION_NAME(Platform_Environment)(Dart_NativeArguments args) { |
| 42 intptr_t count = 0; | 50 intptr_t count = 0; |
| 43 char** env = Platform::Environment(&count); | 51 char** env = Platform::Environment(&count); |
| 44 if (env == NULL) { | 52 if (env == NULL) { |
| 45 OSError error(-1, | 53 OSError error(-1, |
| 46 "Failed to retrieve environment variables.", | 54 "Failed to retrieve environment variables.", |
| 47 OSError::kUnknown); | 55 OSError::kUnknown); |
| 48 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); | 56 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); |
| 49 } else { | 57 } else { |
| 50 Dart_Handle result = Dart_NewList(count); | 58 Dart_Handle result = Dart_NewList(count); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 69 } | 77 } |
| 70 } | 78 } |
| 71 | 79 |
| 72 | 80 |
| 73 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { | 81 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { |
| 74 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); | 82 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); |
| 75 } | 83 } |
| 76 | 84 |
| 77 } // namespace bin | 85 } // namespace bin |
| 78 } // namespace dart | 86 } // namespace dart |
| OLD | NEW |