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

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

Issue 270503007: Eliminate unused url mapping parameter in dartutils (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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
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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 9
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 bool DartUtils::IsDartIOLibURL(const char* url_name) { 167 bool DartUtils::IsDartIOLibURL(const char* url_name) {
168 return (strcmp(url_name, kIOLibURL) == 0); 168 return (strcmp(url_name, kIOLibURL) == 0);
169 } 169 }
170 170
171 171
172 bool DartUtils::IsDartBuiltinLibURL(const char* url_name) { 172 bool DartUtils::IsDartBuiltinLibURL(const char* url_name) {
173 return (strcmp(url_name, kBuiltinLibURL) == 0); 173 return (strcmp(url_name, kBuiltinLibURL) == 0);
174 } 174 }
175 175
176 176
177 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, 177 Dart_Handle DartUtils::CanonicalizeURL(Dart_Handle library,
178 Dart_Handle library,
179 const char* url_str) { 178 const char* url_str) {
180 // Get the url of the including library. 179 // Get the url of the including library.
181 Dart_Handle library_url = Dart_LibraryUrl(library); 180 Dart_Handle library_url = Dart_LibraryUrl(library);
182 if (Dart_IsError(library_url)) { 181 if (Dart_IsError(library_url)) {
183 return Dart_NewApiError("accessing library url failed"); 182 return Dart_NewApiError("accessing library url failed");
184 } 183 }
185 if (!Dart_IsString(library_url)) { 184 if (!Dart_IsString(library_url)) {
186 return Dart_NewApiError("library url is not a string"); 185 return Dart_NewApiError("library url is not a string");
187 } 186 }
188 const char* library_url_str = NULL; 187 const char* library_url_str = NULL;
189 Dart_Handle result = Dart_StringToCString(library_url, &library_url_str); 188 Dart_Handle result = Dart_StringToCString(library_url, &library_url_str);
190 if (Dart_IsError(result)) { 189 if (Dart_IsError(result)) {
191 return Dart_NewApiError("accessing library url characters failed"); 190 return Dart_NewApiError("accessing library url characters failed");
192 } 191 }
193 if (url_mapping != NULL) {
194 const char* mapped_library_url_str = MapLibraryUrl(url_mapping,
195 library_url_str);
196 if (mapped_library_url_str != NULL) {
197 library_url_str = mapped_library_url_str;
198 }
199 }
200 // Calculate the canonical path. 192 // Calculate the canonical path.
201 const char* canon_url_str = GetCanonicalPath(library_url_str, url_str); 193 const char* canon_url_str = GetCanonicalPath(library_url_str, url_str);
202 Dart_Handle canon_url = NewString(canon_url_str); 194 Dart_Handle canon_url = NewString(canon_url_str);
203 free(const_cast<char*>(canon_url_str)); 195 free(const_cast<char*>(canon_url_str));
204 196
205 return canon_url; 197 return canon_url;
206 } 198 }
207 199
208 200
209 void* DartUtils::OpenFile(const char* name, bool write) { 201 void* DartUtils::OpenFile(const char* name, bool write) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 library); 553 library);
562 } else { 554 } else {
563 // Handle 'import' or 'part' requests for all other URIs. 555 // Handle 'import' or 'part' requests for all other URIs.
564 // Get the file path out of the url. 556 // Get the file path out of the url.
565 Dart_Handle file_path = DartUtils::FilePathFromUri(url, builtin_lib); 557 Dart_Handle file_path = DartUtils::FilePathFromUri(url, builtin_lib);
566 if (Dart_IsError(file_path)) { 558 if (Dart_IsError(file_path)) {
567 return file_path; 559 return file_path;
568 } 560 }
569 const char* final_path = NULL; 561 const char* final_path = NULL;
570 Dart_StringToCString(file_path, &final_path); 562 Dart_StringToCString(file_path, &final_path);
571 result = DartUtils::LoadSource(NULL, 563 result = DartUtils::LoadSource(library, url, tag, final_path);
572 library,
573 url,
574 tag,
575 final_path);
576 return result; 564 return result;
577 } 565 }
578 } 566 }
579 567
580 568
581 const uint8_t* DartUtils::SniffForMagicNumber(const uint8_t* text_buffer, 569 const uint8_t* DartUtils::SniffForMagicNumber(const uint8_t* text_buffer,
582 intptr_t* buffer_len, 570 intptr_t* buffer_len,
583 bool* is_snapshot) { 571 bool* is_snapshot) {
584 intptr_t len = sizeof(magic_number); 572 intptr_t len = sizeof(magic_number);
585 for (intptr_t i = 0; i < len; i++) { 573 for (intptr_t i = 0; i < len; i++) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 returnValue = NewError("%s is not a valid UTF-8 script", script_uri); 651 returnValue = NewError("%s is not a valid UTF-8 script", script_uri);
664 } else { 652 } else {
665 returnValue = Dart_LoadScript(resolved_script_uri, source, 0, 0); 653 returnValue = Dart_LoadScript(resolved_script_uri, source, 0, 0);
666 } 654 }
667 } 655 }
668 free(const_cast<uint8_t *>(buffer)); 656 free(const_cast<uint8_t *>(buffer));
669 return returnValue; 657 return returnValue;
670 } 658 }
671 659
672 660
673 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, 661 Dart_Handle DartUtils::LoadSource(Dart_Handle library,
674 Dart_Handle library,
675 Dart_Handle url, 662 Dart_Handle url,
676 Dart_LibraryTag tag, 663 Dart_LibraryTag tag,
677 const char* url_string) { 664 const char* url_string) {
678 bool is_http_scheme_url = DartUtils::IsHttpSchemeURL(url_string); 665 bool is_http_scheme_url = DartUtils::IsHttpSchemeURL(url_string);
679 if (url_mapping != NULL && IsDartSchemeURL(url_string)) {
680 const char* mapped_url_string = MapLibraryUrl(url_mapping, url_string);
681 if (mapped_url_string == NULL) {
682 return NewError("Do not know how to load %s", url_string);
683 }
684 // We have a URL mapping specified, just read the file that the
685 // URL mapping specifies and load it.
686 url_string = mapped_url_string;
687 }
688 Dart_Handle source; 666 Dart_Handle source;
689 if (is_http_scheme_url) { 667 if (is_http_scheme_url) {
690 // Read the file over http. 668 // Read the file over http.
691 source = DartUtils::ReadStringFromHttp(url_string); 669 source = DartUtils::ReadStringFromHttp(url_string);
692 } else { 670 } else {
693 // Read the file. 671 // Read the file.
694 source = DartUtils::ReadStringFromFile(url_string); 672 source = DartUtils::ReadStringFromFile(url_string);
695 } 673 }
696 if (Dart_IsError(source)) { 674 if (Dart_IsError(source)) {
697 return source; // source contains the error string. 675 return source; // source contains the error string.
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 new CObjectString(CObject::NewString(os_error->message())); 1096 new CObjectString(CObject::NewString(os_error->message()));
1119 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1097 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1120 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1098 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1121 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1099 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1122 result->SetAt(2, error_message); 1100 result->SetAt(2, error_message);
1123 return result; 1101 return result;
1124 } 1102 }
1125 1103
1126 } // namespace bin 1104 } // namespace bin
1127 } // namespace dart 1105 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/gen_snapshot.cc » ('j') | runtime/vm/unit_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698