Add a Language::ForAllLanguages helper function

llvm-svn: 246614
This commit is contained in:
Enrico Granata
2015-09-02 01:31:10 +00:00
parent 578c8a7841
commit 28b3831e39
2 changed files with 28 additions and 14 deletions

View File

@@ -27,20 +27,20 @@ namespace lldb_private {
{
public:
~Language() override;
static Language*
FindPlugin (lldb::LanguageType language);
// return false from callback to stop iterating
static void
ForEach (std::function<bool(Language*)> callback);
virtual lldb::LanguageType
GetLanguageType () const = 0;
virtual lldb::TypeCategoryImplSP
GetFormatters ();
~Language() override;
static Language*
FindPlugin (lldb::LanguageType language);
// return false from callback to stop iterating
static void
ForEach (std::function<bool(Language*)> callback);
virtual lldb::LanguageType
GetLanguageType () const = 0;
virtual lldb::TypeCategoryImplSP
GetFormatters ();
// These are accessors for general information about the Languages lldb knows about:
@@ -52,6 +52,10 @@ namespace lldb_private {
static void
PrintAllLanguages (Stream &s, const char *prefix, const char *suffix);
// return false from callback to stop iterating
static void
ForAllLanguages (std::function<bool(lldb::LanguageType)> callback);
static bool
LanguageIsCPlusPlus (lldb::LanguageType language);

View File

@@ -179,6 +179,16 @@ Language::PrintAllLanguages (Stream &s, const char *prefix, const char *suffix)
}
}
void
Language::ForAllLanguages (std::function<bool(lldb::LanguageType)> callback)
{
for (uint32_t i = 1; i < num_languages; i++)
{
if (!callback(language_names[i].type))
break;
}
}
bool
Language::LanguageIsCPlusPlus (LanguageType language)
{