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

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

Issue 180783008: Change handling of dart-ext: URIs for native extensions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make _DART_EXT top-level. Created 6 years, 9 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 468 }
469 Dart_Handle library_url = Dart_LibraryUrl(library); 469 Dart_Handle library_url = Dart_LibraryUrl(library);
470 const char* library_url_string = NULL; 470 const char* library_url_string = NULL;
471 result = Dart_StringToCString(library_url, &library_url_string); 471 result = Dart_StringToCString(library_url, &library_url_string);
472 if (Dart_IsError(result)) { 472 if (Dart_IsError(result)) {
473 return result; 473 return result;
474 } 474 }
475 475
476 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); 476 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string);
477 bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string); 477 bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string);
478 bool is_dart_extension_url = DartUtils::IsDartExtensionSchemeURL(url_string);
479 478
480 // Handle URI canonicalization requests. 479 // Handle URI canonicalization requests.
481 if (tag == Dart_kCanonicalizeUrl) { 480 if (tag == Dart_kCanonicalizeUrl) {
482 // If this is a Dart Scheme URL or 'part' of a io library 481 // If this is a Dart Scheme URL or 'part' of a io library
483 // then it is not modified as it will be handled internally. 482 // then it is not modified as it will be handled internally.
484 if (is_dart_scheme_url || is_io_library) { 483 if (is_dart_scheme_url || is_io_library) {
485 return url; 484 return url;
486 } 485 }
487 // Resolve the url within the context of the library's URL. 486 // Resolve the url within the context of the library's URL.
488 Dart_Handle builtin_lib = 487 Dart_Handle builtin_lib =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 } 520 }
522 521
523 // Handle 'import' or 'part' requests for all other URIs. 522 // Handle 'import' or 'part' requests for all other URIs.
524 // Get the file path out of the url. 523 // Get the file path out of the url.
525 Dart_Handle builtin_lib = 524 Dart_Handle builtin_lib =
526 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); 525 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
527 Dart_Handle file_path = FilePathFromUri(url, builtin_lib); 526 Dart_Handle file_path = FilePathFromUri(url, builtin_lib);
528 if (Dart_IsError(file_path)) { 527 if (Dart_IsError(file_path)) {
529 return file_path; 528 return file_path;
530 } 529 }
531 Dart_StringToCString(file_path, &url_string); 530 const char* final_path = NULL;
532 if (is_dart_extension_url) { 531 Dart_StringToCString(file_path, &final_path);
532 if (DartUtils::IsDartExtensionSchemeURL(url_string)) {
533 if (tag != Dart_kImportTag) { 533 if (tag != Dart_kImportTag) {
534 return NewError("Dart extensions must use import: '%s'", url_string); 534 return NewError("Dart extensions must use import: '%s'", url_string);
535 } 535 }
536 return Extensions::LoadExtension(url_string, library); 536 return Extensions::LoadExtension(final_path, library);
537 } 537 }
538 result = DartUtils::LoadSource(NULL, 538 result = DartUtils::LoadSource(NULL,
539 library, 539 library,
540 url, 540 url,
541 tag, 541 tag,
542 url_string); 542 final_path);
543 return result; 543 return result;
544 } 544 }
545 545
546 546
547 const uint8_t* DartUtils::SniffForMagicNumber(const uint8_t* text_buffer, 547 const uint8_t* DartUtils::SniffForMagicNumber(const uint8_t* text_buffer,
548 intptr_t* buffer_len, 548 intptr_t* buffer_len,
549 bool* is_snapshot) { 549 bool* is_snapshot) {
550 intptr_t len = sizeof(magic_number); 550 intptr_t len = sizeof(magic_number);
551 for (intptr_t i = 0; i < len; i++) { 551 for (intptr_t i = 0; i < len; i++) {
552 if (text_buffer[i] != magic_number[i]) { 552 if (text_buffer[i] != magic_number[i]) {
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 new CObjectString(CObject::NewString(os_error->message())); 1082 new CObjectString(CObject::NewString(os_error->message()));
1083 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1083 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1084 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1084 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1085 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1085 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1086 result->SetAt(2, error_message); 1086 result->SetAt(2, error_message);
1087 return result; 1087 return result;
1088 } 1088 }
1089 1089
1090 } // namespace bin 1090 } // namespace bin
1091 } // namespace dart 1091 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698