OLD | NEW |
---|---|
1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 class LabelableElement; | 197 class LabelableElement; |
198 Dart_Handle toDartValue(LabelableElement* element); | 198 Dart_Handle toDartValue(LabelableElement* element); |
199 | 199 |
200 template<typename T> | 200 template<typename T> |
201 Dart_Handle toDartValue(PassRefPtr< SVGAnimatedEnumerationPropertyTearOff<T> >) | 201 Dart_Handle toDartValue(PassRefPtr< SVGAnimatedEnumerationPropertyTearOff<T> >) |
202 { | 202 { |
203 ASSERT_NOT_REACHED(); | 203 ASSERT_NOT_REACHED(); |
204 return 0; | 204 return 0; |
205 } | 205 } |
206 | 206 |
207 template <class Element> | 207 template<typename T> |
208 inline Dart_Handle vectorToDartList(const Vector< RefPtr<Element> >& vector) | 208 Dart_Handle toDartValue(const Vector<T>& vector) |
209 { | 209 { |
210 Dart_Handle list = Dart_NewList(vector.size()); | 210 Dart_Handle list = Dart_NewList(vector.size()); |
211 if (Dart_IsError(list)) | 211 if (Dart_IsError(list)) |
212 return list; | 212 return list; |
213 for (size_t i = 0; i < vector.size(); i++) { | 213 for (size_t i = 0; i < vector.size(); i++) { |
214 Dart_Handle result = Dart_ListSetAt(list, i, toDartValue(vector[i].get() )); | |
215 if (Dart_IsError(result)) | |
216 return result; | |
217 } | |
218 return list; | |
219 } | |
220 | |
221 template <class Element> | |
222 inline Dart_Handle vectorToDartList(const Vector<Element>& vector) | |
223 { | |
224 // FIXME: create list from vector for primitive types | |
225 // without element-by-element copying and conversion. | |
226 // Need VM support. | |
227 Dart_Handle list = Dart_NewList(vector.size()); | |
228 if (Dart_IsError(list)) | |
229 return list; | |
230 | |
231 for (size_t i = 0; i < vector.size(); i++) { | |
232 Dart_Handle result = Dart_ListSetAt(list, i, toDartValue(vector[i])); | 214 Dart_Handle result = Dart_ListSetAt(list, i, toDartValue(vector[i])); |
233 if (Dart_IsError(result)) | 215 if (Dart_IsError(result)) |
234 return result; | 216 return result; |
235 } | 217 } |
236 return list; | 218 return list; |
237 } | 219 } |
238 | 220 |
221 // FIXME: provide specialization for PassRefPtr as well | |
podivilov
2012/03/23 15:44:12
We are generating toDartValue(PassRefPtr<T>) to gu
Anton Muhin
2012/03/23 17:29:23
Thanks a lot for bringing this. I still hope that
podivilov
2012/03/26 09:45:07
DartArrayBuffer.h generated header looks like this
| |
222 // and do not generate it. | |
223 template<typename T> | |
224 Dart_Handle toDartValue(RefPtr<T> value) | |
225 { | |
226 return toDartValue(value.get()); | |
227 } | |
228 | |
239 template <class Element> | 229 template <class Element> |
240 inline Element toWebGLArrayElement(Dart_Handle, Dart_Handle& exception); | 230 inline Element toWebGLArrayElement(Dart_Handle, Dart_Handle& exception); |
241 | 231 |
242 template <> | 232 template <> |
243 inline double toWebGLArrayElement<double>(Dart_Handle object, Dart_Handle& excep tion) | 233 inline double toWebGLArrayElement<double>(Dart_Handle object, Dart_Handle& excep tion) |
244 { | 234 { |
245 return DartUtilities::toDouble(object, exception); | 235 return DartUtilities::toDouble(object, exception); |
246 } | 236 } |
247 | 237 |
248 template <> | 238 template <> |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 template <> | 768 template <> |
779 class ParameterAdapter<ScriptValue> : public ParameterAdapterBase<ScriptValue> { | 769 class ParameterAdapter<ScriptValue> : public ParameterAdapterBase<ScriptValue> { |
780 public: | 770 public: |
781 explicit ParameterAdapter(Dart_Handle handle) { this->unsupported(); } | 771 explicit ParameterAdapter(Dart_Handle handle) { this->unsupported(); } |
782 operator ScriptValue() const { return this->value(); } | 772 operator ScriptValue() const { return this->value(); } |
783 }; | 773 }; |
784 | 774 |
785 } | 775 } |
786 | 776 |
787 #endif // DartDOMWrapper_h | 777 #endif // DartDOMWrapper_h |
OLD | NEW |