| 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 26 matching lines...) Expand all Loading... |
| 37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
| 38 #include "wtf/text/AtomicString.h" | 38 #include "wtf/text/AtomicString.h" |
| 39 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
| 40 #include <v8.h> | 40 #include <v8.h> |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 // Dictionary class provides ways to retrieve property values as C++ objects | 44 // Dictionary class provides ways to retrieve property values as C++ objects |
| 45 // from a V8 object. Instances of this class must not outlive V8's handle scope | 45 // from a V8 object. Instances of this class must not outlive V8's handle scope |
| 46 // because they hold a V8 value without putting it on persistent handles. | 46 // because they hold a V8 value without putting it on persistent handles. |
| 47 class Dictionary { | 47 class Dictionary final { |
| 48 ALLOW_ONLY_INLINE_ALLOCATION(); | 48 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 49 public: | 49 public: |
| 50 Dictionary(); | 50 Dictionary(); |
| 51 Dictionary(const v8::Handle<v8::Value>& options, v8::Isolate*, ExceptionStat
e&); | 51 Dictionary(const v8::Handle<v8::Value>& options, v8::Isolate*, ExceptionStat
e&); |
| 52 ~Dictionary(); | 52 ~Dictionary(); |
| 53 | 53 |
| 54 Dictionary& operator=(const Dictionary&); | 54 Dictionary& operator=(const Dictionary&); |
| 55 | 55 |
| 56 // This is different from the default constructor: | 56 // This is different from the default constructor: |
| 57 // * isObject() is true when using createEmpty(). | 57 // * isObject() is true when using createEmpty(). |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 bool convert(ConversionContext&, const String&, Dictionary&) const; | 115 bool convert(ConversionContext&, const String&, Dictionary&) const; |
| 116 | 116 |
| 117 bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const; | 117 bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const; |
| 118 bool getPropertyNames(Vector<String>&) const; | 118 bool getPropertyNames(Vector<String>&) const; |
| 119 | 119 |
| 120 bool hasProperty(const String&) const; | 120 bool hasProperty(const String&) const; |
| 121 | 121 |
| 122 v8::Isolate* isolate() const { return m_isolate; } | 122 v8::Isolate* isolate() const { return m_isolate; } |
| 123 // Used by DictionaryHelper. This context could be an empty handle and |
| 124 // should be used only for V8 APIs which return MaybeLocal<T>. |
| 125 v8::Local<v8::Context> context() const; |
| 123 | 126 |
| 124 bool getKey(const String& key, v8::Local<v8::Value>&) const; | 127 bool getKey(const String& key, v8::Local<v8::Value>&) const; |
| 125 | 128 |
| 126 private: | 129 private: |
| 127 v8::Handle<v8::Value> m_options; | 130 v8::Handle<v8::Value> m_options; |
| 128 v8::Isolate* m_isolate; | 131 v8::Isolate* m_isolate; |
| 129 ExceptionState* m_exceptionState; | 132 ExceptionState* m_exceptionState; |
| 130 }; | 133 }; |
| 131 | 134 |
| 132 template<> | 135 template<> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 160 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, T& value); | 163 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, T& value); |
| 161 template <typename T> | 164 template <typename T> |
| 162 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, Nullable<T>& value); | 165 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, Nullable<T>& value); |
| 163 template <template <typename> class PointerType, typename T> | 166 template <template <typename> class PointerType, typename T> |
| 164 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, PointerType<T>& value); | 167 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, PointerType<T>& value); |
| 165 }; | 168 }; |
| 166 | 169 |
| 167 } | 170 } |
| 168 | 171 |
| 169 #endif // Dictionary_h | 172 #endif // Dictionary_h |
| OLD | NEW |