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

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

Issue 36883005: Add fields to platform library, implement them on runtime dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comments. Created 7 years, 1 month 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 11 matching lines...) Expand all
22 22
23 const char* DartUtils::original_working_directory = NULL; 23 const char* DartUtils::original_working_directory = NULL;
24 const char* DartUtils::kDartScheme = "dart:"; 24 const char* DartUtils::kDartScheme = "dart:";
25 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; 25 const char* DartUtils::kDartExtensionScheme = "dart-ext:";
26 const char* DartUtils::kAsyncLibURL = "dart:async"; 26 const char* DartUtils::kAsyncLibURL = "dart:async";
27 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; 27 const char* DartUtils::kBuiltinLibURL = "dart:builtin";
28 const char* DartUtils::kCoreLibURL = "dart:core"; 28 const char* DartUtils::kCoreLibURL = "dart:core";
29 const char* DartUtils::kIOLibURL = "dart:io"; 29 const char* DartUtils::kIOLibURL = "dart:io";
30 const char* DartUtils::kIOLibPatchURL = "dart:io-patch"; 30 const char* DartUtils::kIOLibPatchURL = "dart:io-patch";
31 const char* DartUtils::kUriLibURL = "dart:uri"; 31 const char* DartUtils::kUriLibURL = "dart:uri";
32 const char* DartUtils::kPlatformLibURL = "dart:platform";
32 const char* DartUtils::kHttpScheme = "http:"; 33 const char* DartUtils::kHttpScheme = "http:";
33 34
34 const char* DartUtils::kIdFieldName = "_id"; 35 const char* DartUtils::kIdFieldName = "_id";
35 36
36 uint8_t DartUtils::magic_number[] = { 0xf5, 0xf5, 0xdc, 0xdc }; 37 uint8_t DartUtils::magic_number[] = { 0xf5, 0xf5, 0xdc, 0xdc };
37 38
38 static bool IsWindowsHost() { 39 static bool IsWindowsHost() {
39 #if defined(TARGET_OS_WINDOWS) 40 #if defined(TARGET_OS_WINDOWS)
40 return true; 41 return true;
41 #else // defined(TARGET_OS_WINDOWS) 42 #else // defined(TARGET_OS_WINDOWS)
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 705 }
705 706
706 // Set current working directory. 707 // Set current working directory.
707 result = SetWorkingDirectory(builtin_lib); 708 result = SetWorkingDirectory(builtin_lib);
708 if (Dart_IsError(result)) { 709 if (Dart_IsError(result)) {
709 return result; 710 return result;
710 } 711 }
711 712
712 // Set up package root if specified. 713 // Set up package root if specified.
713 if (package_root != NULL) { 714 if (package_root != NULL) {
714 result = NewString(package_root); 715 Dart_Handle package_root_string = NewString(package_root);
Anders Johnsen 2013/10/24 17:21:01 Why not reuse result here?
Bill Hesse 2013/10/25 11:06:34 It's just a matter of style. In the rest of the f
715 if (!Dart_IsError(result)) { 716 if (Dart_IsError(package_root_string)) {
716 const int kNumArgs = 1; 717 return package_root_string;
717 Dart_Handle dart_args[kNumArgs]; 718 }
718 dart_args[0] = result; 719 const int kNumArgs = 1;
719 return Dart_Invoke(builtin_lib, 720 Dart_Handle dart_args[kNumArgs];
721 dart_args[0] = package_root_string;
722 result = Dart_Invoke(builtin_lib,
720 NewString("_setPackageRoot"), 723 NewString("_setPackageRoot"),
721 kNumArgs, 724 kNumArgs,
722 dart_args); 725 dart_args);
726 if (Dart_IsError(result)) {
727 return result;
723 } 728 }
724 } 729 }
730
731 // Setup the platform library's _platformHook object.
732 internal_lib = Dart_LookupLibrary(NewString(kPlatformLibURL));
733 DART_CHECK_VALID(internal_lib);
734 Dart_Handle platform =
735 Dart_Invoke(builtin_lib, NewString("_getPlatform"), 0, NULL);
736 result = Dart_SetField(internal_lib, NewString("_platformHook"), platform);
737 DART_CHECK_VALID(result);
725 return result; 738 return result;
726 } 739 }
727 740
728 741
729 const char* DartUtils::GetCanonicalPath(const char* reference_dir, 742 const char* DartUtils::GetCanonicalPath(const char* reference_dir,
730 const char* filename) { 743 const char* filename) {
731 if (File::IsAbsolutePath(filename)) { 744 if (File::IsAbsolutePath(filename)) {
732 return strdup(filename); 745 return strdup(filename);
733 } 746 }
734 747
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 new CObjectString(CObject::NewString(os_error->message())); 1055 new CObjectString(CObject::NewString(os_error->message()));
1043 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1056 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1044 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1057 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1045 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1058 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1046 result->SetAt(2, error_message); 1059 result->SetAt(2, error_message);
1047 return result; 1060 return result;
1048 } 1061 }
1049 1062
1050 } // namespace bin 1063 } // namespace bin
1051 } // namespace dart 1064 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698