| 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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 return false; | 42 return false; |
| 43 #endif // defined(TARGET_OS_WINDOWS) | 43 #endif // defined(TARGET_OS_WINDOWS) |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 const char* DartUtils::MapLibraryUrl(CommandLineOptions* url_mapping, | 47 const char* DartUtils::MapLibraryUrl(CommandLineOptions* url_mapping, |
| 48 const char* url_string) { | 48 const char* url_string) { |
| 49 ASSERT(url_mapping != NULL); | 49 ASSERT(url_mapping != NULL); |
| 50 // We need to check if the passed in url is found in the url_mapping array, | 50 // We need to check if the passed in url is found in the url_mapping array, |
| 51 // in that case use the mapped entry. | 51 // in that case use the mapped entry. |
| 52 int len = strlen(url_string); | 52 intptr_t len = strlen(url_string); |
| 53 for (int idx = 0; idx < url_mapping->count(); idx++) { | 53 for (intptr_t idx = 0; idx < url_mapping->count(); idx++) { |
| 54 const char* url_name = url_mapping->GetArgument(idx); | 54 const char* url_name = url_mapping->GetArgument(idx); |
| 55 if (!strncmp(url_string, url_name, len) && (url_name[len] == ',')) { | 55 if (!strncmp(url_string, url_name, len) && (url_name[len] == ',')) { |
| 56 const char* url_mapped_name = url_name + len + 1; | 56 const char* url_mapped_name = url_name + len + 1; |
| 57 if (strlen(url_mapped_name) != 0) { | 57 if (strlen(url_mapped_name) != 0) { |
| 58 return url_mapped_name; // Found a mapping for this URL. | 58 return url_mapped_name; // Found a mapping for this URL. |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 return NULL; // Did not find a mapping for this URL. | 62 return NULL; // Did not find a mapping for this URL. |
| 63 } | 63 } |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 | 932 |
| 933 | 933 |
| 934 Dart_CObject* CObject::NewString(intptr_t length) { | 934 Dart_CObject* CObject::NewString(intptr_t length) { |
| 935 Dart_CObject* cobject = New(Dart_CObject_kString, length + 1); | 935 Dart_CObject* cobject = New(Dart_CObject_kString, length + 1); |
| 936 cobject->value.as_string = reinterpret_cast<char*>(cobject + 1); | 936 cobject->value.as_string = reinterpret_cast<char*>(cobject + 1); |
| 937 return cobject; | 937 return cobject; |
| 938 } | 938 } |
| 939 | 939 |
| 940 | 940 |
| 941 Dart_CObject* CObject::NewString(const char* str) { | 941 Dart_CObject* CObject::NewString(const char* str) { |
| 942 int length = strlen(str); | 942 intptr_t length = strlen(str); |
| 943 Dart_CObject* cobject = NewString(length); | 943 Dart_CObject* cobject = NewString(length); |
| 944 memmove(cobject->value.as_string, str, length + 1); | 944 memmove(cobject->value.as_string, str, length + 1); |
| 945 return cobject; | 945 return cobject; |
| 946 } | 946 } |
| 947 | 947 |
| 948 | 948 |
| 949 Dart_CObject* CObject::NewArray(intptr_t length) { | 949 Dart_CObject* CObject::NewArray(intptr_t length) { |
| 950 Dart_CObject* cobject = | 950 Dart_CObject* cobject = |
| 951 New(Dart_CObject_kArray, length * sizeof(Dart_CObject*)); // NOLINT | 951 New(Dart_CObject_kArray, length * sizeof(Dart_CObject*)); // NOLINT |
| 952 cobject->value.as_array.length = length; | 952 cobject->value.as_array.length = length; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 new CObjectString(CObject::NewString(os_error->message())); | 1024 new CObjectString(CObject::NewString(os_error->message())); |
| 1025 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1025 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 1026 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1026 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 1027 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1027 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 1028 result->SetAt(2, error_message); | 1028 result->SetAt(2, error_message); |
| 1029 return result; | 1029 return result; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 } // namespace bin | 1032 } // namespace bin |
| 1033 } // namespace dart | 1033 } // namespace dart |
| OLD | NEW |