diff options
Diffstat (limited to 'include/lldb/DataFormatters/TypeFormat.h')
-rw-r--r-- | include/lldb/DataFormatters/TypeFormat.h | 129 |
1 files changed, 110 insertions, 19 deletions
diff --git a/include/lldb/DataFormatters/TypeFormat.h b/include/lldb/DataFormatters/TypeFormat.h index 77135c448ed1..20fa8f2d4e7f 100644 --- a/include/lldb/DataFormatters/TypeFormat.h +++ b/include/lldb/DataFormatters/TypeFormat.h @@ -130,15 +130,12 @@ namespace lldb_private { uint32_t m_flags; }; - TypeFormatImpl (lldb::Format f = lldb::eFormatInvalid, - const Flags& flags = Flags()); + TypeFormatImpl (const Flags& flags = Flags()); typedef std::shared_ptr<TypeFormatImpl> SharedPointer; typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&); - ~TypeFormatImpl () - { - } + virtual ~TypeFormatImpl () = default; bool Cascades () const @@ -173,6 +170,66 @@ namespace lldb_private { { m_flags.SetSkipReferences(value); } + + uint32_t + GetOptions () + { + return m_flags.GetValue(); + } + + void + SetOptions (uint32_t value) + { + m_flags.SetValue(value); + } + + uint32_t& + GetRevision () + { + return m_my_revision; + } + + enum class Type + { + eTypeUnknown, + eTypeFormat, + eTypeEnum + }; + + virtual Type + GetType () + { + return Type::eTypeUnknown; + } + + // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for + // extended periods of time and we trust the ValueObject to stay around for as long as it is required + // for us to generate its value + virtual bool + FormatObject (ValueObject *valobj, + std::string& dest) const = 0; + + virtual std::string + GetDescription() = 0; + + protected: + Flags m_flags; + uint32_t m_my_revision; + + private: + DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl); + }; + + class TypeFormatImpl_Format : public TypeFormatImpl + { + public: + TypeFormatImpl_Format (lldb::Format f = lldb::eFormatInvalid, + const TypeFormatImpl::Flags& flags = Flags()); + + typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer; + typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_Format::SharedPointer&); + + virtual ~TypeFormatImpl_Format () = default; lldb::Format GetFormat () const @@ -186,35 +243,69 @@ namespace lldb_private { m_format = fmt; } - uint32_t - GetOptions () + virtual TypeFormatImpl::Type + GetType () { - return m_flags.GetValue(); + return TypeFormatImpl::Type::eTypeFormat; + } + + virtual bool + FormatObject (ValueObject *valobj, + std::string& dest) const; + + virtual std::string + GetDescription(); + + protected: + lldb::Format m_format; + + private: + DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_Format); + }; + + class TypeFormatImpl_EnumType : public TypeFormatImpl + { + public: + TypeFormatImpl_EnumType (ConstString type_name = ConstString(""), + const TypeFormatImpl::Flags& flags = Flags()); + + typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer; + typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_EnumType::SharedPointer&); + + ~TypeFormatImpl_EnumType () = default; + + ConstString + GetTypeName () + { + return m_enum_type; } void - SetOptions (uint32_t value) + SetTypeName (ConstString enum_type) { - m_flags.SetValue(value); + m_enum_type = enum_type; } - uint32_t& - GetRevision () + virtual TypeFormatImpl::Type + GetType () { - return m_my_revision; + return TypeFormatImpl::Type::eTypeEnum; } - std::string + virtual bool + FormatObject (ValueObject *valobj, + std::string& dest) const; + + virtual std::string GetDescription(); protected: - Flags m_flags; - lldb::Format m_format; - uint32_t m_my_revision; + ConstString m_enum_type; + mutable std::map<void*,ClangASTType> m_types; private: - DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl); - }; + DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType); + }; } // namespace lldb_private #endif // lldb_TypeFormat_h_ |