Chromium Code Reviews| Index: Source/platform/TracedValue.h |
| diff --git a/Source/platform/TracedValue.h b/Source/platform/TracedValue.h |
| index 7f751054ea92aa7eb122d661a48432df1af53eb5..b80f0337e4ad85a3e268d715785babbe381339a5 100644 |
| --- a/Source/platform/TracedValue.h |
| +++ b/Source/platform/TracedValue.h |
| @@ -14,6 +14,7 @@ namespace WebCore { |
| class JSONArray; |
| class JSONObject; |
| class JSONValue; |
| +class TracedArrayBase; |
| template<class T> class TracedArray; |
| class PLATFORM_EXPORT TracedValueBase { |
| @@ -44,45 +45,88 @@ protected: |
| Vector<RefPtr<JSONValue> > m_stack; |
| }; |
| +class TracedDictionaryBase : public TracedValueBase { |
| + WTF_MAKE_NONCOPYABLE(TracedDictionaryBase); |
| +public: |
| + void endDictionary() |
| + { |
| + endCurrentDictionary(); |
| + } |
| + |
| + TracedDictionaryBase& beginDictionary(const char* name) |
| + { |
| + beginDictionaryNamed(name); |
| + return *this; |
| + } |
| + TracedArrayBase& beginArray(const char* name) |
| + { |
| + beginArrayNamed(name); |
| + return *reinterpret_cast<TracedArrayBase*>(this); |
| + } |
| + TracedDictionaryBase& setInteger(const char* name, int value) |
| + { |
| + TracedValueBase::setInteger(name, value); |
| + return *this; |
| + } |
| + TracedDictionaryBase& setDouble(const char* name, double value) |
| + { |
| + TracedValueBase::setDouble(name, value); |
| + return *this; |
| + } |
| + TracedDictionaryBase& setBoolean(const char* name, bool value) |
| + { |
| + TracedValueBase::setBoolean(name, value); |
| + return *this; |
| + } |
| + TracedDictionaryBase& setString(const char* name, const String& value) |
| + { |
| + TracedValueBase::setString(name, value); |
| + return *this; |
| + } |
| +private: |
| + TracedDictionaryBase(); |
| + ~TracedDictionaryBase(); |
| +}; |
| + |
| template <class OwnerType> |
| -class TracedDictionary : public TracedValueBase { |
| +class TracedDictionary : public TracedDictionaryBase { |
| WTF_MAKE_NONCOPYABLE(TracedDictionary); |
| public: |
| OwnerType& endDictionary() |
| { |
| ASSERT(m_stack.size() == nestingLevel); |
| - endCurrentDictionary(); |
| + TracedDictionaryBase::endDictionary(); |
| return *reinterpret_cast<OwnerType*>(this); |
| } |
| TracedDictionary<TracedDictionary<OwnerType> >& beginDictionary(const char* name) |
| { |
| - beginDictionaryNamed(name); |
| + TracedDictionaryBase::beginDictionary(name); |
| return *reinterpret_cast<TracedDictionary<TracedDictionary<OwnerType> >* >(this); |
| } |
| TracedArray<TracedDictionary<OwnerType> >& beginArray(const char* name) |
| { |
| - beginArrayNamed(name); |
| + TracedDictionaryBase::beginArray(name); |
| return *reinterpret_cast<TracedArray<TracedDictionary<OwnerType> >* >(this); |
| } |
| TracedDictionary<OwnerType>& setInteger(const char* name, int value) |
| { |
| - TracedValueBase::setInteger(name, value); |
| + TracedDictionaryBase::setInteger(name, value); |
| return *this; |
| } |
| TracedDictionary<OwnerType>& setDouble(const char* name, double value) |
| { |
| - TracedValueBase::setDouble(name, value); |
| + TracedDictionaryBase::setDouble(name, value); |
| return *this; |
| } |
| TracedDictionary<OwnerType>& setBoolean(const char* name, bool value) |
| { |
| - TracedValueBase::setBoolean(name, value); |
| + TracedDictionaryBase::setBoolean(name, value); |
| return *this; |
| } |
| TracedDictionary<OwnerType>& setString(const char* name, const String& value) |
| { |
| - TracedValueBase::setString(name, value); |
| + TracedDictionaryBase::setString(name, value); |
| return *this; |
| } |
| @@ -93,45 +137,89 @@ private: |
| ~TracedDictionary(); |
| }; |
| +class TracedArrayBase : public TracedValueBase { |
| + WTF_MAKE_NONCOPYABLE(TracedArrayBase); |
| +public: |
| + TracedDictionaryBase& beginDictionary() |
|
alph
2014/07/10 14:45:22
You could return TracedDictionary<TracedArrayBase>
yurys
2014/07/10 15:14:07
Sounds good to me too. It would help to resolve th
|
| + { |
| + pushDictionary(); |
| + return *reinterpret_cast<TracedDictionaryBase*>(this); |
| + } |
| + TracedArrayBase& beginArray() |
| + { |
| + pushArray(); |
| + return *this; |
| + } |
| + void endArray() |
| + { |
| + endCurrentArray(); |
| + } |
| + |
| + TracedArrayBase& pushInteger(int value) |
| + { |
| + TracedValueBase::pushInteger(value); |
| + return *this; |
| + } |
| + TracedArrayBase& pushDouble(double value) |
| + { |
| + TracedValueBase::pushDouble(value); |
| + return *this; |
| + } |
| + TracedArrayBase& pushBoolean(bool value) |
| + { |
| + TracedValueBase::pushBoolean(value); |
| + return *this; |
| + } |
| + TracedArrayBase& pushString(const String& value) |
| + { |
| + TracedValueBase::pushString(value); |
| + return *this; |
| + } |
| + |
| +private: |
| + TracedArrayBase(); |
| + ~TracedArrayBase(); |
| +}; |
| + |
| template <class OwnerType> |
| -class TracedArray : public TracedValueBase { |
| +class TracedArray : public TracedArrayBase { |
| WTF_MAKE_NONCOPYABLE(TracedArray); |
| public: |
| TracedDictionary<TracedArray<OwnerType> >& beginDictionary() |
| { |
| - pushDictionary(); |
| + TracedArrayBase::beginDictionary(); |
| return *reinterpret_cast<TracedDictionary<TracedArray<OwnerType> >* >(this); |
| } |
| - TracedDictionary<TracedArray<OwnerType> >& beginArray() |
| + TracedArray<TracedArray<OwnerType> >& beginArray() |
| { |
| - pushArray(); |
| - return *reinterpret_cast<TracedDictionary<TracedArray<OwnerType> >* >(this); |
| + TracedArrayBase::beginArray(); |
| + return *reinterpret_cast<TracedArray<TracedArray<OwnerType> >* >(this); |
| } |
| OwnerType& endArray() |
| { |
| ASSERT(m_stack.size() == nestingLevel); |
| - endCurrentArray(); |
| + TracedArrayBase::endArray(); |
| return *reinterpret_cast<OwnerType*>(this); |
| } |
| TracedArray<OwnerType>& pushInteger(int value) |
| { |
| - TracedValueBase::pushInteger(value); |
| + TracedArrayBase::pushInteger(value); |
| return *this; |
| } |
| TracedArray<OwnerType>& pushDouble(double value) |
| { |
| - TracedValueBase::pushDouble(value); |
| + TracedArrayBase::pushDouble(value); |
| return *this; |
| } |
| TracedArray<OwnerType>& pushBoolean(bool value) |
| { |
| - TracedValueBase::pushBoolean(value); |
| + TracedArrayBase::pushBoolean(value); |
| return *this; |
| } |
| TracedArray<OwnerType>& pushString(const String& value) |
| { |
| - TracedValueBase::pushString(value); |
| + TracedArrayBase::pushString(value); |
| return *this; |
| } |