| 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 27 matching lines...) Expand all Loading... |
| 38 #include "wtf/Vector.h" | 38 #include "wtf/Vector.h" |
| 39 #include "wtf/text/AtomicString.h" | 39 #include "wtf/text/AtomicString.h" |
| 40 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 41 #include <v8.h> | 41 #include <v8.h> |
| 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 { | 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::Handle<v8::Value>& options, v8::Isolate*, ExceptionStat
e&); |
| 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; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 bool convert(ConversionContext&, const String&, Dictionary&) const; | 105 bool convert(ConversionContext&, const String&, Dictionary&) const; |
| 106 | 106 |
| 107 bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const; | 107 bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const; |
| 108 bool getPropertyNames(Vector<String>&) const; | 108 bool getPropertyNames(Vector<String>&) const; |
| 109 | 109 |
| 110 bool hasProperty(const String&) const; | 110 bool hasProperty(const String&) const; |
| 111 | 111 |
| 112 v8::Isolate* isolate() const { return m_isolate; } | 112 v8::Isolate* isolate() const { return m_isolate; } |
| 113 | |
| 114 bool getKey(const String& key, v8::Local<v8::Value>&) const; | |
| 115 | |
| 116 private: | |
| 117 v8::Local<v8::Context> v8Context() const | 113 v8::Local<v8::Context> v8Context() const |
| 118 { | 114 { |
| 119 ASSERT(m_isolate); | 115 ASSERT(m_isolate); |
| 120 return m_isolate->GetCurrentContext(); | 116 return m_isolate->GetCurrentContext(); |
| 121 } | 117 } |
| 122 | 118 |
| 119 bool getKey(const String& key, v8::Local<v8::Value>&) const; |
| 120 |
| 121 private: |
| 122 bool toObject(v8::Local<v8::Object>&) const; |
| 123 |
| 123 v8::Handle<v8::Value> m_options; | 124 v8::Handle<v8::Value> m_options; |
| 124 v8::Isolate* m_isolate; | 125 v8::Isolate* m_isolate; |
| 125 ExceptionState* m_exceptionState; | 126 ExceptionState* m_exceptionState; |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 template<> | 129 template<> |
| 129 struct NativeValueTraits<Dictionary> { | 130 struct NativeValueTraits<Dictionary> { |
| 130 static inline Dictionary nativeValue(v8::Isolate* isolate, v8::Handle<v8::Va
lue> value, ExceptionState& exceptionState) | 131 static inline Dictionary nativeValue(v8::Isolate* isolate, v8::Handle<v8::Va
lue> value, ExceptionState& exceptionState) |
| 131 { | 132 { |
| 132 return Dictionary(value, isolate, exceptionState); | 133 return Dictionary(value, isolate, exceptionState); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 156 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); |
| 157 template <typename T> | 158 template <typename T> |
| 158 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); |
| 159 template <template <typename> class PointerType, typename T> | 160 template <template <typename> class PointerType, typename T> |
| 160 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); |
| 161 }; | 162 }; |
| 162 | 163 |
| 163 } | 164 } |
| 164 | 165 |
| 165 #endif // Dictionary_h | 166 #endif // Dictionary_h |
| OLD | NEW |