1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef DictionaryTest_h 6#define DictionaryTest_h 7 8#include "bindings/core/v8/Nullable.h" 9#include "bindings/core/v8/ScriptValue.h" 10#include "bindings/core/v8/ScriptWrappable.h" 11#include "core/dom/Element.h" 12#include "platform/heap/Handle.h" 13#include "wtf/text/WTFString.h" 14 15namespace blink { 16 17class InternalDictionary; 18 19class DictionaryTest : public GarbageCollectedFinalized<DictionaryTest>, public ScriptWrappable { 20 DEFINE_WRAPPERTYPEINFO(); 21public: 22 static DictionaryTest* create() 23 { 24 return new DictionaryTest(); 25 } 26 virtual ~DictionaryTest(); 27 28 // Stores all members into corresponding fields 29 void set(const InternalDictionary&); 30 // Creates a TestDictionary instnace from fields and returns it 31 InternalDictionary* get(); 32 33 void trace(Visitor*); 34 35private: 36 DictionaryTest(); 37 38 void reset(); 39 40 // The reason to use Nullable<T> is convenience; we use Nullable<T> here to 41 // record whether the member field is set or not. Some members are not 42 // wrapped with Nullable because: 43 // - |longMemberWithDefault| has a non-null default value 44 // - String and PtrTypes can express whether they are null 45 Nullable<int> m_longMember; 46 int m_longMemberWithDefault; 47 Nullable<int> m_longOrNullMember; 48 Nullable<int> m_longOrNullMemberWithDefault; 49 Nullable<bool> m_booleanMember; 50 Nullable<double> m_doubleMember; 51 String m_stringMember; 52 String m_stringMemberWithDefault; 53 Nullable<Vector<String> > m_stringSequenceMember; 54 Nullable<Vector<String> > m_stringSequenceOrNullMember; 55 String m_enumMember; 56 String m_enumMemberWithDefault; 57 String m_enumOrNullMember; 58 RefPtrWillBeMember<Element> m_elementMember; 59 RefPtrWillBeMember<Element> m_elementOrNullMember; 60 ScriptValue m_objectMember; 61 ScriptValue m_objectOrNullMemberWithDefault; 62}; 63 64} // namespace blink 65 66#endif // DictionaryTest_h 67