OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SKY_ENGINE_TONIC_DART_CONVERTER_H_ | 5 #ifndef SKY_ENGINE_TONIC_DART_CONVERTER_H_ |
6 #define SKY_ENGINE_TONIC_DART_CONVERTER_H_ | 6 #define SKY_ENGINE_TONIC_DART_CONVERTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "sky/engine/tonic/dart_state.h" | 9 #include "sky/engine/tonic/dart_state.h" |
10 #include "sky/engine/tonic/dart_string.h" | 10 #include "sky/engine/tonic/dart_string.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 241 } |
242 | 242 |
243 static Vector<T> FromDart(Dart_Handle handle) { | 243 static Vector<T> FromDart(Dart_Handle handle) { |
244 Vector<T> result; | 244 Vector<T> result; |
245 if (!Dart_IsList(handle)) | 245 if (!Dart_IsList(handle)) |
246 return result; | 246 return result; |
247 intptr_t length = 0; | 247 intptr_t length = 0; |
248 Dart_ListLength(handle, &length); | 248 Dart_ListLength(handle, &length); |
249 result.reserveCapacity(length); | 249 result.reserveCapacity(length); |
250 for (intptr_t i = 0; i < length; ++i) { | 250 for (intptr_t i = 0; i < length; ++i) { |
251 Dart_Handle element = Dart_ListGetAt(handle, i); | 251 Dart_Handle item = Dart_ListGetAt(handle, i); |
252 DCHECK(!Dart_IsError(element)); | 252 DCHECK(!Dart_IsError(item)); |
253 result.append(DartConverter<T>::FromDart(element)); | 253 DCHECK(item); |
| 254 result.append(DartConverter<T>::FromDart(item)); |
254 } | 255 } |
255 return result; | 256 return result; |
256 } | 257 } |
257 | 258 |
258 static Vector<T> FromArguments(Dart_NativeArguments args, | 259 static Vector<T> FromArguments(Dart_NativeArguments args, |
259 int index, | 260 int index, |
260 Dart_Handle& exception, | 261 Dart_Handle& exception, |
261 bool auto_scope = true) { | 262 bool auto_scope = true) { |
262 // TODO(abarth): What should we do with auto_scope? | 263 // TODO(abarth): What should we do with auto_scope? |
263 return FromDart(Dart_GetNativeArgument(args, index)); | 264 return FromDart(Dart_GetNativeArgument(args, index)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 323 |
323 | 324 |
324 // Alias Dart_NewStringFromCString for less typing. | 325 // Alias Dart_NewStringFromCString for less typing. |
325 inline Dart_Handle ToDart(const char* val) { | 326 inline Dart_Handle ToDart(const char* val) { |
326 return Dart_NewStringFromCString(val); | 327 return Dart_NewStringFromCString(val); |
327 } | 328 } |
328 | 329 |
329 } // namespace blink | 330 } // namespace blink |
330 | 331 |
331 #endif // SKY_ENGINE_TONIC_DART_CONVERTER_H_ | 332 #endif // SKY_ENGINE_TONIC_DART_CONVERTER_H_ |
OLD | NEW |