| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 m_exceptionState->onStackObjectChecker().remove(this); | 86 m_exceptionState->onStackObjectChecker().remove(this); |
| 87 #endif | 87 #endif |
| 88 m_exceptionState = optionsObject.m_exceptionState; | 88 m_exceptionState = optionsObject.m_exceptionState; |
| 89 #if ENABLE(ASSERT) | 89 #if ENABLE(ASSERT) |
| 90 if (m_exceptionState) | 90 if (m_exceptionState) |
| 91 m_exceptionState->onStackObjectChecker().add(this); | 91 m_exceptionState->onStackObjectChecker().add(this); |
| 92 #endif | 92 #endif |
| 93 return *this; | 93 return *this; |
| 94 } | 94 } |
| 95 | 95 |
| 96 Dictionary Dictionary::createEmpty(v8::Isolate* isolate) | |
| 97 { | |
| 98 return Dictionary(v8::Object::New(isolate), isolate, emptyExceptionState()); | |
| 99 } | |
| 100 | |
| 101 bool Dictionary::isObject() const | 96 bool Dictionary::isObject() const |
| 102 { | 97 { |
| 103 return !isUndefinedOrNull() && m_options->IsObject(); | 98 return !isUndefinedOrNull() && m_options->IsObject(); |
| 104 } | 99 } |
| 105 | 100 |
| 106 bool Dictionary::isUndefinedOrNull() const | 101 bool Dictionary::isUndefinedOrNull() const |
| 107 { | 102 { |
| 108 if (m_options.IsEmpty()) | 103 if (m_options.IsEmpty()) |
| 109 return true; | 104 return true; |
| 110 return blink::isUndefinedOrNull(m_options); | 105 return blink::isUndefinedOrNull(m_options); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 149 |
| 155 if (v8Value->IsObject()) { | 150 if (v8Value->IsObject()) { |
| 156 ASSERT(m_isolate); | 151 ASSERT(m_isolate); |
| 157 ASSERT(m_isolate == v8::Isolate::GetCurrent()); | 152 ASSERT(m_isolate == v8::Isolate::GetCurrent()); |
| 158 value = Dictionary(v8Value, m_isolate, *m_exceptionState); | 153 value = Dictionary(v8Value, m_isolate, *m_exceptionState); |
| 159 } | 154 } |
| 160 | 155 |
| 161 return true; | 156 return true; |
| 162 } | 157 } |
| 163 | 158 |
| 164 bool Dictionary::set(const String& key, const v8::Handle<v8::Value>& value) | |
| 165 { | |
| 166 if (isUndefinedOrNull()) | |
| 167 return false; | |
| 168 v8::Local<v8::Object> options = m_options->ToObject(m_isolate); | |
| 169 ASSERT(!options.IsEmpty()); | |
| 170 ASSERT(m_exceptionState); | |
| 171 | |
| 172 return options->Set(v8String(m_isolate, key), value); | |
| 173 } | |
| 174 | |
| 175 bool Dictionary::set(const String& key, const String& value) | |
| 176 { | |
| 177 return set(key, v8String(m_isolate, value)); | |
| 178 } | |
| 179 | |
| 180 bool Dictionary::set(const String& key, unsigned value) | |
| 181 { | |
| 182 return set(key, v8::Integer::NewFromUnsigned(m_isolate, value)); | |
| 183 } | |
| 184 | |
| 185 bool Dictionary::set(const String& key, const Dictionary& value) | |
| 186 { | |
| 187 return set(key, value.v8Value()); | |
| 188 } | |
| 189 | |
| 190 bool Dictionary::convert(ConversionContext& context, const String& key, Dictiona
ry& value) const | 159 bool Dictionary::convert(ConversionContext& context, const String& key, Dictiona
ry& value) const |
| 191 { | 160 { |
| 192 ConversionContextScope scope(context); | 161 ConversionContextScope scope(context); |
| 193 | 162 |
| 194 v8::Local<v8::Value> v8Value; | 163 v8::Local<v8::Value> v8Value; |
| 195 if (!getKey(key, v8Value)) | 164 if (!getKey(key, v8Value)) |
| 196 return true; | 165 return true; |
| 197 | 166 |
| 198 if (v8Value->IsObject()) | 167 if (v8Value->IsObject()) |
| 199 return get(key, value); | 168 return get(key, value); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 242 |
| 274 return *this; | 243 return *this; |
| 275 } | 244 } |
| 276 | 245 |
| 277 void Dictionary::ConversionContext::throwTypeError(const String& detail) | 246 void Dictionary::ConversionContext::throwTypeError(const String& detail) |
| 278 { | 247 { |
| 279 exceptionState().throwTypeError(detail); | 248 exceptionState().throwTypeError(detail); |
| 280 } | 249 } |
| 281 | 250 |
| 282 } // namespace blink | 251 } // namespace blink |
| OLD | NEW |