OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 bool getOwnPropertyNames(Vector<String>&) const; | 127 bool getOwnPropertyNames(Vector<String>&) const; |
128 | 128 |
129 bool getWithUndefinedOrNullCheck(const String&, String&) const; | 129 bool getWithUndefinedOrNullCheck(const String&, String&) const; |
130 bool getWithUndefinedOrNullCheck(const String&, RefPtrWillBeMember<Element>&
) const; | 130 bool getWithUndefinedOrNullCheck(const String&, RefPtrWillBeMember<Element>&
) const; |
131 bool getWithUndefinedOrNullCheck(const String&, RefPtrWillBeMember<Path2D>&)
const; | 131 bool getWithUndefinedOrNullCheck(const String&, RefPtrWillBeMember<Path2D>&)
const; |
132 | 132 |
133 bool hasProperty(const String&) const; | 133 bool hasProperty(const String&) const; |
134 | 134 |
135 v8::Isolate* isolate() const { return m_isolate; } | 135 v8::Isolate* isolate() const { return m_isolate; } |
136 | 136 |
137 private: | |
138 bool getKey(const String& key, v8::Local<v8::Value>&) const; | 137 bool getKey(const String& key, v8::Local<v8::Value>&) const; |
139 | 138 |
| 139 private: |
140 v8::Handle<v8::Value> m_options; | 140 v8::Handle<v8::Value> m_options; |
141 v8::Isolate* m_isolate; | 141 v8::Isolate* m_isolate; |
142 }; | 142 }; |
143 | 143 |
144 template<> | 144 template<> |
145 struct NativeValueTraits<Dictionary> { | 145 struct NativeValueTraits<Dictionary> { |
146 static inline Dictionary nativeValue(const v8::Handle<v8::Value>& value, v8:
:Isolate* isolate) | 146 static inline Dictionary nativeValue(const v8::Handle<v8::Value>& value, v8:
:Isolate* isolate) |
147 { | 147 { |
148 return Dictionary(value, isolate); | 148 return Dictionary(value, isolate); |
149 } | 149 } |
150 }; | 150 }; |
151 | 151 |
152 // DictionaryHelper is a collection of static methods for getting or | 152 // DictionaryHelper is a collection of static methods for getting or |
153 // converting a value from Dictionary. | 153 // converting a value from Dictionary. |
154 struct DictionaryHelper { | 154 struct DictionaryHelper { |
155 template <typename T> | 155 template <typename T> |
156 static bool get(const Dictionary&, const String& key, T& value); | 156 static bool get(const Dictionary&, const String& key, T& value); |
157 template <typename T> | 157 template <typename T> |
158 static bool get(const Dictionary&, const String& key, T& value, bool& hasVal
ue); | 158 static bool get(const Dictionary&, const String& key, T& value, bool& hasVal
ue); |
| 159 template <typename T> |
| 160 static bool getWithUndefinedOrNullCheck(const Dictionary& dictionary, const
String& key, T& value) |
| 161 { |
| 162 v8::Local<v8::Value> v8Value; |
| 163 if (!dictionary.getKey(key, v8Value) || isUndefinedOrNull(v8Value)) |
| 164 return false; |
| 165 return DictionaryHelper::get(dictionary, key, value); |
| 166 } |
159 template <template <typename> class PointerType, typename T> | 167 template <template <typename> class PointerType, typename T> |
160 static bool get(const Dictionary&, const String& key, PointerType<T>& value)
; | 168 static bool get(const Dictionary&, const String& key, PointerType<T>& value)
; |
161 template <typename T> | 169 template <typename T> |
162 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, T& value); | 170 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, T& value); |
163 template <typename T> | 171 template <typename T> |
164 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, Nullable<T>& value); | 172 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, Nullable<T>& value); |
165 template <template <typename> class PointerType, typename T> | 173 template <template <typename> class PointerType, typename T> |
166 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, PointerType<T>& value); | 174 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, PointerType<T>& value); |
167 }; | 175 }; |
168 | 176 |
169 } | 177 } |
170 | 178 |
171 #endif // Dictionary_h | 179 #endif // Dictionary_h |
OLD | NEW |