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