diff options
| author | Enrico Granata <egranata@apple.com> | 2015-11-14 05:44:23 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2015-11-14 05:44:23 +0000 |
| commit | b56d01033e524cbf3e6281282cf21950499c3d7f (patch) | |
| tree | 7e0623d4f97252d07a8898ec094485fa96abf1c6 /lldb/source/DataFormatters | |
| parent | bd9fc28444c256bd1ed1e29a59bd938160c60674 (diff) | |
| download | bcm5719-llvm-b56d01033e524cbf3e6281282cf21950499c3d7f.tar.gz bcm5719-llvm-b56d01033e524cbf3e6281282cf21950499c3d7f.zip | |
The existing logic to loop over formatters is very pre-C++11, using void* batons, and function pointers, and raw memory allocations instead of safer more modern constructs
This is a first pass at a cleanup of that code, modernizing the "type X clear" commands, and providing the basic infrastructure I plan to use all over
More cleanup will come over the next few days
llvm-svn: 253125
Diffstat (limited to 'lldb/source/DataFormatters')
| -rw-r--r-- | lldb/source/DataFormatters/DataVisualization.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/DataFormatters/FormatManager.cpp | 15 | ||||
| -rw-r--r-- | lldb/source/DataFormatters/TypeCategoryMap.cpp | 33 |
3 files changed, 54 insertions, 0 deletions
diff --git a/lldb/source/DataFormatters/DataVisualization.cpp b/lldb/source/DataFormatters/DataVisualization.cpp index 440091d1ed6..581ef3f851a 100644 --- a/lldb/source/DataFormatters/DataVisualization.cpp +++ b/lldb/source/DataFormatters/DataVisualization.cpp @@ -231,6 +231,12 @@ DataVisualization::Categories::LoopThrough (FormatManager::CategoryCallback call GetFormatManager().LoopThroughCategories(callback, callback_baton); } +void +DataVisualization::Categories::ForEach (TypeCategoryMap::ForEachCallback callback) +{ + GetFormatManager().ForEachCategory(callback); +} + uint32_t DataVisualization::Categories::GetCount () { diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 2362ba52526..3237f73f64e 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -500,6 +500,21 @@ FormatManager::LoopThroughCategories (CategoryCallback callback, void* param) } } +void +FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback) +{ + m_categories_map.ForEach(callback); + Mutex::Locker locker(m_language_categories_mutex); + for (const auto& entry : m_language_categories_map) + { + if (auto category_sp = entry.second->GetCategory()) + { + if (!callback(category_sp)) + break; + } + } +} + lldb::TypeCategoryImplSP FormatManager::GetCategory (const ConstString& category_name, bool can_create) diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp index aafcfa9536c..19164a3c003 100644 --- a/lldb/source/DataFormatters/TypeCategoryMap.cpp +++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp @@ -405,6 +405,39 @@ TypeCategoryMap::LoopThrough(CallbackType callback, void* param) } } +void +TypeCategoryMap::ForEach(ForEachCallback callback) +{ + if (callback) + { + Mutex::Locker locker(m_map_mutex); + + // loop through enabled categories in respective order + { + ActiveCategoriesIterator begin, end = m_active_categories.end(); + for (begin = m_active_categories.begin(); begin != end; begin++) + { + lldb::TypeCategoryImplSP category = *begin; + if (!callback(category)) + break; + } + } + + // loop through disabled categories in just any order + { + MapIterator pos, end = m_map.end(); + for (pos = m_map.begin(); pos != end; pos++) + { + if (pos->second->IsEnabled()) + continue; + KeyType type = pos->first; + if (!callback(pos->second)) + break; + } + } + } +} + TypeCategoryImplSP TypeCategoryMap::GetAtIndex (uint32_t index) { |

