| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
| (...skipping 5496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5507 const Library& lib = Api::UnwrapLibraryHandle(Z, library); | 5507 const Library& lib = Api::UnwrapLibraryHandle(Z, library); |
| 5508 if (lib.IsNull()) { | 5508 if (lib.IsNull()) { |
| 5509 RETURN_TYPE_ERROR(Z, library, Library); | 5509 RETURN_TYPE_ERROR(Z, library, Library); |
| 5510 } | 5510 } |
| 5511 const String& url = String::Handle(Z, lib.url()); | 5511 const String& url = String::Handle(Z, lib.url()); |
| 5512 ASSERT(!url.IsNull()); | 5512 ASSERT(!url.IsNull()); |
| 5513 return Api::NewHandle(T, url.raw()); | 5513 return Api::NewHandle(T, url.raw()); |
| 5514 } | 5514 } |
| 5515 | 5515 |
| 5516 | 5516 |
| 5517 DART_EXPORT Dart_Handle Dart_GetLoadedLibraries() { |
| 5518 DARTSCOPE(Thread::Current()); |
| 5519 Isolate* I = T->isolate(); |
| 5520 |
| 5521 const GrowableObjectArray& libs = |
| 5522 GrowableObjectArray::Handle(Z, I->object_store()->libraries()); |
| 5523 int num_libs = libs.Length(); |
| 5524 |
| 5525 // Create new list and populate with the loaded libraries. |
| 5526 Library& lib = Library::Handle(); |
| 5527 const Array& library_list = Array::Handle(Z, Array::New(num_libs)); |
| 5528 for (int i = 0; i < num_libs; i++) { |
| 5529 lib ^= libs.At(i); |
| 5530 ASSERT(!lib.IsNull()); |
| 5531 library_list.SetAt(i, lib); |
| 5532 } |
| 5533 return Api::NewHandle(T, library_list.raw()); |
| 5534 } |
| 5535 |
| 5536 |
| 5517 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { | 5537 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { |
| 5518 DARTSCOPE(Thread::Current()); | 5538 DARTSCOPE(Thread::Current()); |
| 5519 const String& url_str = Api::UnwrapStringHandle(Z, url); | 5539 const String& url_str = Api::UnwrapStringHandle(Z, url); |
| 5520 if (url_str.IsNull()) { | 5540 if (url_str.IsNull()) { |
| 5521 RETURN_TYPE_ERROR(Z, url, String); | 5541 RETURN_TYPE_ERROR(Z, url, String); |
| 5522 } | 5542 } |
| 5523 const Library& library = | 5543 const Library& library = |
| 5524 Library::Handle(Z, Library::LookupLibrary(T, url_str)); | 5544 Library::Handle(Z, Library::LookupLibrary(T, url_str)); |
| 5525 if (library.IsNull()) { | 5545 if (library.IsNull()) { |
| 5526 return Api::NewError("%s: library '%s' not found.", CURRENT_FUNC, | 5546 return Api::NewError("%s: library '%s' not found.", CURRENT_FUNC, |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6624 | 6644 |
| 6625 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6645 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
| 6626 #if defined(DART_PRECOMPILED_RUNTIME) | 6646 #if defined(DART_PRECOMPILED_RUNTIME) |
| 6627 return true; | 6647 return true; |
| 6628 #else | 6648 #else |
| 6629 return false; | 6649 return false; |
| 6630 #endif | 6650 #endif |
| 6631 } | 6651 } |
| 6632 | 6652 |
| 6633 } // namespace dart | 6653 } // namespace dart |
| OLD | NEW |