Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: runtime/bin/dartutils.cc

Issue 10905125: Move dart:web to pkg:htmlescape. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/web_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extensions.h" 7 #include "bin/extensions.h"
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/file.h" 9 #include "bin/file.h"
10 #include "include/dart_api.h" 10 #include "include/dart_api.h"
11 #include "platform/assert.h" 11 #include "platform/assert.h"
12 #include "platform/globals.h" 12 #include "platform/globals.h"
13 13
14 const char* DartUtils::original_working_directory = NULL; 14 const char* DartUtils::original_working_directory = NULL;
15 const char* DartUtils::kDartScheme = "dart:"; 15 const char* DartUtils::kDartScheme = "dart:";
16 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; 16 const char* DartUtils::kDartExtensionScheme = "dart-ext:";
17 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; 17 const char* DartUtils::kBuiltinLibURL = "dart:builtin";
18 const char* DartUtils::kCoreLibURL = "dart:core"; 18 const char* DartUtils::kCoreLibURL = "dart:core";
19 const char* DartUtils::kCoreImplLibURL = "dart:coreimpl"; 19 const char* DartUtils::kCoreImplLibURL = "dart:coreimpl";
20 const char* DartUtils::kCryptoLibURL = "dart:crypto"; 20 const char* DartUtils::kCryptoLibURL = "dart:crypto";
21 const char* DartUtils::kIOLibURL = "dart:io"; 21 const char* DartUtils::kIOLibURL = "dart:io";
22 const char* DartUtils::kJsonLibURL = "dart:json"; 22 const char* DartUtils::kJsonLibURL = "dart:json";
23 const char* DartUtils::kUriLibURL = "dart:uri"; 23 const char* DartUtils::kUriLibURL = "dart:uri";
24 const char* DartUtils::kUtfLibURL = "dart:utf"; 24 const char* DartUtils::kUtfLibURL = "dart:utf";
25 const char* DartUtils::kIsolateLibURL = "dart:isolate"; 25 const char* DartUtils::kIsolateLibURL = "dart:isolate";
26 const char* DartUtils::kWebLibURL = "dart:web";
27 26
28 27
29 const char* DartUtils::kIdFieldName = "_id"; 28 const char* DartUtils::kIdFieldName = "_id";
30 29
31 30
32 static bool IsWindowsHost() { 31 static bool IsWindowsHost() {
33 #if defined(TARGET_OS_WINDOWS) 32 #if defined(TARGET_OS_WINDOWS)
34 return true; 33 return true;
35 #else // defined(TARGET_OS_WINDOWS) 34 #else // defined(TARGET_OS_WINDOWS)
36 return false; 35 return false;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 bool DartUtils::IsDartUriLibURL(const char* url_name) { 158 bool DartUtils::IsDartUriLibURL(const char* url_name) {
160 return (strcmp(url_name, kUriLibURL) == 0); 159 return (strcmp(url_name, kUriLibURL) == 0);
161 } 160 }
162 161
163 162
164 bool DartUtils::IsDartUtfLibURL(const char* url_name) { 163 bool DartUtils::IsDartUtfLibURL(const char* url_name) {
165 return (strcmp(url_name, kUtfLibURL) == 0); 164 return (strcmp(url_name, kUtfLibURL) == 0);
166 } 165 }
167 166
168 167
169 bool DartUtils::IsDartWebLibURL(const char* url_name) {
170 return (strcmp(url_name, kWebLibURL) == 0);
171 }
172
173
174 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, 168 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping,
175 Dart_Handle library, 169 Dart_Handle library,
176 const char* url_str) { 170 const char* url_str) {
177 // Get the url of the including library. 171 // Get the url of the including library.
178 Dart_Handle library_url = Dart_LibraryUrl(library); 172 Dart_Handle library_url = Dart_LibraryUrl(library);
179 if (Dart_IsError(library_url)) { 173 if (Dart_IsError(library_url)) {
180 return Dart_Error("accessing library url failed"); 174 return Dart_Error("accessing library url failed");
181 } 175 }
182 if (!Dart_IsString8(library_url)) { 176 if (!Dart_IsString8(library_url)) {
183 return Dart_Error("library url is not a string"); 177 return Dart_Error("library url is not a string");
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (DartUtils::IsDartCryptoLibURL(url_string)) { 293 if (DartUtils::IsDartCryptoLibURL(url_string)) {
300 id = Builtin::kCryptoLibrary; 294 id = Builtin::kCryptoLibrary;
301 } else if (DartUtils::IsDartIOLibURL(url_string)) { 295 } else if (DartUtils::IsDartIOLibURL(url_string)) {
302 id = Builtin::kIOLibrary; 296 id = Builtin::kIOLibrary;
303 } else if (DartUtils::IsDartJsonLibURL(url_string)) { 297 } else if (DartUtils::IsDartJsonLibURL(url_string)) {
304 id = Builtin::kJsonLibrary; 298 id = Builtin::kJsonLibrary;
305 } else if (DartUtils::IsDartUriLibURL(url_string)) { 299 } else if (DartUtils::IsDartUriLibURL(url_string)) {
306 id = Builtin::kUriLibrary; 300 id = Builtin::kUriLibrary;
307 } else if (DartUtils::IsDartUtfLibURL(url_string)) { 301 } else if (DartUtils::IsDartUtfLibURL(url_string)) {
308 id = Builtin::kUtfLibrary; 302 id = Builtin::kUtfLibrary;
309 } else if (DartUtils::IsDartWebLibURL(url_string)) {
310 id = Builtin::kWebLibrary;
311 } else { 303 } else {
312 return Dart_Error("Do not know how to load '%s'", url_string); 304 return Dart_Error("Do not know how to load '%s'", url_string);
313 } 305 }
314 return Builtin::LoadAndCheckLibrary(id); 306 return Builtin::LoadAndCheckLibrary(id);
315 } else { 307 } else {
316 // Get the file path out of the url. 308 // Get the file path out of the url.
317 Dart_Handle builtin_lib = 309 Dart_Handle builtin_lib =
318 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); 310 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
319 Dart_Handle file_path = FilePathFromUri(url, builtin_lib); 311 Dart_Handle file_path = FilePathFromUri(url, builtin_lib);
320 if (Dart_IsError(file_path)) { 312 if (Dart_IsError(file_path)) {
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 652
661 CObject* CObject::NewOSError(OSError* os_error) { 653 CObject* CObject::NewOSError(OSError* os_error) {
662 CObject* error_message = 654 CObject* error_message =
663 new CObjectString(CObject::NewString(os_error->message())); 655 new CObjectString(CObject::NewString(os_error->message()));
664 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 656 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
665 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 657 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
666 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 658 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
667 result->SetAt(2, error_message); 659 result->SetAt(2, error_message);
668 return result; 660 return result;
669 } 661 }
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/web_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698