Chromium Code Reviews| 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::kCoreLibURL = "dart:core"; | 29 const char* DartUtils::kCoreLibURL = "dart:core"; |
| 30 const char* DartUtils::kIsolateLibURL = "dart:isolate"; | |
| 31 const char* DartUtils::kInternalLibURL = "dart:_collection-dev"; | |
|
Ivan Posva
2013/11/27 22:08:32
The name does not match. If we are starting to use
floitsch
2013/11/28 19:05:54
Done.
| |
| 30 const char* DartUtils::kIOLibURL = "dart:io"; | 32 const char* DartUtils::kIOLibURL = "dart:io"; |
| 31 const char* DartUtils::kIOLibPatchURL = "dart:io-patch"; | 33 const char* DartUtils::kIOLibPatchURL = "dart:io-patch"; |
| 32 const char* DartUtils::kUriLibURL = "dart:uri"; | 34 const char* DartUtils::kUriLibURL = "dart:uri"; |
| 33 const char* DartUtils::kHttpScheme = "http:"; | 35 const char* DartUtils::kHttpScheme = "http:"; |
| 34 | 36 |
| 35 const char* DartUtils::kIdFieldName = "_id"; | 37 const char* DartUtils::kIdFieldName = "_id"; |
| 36 | 38 |
| 37 uint8_t DartUtils::magic_number[] = { 0xf5, 0xf5, 0xdc, 0xdc }; | 39 uint8_t DartUtils::magic_number[] = { 0xf5, 0xf5, 0xdc, 0xdc }; |
| 38 | 40 |
| 39 static bool IsWindowsHost() { | 41 static bool IsWindowsHost() { |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 } else if (tag == Dart_kSourceTag) { | 662 } else if (tag == Dart_kSourceTag) { |
| 661 return Dart_LoadSource(library, url, source); | 663 return Dart_LoadSource(library, url, source); |
| 662 } | 664 } |
| 663 return Dart_NewApiError("wrong tag"); | 665 return Dart_NewApiError("wrong tag"); |
| 664 } | 666 } |
| 665 | 667 |
| 666 | 668 |
| 667 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, | 669 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, |
| 668 Dart_Handle builtin_lib) { | 670 Dart_Handle builtin_lib) { |
| 669 // Setup the internal library's 'internalPrint' function. | 671 // Setup the internal library's 'internalPrint' function. |
| 670 Dart_Handle internal_lib = | 672 Dart_Handle url = NewString(kInternalLibURL); |
|
Ivan Posva
2013/11/27 22:08:32
Can you please move these lines dealing with dart:
floitsch
2013/11/28 19:05:54
Done.
| |
| 671 Dart_LookupLibrary(NewString("dart:_collection-dev")); | 673 DART_CHECK_VALID(url); |
| 674 Dart_Handle internal_lib = Dart_LookupLibrary(url); | |
| 672 DART_CHECK_VALID(internal_lib); | 675 DART_CHECK_VALID(internal_lib); |
| 673 Dart_Handle print = Dart_Invoke( | 676 Dart_Handle print = Dart_Invoke( |
| 674 builtin_lib, NewString("_getPrintClosure"), 0, NULL); | 677 builtin_lib, NewString("_getPrintClosure"), 0, NULL); |
| 675 Dart_Handle result = Dart_SetField(internal_lib, | 678 Dart_Handle result = Dart_SetField(internal_lib, |
| 676 NewString("_printClosure"), | 679 NewString("_printClosure"), |
| 677 print); | 680 print); |
| 678 DART_CHECK_VALID(result); | 681 DART_CHECK_VALID(result); |
| 679 | 682 |
| 680 // Setup the 'timer' factory. | 683 // Setup the 'timer' factory. |
| 681 Dart_Handle url = NewString(kAsyncLibURL); | 684 url = NewString(kAsyncLibURL); |
| 682 DART_CHECK_VALID(url); | 685 DART_CHECK_VALID(url); |
| 683 Dart_Handle async_lib = Dart_LookupLibrary(url); | 686 Dart_Handle async_lib = Dart_LookupLibrary(url); |
| 684 DART_CHECK_VALID(async_lib); | 687 DART_CHECK_VALID(async_lib); |
| 685 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); | 688 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); |
| 686 Dart_Handle timer_closure = | 689 Dart_Handle timer_closure = |
| 687 Dart_Invoke(io_lib, NewString("_getTimerFactoryClosure"), 0, NULL); | 690 Dart_Invoke(io_lib, NewString("_getTimerFactoryClosure"), 0, NULL); |
| 688 Dart_Handle args[1]; | 691 Dart_Handle args[1]; |
| 689 args[0] = timer_closure; | 692 args[0] = timer_closure; |
| 690 DART_CHECK_VALID(Dart_Invoke( | 693 DART_CHECK_VALID(Dart_Invoke( |
| 691 async_lib, NewString("_setTimerFactoryClosure"), 1, args)); | 694 async_lib, NewString("_setTimerFactoryClosure"), 1, args)); |
| 692 | 695 |
| 696 // Setup the 'scheduleImmediate' closure. | |
| 697 url = NewString(kIsolateLibURL); | |
| 698 DART_CHECK_VALID(url); | |
| 699 Dart_Handle isolate_lib = Dart_LookupLibrary(url); | |
| 700 DART_CHECK_VALID(isolate_lib); | |
| 701 Dart_Handle schedule_immediate_closure = | |
| 702 Dart_Invoke(isolate_lib, NewString("_getIsolateScheduleImmediateClosure"), | |
| 703 0, NULL); | |
| 704 args[0] = schedule_immediate_closure; | |
| 705 DART_CHECK_VALID(Dart_Invoke( | |
| 706 internal_lib, NewString("setScheduleImmediateClosure"), 1, args)); | |
| 707 | |
| 693 // Setup the corelib 'Uri.base' getter. | 708 // Setup the corelib 'Uri.base' getter. |
| 694 Dart_Handle corelib = Dart_LookupLibrary(NewString("dart:core")); | 709 url = NewString(kCoreLibURL); |
| 710 DART_CHECK_VALID(url); | |
| 711 Dart_Handle corelib = Dart_LookupLibrary(url); | |
| 695 DART_CHECK_VALID(corelib); | 712 DART_CHECK_VALID(corelib); |
| 696 Dart_Handle uri_base = Dart_Invoke( | 713 Dart_Handle uri_base = Dart_Invoke( |
| 697 builtin_lib, NewString("_getUriBaseClosure"), 0, NULL); | 714 builtin_lib, NewString("_getUriBaseClosure"), 0, NULL); |
| 698 DART_CHECK_VALID(uri_base); | 715 DART_CHECK_VALID(uri_base); |
| 699 result = Dart_SetField(corelib, | 716 result = Dart_SetField(corelib, |
| 700 NewString("_uriBaseClosure"), | 717 NewString("_uriBaseClosure"), |
| 701 uri_base); | 718 uri_base); |
| 702 DART_CHECK_VALID(result); | 719 DART_CHECK_VALID(result); |
| 703 | 720 |
| 704 if (IsWindowsHost()) { | 721 if (IsWindowsHost()) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1048 new CObjectString(CObject::NewString(os_error->message())); | 1065 new CObjectString(CObject::NewString(os_error->message())); |
| 1049 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1066 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 1050 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1067 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 1051 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1068 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 1052 result->SetAt(2, error_message); | 1069 result->SetAt(2, error_message); |
| 1053 return result; | 1070 return result; |
| 1054 } | 1071 } |
| 1055 | 1072 |
| 1056 } // namespace bin | 1073 } // namespace bin |
| 1057 } // namespace dart | 1074 } // namespace dart |
| OLD | NEW |