| OLD | NEW |
| 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" |
| 11 #include "platform/globals.h" | 11 #include "platform/globals.h" |
| 12 | 12 |
| 13 #include "bin/crypto.h" | 13 #include "bin/crypto.h" |
| 14 #include "bin/directory.h" | 14 #include "bin/directory.h" |
| 15 #include "bin/extensions.h" | 15 #include "bin/extensions.h" |
| 16 #include "bin/file.h" | 16 #include "bin/file.h" |
| 17 #include "bin/io_buffer.h" | 17 #include "bin/io_buffer.h" |
| 18 #include "bin/socket.h" | 18 #include "bin/socket.h" |
| 19 #include "bin/utils.h" | 19 #include "bin/utils.h" |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 namespace bin { | 22 namespace bin { |
| 23 | 23 |
| 24 const char* DartUtils::original_working_directory = NULL; | 24 const char* DartUtils::original_working_directory = NULL; |
| 25 const char* DartUtils::kDartScheme = "dart:"; | 25 const char* DartUtils::kDartScheme = "dart:"; |
| 26 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; | 26 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; |
| 27 const char* DartUtils::kAsyncLibURL = "dart:async"; | 27 const char* DartUtils::kAsyncLibURL = "dart:async"; |
| 28 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; | 28 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; |
| 29 const char* DartUtils::kCollectionDevLibURL = "dart:_collection-dev"; | |
| 30 const char* DartUtils::kCoreLibURL = "dart:core"; | 29 const char* DartUtils::kCoreLibURL = "dart:core"; |
| 30 const char* DartUtils::kInternalLibURL = "dart:_internal"; |
| 31 const char* DartUtils::kIsolateLibURL = "dart:isolate"; | 31 const char* DartUtils::kIsolateLibURL = "dart:isolate"; |
| 32 const char* DartUtils::kIOLibURL = "dart:io"; | 32 const char* DartUtils::kIOLibURL = "dart:io"; |
| 33 const char* DartUtils::kIOLibPatchURL = "dart:io-patch"; | 33 const char* DartUtils::kIOLibPatchURL = "dart:io-patch"; |
| 34 const char* DartUtils::kUriLibURL = "dart:uri"; | 34 const char* DartUtils::kUriLibURL = "dart:uri"; |
| 35 const char* DartUtils::kHttpScheme = "http:"; | 35 const char* DartUtils::kHttpScheme = "http:"; |
| 36 const char* DartUtils::kVMServiceLibURL = "dart:vmservice"; | 36 const char* DartUtils::kVMServiceLibURL = "dart:vmservice"; |
| 37 | 37 |
| 38 const char* DartUtils::kIdFieldName = "_id"; | 38 const char* DartUtils::kIdFieldName = "_id"; |
| 39 | 39 |
| 40 uint8_t DartUtils::magic_number[] = { 0xf5, 0xf5, 0xdc, 0xdc }; | 40 uint8_t DartUtils::magic_number[] = { 0xf5, 0xf5, 0xdc, 0xdc }; |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 } | 676 } |
| 677 return Dart_NewApiError("wrong tag"); | 677 return Dart_NewApiError("wrong tag"); |
| 678 } | 678 } |
| 679 | 679 |
| 680 | 680 |
| 681 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, | 681 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, |
| 682 Dart_Handle builtin_lib) { | 682 Dart_Handle builtin_lib) { |
| 683 // Setup the internal library's 'internalPrint' function. | 683 // Setup the internal library's 'internalPrint' function. |
| 684 Dart_Handle print = Dart_Invoke( | 684 Dart_Handle print = Dart_Invoke( |
| 685 builtin_lib, NewString("_getPrintClosure"), 0, NULL); | 685 builtin_lib, NewString("_getPrintClosure"), 0, NULL); |
| 686 Dart_Handle url = NewString(kCollectionDevLibURL); | 686 Dart_Handle url = NewString(kInternalLibURL); |
| 687 DART_CHECK_VALID(url); | 687 DART_CHECK_VALID(url); |
| 688 Dart_Handle collection_dev_lib = Dart_LookupLibrary(url); | 688 Dart_Handle internal_lib = Dart_LookupLibrary(url); |
| 689 DART_CHECK_VALID(collection_dev_lib); | 689 DART_CHECK_VALID(internal_lib); |
| 690 Dart_Handle result = Dart_SetField(collection_dev_lib, | 690 Dart_Handle result = Dart_SetField(internal_lib, |
| 691 NewString("_printClosure"), | 691 NewString("_printClosure"), |
| 692 print); | 692 print); |
| 693 DART_CHECK_VALID(result); | 693 DART_CHECK_VALID(result); |
| 694 | 694 |
| 695 // Setup the 'timer' factory. | 695 // Setup the 'timer' factory. |
| 696 url = NewString(kAsyncLibURL); | 696 url = NewString(kAsyncLibURL); |
| 697 DART_CHECK_VALID(url); | 697 DART_CHECK_VALID(url); |
| 698 Dart_Handle async_lib = Dart_LookupLibrary(url); | 698 Dart_Handle async_lib = Dart_LookupLibrary(url); |
| 699 DART_CHECK_VALID(async_lib); | 699 DART_CHECK_VALID(async_lib); |
| 700 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); | 700 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 new CObjectString(CObject::NewString(os_error->message())); | 1077 new CObjectString(CObject::NewString(os_error->message())); |
| 1078 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1078 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 1079 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1079 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 1080 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1080 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 1081 result->SetAt(2, error_message); | 1081 result->SetAt(2, error_message); |
| 1082 return result; | 1082 return result; |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 } // namespace bin | 1085 } // namespace bin |
| 1086 } // namespace dart | 1086 } // namespace dart |
| OLD | NEW |