diff options
author | Enrico Granata <egranata@apple.com> | 2015-10-07 18:36:53 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2015-10-07 18:36:53 +0000 |
commit | 675f49bbd58ef78c947ac0ba32835051ff33f4e5 (patch) | |
tree | 00baf04dc2cd932e2cf4e227fa51f78f4c444f23 /lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp | |
parent | 75230398c233828a07806c4ffd627df3b239b73d (diff) | |
download | bcm5719-llvm-675f49bbd58ef78c947ac0ba32835051ff33f4e5.tar.gz bcm5719-llvm-675f49bbd58ef78c947ac0ba32835051ff33f4e5.zip |
This is the work I was building up to with my patches yesterday
Introduce the notion of Language-based formatter prefix/suffix
This is meant for languages that share certain data types but present them in syntatically different ways, such that LLDB can now have language-based awareness of which of the syntax variations it has to present to the user when formatting those values
This is goodness for new languages and interoperability, but is NFC for existing languages. As such, existing tests cover this
llvm-svn: 249587
Diffstat (limited to 'lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp')
-rw-r--r-- | lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index 2fd85c0d395..3995be919f8 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -770,3 +770,84 @@ ObjCLanguage::GetTypeScavenger () return std::unique_ptr<TypeScavenger>(new ObjCTypeScavenger()); } + +bool +ObjCLanguage::GetFormatterPrefixSuffix (ValueObject& valobj, ConstString type_hint, + std::string& prefix, std::string& suffix) +{ + static ConstString g_CFBag("CFBag"); + static ConstString g_CFBinaryHeap("CFBinaryHeap"); + + static ConstString g_NSNumberChar("NSNumber:char"); + static ConstString g_NSNumberShort("NSNumber:short"); + static ConstString g_NSNumberInt("NSNumber:int"); + static ConstString g_NSNumberLong("NSNumber:long"); + static ConstString g_NSNumberFloat("NSNumber:float"); + static ConstString g_NSNumberDouble("NSNumber:double"); + + static ConstString g_NSData("NSData"); + static ConstString g_NSArray("NSArray"); + static ConstString g_NSString("NSString"); + static ConstString g_NSStringStar("NSString*"); + + if (type_hint.IsEmpty()) + return false; + + prefix.clear(); + suffix.clear(); + + if (type_hint == g_CFBag || + type_hint == g_CFBinaryHeap) + { + prefix = "@"; + return true; + } + + if (type_hint == g_NSNumberChar) + { + prefix = "(char)"; + return true; + } + if (type_hint == g_NSNumberShort) + { + prefix = "(short)"; + return true; + } + if (type_hint == g_NSNumberInt) + { + prefix = "(int)"; + return true; + } + if (type_hint == g_NSNumberLong) + { + prefix = "(long)"; + return true; + } + if (type_hint == g_NSNumberFloat) + { + prefix = "(float)"; + return true; + } + if (type_hint == g_NSNumberDouble) + { + prefix = "(double)"; + return true; + } + + if (type_hint == g_NSData || + type_hint == g_NSArray) + { + prefix = "@\""; + suffix = "\""; + return true; + } + + if (type_hint == g_NSString || + type_hint == g_NSStringStar) + { + prefix = "@"; + return true; + } + + return false; +} |