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

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

Issue 1896203002: Search for a native extension for the host architecture (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « runtime/bin/builtin_natives.cc ('k') | runtime/bin/extensions.h » ('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/crypto.h" 7 #include "bin/crypto.h"
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/extensions.h" 9 #include "bin/extensions.h"
10 #include "bin/file.h" 10 #include "bin/file.h"
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 443
444 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { 444 if (DartUtils::IsDartExtensionSchemeURL(url_string)) {
445 // Load a native code shared library to use in a native extension 445 // Load a native code shared library to use in a native extension
446 if (tag != Dart_kImportTag) { 446 if (tag != Dart_kImportTag) {
447 return NewError("Dart extensions must use import: '%s'", url_string); 447 return NewError("Dart extensions must use import: '%s'", url_string);
448 } 448 }
449 Dart_Handle path_parts = DartUtils::ExtensionPathFromUri(url); 449 Dart_Handle path_parts = DartUtils::ExtensionPathFromUri(url);
450 if (Dart_IsError(path_parts)) { 450 if (Dart_IsError(path_parts)) {
451 return path_parts; 451 return path_parts;
452 } 452 }
453 #if defined(DEBUG)
454 intptr_t path_parts_length;
455 result = Dart_ListLength(path_parts, &path_parts_length);
456 if (Dart_IsError(result)) {
457 return result;
458 }
459 ASSERT(path_parts_length == 2);
460 #endif
453 const char* extension_directory = NULL; 461 const char* extension_directory = NULL;
454 Dart_StringToCString(Dart_ListGetAt(path_parts, 0), &extension_directory); 462 Dart_StringToCString(Dart_ListGetAt(path_parts, 0), &extension_directory);
455 const char* extension_filename = NULL;
456 Dart_StringToCString(Dart_ListGetAt(path_parts, 1), &extension_filename);
457 const char* extension_name = NULL; 463 const char* extension_name = NULL;
458 Dart_StringToCString(Dart_ListGetAt(path_parts, 2), &extension_name); 464 Dart_StringToCString(Dart_ListGetAt(path_parts, 1), &extension_name);
459 465
460 return Extensions::LoadExtension(extension_directory, 466 return Extensions::LoadExtension(extension_directory,
461 extension_filename,
462 extension_name, 467 extension_name,
463 library); 468 library);
464 } 469 }
465 470
466 // Handle 'import' or 'part' requests for all other URIs. Call dart code to 471 // Handle 'import' or 'part' requests for all other URIs. Call dart code to
467 // read the source code asynchronously. 472 // read the source code asynchronously.
468 return LoadDataAsync_Invoke(Dart_NewInteger(tag), url, library_url); 473 return LoadDataAsync_Invoke(Dart_NewInteger(tag), url, library_url);
469 } 474 }
470 475
471 476
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 Dart_Handle res = Dart_FinalizeLoading(true); 617 Dart_Handle res = Dart_FinalizeLoading(true);
613 if (Dart_IsError(res)) { 618 if (Dart_IsError(res)) {
614 // TODO(hausner): If compilation/loading errors are supposed to 619 // TODO(hausner): If compilation/loading errors are supposed to
615 // be observable by the program, we need to mark the bad library 620 // be observable by the program, we need to mark the bad library
616 // with the error instead of propagating it. 621 // with the error instead of propagating it.
617 Dart_PropagateError(res); 622 Dart_PropagateError(res);
618 } 623 }
619 } 624 }
620 625
621 626
622 void FUNCTION_NAME(Builtin_NativeLibraryExtension)(Dart_NativeArguments args) {
623 const char* suffix = Platform::LibraryExtension();
624 ASSERT(suffix != NULL);
625 Dart_Handle res = Dart_NewStringFromCString(suffix);
626 if (Dart_IsError(res)) {
627 Dart_PropagateError(res);
628 }
629 Dart_SetReturnValue(args, res);
630 }
631
632
633 void FUNCTION_NAME(Builtin_GetCurrentDirectory)(Dart_NativeArguments args) { 627 void FUNCTION_NAME(Builtin_GetCurrentDirectory)(Dart_NativeArguments args) {
634 const char* current = Directory::Current(); 628 const char* current = Directory::Current();
635 if (current != NULL) { 629 if (current != NULL) {
636 Dart_SetReturnValue(args, DartUtils::NewString(current)); 630 Dart_SetReturnValue(args, DartUtils::NewString(current));
637 } else { 631 } else {
638 Dart_Handle err = DartUtils::NewError("Failed to get current directory."); 632 Dart_Handle err = DartUtils::NewError("Failed to get current directory.");
639 Dart_PropagateError(err); 633 Dart_PropagateError(err);
640 } 634 }
641 } 635 }
642 636
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 new CObjectString(CObject::NewString(os_error->message())); 1255 new CObjectString(CObject::NewString(os_error->message()));
1262 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1256 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1263 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1257 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1264 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1258 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1265 result->SetAt(2, error_message); 1259 result->SetAt(2, error_message);
1266 return result; 1260 return result;
1267 } 1261 }
1268 1262
1269 } // namespace bin 1263 } // namespace bin
1270 } // namespace dart 1264 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/builtin_natives.cc ('k') | runtime/bin/extensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698