Index: base/mac/foundation_util.mm |
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm |
index 8a4ce471765e1157886e293ae4c7b9007ccc24f7..9467314cfa2e8eae4ec1675cee74b50c76ec77f6 100644 |
--- a/base/mac/foundation_util.mm |
+++ b/base/mac/foundation_util.mm |
@@ -9,7 +9,6 @@ |
#include "base/file_path.h" |
#include "base/logging.h" |
-#include "base/mac/scoped_cftyperef.h" |
#include "base/sys_string_conversions.h" |
namespace base { |
@@ -200,6 +199,37 @@ FilePath GetAppBundlePath(const FilePath& exec_name) { |
return FilePath(); |
} |
+#define TYPE_NAME_FOR_CF_TYPE_DEFN(TypeCF) \ |
+std::string TypeNameForCFType(TypeCF##Ref cfo) { \ |
+ std::string type_name = #TypeCF; \ |
+ return type_name + "Ref"; \ |
Mark Mentovai
2011/11/14 18:08:55
The values returned by CFCopyTypeIDDescription don
KushalP
2011/11/14 18:47:02
No. They do not. Fixed.
|
+} |
+ |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFArray); |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFBag); |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFBoolean); |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFData); |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFDate); |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFDictionary); |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFNull); |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFNumber); |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFSet); |
+TYPE_NAME_FOR_CF_TYPE_DEFN(CFString); |
+ |
+std::string GetValueFromDictionaryErrorMessage(CFStringRef key, |
+ CFStringRef expected_type_ref, |
Mark Mentovai
2011/11/14 18:08:55
Do something about this cheesey alignment.
|
+ CFTypeRef value) { |
+ ScopedCFTypeRef<CFStringRef> actual_type_ref( |
+ CFCopyTypeIDDescription(CFGetTypeID(value))); |
+ return "Expected value for key " + |
+ base::SysCFStringRefToUTF8(key) + |
+ " to be " + |
+ base::SysCFStringRefToUTF8(expected_type_ref) + |
+ " but it was " + |
+ base::SysCFStringRefToUTF8(actual_type_ref) + |
+ " instead"; |
+} |
+ |
CFTypeRef GetValueFromDictionary(CFDictionaryRef dict, |
CFStringRef key, |
CFTypeID expected_type) { |
@@ -210,15 +240,9 @@ CFTypeRef GetValueFromDictionary(CFDictionaryRef dict, |
if (CFGetTypeID(value) != expected_type) { |
ScopedCFTypeRef<CFStringRef> expected_type_ref( |
CFCopyTypeIDDescription(expected_type)); |
- ScopedCFTypeRef<CFStringRef> actual_type_ref( |
- CFCopyTypeIDDescription(CFGetTypeID(value))); |
- DLOG(WARNING) << "Expected value for key " |
- << base::SysCFStringRefToUTF8(key) |
- << " to be " |
- << base::SysCFStringRefToUTF8(expected_type_ref) |
- << " but it was " |
- << base::SysCFStringRefToUTF8(actual_type_ref) |
- << " instead"; |
+ DLOG(WARNING) << GetValueFromDictionaryErrorMessage(key, |
+ expected_type_ref, |
+ value); |
return NULL; |
} |