| 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 "config.h" | 5 #include "config.h" |
| 6 #include "DartDOMStringList.h" | 6 #include "DartDOMStringList.h" |
| 7 | 7 |
| 8 #include <wtf/Vector.h> | 8 #include <wtf/Vector.h> |
| 9 | 9 |
| 10 namespace WebCore { | 10 namespace WebCore { |
| 11 | 11 |
| 12 PassRefPtr<DOMStringList> DartDOMStringList::toNative(Dart_Handle handle, Dart_H
andle& exception) | 12 PassRefPtr<DOMStringList> DartDOMStringList::toNative(Dart_Handle handle, Dart_H
andle& exception) |
| 13 { | 13 { |
| 14 DartDOMData* domData = DartDOMData::current(); | 14 DartDOMData* domData = DartDOMData::current(); |
| 15 if (DartDOMWrapper::instanceOf<DartDOMStringList>(domData, handle)) | 15 if (DartDOMWrapper::subtypeOf<DartDOMStringList>(domData, handle)) |
| 16 return DartDOMWrapper::unwrapDartWrapper<DartDOMStringList>(domData, han
dle, exception); | 16 return DartDOMWrapper::unwrapDartWrapper<DartDOMStringList>(domData, han
dle, exception); |
| 17 | 17 |
| 18 Vector<Dart_Handle> elements; | 18 Vector<Dart_Handle> elements; |
| 19 DartUtilities::extractListElements(handle, exception, elements); | 19 DartUtilities::extractListElements(handle, exception, elements); |
| 20 if (exception) | 20 if (exception) |
| 21 return 0; | 21 return 0; |
| 22 | 22 |
| 23 RefPtr<DOMStringList> m_domStringList = DOMStringList::create(); | 23 RefPtr<DOMStringList> m_domStringList = DOMStringList::create(); |
| 24 for (size_t i = 0; i < elements.size(); i++) { | 24 for (size_t i = 0; i < elements.size(); i++) { |
| 25 DartStringAdapter element = DartUtilities::dartToString(elements[i], exc
eption); | 25 DartStringAdapter element = DartUtilities::dartToString(elements[i], exc
eption); |
| 26 if (exception) | 26 if (exception) |
| 27 return 0; | 27 return 0; |
| 28 m_domStringList->append(element); | 28 m_domStringList->append(element); |
| 29 } | 29 } |
| 30 return m_domStringList.release(); | 30 return m_domStringList.release(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 PassRefPtr<DOMStringList> DartDOMStringList::toNative(Dart_NativeArguments args,
int idx, Dart_Handle& exception) | 34 PassRefPtr<DOMStringList> DartDOMStringList::toNative(Dart_NativeArguments args,
int idx, Dart_Handle& exception) |
| 35 { | 35 { |
| 36 Dart_Handle handle = Dart_GetNativeArgument(args, idx); | 36 Dart_Handle handle = Dart_GetNativeArgument(args, idx); |
| 37 return toNative(handle, exception); | 37 return toNative(handle, exception); |
| 38 } | 38 } |
| 39 | 39 |
| 40 } | 40 } |
| OLD | NEW |