| 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/file.h" | 7 #include "bin/file.h" |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| 11 | 11 |
| 12 const char* DartUtils::kDartScheme = "dart:"; | 12 const char* DartUtils::kDartScheme = "dart:"; |
| 13 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; | 13 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; |
| 14 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; | 14 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; |
| 15 const char* DartUtils::kCoreLibURL = "dart:core"; | 15 const char* DartUtils::kCoreLibURL = "dart:core"; |
| 16 const char* DartUtils::kCoreImplLibURL = "dart:coreimpl"; | 16 const char* DartUtils::kCoreImplLibURL = "dart:coreimpl"; |
| 17 const char* DartUtils::kIOLibURL = "dart:io"; | 17 const char* DartUtils::kIOLibURL = "dart:io"; |
| 18 const char* DartUtils::kJsonLibURL = "dart:json"; | 18 const char* DartUtils::kJsonLibURL = "dart:json"; |
| 19 const char* DartUtils::kUriLibURL = "dart:uri"; | 19 const char* DartUtils::kUriLibURL = "dart:uri"; |
| 20 const char* DartUtils::kUtf8LibURL = "dart:utf8"; | 20 const char* DartUtils::kUtfLibURL = "dart:utf"; |
| 21 | 21 |
| 22 | 22 |
| 23 const char* DartUtils::kIdFieldName = "_id"; | 23 const char* DartUtils::kIdFieldName = "_id"; |
| 24 | 24 |
| 25 | 25 |
| 26 static const char* MapLibraryUrl(CommandLineOptions* url_mapping, | 26 static const char* MapLibraryUrl(CommandLineOptions* url_mapping, |
| 27 const char* url_string) { | 27 const char* url_string) { |
| 28 ASSERT(url_mapping != NULL); | 28 ASSERT(url_mapping != NULL); |
| 29 // We need to check if the passed in url is found in the url_mapping array, | 29 // We need to check if the passed in url is found in the url_mapping array, |
| 30 // in that case use the mapped entry. | 30 // in that case use the mapped entry. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 bool DartUtils::IsDartJsonLibURL(const char* url_name) { | 122 bool DartUtils::IsDartJsonLibURL(const char* url_name) { |
| 123 return (strcmp(url_name, kJsonLibURL) == 0); | 123 return (strcmp(url_name, kJsonLibURL) == 0); |
| 124 } | 124 } |
| 125 | 125 |
| 126 | 126 |
| 127 bool DartUtils::IsDartUriLibURL(const char* url_name) { | 127 bool DartUtils::IsDartUriLibURL(const char* url_name) { |
| 128 return (strcmp(url_name, kUriLibURL) == 0); | 128 return (strcmp(url_name, kUriLibURL) == 0); |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 bool DartUtils::IsDartUtf8LibURL(const char* url_name) { | 132 bool DartUtils::IsDartUtfLibURL(const char* url_name) { |
| 133 return (strcmp(url_name, kUtf8LibURL) == 0); | 133 return (strcmp(url_name, kUtfLibURL) == 0); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, | 137 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, |
| 138 Dart_Handle library, | 138 Dart_Handle library, |
| 139 const char* url_str) { | 139 const char* url_str) { |
| 140 // Get the url of the including library. | 140 // Get the url of the including library. |
| 141 Dart_Handle library_url = Dart_LibraryUrl(library); | 141 Dart_Handle library_url = Dart_LibraryUrl(library); |
| 142 if (Dart_IsError(library_url)) { | 142 if (Dart_IsError(library_url)) { |
| 143 return Dart_Error("accessing library url failed"); | 143 return Dart_Error("accessing library url failed"); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 return cobject; | 371 return cobject; |
| 372 } | 372 } |
| 373 | 373 |
| 374 | 374 |
| 375 Dart_CObject* CObject::NewByteArray(int length) { | 375 Dart_CObject* CObject::NewByteArray(int length) { |
| 376 Dart_CObject* cobject = New(Dart_CObject::kByteArray, length); | 376 Dart_CObject* cobject = New(Dart_CObject::kByteArray, length); |
| 377 cobject->value.as_byte_array.length = length; | 377 cobject->value.as_byte_array.length = length; |
| 378 cobject->value.as_byte_array.values = reinterpret_cast<uint8_t*>(cobject + 1); | 378 cobject->value.as_byte_array.values = reinterpret_cast<uint8_t*>(cobject + 1); |
| 379 return cobject; | 379 return cobject; |
| 380 } | 380 } |
| OLD | NEW |