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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 // Dictionary class provides ways to retrieve property values as C++ objects | 45 // Dictionary class provides ways to retrieve property values as C++ objects |
46 // from a V8 object. Instances of this class must not outlive V8's handle scope | 46 // from a V8 object. Instances of this class must not outlive V8's handle scope |
47 // because they hold a V8 value without putting it on persistent handles. | 47 // because they hold a V8 value without putting it on persistent handles. |
48 class CORE_EXPORT Dictionary final { | 48 class CORE_EXPORT Dictionary final { |
49 ALLOW_ONLY_INLINE_ALLOCATION(); | 49 ALLOW_ONLY_INLINE_ALLOCATION(); |
50 public: | 50 public: |
51 Dictionary(); | 51 Dictionary(); |
52 Dictionary(const v8::Handle<v8::Value>& options, v8::Isolate*, ExceptionStat
e&); | 52 Dictionary(const v8::Local<v8::Value>& options, v8::Isolate*, ExceptionState
&); |
53 ~Dictionary(); | 53 ~Dictionary(); |
54 | 54 |
55 Dictionary& operator=(const Dictionary&); | 55 Dictionary& operator=(const Dictionary&); |
56 | 56 |
57 bool isObject() const; | 57 bool isObject() const; |
58 bool isUndefinedOrNull() const; | 58 bool isUndefinedOrNull() const; |
59 | 59 |
60 bool get(const String&, Dictionary&) const; | 60 bool get(const String&, Dictionary&) const; |
61 bool get(const String&, v8::Local<v8::Value>&) const; | 61 bool get(const String&, v8::Local<v8::Value>&) const; |
62 | 62 |
63 v8::Handle<v8::Value> v8Value() const { return m_options; } | 63 v8::Local<v8::Value> v8Value() const { return m_options; } |
64 | 64 |
65 class CORE_EXPORT ConversionContext { | 65 class CORE_EXPORT ConversionContext { |
66 public: | 66 public: |
67 explicit ConversionContext(ExceptionState& exceptionState) | 67 explicit ConversionContext(ExceptionState& exceptionState) |
68 : m_exceptionState(exceptionState) | 68 : m_exceptionState(exceptionState) |
69 , m_dirty(true) | 69 , m_dirty(true) |
70 { | 70 { |
71 resetPerPropertyContext(); | 71 resetPerPropertyContext(); |
72 } | 72 } |
73 | 73 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 { | 114 { |
115 ASSERT(m_isolate); | 115 ASSERT(m_isolate); |
116 return m_isolate->GetCurrentContext(); | 116 return m_isolate->GetCurrentContext(); |
117 } | 117 } |
118 | 118 |
119 bool getKey(const String& key, v8::Local<v8::Value>&) const; | 119 bool getKey(const String& key, v8::Local<v8::Value>&) const; |
120 | 120 |
121 private: | 121 private: |
122 bool toObject(v8::Local<v8::Object>&) const; | 122 bool toObject(v8::Local<v8::Object>&) const; |
123 | 123 |
124 v8::Handle<v8::Value> m_options; | 124 v8::Local<v8::Value> m_options; |
125 v8::Isolate* m_isolate; | 125 v8::Isolate* m_isolate; |
126 ExceptionState* m_exceptionState; | 126 ExceptionState* m_exceptionState; |
127 }; | 127 }; |
128 | 128 |
129 template<> | 129 template<> |
130 struct NativeValueTraits<Dictionary> { | 130 struct NativeValueTraits<Dictionary> { |
131 static inline Dictionary nativeValue(v8::Isolate* isolate, v8::Handle<v8::Va
lue> value, ExceptionState& exceptionState) | 131 static inline Dictionary nativeValue(v8::Isolate* isolate, v8::Local<v8::Val
ue> value, ExceptionState& exceptionState) |
132 { | 132 { |
133 return Dictionary(value, isolate, exceptionState); | 133 return Dictionary(value, isolate, exceptionState); |
134 } | 134 } |
135 }; | 135 }; |
136 | 136 |
137 // DictionaryHelper is a collection of static methods for getting or | 137 // DictionaryHelper is a collection of static methods for getting or |
138 // converting a value from Dictionary. | 138 // converting a value from Dictionary. |
139 struct DictionaryHelper { | 139 struct DictionaryHelper { |
140 template <typename T> | 140 template <typename T> |
141 static bool get(const Dictionary&, const String& key, T& value); | 141 static bool get(const Dictionary&, const String& key, T& value); |
(...skipping 15 matching lines...) Expand all Loading... |
157 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, T& value); | 157 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, T& value); |
158 template <typename T> | 158 template <typename T> |
159 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, Nullable<T>& value); | 159 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, Nullable<T>& value); |
160 template <template <typename> class PointerType, typename T> | 160 template <template <typename> class PointerType, typename T> |
161 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, PointerType<T>& value); | 161 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, PointerType<T>& value); |
162 }; | 162 }; |
163 | 163 |
164 } | 164 } |
165 | 165 |
166 #endif // Dictionary_h | 166 #endif // Dictionary_h |
OLD | NEW |