| 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 "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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 return Dart_Invoke(DartUtils::BuiltinLib(), | 401 return Dart_Invoke(DartUtils::BuiltinLib(), |
| 402 DartUtils::NewString("_loadDataAsync"), | 402 DartUtils::NewString("_loadDataAsync"), |
| 403 kNumArgs, | 403 kNumArgs, |
| 404 dart_args); | 404 dart_args); |
| 405 } | 405 } |
| 406 | 406 |
| 407 | 407 |
| 408 Dart_Handle DartUtils::LibraryTagHandler(Dart_LibraryTag tag, | 408 Dart_Handle DartUtils::LibraryTagHandler(Dart_LibraryTag tag, |
| 409 Dart_Handle library, | 409 Dart_Handle library, |
| 410 Dart_Handle url) { | 410 Dart_Handle url) { |
| 411 Dart_Handle library_url = Dart_LibraryUrl(library); |
| 412 if (Dart_IsError(library_url)) { |
| 413 return library_url; |
| 414 } |
| 411 if (tag == Dart_kCanonicalizeUrl) { | 415 if (tag == Dart_kCanonicalizeUrl) { |
| 412 return Dart_DefaultCanonicalizeUrl(library, url); | 416 return Dart_DefaultCanonicalizeUrl(library_url, url); |
| 413 } | |
| 414 if (!Dart_IsLibrary(library)) { | |
| 415 return Dart_NewApiError("not a library"); | |
| 416 } | 417 } |
| 417 if (!Dart_IsString(url)) { | 418 if (!Dart_IsString(url)) { |
| 418 return Dart_NewApiError("url is not a string"); | 419 return Dart_NewApiError("url is not a string"); |
| 419 } | 420 } |
| 420 const char* url_string = NULL; | 421 const char* url_string = NULL; |
| 421 Dart_Handle result = Dart_StringToCString(url, &url_string); | 422 Dart_Handle result = Dart_StringToCString(url, &url_string); |
| 422 if (Dart_IsError(result)) { | 423 if (Dart_IsError(result)) { |
| 423 return result; | 424 return result; |
| 424 } | 425 } |
| 425 Dart_Handle library_url = Dart_LibraryUrl(library); | |
| 426 const char* library_url_string = NULL; | 426 const char* library_url_string = NULL; |
| 427 result = Dart_StringToCString(library_url, &library_url_string); | 427 result = Dart_StringToCString(library_url, &library_url_string); |
| 428 if (Dart_IsError(result)) { | 428 if (Dart_IsError(result)) { |
| 429 return result; | 429 return result; |
| 430 } | 430 } |
| 431 | 431 |
| 432 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); | 432 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); |
| 433 bool is_dart_library = DartUtils::IsDartSchemeURL(library_url_string); | 433 bool is_dart_library = DartUtils::IsDartSchemeURL(library_url_string); |
| 434 | 434 |
| 435 // Handle canonicalization, 'import' and 'part' of 'dart:' libraries. | 435 // Handle canonicalization, 'import' and 'part' of 'dart:' libraries. |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 new CObjectString(CObject::NewString(os_error->message())); | 1270 new CObjectString(CObject::NewString(os_error->message())); |
| 1271 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1271 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 1272 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1272 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 1273 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1273 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 1274 result->SetAt(2, error_message); | 1274 result->SetAt(2, error_message); |
| 1275 return result; | 1275 return result; |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 } // namespace bin | 1278 } // namespace bin |
| 1279 } // namespace dart | 1279 } // namespace dart |
| OLD | NEW |