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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 | 78 |
79 void FUNCTION_NAME(Platform_PackageRoot)(Dart_NativeArguments args) { | 79 void FUNCTION_NAME(Platform_PackageRoot)(Dart_NativeArguments args) { |
80 const char* package_root = Platform::GetPackageRoot(); | 80 const char* package_root = Platform::GetPackageRoot(); |
81 if (package_root == NULL) { | 81 if (package_root == NULL) { |
82 package_root = ""; | 82 package_root = ""; |
83 } | 83 } |
84 Dart_SetReturnValue(args, Dart_NewStringFromCString(package_root)); | 84 Dart_SetReturnValue(args, Dart_NewStringFromCString(package_root)); |
85 } | 85 } |
86 | 86 |
87 | 87 |
88 void FUNCTION_NAME(Platform_PackageResolution)(Dart_NativeArguments args) { | |
Ivan Posva
2015/08/26 04:29:35
There should be no need to rely on C++ code for th
Lasse Reichstein Nielsen
2015/08/26 06:26:06
Excellent. It did seem a bit overengineered to go
| |
89 Dart_Handle builtin_lib = | |
90 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); | |
91 ASSERT(!Dart_IsError(builtin_lib)); | |
92 Dart_Handle field_name = DartUtils::NewString("_packageRoot"); | |
93 Dart_Handle result = Dart_GetField(builtin_lib, field_name); | |
94 ASSERT(!Dart_IsError(result)); | |
95 if (Dart_IsNull(result)) { | |
96 field_name = DartUtils::NewString("_packageMap"); | |
97 result = Dart_GetField(builtin_lib, field_name); | |
98 ASSERT(!Dart_IsError(result)); | |
99 } | |
100 Dart_SetReturnValue(args, result); | |
101 } | |
102 | |
103 | |
88 void FUNCTION_NAME(Platform_Environment)(Dart_NativeArguments args) { | 104 void FUNCTION_NAME(Platform_Environment)(Dart_NativeArguments args) { |
89 intptr_t count = 0; | 105 intptr_t count = 0; |
90 char** env = Platform::Environment(&count); | 106 char** env = Platform::Environment(&count); |
91 if (env == NULL) { | 107 if (env == NULL) { |
92 OSError error(-1, | 108 OSError error(-1, |
93 "Failed to retrieve environment variables.", | 109 "Failed to retrieve environment variables.", |
94 OSError::kUnknown); | 110 OSError::kUnknown); |
95 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); | 111 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); |
96 } else { | 112 } else { |
97 Dart_Handle result = Dart_NewList(count); | 113 Dart_Handle result = Dart_NewList(count); |
(...skipping 18 matching lines...) Expand all Loading... | |
116 } | 132 } |
117 } | 133 } |
118 | 134 |
119 | 135 |
120 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { | 136 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { |
121 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); | 137 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); |
122 } | 138 } |
123 | 139 |
124 } // namespace bin | 140 } // namespace bin |
125 } // namespace dart | 141 } // namespace dart |
OLD | NEW |