main.m revision 9abbfba957db139beed19866f61599424ddcd37a
1//===-- main.m ------------------------------------------------*- ObjC -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#import <Foundation/Foundation.h> 11#include <Carbon/Carbon.h> 12 13@interface MyClass : NSObject 14{ 15 int i; 16 char c; 17 float f; 18} 19 20- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z; 21- (int)doIncrementByInt: (int)x; 22 23@end 24 25@interface MyOtherClass : MyClass 26{ 27 int i2; 28 MyClass *backup; 29} 30- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q; 31 32@end 33 34@implementation MyClass 35 36- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z 37{ 38 self = [super init]; 39 if (self) { 40 self->i = x; 41 self->f = y; 42 self->c = z; 43 } 44 return self; 45} 46 47- (int)doIncrementByInt: (int)x 48{ 49 self->i += x; 50 return self->i; 51} 52 53@end 54 55@implementation MyOtherClass 56 57- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q 58{ 59 self = [super initWithInt:x andFloat:y andChar:z]; 60 if (self) { 61 self->i2 = q; 62 self->backup = [[MyClass alloc] initWithInt:x andFloat:y andChar:z]; 63 } 64 return self; 65} 66 67@end 68 69@interface Atom : NSObject { 70 float mass; 71} 72-(void)setMass:(float)newMass; 73-(float)mass; 74@end 75 76@interface Molecule : NSObject { 77 NSArray *atoms; 78} 79-(void)setAtoms:(NSArray *)newAtoms; 80-(NSArray *)atoms; 81@end 82 83@implementation Atom 84 85-(void)setMass:(float)newMass 86{ 87 mass = newMass; 88} 89-(float)mass 90{ 91 return mass; 92} 93 94@end 95 96@implementation Molecule 97 98-(void)setAtoms:(NSArray *)newAtoms 99{ 100 atoms = newAtoms; 101} 102-(NSArray *)atoms 103{ 104 return atoms; 105} 106@end 107 108@interface My_KVO_Observer : NSObject 109-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change 110 context:(void *)context; 111- (id) init; 112- (void) dealloc; 113@end 114 115@implementation My_KVO_Observer 116-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change 117 context:(void *)context { 118 // we do not really care about KVO'ing - do nothing 119 return; 120} 121- (id) init 122{ 123 self = [super init]; 124 return self; 125} 126 127- (void) dealloc 128{ 129 [super dealloc]; 130} 131@end 132 133int main (int argc, const char * argv[]) 134{ 135 136 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 137 138 MyClass *object = [[MyClass alloc] initWithInt:1 andFloat:3.14 andChar: 'E']; 139 140 [object doIncrementByInt:3]; 141 142 MyOtherClass *object2 = [[MyOtherClass alloc] initWithInt:2 andFloat:6.28 andChar: 'G' andOtherInt:-1]; 143 144 [object2 doIncrementByInt:3]; 145 146 NSNumber* num1 = [NSNumber numberWithInt:5]; 147 NSNumber* num2 = [NSNumber numberWithFloat:3.14]; 148 NSNumber* num3 = [NSNumber numberWithDouble:3.14]; 149 NSNumber* num4 = [NSNumber numberWithUnsignedLongLong:0xFFFFFFFFFFFFFFFE]; 150 NSNumber* num5 = [NSNumber numberWithChar:'A']; 151 NSNumber* num6 = [NSNumber numberWithUnsignedLongLong:0xFF]; 152 NSNumber* num7 = [NSNumber numberWithLong:0x1E8480]; 153 NSNumber* num8_Y = [NSNumber numberWithBool:YES]; 154 NSNumber* num8_N = [NSNumber numberWithBool:NO]; 155 NSNumber* num9 = [NSNumber numberWithShort:0x1E8480]; 156 NSNumber* num_at1 = @12; 157 NSNumber* num_at2 = @-12; 158 NSNumber* num_at3 = @12.5; 159 NSNumber* num_at4 = @-12.5; 160 161 NSDecimalNumber* decimal_one = [NSDecimalNumber one]; 162 163 NSString *str0 = [num6 stringValue]; 164 165 NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; 166 167 NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; 168 169 NSString *str3 = @"A string made with the at sign is here"; 170 171 NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; 172 173 NSRect ns_rect_4str = {{1,1},{5,5}}; 174 175 NSString* str5 = NSStringFromRect(ns_rect_4str); 176 177 NSString* str6 = [@"/usr/doc/README.1ST" pathExtension]; 178 179 const unichar myCharacters[] = {0x03C3,'x','x'}; 180 NSString *str7 = [NSString stringWithCharacters: myCharacters 181 length: sizeof myCharacters / sizeof *myCharacters]; 182 183 NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; 184 185 const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ', 186 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k', 187 ' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 188 't','h','i','s',' ','w','a','y','!','!',0x03C3, 0}; 189 NSString *str9 = [NSString stringWithCharacters: myOtherCharacters 190 length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; 191 192 const unichar myNextCharacters[] = {0x03C3, 0x0000}; 193 194 NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; 195 196 NSString *str11 = [str10 className]; 197 198 NSString *label1 = @"Process Name: "; 199 NSString *label2 = @"Process Id: "; 200 NSString *processName = [[NSProcessInfo processInfo] processName]; 201 NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]]; 202 NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 203 204 NSString *strA1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; 205 206 NSString *strA2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; 207 208 NSString *strA3 = @"A string made with the at sign is here"; 209 210 NSString *strA4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; 211 212 NSString* strA5 = NSStringFromRect(ns_rect_4str); 213 214 NSString* strA6 = [@"/usr/doc/README.1ST" pathExtension]; 215 216 NSString *strA7 = [NSString stringWithCharacters: myCharacters 217 length: sizeof myCharacters / sizeof *myCharacters]; 218 219 NSString* strA8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; 220 221 NSString *strA9 = [NSString stringWithCharacters: myOtherCharacters 222 length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; 223 224 NSString *strA10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; 225 226 NSString *strA11 = [str10 className]; 227 228 NSString *strA12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 229 230 NSString *strB1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; 231 232 NSString *strB2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; 233 234 NSString *strB3 = @"A string made with the at sign is here"; 235 236 NSString *strB4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; 237 238 NSString* strB5 = NSStringFromRect(ns_rect_4str); 239 240 NSString* strB6 = [@"/usr/doc/README.1ST" pathExtension]; 241 242 NSString *strB7 = [NSString stringWithCharacters: myCharacters 243 length: sizeof myCharacters / sizeof *myCharacters]; 244 245 NSString* strB8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; 246 247 NSString *strB9 = [NSString stringWithCharacters: myOtherCharacters 248 length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; 249 250 NSString *strB10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; 251 252 NSString *strB11 = [str10 className]; 253 254 NSString *strB12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 255 256 NSString *strC11 = [str10 className]; 257 258 NSString *strC12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 259 260 NSString *strC1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding]; 261 262 NSString *strC2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"]; 263 264 NSString *strC3 = @"A string made with the at sign is here"; 265 266 NSString *strC4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4]; 267 268 NSString* strC5 = NSStringFromRect(ns_rect_4str); 269 270 NSString* strC6 = [@"/usr/doc/README.1ST" pathExtension]; 271 272 NSString *strC7 = [NSString stringWithCharacters: myCharacters 273 length: sizeof myCharacters / sizeof *myCharacters]; 274 275 NSString* strC8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension]; 276 277 NSString *strC9 = [NSString stringWithCharacters: myOtherCharacters 278 length: sizeof myOtherCharacters / sizeof *myOtherCharacters]; 279 280 NSString *strC10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4]; 281 282 NSString *strD11 = [str10 className]; 283 284 NSString *strD12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID]; 285 286 NSString *eAcute = [NSString stringWithFormat: @"%C", 0x00E9]; 287 NSString *randomHaziChar = [NSString stringWithFormat: @"%C", 0x9DC5]; 288 NSString *japanese = @"色は匂へど散りぬるを"; 289 NSString *italian = @"L'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione."; 290 NSString* french = @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?"; 291 NSString* german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt"; 292 293 void* data_set[3] = {str1,str2,str3}; 294 295 NSString *hebrew = [NSString stringWithString:@"לילה טוב"]; 296 297 NSArray* newArray = [[NSMutableArray alloc] init]; 298 [newArray addObject:str1]; 299 [newArray addObject:str2]; 300 [newArray addObject:str3]; 301 [newArray addObject:str4]; 302 [newArray addObject:str5]; 303 [newArray addObject:str6]; 304 [newArray addObject:str7]; 305 [newArray addObject:str8]; 306 [newArray addObject:str9]; 307 [newArray addObject:str10]; 308 [newArray addObject:str11]; 309 [newArray addObject:str12]; 310 [newArray addObject:strA1]; 311 [newArray addObject:strA2]; 312 [newArray addObject:strA3]; 313 [newArray addObject:strA4]; 314 [newArray addObject:strA5]; 315 [newArray addObject:strA6]; 316 [newArray addObject:strA7]; 317 [newArray addObject:strA8]; 318 [newArray addObject:strA9]; 319 [newArray addObject:strA10]; 320 [newArray addObject:strA11]; 321 [newArray addObject:strA12]; 322 [newArray addObject:strB1]; 323 [newArray addObject:strB2]; 324 [newArray addObject:strB3]; 325 [newArray addObject:strB4]; 326 [newArray addObject:strB5]; 327 [newArray addObject:strB6]; 328 [newArray addObject:strB7]; 329 [newArray addObject:strB8]; 330 [newArray addObject:strB9]; 331 [newArray addObject:strB10]; 332 [newArray addObject:strB11]; 333 [newArray addObject:strB12]; 334 [newArray addObject:strC1]; 335 [newArray addObject:strC2]; 336 [newArray addObject:strC3]; 337 [newArray addObject:strC4]; 338 [newArray addObject:strC5]; 339 [newArray addObject:strC6]; 340 [newArray addObject:strC7]; 341 [newArray addObject:strC8]; 342 [newArray addObject:strC9]; 343 [newArray addObject:strC10]; 344 [newArray addObject:strC11]; 345 [newArray addObject:strC12]; 346 [newArray addObject:strD11]; 347 [newArray addObject:strD12]; 348 349 NSDictionary* newDictionary = [[NSDictionary alloc] initWithObjects:newArray forKeys:newArray]; 350 NSDictionary *newMutableDictionary = [[NSMutableDictionary alloc] init]; 351 [newMutableDictionary setObject:@"foo" forKey:@"bar0"]; 352 [newMutableDictionary setObject:@"foo" forKey:@"bar1"]; 353 [newMutableDictionary setObject:@"foo" forKey:@"bar2"]; 354 [newMutableDictionary setObject:@"foo" forKey:@"bar3"]; 355 [newMutableDictionary setObject:@"foo" forKey:@"bar4"]; 356 [newMutableDictionary setObject:@"foo" forKey:@"bar5"]; 357 [newMutableDictionary setObject:@"foo" forKey:@"bar6"]; 358 [newMutableDictionary setObject:@"foo" forKey:@"bar7"]; 359 [newMutableDictionary setObject:@"foo" forKey:@"bar8"]; 360 [newMutableDictionary setObject:@"foo" forKey:@"bar9"]; 361 [newMutableDictionary setObject:@"foo" forKey:@"bar10"]; 362 [newMutableDictionary setObject:@"foo" forKey:@"bar11"]; 363 [newMutableDictionary setObject:@"foo" forKey:@"bar12"]; 364 [newMutableDictionary setObject:@"foo" forKey:@"bar13"]; 365 [newMutableDictionary setObject:@"foo" forKey:@"bar14"]; 366 [newMutableDictionary setObject:@"foo" forKey:@"bar15"]; 367 [newMutableDictionary setObject:@"foo" forKey:@"bar16"]; 368 [newMutableDictionary setObject:@"foo" forKey:@"bar17"]; 369 [newMutableDictionary setObject:@"foo" forKey:@"bar18"]; 370 [newMutableDictionary setObject:@"foo" forKey:@"bar19"]; 371 [newMutableDictionary setObject:@"foo" forKey:@"bar20"]; 372 373 NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary]; 374 [attrString isEqual:nil]; 375 NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:newDictionary]; 376 [mutableAttrString isEqual:nil]; 377 378 NSString* mutableString = [[NSMutableString alloc] initWithString:@"foo"]; 379 [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]; 380 381 NSString* mutableGetConst = [NSString stringWithCString:[mutableString cString]]; 382 383 [mutableGetConst length]; 384 385 NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:4]; 386 NSData *mutableData = [[NSMutableData alloc] initWithBytes:"NODATA" length:6]; 387 388 [mutableData appendBytes:"MOREDATA" length:8]; 389 390 [immutableData length]; 391 [mutableData length]; 392 393 NSSet* nsset = [[NSSet alloc] initWithObjects:str1,str2,str3,nil]; 394 NSSet *nsmutableset = [[NSMutableSet alloc] initWithObjects:str1,str2,str3,nil]; 395 [nsmutableset addObject:str4]; 396 397 CFDataRef data_ref = CFDataCreate(kCFAllocatorDefault, [immutableData bytes], 5); 398 399 CFMutableDataRef mutable_data_ref = CFDataCreateMutable(kCFAllocatorDefault, 8); 400 CFDataAppendBytes(mutable_data_ref, [mutableData bytes], 5); 401 402 CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL,100); 403 CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew")); 404 405 CFStringRef cfstring_ref = CFSTR("HELLO WORLD"); 406 407 408 CFSetRef set_ref = CFSetCreate(NULL, data_set, 3, NULL); 409 410 CFMutableSetRef mutable_set_ref = CFSetCreateMutable(NULL, 5, NULL); 411 412 CFSetAddValue(mutable_set_ref, str1); 413 CFSetAddValue(mutable_set_ref, str2); 414 CFSetAddValue(mutable_set_ref, str3); 415 CFSetAddValue(mutable_set_ref, str4); 416 CFSetAddValue(mutable_set_ref, str5); 417 CFSetAddValue(mutable_set_ref, str6); 418 CFSetAddValue(mutable_set_ref, str7); 419 CFSetAddValue(mutable_set_ref, str8); 420 CFSetAddValue(mutable_set_ref, str9); 421 CFSetAddValue(mutable_set_ref, str10); 422 CFSetAddValue(mutable_set_ref, str11); 423 CFSetAddValue(mutable_set_ref, str12); 424 425 426 CFDictionaryRef cfdict_ref = CFDictionaryCreate(NULL, data_set, data_set, 3, NULL, NULL); 427 CFMutableDictionaryRef mutable_dict_ref = CFDictionaryCreateMutable(NULL, 16, NULL, NULL); 428 429 CFDictionarySetValue(mutable_dict_ref, str1, str1); 430 CFDictionarySetValue(mutable_dict_ref, str2, str2); 431 CFDictionarySetValue(mutable_dict_ref, str3, str3); 432 CFDictionarySetValue(mutable_dict_ref, str4, str1); 433 CFDictionarySetValue(mutable_dict_ref, str5, str2); 434 CFDictionarySetValue(mutable_dict_ref, str6, str3); 435 CFDictionarySetValue(mutable_dict_ref, str7, str1); 436 CFDictionarySetValue(mutable_dict_ref, str8, str2); 437 CFDictionarySetValue(mutable_dict_ref, str9, str3); 438 CFDictionarySetValue(mutable_dict_ref, str10, str1); 439 CFDictionarySetValue(mutable_dict_ref, str11, str2); 440 CFDictionarySetValue(mutable_dict_ref, str12, str3); 441 442 CFArrayRef cfarray_ref = CFArrayCreate(NULL, data_set, 3, NULL); 443 CFMutableArrayRef mutable_array_ref = CFArrayCreateMutable(NULL, 16, NULL); 444 445 CFArraySetValueAtIndex(mutable_array_ref, 0, str1); 446 CFArraySetValueAtIndex(mutable_array_ref, 1, str2); 447 CFArraySetValueAtIndex(mutable_array_ref, 2, str3); 448 CFArraySetValueAtIndex(mutable_array_ref, 3, str4); 449 CFArraySetValueAtIndex(mutable_array_ref, 0, str5); // replacing value at 0!! 450 CFArraySetValueAtIndex(mutable_array_ref, 4, str6); 451 CFArraySetValueAtIndex(mutable_array_ref, 5, str7); 452 CFArraySetValueAtIndex(mutable_array_ref, 6, str8); 453 CFArraySetValueAtIndex(mutable_array_ref, 7, str9); 454 CFArraySetValueAtIndex(mutable_array_ref, 8, str10); 455 CFArraySetValueAtIndex(mutable_array_ref, 9, str11); 456 CFArraySetValueAtIndex(mutable_array_ref, 10, str12); 457 458 CFMutableBagRef mutable_bag_ref = CFBagCreateMutable(NULL, 15, NULL); 459 460 CFBagSetValue(mutable_bag_ref, strB10); 461 CFBagSetValue(mutable_bag_ref, str1); 462 CFBagSetValue(mutable_bag_ref, str2); 463 CFBagSetValue(mutable_bag_ref, str3); 464 CFBagSetValue(mutable_bag_ref, str4); 465 CFBagSetValue(mutable_bag_ref, str5); 466 CFBagSetValue(mutable_bag_ref, str6); 467 CFBagSetValue(mutable_bag_ref, str7); 468 CFBagSetValue(mutable_bag_ref, str8); 469 CFBagSetValue(mutable_bag_ref, str9); 470 CFBagSetValue(mutable_bag_ref, str10); 471 CFBagSetValue(mutable_bag_ref, str11); 472 CFBagSetValue(mutable_bag_ref, str12); 473 CFBagSetValue(mutable_bag_ref, strA1); 474 CFBagSetValue(mutable_bag_ref, strA2); 475 CFBagSetValue(mutable_bag_ref, strA3); 476 477 CFBagRef cfbag_ref = CFBagCreateCopy(NULL, mutable_bag_ref); 478 479 CFBagSetValue(mutable_bag_ref, strB8); 480 CFBagSetValue(mutable_bag_ref, strC4); 481 482 483 CFBinaryHeapRef binheap_ref = CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL); 484 CFBinaryHeapAddValue(binheap_ref, str1); 485 CFBinaryHeapAddValue(binheap_ref, str2); 486 CFBinaryHeapAddValue(binheap_ref, str3); 487 CFBinaryHeapAddValue(binheap_ref, str4); 488 CFBinaryHeapAddValue(binheap_ref, str5); 489 CFBinaryHeapAddValue(binheap_ref, str6); 490 CFBinaryHeapAddValue(binheap_ref, str7); 491 CFBinaryHeapAddValue(binheap_ref, str8); 492 CFBinaryHeapAddValue(binheap_ref, str9); 493 CFBinaryHeapAddValue(binheap_ref, str10); 494 CFBinaryHeapAddValue(binheap_ref, str11); 495 CFBinaryHeapAddValue(binheap_ref, str12); 496 CFBinaryHeapAddValue(binheap_ref, strA1); 497 CFBinaryHeapAddValue(binheap_ref, strB1); 498 CFBinaryHeapAddValue(binheap_ref, strC1); 499 CFBinaryHeapAddValue(binheap_ref, strA11); 500 CFBinaryHeapAddValue(binheap_ref, strB11); 501 CFBinaryHeapAddValue(binheap_ref, strC11); 502 CFBinaryHeapAddValue(binheap_ref, strB12); 503 CFBinaryHeapAddValue(binheap_ref, strC12); 504 CFBinaryHeapAddValue(binheap_ref, strA12); 505 506 CFURLRef cfurl_ref = CFURLCreateWithString(NULL, CFSTR("http://www.foo.bar/"), NULL); 507 CFURLRef cfchildurl_ref = CFURLCreateWithString(NULL, CFSTR("page.html"), cfurl_ref); 508 CFURLRef cfgchildurl_ref = CFURLCreateWithString(NULL, CFSTR("?whatever"), cfchildurl_ref); 509 510 NSBundle* bundle_string = [[NSBundle alloc] initWithPath:@"/System/Library/Frameworks/Accelerate.framework"]; 511 NSBundle* bundle_url = [[NSBundle alloc] initWithURL:[[NSURL alloc] initWithString:@"file://localhost/System/Library/Frameworks/Cocoa.framework"]]; 512 513 NSBundle* main_bundle = [NSBundle mainBundle]; 514 515 NSArray* bundles = [NSBundle allBundles]; 516 517 NSURL *nsurl0; 518 519 for (NSBundle* bundle in bundles) 520 { 521 nsurl0 = [bundle bundleURL]; 522 } 523 524 NSException* except0 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName" reason:@"cuz it's funny" userInfo:nil]; 525 NSException* except1 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName~1" reason:@"cuz it's funny" userInfo:nil]; 526 NSException* except2 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2" reason:@"cuz it's funny" userInfo:nil]; 527 NSException* except3 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3" reason:@"cuz it's funny" userInfo:nil]; 528 529 NSMachPort *port = [NSMachPort port]; 530 531 NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"]; 532 NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl]; 533 NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2]; 534 535 NSDate *date1 = [NSDate dateWithNaturalLanguageString:@"6pm April 10, 1985"]; 536 NSDate *date2 = [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"]; 537 NSDate *date3 = [NSDate date]; 538 NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24*60*60]; 539 540 CFAbsoluteTime date1_abs = CFDateGetAbsoluteTime(date1); 541 CFAbsoluteTime date2_abs = CFDateGetAbsoluteTime(date2); 542 CFAbsoluteTime date3_abs = CFDateGetAbsoluteTime(date3); 543 CFAbsoluteTime date4_abs = CFDateGetAbsoluteTime(date4); 544 545 NSCountedSet *nscounted_set = [[NSCountedSet alloc] initWithCapacity:5]; 546 547 [nscounted_set addObject:str0]; 548 [nscounted_set addObject:str1]; 549 [nscounted_set addObject:str0]; 550 [nscounted_set addObject:str0]; 551 [nscounted_set addObject:@"foo1"]; 552 [nscounted_set addObject:@"foo2"]; 553 [nscounted_set addObject:@"foo3"]; 554 555 NSIndexSet *iset1 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 4)]; 556 NSIndexSet *iset2 = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 512)]; 557 558 NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init]; 559 [imset addIndex:4]; 560 [imset addIndex:7]; 561 [imset addIndex:9]; 562 [imset addIndex:11]; 563 [imset addIndex:24]; 564 [imset addIndex:41]; 565 [imset addIndex:58]; 566 [imset addIndex:61]; 567 [imset addIndex:62]; 568 [imset addIndex:63]; 569 570 CFTimeZoneRef cupertino = CFTimeZoneCreateWithName ( 571 NULL, 572 CFSTR("PST"), 573 YES); 574 CFTimeZoneRef home = CFTimeZoneCreateWithName ( 575 NULL, 576 CFSTR("Europe/Rome"), 577 YES); 578 CFTimeZoneRef europe = CFTimeZoneCreateWithName ( 579 NULL, 580 CFSTR("CET"), 581 YES); 582 583 NSTimeZone *cupertino_ns = [NSTimeZone timeZoneWithAbbreviation:@"PST"]; 584 NSTimeZone *home_ns = [NSTimeZone timeZoneWithName:@"Europe/Rome"]; 585 NSTimeZone *europe_ns = [NSTimeZone timeZoneWithAbbreviation:@"CET"]; 586 587 NSHost *localhost = [NSHost hostWithAddress:@"127.0.0.1"]; 588 589 NSTask *my_task = [[NSTask alloc] init]; 590 591 592 CFGregorianUnits cf_greg_units = {1,3,5,12,5,7}; 593 CFGregorianDate cf_greg_date = CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime(date1), NULL); 594 CFRange cf_range = {4,4}; 595 NSPoint ns_point = {4,4}; 596 NSRange ns_range = {4,4}; 597 598 NSValue *range_value = [NSValue valueWithRange:ns_range]; 599 600 NSRect ns_rect = {{1,1},{5,5}}; 601 NSRect* ns_rect_ptr = &ns_rect; 602 NSRectArray ns_rect_arr = &ns_rect; 603 NSSize ns_size = {5,7}; 604 NSSize* ns_size_ptr = &ns_size; 605 606 CGSize cg_size = {1,6}; 607 CGPoint cg_point = {2,7}; 608 CGRect cg_rect = {{1,2}, {7,7}}; 609 610 RGBColor rgb_color = {3,56,35}; 611 RGBColor* rgb_color_ptr = &rgb_color; 612 613 Rect rect = {4,8,4,7}; 614 Rect* rect_ptr = ▭ 615 616 Point point = {7,12}; 617 Point* point_ptr = &point; 618 619 HIPoint hi_point = {7,12}; 620 HIRect hi_rect = {{3,5},{4,6}}; 621 622 SEL foo_selector = @selector(foo_selector_impl); 623 624 CFMutableBitVectorRef mut_bv = CFBitVectorCreateMutable(NULL, 64); 625 CFBitVectorSetCount(mut_bv, 50); 626 CFBitVectorSetBitAtIndex(mut_bv, 0, 1); 627 CFBitVectorSetBitAtIndex(mut_bv, 1, 1); 628 CFBitVectorSetBitAtIndex(mut_bv, 2, 1); 629 CFBitVectorSetBitAtIndex(mut_bv, 5, 1); 630 CFBitVectorSetBitAtIndex(mut_bv, 6, 1); 631 CFBitVectorSetBitAtIndex(mut_bv, 8, 1); 632 CFBitVectorSetBitAtIndex(mut_bv, 10, 1); 633 CFBitVectorSetBitAtIndex(mut_bv, 11, 1); 634 CFBitVectorSetBitAtIndex(mut_bv, 16, 1); 635 CFBitVectorSetBitAtIndex(mut_bv, 17, 1); 636 CFBitVectorSetBitAtIndex(mut_bv, 19, 1); 637 CFBitVectorSetBitAtIndex(mut_bv, 20, 1); 638 CFBitVectorSetBitAtIndex(mut_bv, 22, 1); 639 CFBitVectorSetBitAtIndex(mut_bv, 24, 1); 640 CFBitVectorSetBitAtIndex(mut_bv, 28, 1); 641 CFBitVectorSetBitAtIndex(mut_bv, 29, 1); 642 CFBitVectorSetBitAtIndex(mut_bv, 30, 1); 643 CFBitVectorSetBitAtIndex(mut_bv, 30, 1); 644 CFBitVectorSetBitAtIndex(mut_bv, 31, 1); 645 CFBitVectorSetBitAtIndex(mut_bv, 34, 1); 646 CFBitVectorSetBitAtIndex(mut_bv, 35, 1); 647 CFBitVectorSetBitAtIndex(mut_bv, 37, 1); 648 CFBitVectorSetBitAtIndex(mut_bv, 39, 1); 649 CFBitVectorSetBitAtIndex(mut_bv, 40, 1); 650 CFBitVectorSetBitAtIndex(mut_bv, 41, 1); 651 CFBitVectorSetBitAtIndex(mut_bv, 43, 1); 652 CFBitVectorSetBitAtIndex(mut_bv, 47, 1); 653 654 Molecule *molecule = [Molecule new]; 655 656 Class myclass = NSClassFromString(@"NSValue"); 657 Class myclass2 = [str0 class]; 658 Class myclass3 = [molecule class]; 659 Class myclass4 = NSClassFromString(@"NSMutableArray"); 660 Class myclass5 = [nil class]; 661 662 NSArray *components = @[@"usr", @"blah", @"stuff"]; 663 NSString *path = [NSString pathWithComponents: components]; 664 665 [molecule addObserver:[My_KVO_Observer new] forKeyPath:@"atoms" options:0 context:NULL]; // Set break point at this line. 666 [newMutableDictionary addObserver:[My_KVO_Observer new] forKeyPath:@"weirdKeyToKVO" options:NSKeyValueObservingOptionNew context:NULL]; 667 668 [molecule setAtoms:nil]; 669 [molecule setAtoms:[NSMutableArray new]]; 670 671 [pool drain]; 672 return 0; 673} 674 675