Author: enrico Date: Wed Aug 26 19:45:33 2015 New Revision: 246130 URL: http://llvm.org/viewvc/llvm-project?rev=246130&view=rev Log: Switch data formatters over to using std::function for their callbacks instead of raw function pointers. NFC
Modified: lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h lldb/trunk/include/lldb/DataFormatters/TypeFormat.h lldb/trunk/include/lldb/DataFormatters/TypeSummary.h lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h lldb/trunk/include/lldb/DataFormatters/TypeValidator.h lldb/trunk/source/API/SBTypeSummary.cpp lldb/trunk/source/DataFormatters/TypeSummary.cpp lldb/trunk/source/DataFormatters/TypeSynthetic.cpp Modified: lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h?rev=246130&r1=246129&r2=246130&view=diff ============================================================================== --- lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h (original) +++ lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h Wed Aug 26 19:45:33 2015 @@ -12,6 +12,7 @@ // C Includes // C++ Includes +#include <functional> // Other libraries and framework includes #include "clang/AST/DeclCXX.h" @@ -92,7 +93,7 @@ public: typedef typename ValueType::SharedPointer ValueSP; typedef std::map<KeyType, ValueSP> MapType; typedef typename MapType::iterator MapIterator; - typedef bool(*CallbackType)(void*, KeyType, const ValueSP&); + typedef std::function<bool(void*, KeyType, const ValueSP&)> CallbackType; FormatMap(IFormatChangeListener* lst) : m_map(), Modified: lldb/trunk/include/lldb/DataFormatters/TypeFormat.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeFormat.h?rev=246130&r1=246129&r2=246130&view=diff ============================================================================== --- lldb/trunk/include/lldb/DataFormatters/TypeFormat.h (original) +++ lldb/trunk/include/lldb/DataFormatters/TypeFormat.h Wed Aug 26 19:45:33 2015 @@ -13,6 +13,7 @@ // C Includes // C++ Includes +#include <functional> #include <string> #include <unordered_map> @@ -150,7 +151,7 @@ namespace lldb_private { TypeFormatImpl (const Flags& flags = Flags()); typedef std::shared_ptr<TypeFormatImpl> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&); + typedef std::function<bool(void*, ConstString, lldb::TypeFormatImplSP)> ValueCallback; virtual ~TypeFormatImpl (); @@ -258,7 +259,7 @@ namespace lldb_private { const TypeFormatImpl::Flags& flags = Flags()); typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_Format::SharedPointer&); + typedef std::function<bool(void*, ConstString, TypeFormatImpl_Format::SharedPointer)> ValueCallback; ~TypeFormatImpl_Format() override; @@ -301,7 +302,7 @@ namespace lldb_private { const TypeFormatImpl::Flags& flags = Flags()); typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_EnumType::SharedPointer&); + typedef std::function<bool(void*, ConstString, TypeFormatImpl_EnumType::SharedPointer)> ValueCallback; ~TypeFormatImpl_EnumType() override; Modified: lldb/trunk/include/lldb/DataFormatters/TypeSummary.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSummary.h?rev=246130&r1=246129&r2=246130&view=diff ============================================================================== --- lldb/trunk/include/lldb/DataFormatters/TypeSummary.h (original) +++ lldb/trunk/include/lldb/DataFormatters/TypeSummary.h Wed Aug 26 19:45:33 2015 @@ -14,6 +14,7 @@ #include <stdint.h> // C++ Includes +#include <functional> #include <string> #include <vector> @@ -409,8 +410,8 @@ namespace lldb_private { } typedef std::shared_ptr<TypeSummaryImpl> SharedPointer; - typedef bool(*SummaryCallback)(void*, ConstString, const lldb::TypeSummaryImplSP&); - typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::TypeSummaryImplSP&); + typedef std::function<bool(void*, ConstString, TypeSummaryImpl::SharedPointer)> SummaryCallback; + typedef std::function<bool(void*, lldb::RegularExpressionSP, TypeSummaryImpl::SharedPointer)> RegexSummaryCallback; protected: uint32_t m_my_revision; @@ -472,9 +473,9 @@ namespace lldb_private { { // we should convert these to SBValue and SBStream if we ever cross // the boundary towards the external world - typedef bool (*Callback)(ValueObject&, - Stream&, - const TypeSummaryOptions&); + typedef std::function<bool(ValueObject&, + Stream&, + const TypeSummaryOptions&)> Callback; Callback m_impl; std::string m_description; Modified: lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h?rev=246130&r1=246129&r2=246130&view=diff ============================================================================== --- lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h (original) +++ lldb/trunk/include/lldb/DataFormatters/TypeSynthetic.h Wed Aug 26 19:45:33 2015 @@ -14,6 +14,7 @@ #include <stdint.h> // C++ Includes +#include <functional> #include <string> #include <vector> @@ -344,7 +345,7 @@ namespace lldb_private { GetFrontEnd (ValueObject &backend) = 0; typedef std::shared_ptr<SyntheticChildren> SharedPointer; - typedef bool(*SyntheticChildrenCallback)(void*, ConstString, const SyntheticChildren::SharedPointer&); + typedef std::function<bool(void*, ConstString, SyntheticChildren::SharedPointer)> SyntheticChildrenCallback; uint32_t& GetRevision () @@ -485,11 +486,7 @@ namespace lldb_private { class CXXSyntheticChildren : public SyntheticChildren { public: - typedef SyntheticChildrenFrontEnd* (*CreateFrontEndCallback) (CXXSyntheticChildren*, lldb::ValueObjectSP); - protected: - CreateFrontEndCallback m_create_callback; - std::string m_description; - public: + typedef std::function<SyntheticChildrenFrontEnd*(CXXSyntheticChildren*, lldb::ValueObjectSP)> CreateFrontEndCallback; CXXSyntheticChildren (const SyntheticChildren::Flags& flags, const char* description, CreateFrontEndCallback callback) : @@ -514,6 +511,10 @@ namespace lldb_private { return SyntheticChildrenFrontEnd::AutoPointer(m_create_callback(this, backend.GetSP())); } + protected: + CreateFrontEndCallback m_create_callback; + std::string m_description; + private: DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren); }; Modified: lldb/trunk/include/lldb/DataFormatters/TypeValidator.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeValidator.h?rev=246130&r1=246129&r2=246130&view=diff ============================================================================== --- lldb/trunk/include/lldb/DataFormatters/TypeValidator.h (original) +++ lldb/trunk/include/lldb/DataFormatters/TypeValidator.h Wed Aug 26 19:45:33 2015 @@ -13,8 +13,8 @@ // C Includes // C++ Includes -#include <string> #include <functional> +#include <string> // Other libraries and framework includes @@ -150,7 +150,7 @@ public: TypeValidatorImpl (const Flags& flags = Flags()); typedef std::shared_ptr<TypeValidatorImpl> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeValidatorImplSP&); + typedef std::function<bool(void*, ConstString, TypeValidatorImpl::SharedPointer)> ValueCallback; virtual ~TypeValidatorImpl (); @@ -265,7 +265,7 @@ public: TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags = Flags()); typedef std::shared_ptr<TypeValidatorImpl_CXX> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const TypeValidatorImpl_CXX::SharedPointer&); + typedef std::function<bool(void*, ConstString, TypeValidatorImpl_CXX::SharedPointer)> ValueCallback; ~TypeValidatorImpl_CXX() override; Modified: lldb/trunk/source/API/SBTypeSummary.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeSummary.cpp?rev=246130&r1=246129&r2=246130&view=diff ============================================================================== --- lldb/trunk/source/API/SBTypeSummary.cpp (original) +++ lldb/trunk/source/API/SBTypeSummary.cpp Wed Aug 26 19:45:33 2015 @@ -315,7 +315,7 @@ SBTypeSummary::IsEqualTo (lldb::SBTypeSu { lldb_private::CXXFunctionSummaryFormat *self_cxx = (lldb_private::CXXFunctionSummaryFormat*)m_opaque_sp.get(); lldb_private::CXXFunctionSummaryFormat *other_cxx = (lldb_private::CXXFunctionSummaryFormat*)rhs.m_opaque_sp.get(); - return (self_cxx->m_impl == other_cxx->m_impl); + return (self_cxx == other_cxx); } if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted()) Modified: lldb/trunk/source/DataFormatters/TypeSummary.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeSummary.cpp?rev=246130&r1=246129&r2=246130&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/TypeSummary.cpp (original) +++ lldb/trunk/source/DataFormatters/TypeSummary.cpp Wed Aug 26 19:45:33 2015 @@ -193,15 +193,15 @@ std::string CXXFunctionSummaryFormat::GetDescription () { StreamString sstr; - sstr.Printf ("`%s (%p) `%s%s%s%s%s%s%s", m_description.c_str(), - static_cast<void*>(&m_impl), + sstr.Printf ("%s%s%s%s%s%s%s %s", Cascades() ? "" : " (not cascading)", !DoesPrintChildren(nullptr) ? "" : " (show children)", !DoesPrintValue(nullptr) ? " (hide value)" : "", IsOneLiner() ? " (one-line printout)" : "", SkipsPointers() ? " (skip pointers)" : "", SkipsReferences() ? " (skip references)" : "", - HideNames(nullptr) ? " (hide member names)" : ""); + HideNames(nullptr) ? " (hide member names)" : "", + m_description.c_str()); return sstr.GetString(); } Modified: lldb/trunk/source/DataFormatters/TypeSynthetic.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeSynthetic.cpp?rev=246130&r1=246129&r2=246130&view=diff ============================================================================== --- lldb/trunk/source/DataFormatters/TypeSynthetic.cpp (original) +++ lldb/trunk/source/DataFormatters/TypeSynthetic.cpp Wed Aug 26 19:45:33 2015 @@ -111,11 +111,10 @@ std::string CXXSyntheticChildren::GetDescription() { StreamString sstr; - sstr.Printf("%s%s%s Generator at %p - %s", + sstr.Printf("%s%s%s %s", Cascades() ? "" : " (not cascading)", SkipsPointers() ? " (skip pointers)" : "", SkipsReferences() ? " (skip references)" : "", - reinterpret_cast<void*>(reinterpret_cast<intptr_t>(m_create_callback)), m_description.c_str()); return sstr.GetString(); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits