| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::Local<v8::Value> v8Value() const { return m_options; } | 63 v8::Local<v8::Value> v8Value() const { return m_options; } |
| 64 | 64 |
| 65 class CORE_EXPORT ConversionContext { | |
| 66 public: | |
| 67 explicit ConversionContext(ExceptionState& exceptionState) | |
| 68 : m_exceptionState(exceptionState) | |
| 69 , m_dirty(true) | |
| 70 { | |
| 71 resetPerPropertyContext(); | |
| 72 } | |
| 73 | |
| 74 ExceptionState& exceptionState() const { return m_exceptionState; } | |
| 75 | |
| 76 bool isNullable() const { return m_isNullable; } | |
| 77 String typeName() const { return m_propertyTypeName; } | |
| 78 | |
| 79 ConversionContext& setConversionType(const String&, bool); | |
| 80 | |
| 81 void throwTypeError(const String& detail); | |
| 82 | |
| 83 void resetPerPropertyContext(); | |
| 84 | |
| 85 private: | |
| 86 ExceptionState& m_exceptionState; | |
| 87 bool m_dirty; | |
| 88 | |
| 89 bool m_isNullable; | |
| 90 String m_propertyTypeName; | |
| 91 }; | |
| 92 | |
| 93 class ConversionContextScope { | |
| 94 public: | |
| 95 explicit ConversionContextScope(ConversionContext& context) | |
| 96 : m_context(context) { } | |
| 97 ~ConversionContextScope() | |
| 98 { | |
| 99 m_context.resetPerPropertyContext(); | |
| 100 } | |
| 101 private: | |
| 102 ConversionContext& m_context; | |
| 103 }; | |
| 104 | |
| 105 // Note that this function returns true when there is no value associated | |
| 106 // with a given key. | |
| 107 bool convert(ConversionContext&, const String&, Dictionary&) const; | |
| 108 | |
| 109 bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const; | 65 bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const; |
| 110 bool getPropertyNames(Vector<String>&) const; | 66 bool getPropertyNames(Vector<String>&) const; |
| 111 | 67 |
| 112 bool hasProperty(const String&) const; | 68 bool hasProperty(const String&) const; |
| 113 | 69 |
| 114 v8::Isolate* isolate() const { return m_isolate; } | 70 v8::Isolate* isolate() const { return m_isolate; } |
| 115 v8::Local<v8::Context> v8Context() const | 71 v8::Local<v8::Context> v8Context() const |
| 116 { | 72 { |
| 117 ASSERT(m_isolate); | 73 ASSERT(m_isolate); |
| 118 return m_isolate->GetCurrentContext(); | 74 return m_isolate->GetCurrentContext(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 148 template <typename T> | 104 template <typename T> |
| 149 static bool getWithUndefinedOrNullCheck(const Dictionary& dictionary, const
String& key, T& value) | 105 static bool getWithUndefinedOrNullCheck(const Dictionary& dictionary, const
String& key, T& value) |
| 150 { | 106 { |
| 151 v8::Local<v8::Value> v8Value; | 107 v8::Local<v8::Value> v8Value; |
| 152 if (!dictionary.getKey(key, v8Value) || isUndefinedOrNull(v8Value)) | 108 if (!dictionary.getKey(key, v8Value) || isUndefinedOrNull(v8Value)) |
| 153 return false; | 109 return false; |
| 154 return DictionaryHelper::get(dictionary, key, value); | 110 return DictionaryHelper::get(dictionary, key, value); |
| 155 } | 111 } |
| 156 template <template <typename> class PointerType, typename T> | 112 template <template <typename> class PointerType, typename T> |
| 157 static bool get(const Dictionary&, const String& key, PointerType<T>& value)
; | 113 static bool get(const Dictionary&, const String& key, PointerType<T>& value)
; |
| 158 template <typename T> | |
| 159 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, T& value); | |
| 160 template <typename T> | |
| 161 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, Nullable<T>& value); | |
| 162 template <template <typename> class PointerType, typename T> | |
| 163 static bool convert(const Dictionary&, Dictionary::ConversionContext&, const
String& key, PointerType<T>& value); | |
| 164 }; | 114 }; |
| 165 | 115 |
| 166 } | 116 } |
| 167 | 117 |
| 168 #endif // Dictionary_h | 118 #endif // Dictionary_h |
| OLD | NEW |