This patch provides a set of formatters for most of the commonly used Cocoa classes.

The formatter for NSString is an improved version of the one previously shipped as an example, the others are new in design and implementation.
A more robust and OO-compliant Objective-C runtime wrapper is provided for runtime versions 1 and 2 on 32 and 64 bit.
The formatters are contained in a category named "AppKit", which is not enabled at startup.

llvm-svn: 151299
This commit is contained in:
Enrico Granata 2012-02-23 23:10:03 +00:00
parent 8195ad7b87
commit d3d444f811
8 changed files with 768 additions and 411 deletions

View File

@ -675,6 +675,7 @@ private:
ConstString m_coregraphics_category_name;
ConstString m_coreservices_category_name;
ConstString m_vectortypes_category_name;
ConstString m_appkit_category_name;
CategoryMap&
GetCategories ()

View File

@ -185,7 +185,7 @@ else
fi
# Copy the ObjC formatters over to the framework Python directory
if [ -f "${SRC_ROOT}/examples/synthetic/objc.py" ]
if [ -f "${SRC_ROOT}/examples/summaries/objc.py" ]
then
if [ $Debug == 1 ]
then
@ -199,6 +199,245 @@ else
fi
fi
# Copy the Cocoa formatters over to the framework Python directory
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFArray.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying CFArray.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/CFArray.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFArray.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFDictionary.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying CFDictionary.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/CFDictionary.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFDictionary.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFString.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying CFString.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/CFString.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFString.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSData.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying NSData.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/NSData.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSData.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSMachPort.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying NSMachPort.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/NSMachPort.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSMachPort.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSSet.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying NSSet.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/NSSet.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSSet.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSNotification.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying NSNotification.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/NSNotification.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSNotification.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSException.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying NSException.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/NSException.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSException.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFBag.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying CFBag.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/CFBag.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFBag.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/CFBinaryHeap.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying CFBinaryHeap.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/CFBinaryHeap.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/CFBinaryHeap.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSURL.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying NSURL.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/NSURL.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSURL.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSBundle.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying NSBundle.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/NSBundle.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSBundle.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/NSNumber.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying NSNumber.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/NSNumber.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/NSNumber.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/cache.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying cache.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/cache.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/cache.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/metrics.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying metrics.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/metrics.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/metrics.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/objc_lldb.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying objc_lldb.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/objc_lldb.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/objc_lldb.py"
fi
fi
if [ -f "${SRC_ROOT}/examples/summaries/cocoa/objc_runtime.py" ]
then
if [ $Debug == 1 ]
then
echo "Copying objc_runtime.py to ${framework_python_dir}"
fi
cp "${SRC_ROOT}/examples/summaries/cocoa/objc_runtime.py" "${framework_python_dir}"
else
if [ $Debug == 1 ]
then
echo "Unable to find ${SRC_ROOT}/examples/summaries/cocoa/objc_runtime.py"
fi
fi
fi
exit 0

View File

@ -584,7 +584,8 @@ FormatManager::FormatManager() :
m_corefoundation_category_name(ConstString("CoreFoundation")),
m_coregraphics_category_name(ConstString("CoreGraphics")),
m_coreservices_category_name(ConstString("CoreServices")),
m_vectortypes_category_name(ConstString("VectorTypes"))
m_vectortypes_category_name(ConstString("VectorTypes")),
m_appkit_category_name(ConstString("AppKit"))
{
LoadSystemFormatters();
@ -595,6 +596,7 @@ FormatManager::FormatManager() :
EnableCategory(m_objc_category_name,CategoryMap::Last);
//EnableCategory(m_corefoundation_category_name,CategoryMap::Last);
//EnableCategory(m_appkit_category_name,CategoryMap::Last);
//EnableCategory(m_coreservices_category_name,CategoryMap::Last);
//EnableCategory(m_coregraphics_category_name,CategoryMap::Last);
EnableCategory(m_gnu_cpp_category_name,CategoryMap::Last);
@ -686,6 +688,24 @@ AddSummary(TypeCategoryImpl::SharedPointer category_sp,
summary_sp);
}
static void
AddScriptSummary(TypeCategoryImpl::SharedPointer category_sp,
const char* funct_name,
ConstString type_name,
TypeSummaryImpl::Flags flags)
{
std::string code(" ");
code.append(funct_name).append("(valobj,dict)");
lldb::TypeSummaryImplSP summary_sp(new ScriptSummaryFormat(flags,
funct_name,
code.c_str()));
category_sp->GetSummaryNavigator()->Add(type_name,
summary_sp);
}
#ifndef LLDB_DISABLE_PYTHON
void
FormatManager::LoadObjCFormatters()
@ -784,6 +804,56 @@ FormatManager::LoadObjCFormatters()
ConstString("HIRect"),
objc_flags);
TypeCategoryImpl::SharedPointer appkit_category_sp = GetCategory(m_appkit_category_name);
TypeSummaryImpl::Flags appkit_flags;
appkit_flags.SetCascades(true)
.SetSkipPointers(false)
.SetSkipReferences(false)
.SetDontShowChildren(true)
.SetDontShowValue(false)
.SetShowMembersOneLiner(false)
.SetHideItemNames(false);
AddScriptSummary(appkit_category_sp, "CFArray.CFArray_SummaryProvider", ConstString("NSArray"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFArray.CFArray_SummaryProvider", ConstString("CFArrayRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFArray.CFArray_SummaryProvider", ConstString("CFMutableArrayRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFBag.CFBag_SummaryProvider", ConstString("CFBagRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFBag.CFBag_SummaryProvider", ConstString("CFMutableBagRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFBinaryHeap.CFBinaryHeap_SummaryProvider", ConstString("CFBinaryHeapRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFDictionary.CFDictionary_SummaryProvider", ConstString("NSDictionary"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFDictionary.CFDictionary_SummaryProvider2", ConstString("CFDictionaryRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFDictionary.CFDictionary_SummaryProvider2", ConstString("CFMutableDictionaryRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFString.CFString_SummaryProvider", ConstString("NSString"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFString.CFString_SummaryProvider", ConstString("CFStringRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFString.CFString_SummaryProvider", ConstString("CFMutableStringRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "CFString.CFAttributedString_SummaryProvider", ConstString("NSAttributedString"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSBundle.NSBundle_SummaryProvider", ConstString("NSBundle"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSData.NSData_SummaryProvider", ConstString("NSData"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSData.NSData_SummaryProvider", ConstString("CFDataRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSData.NSData_SummaryProvider", ConstString("CFMutableDataRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSException.NSException_SummaryProvider", ConstString("NSException"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSMachPort.NSMachPort_SummaryProvider", ConstString("NSMachPort"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSNotification.NSNotification_SummaryProvider", ConstString("NSNotification"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSNumber.NSNumber_SummaryProvider", ConstString("NSNumber"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSSet.NSSet_SummaryProvider", ConstString("NSSet"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSSet.NSSet_SummaryProvider2", ConstString("CFSetRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSSet.NSSet_SummaryProvider2", ConstString("CFMutableSetRef"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSURL.NSURL_SummaryProvider", ConstString("NSURL"), appkit_flags);
AddScriptSummary(appkit_category_sp, "NSURL.NSURL_SummaryProvider", ConstString("CFURLRef"), appkit_flags);
TypeCategoryImpl::SharedPointer vectors_category_sp = GetCategory(m_vectortypes_category_name);
TypeSummaryImpl::Flags vector_flags;

View File

@ -223,6 +223,11 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete
run_string.Printf ("run_one_line (%s, 'import copy, os, re, sys, uuid, lldb, gnu_libstdcpp, objc')", m_dictionary_name.c_str());
PyRun_SimpleString (run_string.GetData());
// WARNING: temporary code that loads Cocoa formatters - this should be done on a per-platform basis rather than loading the whole set
// and letting the individual formatter classes exploit APIs to check whether they can/cannot do their task
run_string.Clear();
run_string.Printf ("run_one_line (%s, 'import CFString, CFArray, CFDictionary, NSData, NSMachPort, NSSet, NSNotification, NSException, CFBag, CFBinaryHeap, NSURL, NSBundle, NSNumber')", m_dictionary_name.c_str());
PyRun_SimpleString (run_string.GetData());
int new_count = Debugger::TestDebuggerRefCount();

View File

@ -1,237 +0,0 @@
# synthetic children and summary provider for CFString
# (and related NSString class)
import lldb
def CFString_SummaryProvider (valobj,dict):
provider = CFStringSynthProvider(valobj,dict);
if provider.invalid == False:
return '@'+provider.get_child_at_index(provider.get_child_index("content")).GetSummary();
return ''
class CFStringSynthProvider:
def __init__(self,valobj,dict):
self.valobj = valobj;
self.update()
# children other than "content" are for debugging only and must not be used in production code
def num_children(self):
if self.invalid:
return 0;
return 6;
def read_unicode(self, pointer):
process = self.valobj.GetTarget().GetProcess()
error = lldb.SBError()
pystr = u''
# cannot do the read at once because the length value has
# a weird encoding. better play it safe here
while True:
content = process.ReadMemory(pointer, 2, error)
new_bytes = bytearray(content)
b0 = new_bytes[0]
b1 = new_bytes[1]
pointer = pointer + 2
if b0 == 0 and b1 == 0:
break
# rearrange bytes depending on endianness
# (do we really need this or is Cocoa going to
# use Windows-compatible little-endian even
# if the target is big endian?)
if self.is_little:
value = b1 * 256 + b0
else:
value = b0 * 256 + b1
pystr = pystr + unichr(value)
return pystr
# handle the special case strings
# only use the custom code for the tested LP64 case
def handle_special(self):
if self.lp64 == False:
# for 32bit targets, use safe ObjC code
return self.handle_unicode_string_safe()
offset = 12
pointer = self.valobj.GetValueAsUnsigned(0) + offset
pystr = self.read_unicode(pointer)
return self.valobj.CreateValueFromExpression("content",
"(char*)\"" + pystr.encode('utf-8') + "\"")
# last resort call, use ObjC code to read; the final aim is to
# be able to strip this call away entirely and only do the read
# ourselves
def handle_unicode_string_safe(self):
return self.valobj.CreateValueFromExpression("content",
"(char*)\"" + self.valobj.GetObjectDescription() + "\"");
def handle_unicode_string(self):
# step 1: find offset
if self.inline:
pointer = self.valobj.GetValueAsUnsigned(0) + self.size_of_cfruntime_base();
if self.explicit == False:
# untested, use the safe code path
return self.handle_unicode_string_safe();
else:
# not sure why 8 bytes are skipped here
# (lldb) mem read -c 50 0x00000001001154f0
# 0x1001154f0: 98 1a 85 71 ff 7f 00 00 90 07 00 00 01 00 00 00 ...q?...........
# 0x100115500: 03 00 00 00 00 00 00 00 *c3 03 78 00 78 00 00 00 ........?.x.x...
# 0x100115510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
# 0x100115520: 00 00 ..
# content begins at * (i.e. 8 bytes into variants, skipping void* buffer in
# __notInlineImmutable1 entirely, while the length byte is correctly located
# for an inline string)
pointer = pointer + 8;
else:
pointer = self.valobj.GetValueAsUnsigned(0) + self.size_of_cfruntime_base();
# read 8 bytes here and make an address out of them
vopointer = self.valobj.CreateChildAtOffset("dummy",
pointer,self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar).GetPointerType());
pointer = vopointer.GetValueAsUnsigned(0)
# step 2: read Unicode data at pointer
pystr = self.read_unicode(pointer)
# step 3: return it
return self.valobj.CreateValueFromExpression("content",
"(char*)\"" + pystr.encode('utf-8') + "\"")
# we read at "the right place" into the __CFString object instead of running code
# we are replicating the functionality of __CFStrContents in CFString.c here
def handle_UTF8_inline(self):
offset = int(self.valobj.GetValue(), 0) + self.size_of_cfruntime_base();
if self.explicit == False:
offset = offset + 1;
return self.valobj.CreateValueFromAddress("content",
offset, self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)).AddressOf();
def handle_UTF8_not_inline(self):
offset = self.size_of_cfruntime_base();
return self.valobj.CreateChildAtOffset("content",
offset,self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar).GetPointerType());
def get_child_at_index(self,index):
if index == 0:
return self.valobj.CreateValueFromExpression("mutable",
str(int(self.mutable)));
if index == 1:
return self.valobj.CreateValueFromExpression("inline",
str(int(self.inline)));
if index == 2:
return self.valobj.CreateValueFromExpression("explicit",
str(int(self.explicit)));
if index == 3:
return self.valobj.CreateValueFromExpression("unicode",
str(int(self.unicode)));
if index == 4:
return self.valobj.CreateValueFromExpression("special",
str(int(self.special)));
if index == 5:
if self.unicode == True:
return self.handle_unicode_string();
elif self.special == True:
return self.handle_special();
elif self.inline == True:
return self.handle_UTF8_inline();
else:
return self.handle_UTF8_not_inline();
def get_child_index(self,name):
if name == "content":
return self.num_children() - 1;
if name == "mutable":
return 0;
if name == "inline":
return 1;
if name == "explicit":
return 2;
if name == "unicode":
return 3;
if name == "special":
return 4;
def is_64bit(self):
return self.valobj.GetTarget().GetProcess().GetAddressByteSize() == 8
def is_little_endian(self):
return self.valobj.GetTarget().GetProcess().GetByteOrder() == lldb.eByteOrderLittle
# CFRuntimeBase is defined as having an additional
# 4 bytes (padding?) on LP64 architectures
# to get its size we add up sizeof(pointer)+4
# and then add 4 more bytes if we are on a 64bit system
def size_of_cfruntime_base(self):
if self.lp64 == True:
return 8+4+4;
else:
return 4+4;
# the info bits are part of the CFRuntimeBase structure
# to get at them we have to skip a uintptr_t and then get
# at the least-significant byte of a 4 byte array. If we are
# on big-endian this means going to byte 3, if we are on
# little endian (OSX & iOS), this means reading byte 0
def offset_of_info_bits(self):
if self.lp64 == True:
offset = 8;
else:
offset = 4;
if self.is_little == False:
offset = offset + 3;
return offset;
def read_info_bits(self):
cfinfo = self.valobj.CreateChildAtOffset("cfinfo",
self.offset_of_info_bits(),
self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar));
cfinfo.SetFormat(11)
info = cfinfo.GetValue();
if info != None:
self.invalid = False;
return int(info,0);
else:
self.invalid = True;
return None;
# calculating internal flag bits of the CFString object
# this stuff is defined and discussed in CFString.c
def is_mutable(self):
return (self.info_bits & 1) == 1;
def is_inline(self):
return (self.info_bits & 0x60) == 0;
# this flag's name is ambiguous, it turns out
# we must skip a length byte to get at the data
# when this flag is False
def has_explicit_length(self):
return (self.info_bits & (1 | 4)) != 4;
# probably a subclass of NSString. obtained this from [str pathExtension]
# here info_bits = 0 and Unicode data at the start of the padding word
# in the long run using the isa value might be safer as a way to identify this
# instead of reading the info_bits
def is_special_case(self):
return self.info_bits == 0;
def is_unicode(self):
return (self.info_bits & 0x10) == 0x10;
# preparing ourselves to read into memory
# by adjusting architecture-specific info
def adjust_for_architecture(self):
self.lp64 = self.is_64bit();
self.is_little = self.is_little_endian();
# reading info bits out of the CFString and computing
# useful values to get at the real data
def compute_flags(self):
self.info_bits = self.read_info_bits();
if self.info_bits == None:
return;
self.mutable = self.is_mutable();
self.inline = self.is_inline();
self.explicit = self.has_explicit_length();
self.unicode = self.is_unicode();
self.special = self.is_special_case();
def update(self):
self.adjust_for_architecture();
self.compute_flags();

View File

@ -2,6 +2,8 @@ LEVEL = ../../../make
OBJC_SOURCES := main.m
CFLAGS_EXTRAS += -w
include $(LEVEL)/Makefile.rules
LDFLAGS += -framework Foundation

View File

@ -55,6 +55,7 @@ class ObjCDataFormatterTestCase(TestBase):
self.runCmd('type category disable CoreFoundation', check=False)
self.runCmd('type category disable CoreGraphics', check=False)
self.runCmd('type category disable CoreServices', check=False)
self.runCmd('type category disable AppKit', check=False)
# Execute the cleanup function during test case tear down.
@ -105,145 +106,87 @@ class ObjCDataFormatterTestCase(TestBase):
self.expect("frame variable *object",
substrs = ['a test']);
# Now check that the synth for CFString works
self.runCmd("script from CFString import *")
self.runCmd("type synth add -l CFStringSynthProvider NSString")
# Now enable AppKit and check we are displaying Cocoa classes correctly
self.runCmd("type category enable AppKit")
self.expect('frame variable num1 num2 num3 num4 num5 num6 num7 num8_Y num8_N num9',
substrs = ['(NSNumber *) num1 = 0x0000000000000583 (int)5',
'(NSNumber *) num2 = ',' (float)3.1',
'(NSNumber *) num3 = ',' (double)3.14',
'(NSNumber *) num4 = ',' (long)18446744073709551614',
'(NSNumber *) num5 = ',' (char)65',
'(NSNumber *) num6 = ',' (long)255',
'(NSNumber *) num7 = ',' (long)2000000',
'(NSNumber *) num8_Y = ',' @"1"',
'(NSNumber *) num8_N = ',' @"0"',
'(NSNumber *) num9 = ',' (short)33920'])
self.expect('frame variable str -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'A rather short ASCII NSString object is here'])
self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
substrs = ['(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
'(NSString *) str0 = ',' @"255"',
'(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
'(NSString *) str2 = ',' @"A rather short UTF8 NSString object is here"',
'(NSString *) str3 = ',' @"A string made with the at sign is here"',
'(NSString *) str4 = ',' @"This is string number 4 right here"',
'(NSString *) str5 = ',' @"{{1, 1}, {5, 5}}"',
'(NSString *) str6 = ',' @"1ST"',
'(NSString *) str8 = ',' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime',
'(NSString *) str9 = ',' @"a very much boring task to write a string this way!!',
'(NSString *) str10 = ',' @"This is a Unicode string',
'(NSString *) str11 = ',' @"__NSCFString"',
'(NSString *) label1 = ',' @"Process Name: "',
'(NSString *) label2 = ',' @"Process Id: "',
'(NSString *) str12 = ',' @"Process Name: a.out Process Id:'])
self.expect('frame variable str2 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'A rather short UTF8 NSString object is here'])
self.expect('frame variable newArray newDictionary newMutableDictionary cfdict_ref mutable_dict_ref cfarray_ref mutable_array_ref',
substrs = ['(NSArray *) newArray = ',' size=50',
'(NSDictionary *) newDictionary = ',' 12 key/value pairs',
'(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs',
'(CFDictionaryRef) cfdict_ref = ',' 3 key/value pairs',
'(CFMutableDictionaryRef) mutable_dict_ref = ',' 12 key/value pairs',
'(CFArrayRef) cfarray_ref = ',' size=3',
'(CFMutableArrayRef) mutable_array_ref = ',' size=11'])
self.expect('frame variable str3 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'A string made with the at sign is here'])
self.expect('frame variable attrString mutableAttrString mutableGetConst',
substrs = ['(NSAttributedString *) attrString = ',' @"hello world from foo"',
'(NSAttributedString *) mutableAttrString = ',' @"hello world from foo"',
'(NSString *) mutableGetConst = ',' @"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear foo"'])
self.expect('frame variable str4 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'This is string number 4 right here'])
self.expect('frame variable str5 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'{{1, 1}, {5, 5}}'])
self.expect('frame variable str6 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'1ST'])
self.expect('frame variable str7 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'\\xcf\\x83xx'])
self.expect('frame variable str8 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'hasVeryLongExtensionThisTime'])
self.expect('frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref',
substrs = ['(NSData *) immutableData = ',' 4 bytes',
'(NSData *) mutableData = ',' 14 bytes',
'(CFDataRef) data_ref = ',' 5 bytes',
'(CFMutableDataRef) mutable_data_ref = ',' 5 bytes',
'(CFMutableStringRef) mutable_string_ref = ',' @"Wish ya knew"'])
self.expect('frame variable str9 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'a very much boring task to write a string this way!!\\xcf\\x83'])
self.expect('frame variable str10 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'This is a Unicode string \\xcf\\x83 number 4 right here'])
self.expect('frame variable str11 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'NSCFString'])
self.expect('frame variable processName -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'a.out'])
self.expect('frame variable str12 -P 1 -Y',
substrs = ['mutable =',
'inline = ',
'explicit = ',
'content = ',
'Process Name: a.out Process Id:'])
# check that access to synthetic children by name works
self.expect("frame variable str12->mutable",
substrs = ['(int) mutable = 0'])
# delete the synth and set a summary
self.runCmd("type synth delete NSString")
self.runCmd("type summary add -F CFString_SummaryProvider NSString")
self.expect('frame variable mutable_bag_ref cfbag_ref binheap_ref',
substrs = ['(CFMutableBagRef) mutable_bag_ref = ',' 17 items',
'(CFBagRef) cfbag_ref = ',' 15 items',
'(CFBinaryHeapRef) binheap_ref = ',' 21 items'])
self.expect('frame variable str',
substrs = ['A rather short ASCII NSString object is here'])
self.expect('frame variable str2',
substrs = ['A rather short UTF8 NSString object is here'])
self.expect('frame variable str3',
substrs = ['A string made with the at sign is here'])
self.expect('frame variable str4',
substrs = ['This is string number 4 right here'])
self.expect('frame variable str5',
substrs = ['{{1, 1}, {5, 5}}'])
self.expect('frame variable str6',
substrs = ['1ST'])
self.expect('frame variable str7',
substrs = ['\\xcf\\x83xx'])
self.expect('frame variable str8',
substrs = ['hasVeryLongExtensionThisTime'])
self.expect('frame variable str9',
substrs = ['a very much boring task to write a string this way!!\\xcf\\x83'])
self.expect('frame variable str10',
substrs = ['This is a Unicode string \\xcf\\x83 number 4 right here'])
self.expect('frame variable str11',
substrs = ['NSCFString'])
self.expect('frame variable processName',
substrs = ['a.out'])
self.expect('frame variable str12',
substrs = ['Process Name: a.out Process Id:'])
self.expect('frame variable dyn_test', matching=False,
substrs = ['Process Name: a.out Process Id:'])
self.expect('frame variable dyn_test -d run-target -T',
substrs = ['(__NSCFString *, dynamic type:',
'Process Name: a.out Process Id:'])
self.expect('frame variable dyn_test -d run-target',
substrs = ['(__NSCFString *)',
'Process Name: a.out Process Id:'])
self.expect('frame variable cfurl_ref cfchildurl_ref cfgchildurl_ref',
substrs = ['(CFURLRef) cfurl_ref = ',' @"http://www.foo.bar/"',
'cfchildurl_ref = ',' @"page.html" (base path: @"http://www.foo.bar/")',
'(CFURLRef) cfgchildurl_ref = ',' @"?whatever" (base path: @"http://www.foo.bar/page.html")'])
self.expect('frame variable nsurl nsurl2 nsurl3',
substrs = ['(NSURL *) nsurl = ',' @"http://www.foo.bar"',
'(NSURL *) nsurl2 =',' @"page.html" (base path: @"http://www.foo.bar")',
'(NSURL *) nsurl3 = ',' @"?whatever" (base path: @"http://www.foo.bar/page.html")'])
self.expect('frame variable bundle_string bundle_url main_bundle',
substrs = ['(NSBundle *) bundle_string = ',' @"/System/Library/Frameworks/Accelerate.framework"',
'(NSBundle *) bundle_url = ',' @"/System/Library/Frameworks/Cocoa.framework"',
'(NSBundle *) main_bundle = ','test/functionalities/data-formatter/data-formatter-objc'])
self.expect('frame variable except0 except1 except2 except3',
substrs = ['(NSException *) except0 = ',' @"TheGuyWhoHasNoName" @"cuz it\'s funny"',
'(NSException *) except1 = ',' @"TheGuyWhoHasNoName~1" @"cuz it\'s funny"',
'(NSException *) except2 = ',' @"TheGuyWhoHasNoName`2" @"cuz it\'s funny"',
'(NSException *) except3 = ',' @"TheGuyWhoHasNoName/3" @"cuz it\'s funny"'])
self.expect('frame variable port',
substrs = ['(NSMachPort *) port = ',' mach port: '])
# check that we can format stuff out of the expression parser
self.expect('expression ((id)@"Hello")', matching=False,
substrs = ['Hello'])

View File

@ -79,51 +79,385 @@ int main (int argc, const char * argv[])
[object2 doIncrementByInt:3];
NSString *str = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
NSString *str3 = @"A string made with the at sign is here";
NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
NSRect ns_rect = {{1,1},{5,5}};
NSString* str5 = NSStringFromRect(ns_rect);
NSString* str6 = [@"/usr/doc/README.1ST" pathExtension];
const unichar myCharacters[] = {0x03C3,'x','x'};
NSString *str7 = [NSString stringWithCharacters: myCharacters
length: sizeof myCharacters / sizeof *myCharacters];
NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ',
'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
't','h','i','s',' ','w','a','y','!','!',0x03C3, 0};
NSString *str9 = [NSString stringWithCharacters: myOtherCharacters
length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
const unichar myNextCharacters[] = {0x03C3, 0x0000};
NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
NSString *str11 = [str10 className];
NSString *label1 = @"Process Name: ";
NSString *label2 = @"Process Id: ";
NSString *processName = [[NSProcessInfo processInfo] processName];
NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]];
NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
id dyn_test = str12;
NSNumber* num1 = [NSNumber numberWithInt:5];
NSNumber* num2 = [NSNumber numberWithFloat:3.14];
NSNumber* num3 = [NSNumber numberWithDouble:3.14];
NSNumber* num4 = [NSNumber numberWithUnsignedLongLong:0xFFFFFFFFFFFFFFFE];
NSNumber* num5 = [NSNumber numberWithChar:'A'];
NSNumber* num6 = [NSNumber numberWithUnsignedLongLong:0xFF];
NSNumber* num7 = [NSNumber numberWithLong:0x1E8480];
NSNumber* num8_Y = [NSNumber numberWithBool:YES];
NSNumber* num8_N = [NSNumber numberWithBool:NO];
NSNumber* num9 = [NSNumber numberWithShort:0x1E8480];
NSString *str0 = [num6 stringValue];
NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
NSString *str3 = @"A string made with the at sign is here";
NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
NSRect ns_rect_4str = {{1,1},{5,5}};
NSString* str5 = NSStringFromRect(ns_rect_4str);
NSString* str6 = [@"/usr/doc/README.1ST" pathExtension];
const unichar myCharacters[] = {0x03C3,'x','x'};
NSString *str7 = [NSString stringWithCharacters: myCharacters
length: sizeof myCharacters / sizeof *myCharacters];
NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ',
'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
't','h','i','s',' ','w','a','y','!','!',0x03C3, 0};
NSString *str9 = [NSString stringWithCharacters: myOtherCharacters
length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
const unichar myNextCharacters[] = {0x03C3, 0x0000};
NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
NSString *str11 = [str10 className];
NSString *label1 = @"Process Name: ";
NSString *label2 = @"Process Id: ";
NSString *processName = [[NSProcessInfo processInfo] processName];
NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]];
NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
NSString *strA1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
NSString *strA2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
NSString *strA3 = @"A string made with the at sign is here";
NSString *strA4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
NSString* strA5 = NSStringFromRect(ns_rect_4str);
NSString* strA6 = [@"/usr/doc/README.1ST" pathExtension];
NSString *strA7 = [NSString stringWithCharacters: myCharacters
length: sizeof myCharacters / sizeof *myCharacters];
NSString* strA8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
NSString *strA9 = [NSString stringWithCharacters: myOtherCharacters
length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
NSString *strA10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
NSString *strA11 = [str10 className];
NSString *strA12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
NSString *strB1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
NSString *strB2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
NSString *strB3 = @"A string made with the at sign is here";
NSString *strB4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
NSString* strB5 = NSStringFromRect(ns_rect_4str);
NSString* strB6 = [@"/usr/doc/README.1ST" pathExtension];
NSString *strB7 = [NSString stringWithCharacters: myCharacters
length: sizeof myCharacters / sizeof *myCharacters];
NSString* strB8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
NSString *strB9 = [NSString stringWithCharacters: myOtherCharacters
length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
NSString *strB10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
NSString *strB11 = [str10 className];
NSString *strB12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
NSString *strC11 = [str10 className];
NSString *strC12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
NSString *strC1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
NSString *strC2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
NSString *strC3 = @"A string made with the at sign is here";
NSString *strC4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
NSString* strC5 = NSStringFromRect(ns_rect_4str);
NSString* strC6 = [@"/usr/doc/README.1ST" pathExtension];
NSString *strC7 = [NSString stringWithCharacters: myCharacters
length: sizeof myCharacters / sizeof *myCharacters];
NSString* strC8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
NSString *strC9 = [NSString stringWithCharacters: myOtherCharacters
length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
NSString *strC10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
NSString *strD11 = [str10 className];
NSString *strD12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
void* data_set[3] = {str1,str2,str3};
NSArray* newArray = [[NSMutableArray alloc] init];
[newArray addObject:str1];
[newArray addObject:str2];
[newArray addObject:str3];
[newArray addObject:str4];
[newArray addObject:str5];
[newArray addObject:str6];
[newArray addObject:str7];
[newArray addObject:str8];
[newArray addObject:str9];
[newArray addObject:str10];
[newArray addObject:str11];
[newArray addObject:str12];
[newArray addObject:strA1];
[newArray addObject:strA2];
[newArray addObject:strA3];
[newArray addObject:strA4];
[newArray addObject:strA5];
[newArray addObject:strA6];
[newArray addObject:strA7];
[newArray addObject:strA8];
[newArray addObject:strA9];
[newArray addObject:strA10];
[newArray addObject:strA11];
[newArray addObject:strA12];
[newArray addObject:strB1];
[newArray addObject:strB2];
[newArray addObject:strB3];
[newArray addObject:strB4];
[newArray addObject:strB5];
[newArray addObject:strB6];
[newArray addObject:strB7];
[newArray addObject:strB8];
[newArray addObject:strB9];
[newArray addObject:strB10];
[newArray addObject:strB11];
[newArray addObject:strB12];
[newArray addObject:strC1];
[newArray addObject:strC2];
[newArray addObject:strC3];
[newArray addObject:strC4];
[newArray addObject:strC5];
[newArray addObject:strC6];
[newArray addObject:strC7];
[newArray addObject:strC8];
[newArray addObject:strC9];
[newArray addObject:strC10];
[newArray addObject:strC11];
[newArray addObject:strC12];
[newArray addObject:strD11];
[newArray addObject:strD12];
NSDictionary* newDictionary = [[NSDictionary alloc] initWithObjects:newArray forKeys:newArray];
NSDictionary *newMutableDictionary = [[NSMutableDictionary alloc] init];
[newMutableDictionary setObject:@"foo" forKey:@"bar0"];
[newMutableDictionary setObject:@"foo" forKey:@"bar1"];
[newMutableDictionary setObject:@"foo" forKey:@"bar2"];
[newMutableDictionary setObject:@"foo" forKey:@"bar3"];
[newMutableDictionary setObject:@"foo" forKey:@"bar4"];
[newMutableDictionary setObject:@"foo" forKey:@"bar5"];
[newMutableDictionary setObject:@"foo" forKey:@"bar6"];
[newMutableDictionary setObject:@"foo" forKey:@"bar7"];
[newMutableDictionary setObject:@"foo" forKey:@"bar8"];
[newMutableDictionary setObject:@"foo" forKey:@"bar9"];
[newMutableDictionary setObject:@"foo" forKey:@"bar10"];
[newMutableDictionary setObject:@"foo" forKey:@"bar11"];
[newMutableDictionary setObject:@"foo" forKey:@"bar12"];
[newMutableDictionary setObject:@"foo" forKey:@"bar13"];
[newMutableDictionary setObject:@"foo" forKey:@"bar14"];
[newMutableDictionary setObject:@"foo" forKey:@"bar15"];
[newMutableDictionary setObject:@"foo" forKey:@"bar16"];
[newMutableDictionary setObject:@"foo" forKey:@"bar17"];
[newMutableDictionary setObject:@"foo" forKey:@"bar18"];
[newMutableDictionary setObject:@"foo" forKey:@"bar19"];
[newMutableDictionary setObject:@"foo" forKey:@"bar20"];
NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary];
[attrString isEqual:nil];
NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary];
[mutableAttrString isEqual:nil];
NSString* mutableString = [[NSMutableString alloc] initWithString:@"foo"];
[mutableString insertString:@"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear " atIndex:0];
NSString* mutableGetConst = [NSString stringWithCString:[mutableString cString]];
[mutableGetConst length];
NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:4];
NSData *mutableData = [[NSMutableData alloc] initWithBytes:"NODATA" length:6];
[mutableData appendBytes:"MOREDATA" length:8];
[immutableData length];
[mutableData length];
NSSet* nsset = [[NSSet alloc] initWithObjects:str1,str2,str3,nil];
NSSet *nsmutableset = [[NSMutableSet alloc] initWithObjects:str1,str2,str3,nil];
[nsmutableset addObject:str4];
CFDataRef data_ref = CFDataCreate(kCFAllocatorDefault, [immutableData bytes], 5);
CFMutableDataRef mutable_data_ref = CFDataCreateMutable(kCFAllocatorDefault, 8);
CFDataAppendBytes(mutable_data_ref, [mutableData bytes], 5);
CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL,100);
CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew"));
CFStringRef cfstring_ref = CFSTR("HELLO WORLD");
CFSetRef set_ref = CFSetCreate(NULL, data_set, 3, NULL);
CFMutableSetRef mutable_set_ref = CFSetCreateMutable(NULL, 5, NULL);
CFSetAddValue(mutable_set_ref, str1);
CFSetAddValue(mutable_set_ref, str2);
CFSetAddValue(mutable_set_ref, str3);
CFSetAddValue(mutable_set_ref, str4);
CFSetAddValue(mutable_set_ref, str5);
CFSetAddValue(mutable_set_ref, str6);
CFSetAddValue(mutable_set_ref, str7);
CFSetAddValue(mutable_set_ref, str8);
CFSetAddValue(mutable_set_ref, str9);
CFSetAddValue(mutable_set_ref, str10);
CFSetAddValue(mutable_set_ref, str11);
CFSetAddValue(mutable_set_ref, str12);
CFDictionaryRef cfdict_ref = CFDictionaryCreate(NULL, data_set, data_set, 3, NULL, NULL);
CFMutableDictionaryRef mutable_dict_ref = CFDictionaryCreateMutable(NULL, 16, NULL, NULL);
CFDictionarySetValue(mutable_dict_ref, str1, str1);
CFDictionarySetValue(mutable_dict_ref, str2, str2);
CFDictionarySetValue(mutable_dict_ref, str3, str3);
CFDictionarySetValue(mutable_dict_ref, str4, str1);
CFDictionarySetValue(mutable_dict_ref, str5, str2);
CFDictionarySetValue(mutable_dict_ref, str6, str3);
CFDictionarySetValue(mutable_dict_ref, str7, str1);
CFDictionarySetValue(mutable_dict_ref, str8, str2);
CFDictionarySetValue(mutable_dict_ref, str9, str3);
CFDictionarySetValue(mutable_dict_ref, str10, str1);
CFDictionarySetValue(mutable_dict_ref, str11, str2);
CFDictionarySetValue(mutable_dict_ref, str12, str3);
CFArrayRef cfarray_ref = CFArrayCreate(NULL, data_set, 3, NULL);
CFMutableArrayRef mutable_array_ref = CFArrayCreateMutable(NULL, 16, NULL);
CFArraySetValueAtIndex(mutable_array_ref, 0, str1);
CFArraySetValueAtIndex(mutable_array_ref, 1, str2);
CFArraySetValueAtIndex(mutable_array_ref, 2, str3);
CFArraySetValueAtIndex(mutable_array_ref, 3, str4);
CFArraySetValueAtIndex(mutable_array_ref, 0, str5); // replacing value at 0!!
CFArraySetValueAtIndex(mutable_array_ref, 4, str6);
CFArraySetValueAtIndex(mutable_array_ref, 5, str7);
CFArraySetValueAtIndex(mutable_array_ref, 6, str8);
CFArraySetValueAtIndex(mutable_array_ref, 7, str9);
CFArraySetValueAtIndex(mutable_array_ref, 8, str10);
CFArraySetValueAtIndex(mutable_array_ref, 9, str11);
CFArraySetValueAtIndex(mutable_array_ref, 10, str12);
CFMutableBagRef mutable_bag_ref = CFBagCreateMutable(NULL, 15, NULL);
CFBagSetValue(mutable_bag_ref, strB10);
CFBagSetValue(mutable_bag_ref, str1);
CFBagSetValue(mutable_bag_ref, str2);
CFBagSetValue(mutable_bag_ref, str3);
CFBagSetValue(mutable_bag_ref, str4);
CFBagSetValue(mutable_bag_ref, str5);
CFBagSetValue(mutable_bag_ref, str6);
CFBagSetValue(mutable_bag_ref, str7);
CFBagSetValue(mutable_bag_ref, str8);
CFBagSetValue(mutable_bag_ref, str9);
CFBagSetValue(mutable_bag_ref, str10);
CFBagSetValue(mutable_bag_ref, str11);
CFBagSetValue(mutable_bag_ref, str12);
CFBagSetValue(mutable_bag_ref, strA1);
CFBagSetValue(mutable_bag_ref, strA2);
CFBagSetValue(mutable_bag_ref, strA3);
CFBagRef cfbag_ref = CFBagCreateCopy(NULL, mutable_bag_ref);
CFBagSetValue(mutable_bag_ref, strB8);
CFBagSetValue(mutable_bag_ref, strC4);
CFBinaryHeapRef binheap_ref = CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL);
CFBinaryHeapAddValue(binheap_ref, str1);
CFBinaryHeapAddValue(binheap_ref, str2);
CFBinaryHeapAddValue(binheap_ref, str3);
CFBinaryHeapAddValue(binheap_ref, str4);
CFBinaryHeapAddValue(binheap_ref, str5);
CFBinaryHeapAddValue(binheap_ref, str6);
CFBinaryHeapAddValue(binheap_ref, str7);
CFBinaryHeapAddValue(binheap_ref, str8);
CFBinaryHeapAddValue(binheap_ref, str9);
CFBinaryHeapAddValue(binheap_ref, str10);
CFBinaryHeapAddValue(binheap_ref, str11);
CFBinaryHeapAddValue(binheap_ref, str12);
CFBinaryHeapAddValue(binheap_ref, strA1);
CFBinaryHeapAddValue(binheap_ref, strB1);
CFBinaryHeapAddValue(binheap_ref, strC1);
CFBinaryHeapAddValue(binheap_ref, strA11);
CFBinaryHeapAddValue(binheap_ref, strB11);
CFBinaryHeapAddValue(binheap_ref, strC11);
CFBinaryHeapAddValue(binheap_ref, strB12);
CFBinaryHeapAddValue(binheap_ref, strC12);
CFBinaryHeapAddValue(binheap_ref, strA12);
CFURLRef cfurl_ref = CFURLCreateWithString(NULL, CFSTR("http://www.foo.bar/"), NULL);
CFURLRef cfchildurl_ref = CFURLCreateWithString(NULL, CFSTR("page.html"), cfurl_ref);
CFURLRef cfgchildurl_ref = CFURLCreateWithString(NULL, CFSTR("?whatever"), cfchildurl_ref);
NSBundle* bundle_string = [[NSBundle alloc] initWithPath:@"/System/Library/Frameworks/Accelerate.framework"];
NSBundle* bundle_url = [[NSBundle alloc] initWithURL:[[NSURL alloc] initWithString:@"file://localhost/System/Library/Frameworks/Cocoa.framework"]];
NSBundle* main_bundle = [NSBundle mainBundle];
NSArray* bundles = [NSBundle allBundles];
NSURL *nsurl0;
for (NSBundle* bundle in bundles)
{
nsurl0 = [bundle bundleURL];
}
NSException* except0 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName" reason:@"cuz it's funny" userInfo:nil];
NSException* except1 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName~1" reason:@"cuz it's funny" userInfo:nil];
NSException* except2 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" reason:@"cuz it's funny" userInfo:nil];
NSException* except3 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" reason:@"cuz it's funny" userInfo:nil];
NSMachPort *port = [NSMachPort port];
NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"];
NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl];
NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2];
CFGregorianUnits cf_greg_units = {1,3,5,12,5,7};
CFRange cf_range = {4,4};
NSPoint ns_point = {4,4};
NSRange ns_range = {4,4};
NSRect ns_rect = {{1,1},{5,5}};
NSRect* ns_rect_ptr = &ns_rect;
NSRectArray ns_rect_arr = &ns_rect;
NSSize ns_size = {5,7};