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/dartutils.h" | 5 #include "bin/dartutils.h" |
6 | 6 |
7 #include "bin/file.h" | 7 #include "bin/file.h" |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
11 | 11 |
12 const char* DartUtils::kDartScheme = "dart:"; | 12 const char* DartUtils::kDartScheme = "dart:"; |
13 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; | 13 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; |
14 const char* DartUtils::kCoreLibURL = "dart:core"; | 14 const char* DartUtils::kCoreLibURL = "dart:core"; |
15 const char* DartUtils::kCoreImplLibURL = "dart:coreimpl"; | 15 const char* DartUtils::kCoreImplLibURL = "dart:coreimpl"; |
16 const char* DartUtils::kIOLibURL = "dart:io"; | 16 const char* DartUtils::kIOLibURL = "dart:io"; |
| 17 const char* DartUtils::kJsonLibURL = "dart:json"; |
| 18 const char* DartUtils::kUriLibURL = "dart:uri"; |
| 19 const char* DartUtils::kUtf8LibURL = "dart:utf8"; |
17 | 20 |
18 | 21 |
19 const char* DartUtils::kIdFieldName = "_id"; | 22 const char* DartUtils::kIdFieldName = "_id"; |
20 | 23 |
21 | 24 |
22 static const char* MapLibraryUrl(CommandLineOptions* url_mapping, | 25 static const char* MapLibraryUrl(CommandLineOptions* url_mapping, |
23 const char* url_string) { | 26 const char* url_string) { |
24 ASSERT(url_mapping != NULL); | 27 ASSERT(url_mapping != NULL); |
25 // We need to check if the passed in url is found in the url_mapping array, | 28 // We need to check if the passed in url is found in the url_mapping array, |
26 // in that case use the mapped entry. | 29 // in that case use the mapped entry. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // library URL which is handled differently from other URLs. | 102 // library URL which is handled differently from other URLs. |
100 return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0); | 103 return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0); |
101 } | 104 } |
102 | 105 |
103 | 106 |
104 bool DartUtils::IsDartIOLibURL(const char* url_name) { | 107 bool DartUtils::IsDartIOLibURL(const char* url_name) { |
105 return (strcmp(url_name, kIOLibURL) == 0); | 108 return (strcmp(url_name, kIOLibURL) == 0); |
106 } | 109 } |
107 | 110 |
108 | 111 |
| 112 bool DartUtils::IsDartJsonLibURL(const char* url_name) { |
| 113 return (strcmp(url_name, kJsonLibURL) == 0); |
| 114 } |
| 115 |
| 116 |
| 117 bool DartUtils::IsDartUriLibURL(const char* url_name) { |
| 118 return (strcmp(url_name, kUriLibURL) == 0); |
| 119 } |
| 120 |
| 121 |
| 122 bool DartUtils::IsDartUtf8LibURL(const char* url_name) { |
| 123 return (strcmp(url_name, kUtf8LibURL) == 0); |
| 124 } |
| 125 |
109 | 126 |
110 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, | 127 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, |
111 Dart_Handle library, | 128 Dart_Handle library, |
112 const char* url_str) { | 129 const char* url_str) { |
113 // Get the url of the including library. | 130 // Get the url of the including library. |
114 Dart_Handle library_url = Dart_LibraryUrl(library); | 131 Dart_Handle library_url = Dart_LibraryUrl(library); |
115 if (Dart_IsError(library_url)) { | 132 if (Dart_IsError(library_url)) { |
116 return Dart_Error("accessing library url failed"); | 133 return Dart_Error("accessing library url failed"); |
117 } | 134 } |
118 if (!Dart_IsString8(library_url)) { | 135 if (!Dart_IsString8(library_url)) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 bool DartUtils::PostInt32(Dart_Port port_id, int32_t value) { | 261 bool DartUtils::PostInt32(Dart_Port port_id, int32_t value) { |
245 // Post a message with the integer value. | 262 // Post a message with the integer value. |
246 int32_t min = 0xc0000000; // -1073741824 | 263 int32_t min = 0xc0000000; // -1073741824 |
247 int32_t max = 0x3fffffff; // 1073741823 | 264 int32_t max = 0x3fffffff; // 1073741823 |
248 ASSERT(min <= value && value < max); | 265 ASSERT(min <= value && value < max); |
249 Dart_CObject object; | 266 Dart_CObject object; |
250 object.type = Dart_CObject::kInt32; | 267 object.type = Dart_CObject::kInt32; |
251 object.value.as_int32 = value; | 268 object.value.as_int32 = value; |
252 return Dart_PostCObject(port_id, &object); | 269 return Dart_PostCObject(port_id, &object); |
253 } | 270 } |
OLD | NEW |