1#import <Foundation/Foundation.h>
2
3#if defined(__APPLE__)
4#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
5#define IOS
6#endif
7#endif
8
9#if defined(IOS)
10#import <Foundation/NSGeometry.h>
11#else
12#import <Carbon/Carbon.h>
13#endif
14
15@interface MyClass : NSObject {
16 int i;
17 char c;
18 float f;
19}
20
21- (id)initWithInt:(int)x andFloat:(float)y andChar:(char)z;
22- (int)doIncrementByInt:(int)x;
23
24@end
25
26@interface MyOtherClass : MyClass {
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 self = [super init];
38 if (self) {
39 self->i = x;
40 self->f = y;
41 self->c = z;
42 }
43 return self;
44}
45
46- (int)doIncrementByInt:(int)x {
47 self->i += x;
48 return self->i;
49}
50
51@end
52
53@implementation MyOtherClass
54
55- (id)initWithInt:(int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q {
56 self = [super initWithInt:x andFloat:y andChar:z];
57 if (self) {
58 self->i2 = q;
59 self->backup = [[MyClass alloc] initWithInt:x andFloat:y andChar:z];
60 }
61 return self;
62}
63
64@end
65
66@interface Atom : NSObject {
67 float mass;
68}
69- (void)setMass:(float)newMass;
70- (float)mass;
71@end
72
73@interface Molecule : NSObject {
74 NSArray *atoms;
75}
76- (void)setAtoms:(NSArray *)newAtoms;
77- (NSArray *)atoms;
78@end
79
80@implementation Atom
81
82- (void)setMass:(float)newMass {
83 mass = newMass;
84}
85- (float)mass {
86 return mass;
87}
88
89@end
90
91@implementation Molecule
92
93- (void)setAtoms:(NSArray *)newAtoms {
94 atoms = newAtoms;
95}
96- (NSArray *)atoms {
97 return atoms;
98}
99@end
100
101@interface My_KVO_Observer : NSObject
102- (void)observeValueForKeyPath:(NSString *)keyPath
103 ofObject:(id)object
104 change:(NSDictionary *)change
105 context:(void *)context;
106- (id)init;
107- (void)dealloc;
108@end
109
110@implementation My_KVO_Observer
111- (void)observeValueForKeyPath:(NSString *)keyPath
112 ofObject:(id)object
113 change:(NSDictionary *)change
114 context:(void *)context {
115 // we do not really care about KVO'ing - do nothing
116 return;
117}
118- (id)init {
119 self = [super init];
120 return self;
121}
122
123- (void)dealloc {
124 [super dealloc];
125}
126@end
127
128int main(int argc, const char *argv[]) {
129
130 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
131
132 MyClass *object = [[MyClass alloc] initWithInt:1 andFloat:3.14 andChar:'E'];
133
134 [object doIncrementByInt:3];
135
136 MyOtherClass *object2 = [[MyOtherClass alloc] initWithInt:2
137 andFloat:6.28
138 andChar:'G'
139 andOtherInt:-1];
140
141 [object2 doIncrementByInt:3];
142
143 NSNumber *num1 = [NSNumber numberWithInt:5];
144 NSNumber *num2 = [NSNumber numberWithFloat:3.14];
145 NSNumber *num3 = [NSNumber numberWithDouble:3.14];
146 NSNumber *num4 = [NSNumber numberWithUnsignedLongLong:0xFFFFFFFFFFFFFFFE];
147 NSNumber *num5 = [NSNumber numberWithChar:'A'];
148 NSNumber *num6 = [NSNumber numberWithUnsignedLongLong:0xFF];
149 NSNumber *num7 = [NSNumber numberWithLong:0x1E8480];
150 NSNumber *num8_Y = [NSNumber numberWithBool:YES];
151 NSNumber *num8_N = [NSNumber numberWithBool:NO];
152 NSNumber *num9 = [NSNumber numberWithShort:0x1E8480];
153 NSNumber *num_at1 = @12;
154 NSNumber *num_at2 = @-12;
155 NSNumber *num_at3 = @12.5;
156 NSNumber *num_at4 = @-12.5;
157 NSNumber *num_at5 = @'a';
158 NSNumber *num_at6 = @42.123f;
159 NSNumber *num_at7 = @43.123;
160 NSNumber *num_at8 = @12345ll;
161 NSNumber *num_at9 = @0xF1234567890abcdeull;
162 NSNumber *num_at9b = @-1070935975400915746;
163 NSNumber *num_at10 = @YES;
164 NSNumber *num_at11 = @NO;
165
166 NSDecimalNumber *decimal_number =
167 [NSDecimalNumber decimalNumberWithMantissa:123456
168 exponent:-10
169 isNegative:NO];
170 NSDecimalNumber *decimal_number_neg =
171 [NSDecimalNumber decimalNumberWithMantissa:123456
172 exponent:10
173 isNegative:YES];
174 NSDecimalNumber *decimal_one = [NSDecimalNumber one];
175 NSDecimalNumber *decimal_zero = [NSDecimalNumber zero];
176 NSDecimalNumber *decimal_nan = [NSDecimalNumber notANumber];
177
178 NSString *str0 = [num6 stringValue];
179
180 NSString *str1 =
181 [NSString stringWithCString:"A rather short ASCII NSString object is here"
182 encoding:NSASCIIStringEncoding];
183
184 NSString *str2 = [NSString
185 stringWithUTF8String:"A rather short UTF8 NSString object is here"];
186
187 NSString *str3 = @"A string made with the at sign is here";
188
189 NSString *str4 = [NSString
190 stringWithFormat:@"This is string number %ld right here", (long)4];
191
192 NSRect ns_rect_4str = {{1, 1}, {5, 5}};
193
194 NSString *str5 = NSStringFromRect(ns_rect_4str);
195
196 NSString *str6 = [@"/usr/doc/README.1ST" pathExtension];
197
198 const unichar myCharacters[] = {0x03C3, 'x', 'x'};
199 NSString *str7 = [NSString
200 stringWithCharacters:myCharacters
201 length:sizeof myCharacters / sizeof *myCharacters];
202
203 NSString *str8 =
204 [@"/usr/doc/"
205 @"file."
206 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
207 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
208 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
209 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
210 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
211 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
212 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
213 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
214 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
215 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
216 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
217 @"ensionThisTime" pathExtension];
218
219 const unichar myOtherCharacters[] = {
220 'a', ' ', 'v', 'e', 'r', 'y', ' ', 'm', 'u', 'c', 'h', ' ', 'b', 'o',
221 'r', 'i', 'n', 'g', ' ', 't', 'a', 's', 'k', ' ', 't', 'o', ' ', 'w',
222 'r', 'i', 't', 'e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
223 't', 'h', 'i', 's', ' ', 'w', 'a', 'y', '!', '!', 0x03C3, 0};
224 NSString *str9 = [NSString stringWithCharacters:myOtherCharacters
225 length:sizeof myOtherCharacters /
226 sizeof *myOtherCharacters];
227
228 const unichar myNextCharacters[] = {0x03C3, 0x0000};
229
230 NSString *str10 = [NSString
231 stringWithFormat:@"This is a Unicode string %S number %ld right here",
232 myNextCharacters, (long)4];
233
234 NSString *str11 = NSStringFromClass([str10 class]);
235
236 NSString *label1 = @"Process Name: ";
237 NSString *label2 = @"Process Id: ";
238 NSString *processName = [[NSProcessInfo processInfo] processName];
239 NSString *processID = [NSString
240 stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]];
241 NSString *str12 = [NSString
242 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
243
244 NSString *strA1 =
245 [NSString stringWithCString:"A rather short ASCII NSString object is here"
246 encoding:NSASCIIStringEncoding];
247
248 NSString *strA2 = [NSString
249 stringWithUTF8String:"A rather short UTF8 NSString object is here"];
250
251 NSString *strA3 = @"A string made with the at sign is here";
252
253 NSString *strA4 = [NSString
254 stringWithFormat:@"This is string number %ld right here", (long)4];
255
256 NSString *strA5 = NSStringFromRect(ns_rect_4str);
257
258 NSString *strA6 = [@"/usr/doc/README.1ST" pathExtension];
259
260 NSString *strA7 = [NSString
261 stringWithCharacters:myCharacters
262 length:sizeof myCharacters / sizeof *myCharacters];
263
264 NSString *strA8 =
265 [@"/usr/doc/"
266 @"file."
267 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
268 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
269 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
270 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
271 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
272 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
273 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
274 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
275 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
276 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
277 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
278 @"ensionThisTime" pathExtension];
279
280 NSString *strA9 = [NSString stringWithCharacters:myOtherCharacters
281 length:sizeof myOtherCharacters /
282 sizeof *myOtherCharacters];
283
284 NSString *strA10 = [NSString
285 stringWithFormat:@"This is a Unicode string %S number %ld right here",
286 myNextCharacters, (long)4];
287
288 NSString *strA11 = NSStringFromClass([str10 class]);
289
290 NSString *strA12 = [NSString
291 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
292
293 NSString *strB1 =
294 [NSString stringWithCString:"A rather short ASCII NSString object is here"
295 encoding:NSASCIIStringEncoding];
296
297 NSString *strB2 = [NSString
298 stringWithUTF8String:"A rather short UTF8 NSString object is here"];
299
300 NSString *strB3 = @"A string made with the at sign is here";
301
302 NSString *strB4 = [NSString
303 stringWithFormat:@"This is string number %ld right here", (long)4];
304
305 NSString *strB5 = NSStringFromRect(ns_rect_4str);
306
307 NSString *strB6 = [@"/usr/doc/README.1ST" pathExtension];
308
309 NSString *strB7 = [NSString
310 stringWithCharacters:myCharacters
311 length:sizeof myCharacters / sizeof *myCharacters];
312
313 NSString *strB8 =
314 [@"/usr/doc/"
315 @"file."
316 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
317 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
318 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
319 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
320 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
321 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
322 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
323 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
324 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
325 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
326 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
327 @"ensionThisTime" pathExtension];
328
329 NSString *strB9 = [NSString stringWithCharacters:myOtherCharacters
330 length:sizeof myOtherCharacters /
331 sizeof *myOtherCharacters];
332
333 NSString *strB10 = [NSString
334 stringWithFormat:@"This is a Unicode string %S number %ld right here",
335 myNextCharacters, (long)4];
336
337 NSString *strB11 = NSStringFromClass([str10 class]);
338
339 NSString *strB12 = [NSString
340 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
341
342 NSString *strC11 = NSStringFromClass([str10 class]);
343
344 NSString *strC12 = [NSString
345 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
346
347 NSString *strC1 =
348 [NSString stringWithCString:"A rather short ASCII NSString object is here"
349 encoding:NSASCIIStringEncoding];
350
351 NSString *strC2 = [NSString
352 stringWithUTF8String:"A rather short UTF8 NSString object is here"];
353
354 NSString *strC3 = @"A string made with the at sign is here";
355
356 NSString *strC4 = [NSString
357 stringWithFormat:@"This is string number %ld right here", (long)4];
358
359 NSString *strC5 = NSStringFromRect(ns_rect_4str);
360
361 NSString *strC6 = [@"/usr/doc/README.1ST" pathExtension];
362
363 NSString *strC7 = [NSString
364 stringWithCharacters:myCharacters
365 length:sizeof myCharacters / sizeof *myCharacters];
366
367 NSString *strC8 =
368 [@"/usr/doc/"
369 @"file."
370 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
371 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
372 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
373 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
374 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
375 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
376 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
377 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
378 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
379 @"ensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime"
380 @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExt"
381 @"ensionThisTime" pathExtension];
382
383 NSString *strC9 = [NSString stringWithCharacters:myOtherCharacters
384 length:sizeof myOtherCharacters /
385 sizeof *myOtherCharacters];
386
387 NSString *strC10 = [NSString
388 stringWithFormat:@"This is a Unicode string %S number %ld right here",
389 myNextCharacters, (long)4];
390
391 NSString *strD11 = NSStringFromClass([str10 class]);
392
393 NSString *strD12 = [NSString
394 stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
395
396 NSString *eAcute = [NSString stringWithFormat:@"%C", 0x00E9];
397 NSString *randomHaziChar = [NSString stringWithFormat:@"%C", 0x9DC5];
398 NSString *japanese = @"色は匂へど散りぬるを";
399 NSString *italian = @"L'Italia è una Repubblica democratica, fondata sul "
400 @"lavoro. La sovranità appartiene al popolo, che la "
401 @"esercita nelle forme e nei limiti della Costituzione.";
402 NSString *french =
403 @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?";
404 NSString *german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt";
405
406 void *data_set[3] = {str1, str2, str3};
407
408 NSString *hebrew = [NSString stringWithString:@"לילה טוב"];
409
410 NSArray *newArray = [[NSMutableArray alloc] init];
411 [newArray addObject:str1];
412 [newArray addObject:str2];
413 [newArray addObject:str3];
414 [newArray addObject:str4];
415 [newArray addObject:str5];
416 [newArray addObject:str6];
417 [newArray addObject:str7];
418 [newArray addObject:str8];
419 [newArray addObject:str9];
420 [newArray addObject:str10];
421 [newArray addObject:str11];
422 [newArray addObject:str12];
423 [newArray addObject:strA1];
424 [newArray addObject:strA2];
425 [newArray addObject:strA3];
426 [newArray addObject:strA4];
427 [newArray addObject:strA5];
428 [newArray addObject:strA6];
429 [newArray addObject:strA7];
430 [newArray addObject:strA8];
431 [newArray addObject:strA9];
432 [newArray addObject:strA10];
433 [newArray addObject:strA11];
434 [newArray addObject:strA12];
435 [newArray addObject:strB1];
436 [newArray addObject:strB2];
437 [newArray addObject:strB3];
438 [newArray addObject:strB4];
439 [newArray addObject:strB5];
440 [newArray addObject:strB6];
441 [newArray addObject:strB7];
442 [newArray addObject:strB8];
443 [newArray addObject:strB9];
444 [newArray addObject:strB10];
445 [newArray addObject:strB11];
446 [newArray addObject:strB12];
447 [newArray addObject:strC1];
448 [newArray addObject:strC2];
449 [newArray addObject:strC3];
450 [newArray addObject:strC4];
451 [newArray addObject:strC5];
452 [newArray addObject:strC6];
453 [newArray addObject:strC7];
454 [newArray addObject:strC8];
455 [newArray addObject:strC9];
456 [newArray addObject:strC10];
457 [newArray addObject:strC11];
458 [newArray addObject:strC12];
459 [newArray addObject:strD11];
460 [newArray addObject:strD12];
461
462 NSDictionary *newDictionary = [[NSDictionary alloc] initWithObjects:newArray
463 forKeys:newArray];
464 NSDictionary *newMutableDictionary = [[NSMutableDictionary alloc] init];
465 [newMutableDictionary setObject:@"foo" forKey:@"bar0"];
466 [newMutableDictionary setObject:@"foo" forKey:@"bar1"];
467 [newMutableDictionary setObject:@"foo" forKey:@"bar2"];
468 [newMutableDictionary setObject:@"foo" forKey:@"bar3"];
469 [newMutableDictionary setObject:@"foo" forKey:@"bar4"];
470 [newMutableDictionary setObject:@"foo" forKey:@"bar5"];
471 [newMutableDictionary setObject:@"foo" forKey:@"bar6"];
472 [newMutableDictionary setObject:@"foo" forKey:@"bar7"];
473 [newMutableDictionary setObject:@"foo" forKey:@"bar8"];
474 [newMutableDictionary setObject:@"foo" forKey:@"bar9"];
475 [newMutableDictionary setObject:@"foo" forKey:@"bar10"];
476 [newMutableDictionary setObject:@"foo" forKey:@"bar11"];
477 [newMutableDictionary setObject:@"foo" forKey:@"bar12"];
478 [newMutableDictionary setObject:@"foo" forKey:@"bar13"];
479 [newMutableDictionary setObject:@"foo" forKey:@"bar14"];
480 [newMutableDictionary setObject:@"foo" forKey:@"bar15"];
481 [newMutableDictionary setObject:@"foo" forKey:@"bar16"];
482 [newMutableDictionary setObject:@"foo" forKey:@"bar17"];
483 [newMutableDictionary setObject:@"foo" forKey:@"bar18"];
484 [newMutableDictionary setObject:@"foo" forKey:@"bar19"];
485 [newMutableDictionary setObject:@"foo" forKey:@"bar20"];
486
487 /* Copying an NSMutableDictionary makes a different member of the
488 class cluster, so let's also make a copy of this one: */
489 NSMutableDictionary *copyDictionary = [newMutableDictionary copy];
490
491 CFMutableDictionaryRef newMutableDictionaryRef = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, newMutableDictionary);
492
493 id cfKeys[4] = {@"foo", @"bar", @"baz", @"quux"};
494 id cfValues[4] = {@"foo", @"bar", @"baz", @"quux"};
495 NSDictionary *nsDictionary = CFBridgingRelease(
496 CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 2, nil, nil));
497 NSDictionary *nscfDictionary = CFBridgingRelease(
498 CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 4, nil, nil));
499 CFDictionaryRef cfDictionaryRef = (__bridge CFDictionaryRef)nsDictionary;
500
501 NSAttributedString *attrString =
502 [[NSAttributedString alloc] initWithString:@"hello world from foo"
503 attributes:newDictionary];
504 [attrString isEqual:nil];
505 NSAttributedString *mutableAttrString =
506 [[NSMutableAttributedString alloc] initWithString:@"hello world from foo"
507 attributes:newDictionary];
508 [mutableAttrString isEqual:nil];
509
510 NSString *mutableString = [[NSMutableString alloc] initWithString:@"foo"];
511 [mutableString
512 insertString:
513 @"foo said this string needs to be very long so much longer than "
514 @"whatever other string has been seen ever before by anyone of the "
515 @"mankind that of course this is still not long enough given what "
516 @"foo our friend foo our lovely dearly friend foo desired of us so i "
517 @"am adding more stuff here for the sake of it and for the joy of "
518 @"our friend who is named guess what just foo. hence, dear friend "
519 @"foo, stay safe, your string is now long enough to accommodate "
520 @"your testing need and I will make sure that if not we extend it "
521 @"with even more fuzzy random meaningless words pasted one after the "
522 @"other from a long tiresome friday evening spent working in my "
523 @"office. my office mate went home but I am still randomly typing "
524 @"just for the fun of seeing what happens of the length of a Mutable "
525 @"String in Cocoa if it goes beyond one byte.. so be it, dear "
526 atIndex:0];
527
528 NSString *mutableGetConst =
529 [NSString stringWithCString:[mutableString cString]];
530
531 [mutableGetConst length];
532
533 NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:5];
534 NSData *mutableData = [[NSMutableData alloc] initWithBytes:"NODATA" length:6];
535
536 // No-copy versions of NSData initializers use NSConcreteData if over 2^16
537 // elements are specified.
538 unsigned concreteLength = 100000;
539 void *zeroes1 = calloc(1, concreteLength);
540 // initWithBytesNoCopy takes ownership of the buffer.
541 NSData *concreteData = [[NSData alloc] initWithBytesNoCopy:zeroes1
542 length:concreteLength];
543 void *zeroes2 = calloc(1, concreteLength);
544 NSMutableData *concreteMutableData =
545 [[NSMutableData alloc] initWithBytesNoCopy:zeroes2 length:concreteLength];
546
547 [mutableData appendBytes:"MOREDATA" length:8];
548
549 [immutableData length];
550 [mutableData length];
551
552 NSSet *nsset = [[NSSet alloc] initWithObjects:str1, str2, str3, nil];
553 NSSet *nsmutableset =
554 [[NSMutableSet alloc] initWithObjects:str1, str2, str3, nil];
555 [nsmutableset addObject:str4];
556 NSSet *nscfSet =
557 CFBridgingRelease(CFSetCreate(nil, (void *)cfValues, 2, nil));
558 CFSetRef cfSetRef = (__bridge CFSetRef)nscfSet;
559
560 CFDataRef data_ref =
561 CFDataCreate(kCFAllocatorDefault, [immutableData bytes], 5);
562
563 CFMutableDataRef mutable_data_ref =
564 CFDataCreateMutable(kCFAllocatorDefault, 8);
565 CFDataAppendBytes(mutable_data_ref, [mutableData bytes], 5);
566
567 CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL, 100);
568 CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew"));
569
570 CFStringRef cfstring_ref = CFSTR("HELLO WORLD");
571
572 CFArrayRef cfarray_ref = CFArrayCreate(NULL, data_set, 3, NULL);
573 CFMutableArrayRef mutable_array_ref = CFArrayCreateMutable(NULL, 16, NULL);
574
575 CFArraySetValueAtIndex(mutable_array_ref, 0, str1);
576 CFArraySetValueAtIndex(mutable_array_ref, 1, str2);
577 CFArraySetValueAtIndex(mutable_array_ref, 2, str3);
578 CFArraySetValueAtIndex(mutable_array_ref, 3, str4);
579 CFArraySetValueAtIndex(mutable_array_ref, 0, str5); // replacing value at 0!!
580 CFArraySetValueAtIndex(mutable_array_ref, 4, str6);
581 CFArraySetValueAtIndex(mutable_array_ref, 5, str7);
582 CFArraySetValueAtIndex(mutable_array_ref, 6, str8);
583 CFArraySetValueAtIndex(mutable_array_ref, 7, str9);
584 CFArraySetValueAtIndex(mutable_array_ref, 8, str10);
585 CFArraySetValueAtIndex(mutable_array_ref, 9, str11);
586 CFArraySetValueAtIndex(mutable_array_ref, 10, str12);
587
588 CFBinaryHeapRef binheap_ref =
589 CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL);
590 CFBinaryHeapAddValue(binheap_ref, str1);
591 CFBinaryHeapAddValue(binheap_ref, str2);
592 CFBinaryHeapAddValue(binheap_ref, str3);
593 CFBinaryHeapAddValue(binheap_ref, str4);
594 CFBinaryHeapAddValue(binheap_ref, str5);
595 CFBinaryHeapAddValue(binheap_ref, str6);
596 CFBinaryHeapAddValue(binheap_ref, str7);
597 CFBinaryHeapAddValue(binheap_ref, str8);
598 CFBinaryHeapAddValue(binheap_ref, str9);
599 CFBinaryHeapAddValue(binheap_ref, str10);
600 CFBinaryHeapAddValue(binheap_ref, str11);
601 CFBinaryHeapAddValue(binheap_ref, str12);
602 CFBinaryHeapAddValue(binheap_ref, strA1);
603 CFBinaryHeapAddValue(binheap_ref, strB1);
604 CFBinaryHeapAddValue(binheap_ref, strC1);
605 CFBinaryHeapAddValue(binheap_ref, strA11);
606 CFBinaryHeapAddValue(binheap_ref, strB11);
607 CFBinaryHeapAddValue(binheap_ref, strC11);
608 CFBinaryHeapAddValue(binheap_ref, strB12);
609 CFBinaryHeapAddValue(binheap_ref, strC12);
610 CFBinaryHeapAddValue(binheap_ref, strA12);
611
612 CFURLRef cfurl_ref =
613 CFURLCreateWithString(NULL, CFSTR("http://www.foo.bar/"), NULL);
614 CFURLRef cfchildurl_ref =
615 CFURLCreateWithString(NULL, CFSTR("page.html"), cfurl_ref);
616 CFURLRef cfgchildurl_ref =
617 CFURLCreateWithString(NULL, CFSTR("?whatever"), cfchildurl_ref);
618
619 NSDictionary *error_userInfo = @{@"a" : @1, @"b" : @2};
620 NSError *nserror = [[NSError alloc] initWithDomain:@"Foobar"
621 code:12
622 userInfo:error_userInfo];
623 NSError **nserrorptr = &nserror;
624
625 NSBundle *bundle_string = [[NSBundle alloc]
626 initWithPath:@"/System/Library/Frameworks/Accelerate.framework"];
627 NSBundle *bundle_url = [[NSBundle alloc]
628 initWithURL:[[NSURL alloc]
629 initWithString:@"file://localhost/System/Library/"
630 @"Frameworks/Foundation.framework"]];
631
632 NSBundle *main_bundle = [NSBundle mainBundle];
633
634 NSArray *bundles = [NSBundle allBundles];
635
636 NSURL *nsurl0;
637
638 for (NSBundle *bundle in bundles) {
639 nsurl0 = [bundle bundleURL];
640 }
641
642 NSException *except0 = [[NSException alloc] initWithName:@"TheGuyWhoHasNoName"
643 reason:@"First"
644 userInfo:nil];
645 NSException *except1 =
646 [[NSException alloc] initWithName:@"TheGuyWhoHasNoName~1"
647 reason:@"Second"
648 userInfo:nil];
649 NSException *except2 =
650 [[NSException alloc] initWithName:@"TheGuyWhoHasNoName`2"
651 reason:@"Third"
652 userInfo:nil];
653 NSException *except3 =
654 [[NSException alloc] initWithName:@"TheGuyWhoHasNoName/3"
655 reason:@"Fourth"
656 userInfo:nil];
657
658 NSURL *nsurl = [[NSURL alloc] initWithString:@"http://www.foo.bar"];
659 NSURL *nsurl2 = [NSURL URLWithString:@"page.html" relativeToURL:nsurl];
660 NSURL *nsurl3 = [NSURL URLWithString:@"?whatever" relativeToURL:nsurl2];
661
662 NSDate *date1 = [NSDate
663 dateWithTimeIntervalSince1970:133890 * 60 * 60]; // 6pm April 10, 1985 GMT
664 NSDate *date2 =
665 [NSDate dateWithNaturalLanguageString:@"12am January 1, 2011"];
666 NSDate *date3 = [NSDate date];
667 NSDate *date4 = [NSDate dateWithTimeIntervalSince1970:24 * 60 * 60];
668 NSDate *date5 =
669 [NSDate dateWithTimeIntervalSinceReferenceDate:
670 floor([[NSDate date] timeIntervalSinceReferenceDate])];
671
672 NSDate *date_1970_minus_06 = [NSDate dateWithTimeIntervalSince1970:-0.6];
673 NSDate *date_1970_minus_05 = [NSDate dateWithTimeIntervalSince1970:-0.5];
674 NSDate *date_1970_minus_04 = [NSDate dateWithTimeIntervalSince1970:-0.4];
675
676 NSDate *date_1970_plus_06 = [NSDate dateWithTimeIntervalSince1970:0.6];
677 NSDate *date_1970_plus_05 = [NSDate dateWithTimeIntervalSince1970:0.5];
678 NSDate *date_1970_plus_04 = [NSDate dateWithTimeIntervalSince1970:0.4];
679
680 NSDate *distant_past = [NSDate distantPast];
681 NSDate *distant_future = [NSDate distantFuture];
682
683 CFAbsoluteTime date1_abs = CFDateGetAbsoluteTime(date1);
684 CFAbsoluteTime date2_abs = CFDateGetAbsoluteTime(date2);
685 CFAbsoluteTime date3_abs = CFDateGetAbsoluteTime(date3);
686 CFAbsoluteTime date4_abs = CFDateGetAbsoluteTime(date4);
687 CFAbsoluteTime date5_abs = CFDateGetAbsoluteTime(date5);
688
689 NSIndexSet *iset1 =
690 [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 4)];
691 NSIndexSet *iset2 =
692 [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(1, 512)];
693
694 NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init];
695 [imset addIndex:1936];
696 [imset addIndex:7];
697 [imset addIndex:9];
698 [imset addIndex:11];
699 [imset addIndex:24];
700 [imset addIndex:41];
701 [imset addIndex:58];
702 [imset addIndex:61];
703 [imset addIndex:62];
704 [imset addIndex:63];
705
706 CFTimeZoneRef cupertino = CFTimeZoneCreateWithName(NULL, CFSTR("PST"), YES);
707 CFTimeZoneRef home =
708 CFTimeZoneCreateWithName(NULL, CFSTR("Europe/Rome"), YES);
709 CFTimeZoneRef europe = CFTimeZoneCreateWithName(NULL, CFSTR("CET"), YES);
710
711 NSTimeZone *cupertino_ns = [NSTimeZone timeZoneWithAbbreviation:@"PST"];
712 NSTimeZone *home_ns = [NSTimeZone timeZoneWithName:@"Europe/Rome"];
713 NSTimeZone *europe_ns = [NSTimeZone timeZoneWithAbbreviation:@"CET"];
714
715 CFGregorianUnits cf_greg_units = {1, 3, 5, 12, 5, 7};
716 CFGregorianDate cf_greg_date =
717 CFAbsoluteTimeGetGregorianDate(CFDateGetAbsoluteTime(date1), NULL);
718 CFRange cf_range = {4, 4};
719 NSPoint ns_point = {4, 4};
720 NSRange ns_range = {4, 4};
721
722 NSRect ns_rect = {{1, 1}, {5, 5}};
723 NSRect *ns_rect_ptr = &ns_rect;
724 NSRectArray ns_rect_arr = &ns_rect;
725 NSSize ns_size = {5, 7};
726 NSSize *ns_size_ptr = &ns_size;
727
728 CGSize cg_size = {1, 6};
729 CGPoint cg_point = {2, 7};
730 CGRect cg_rect = {{1, 2}, {7, 7}};
731
732#ifndef IOS
733 RGBColor rgb_color = {3, 56, 35};
734 RGBColor *rgb_color_ptr = &rgb_color;
735#endif
736
737 Rect rect = {4, 8, 4, 7};
738 Rect *rect_ptr = &rect;
739
740 Point point = {7, 12};
741 Point *point_ptr = &point;
742
743#ifndef IOS
744 HIPoint hi_point = {7, 12};
745 HIRect hi_rect = {{3, 5}, {4, 6}};
746#endif
747
748 SEL foo_selector = @selector(foo_selector_impl);
749
750 CFMutableBitVectorRef mut_bv = CFBitVectorCreateMutable(NULL, 64);
751 CFBitVectorSetCount(mut_bv, 50);
752 CFBitVectorSetBitAtIndex(mut_bv, 0, 1);
753 CFBitVectorSetBitAtIndex(mut_bv, 1, 1);
754 CFBitVectorSetBitAtIndex(mut_bv, 2, 1);
755 CFBitVectorSetBitAtIndex(mut_bv, 5, 1);
756 CFBitVectorSetBitAtIndex(mut_bv, 6, 1);
757 CFBitVectorSetBitAtIndex(mut_bv, 8, 1);
758 CFBitVectorSetBitAtIndex(mut_bv, 10, 1);
759 CFBitVectorSetBitAtIndex(mut_bv, 11, 1);
760 CFBitVectorSetBitAtIndex(mut_bv, 16, 1);
761 CFBitVectorSetBitAtIndex(mut_bv, 17, 1);
762 CFBitVectorSetBitAtIndex(mut_bv, 19, 1);
763 CFBitVectorSetBitAtIndex(mut_bv, 20, 1);
764 CFBitVectorSetBitAtIndex(mut_bv, 22, 1);
765 CFBitVectorSetBitAtIndex(mut_bv, 24, 1);
766 CFBitVectorSetBitAtIndex(mut_bv, 28, 1);
767 CFBitVectorSetBitAtIndex(mut_bv, 29, 1);
768 CFBitVectorSetBitAtIndex(mut_bv, 30, 1);
769 CFBitVectorSetBitAtIndex(mut_bv, 30, 1);
770 CFBitVectorSetBitAtIndex(mut_bv, 31, 1);
771 CFBitVectorSetBitAtIndex(mut_bv, 34, 1);
772 CFBitVectorSetBitAtIndex(mut_bv, 35, 1);
773 CFBitVectorSetBitAtIndex(mut_bv, 37, 1);
774 CFBitVectorSetBitAtIndex(mut_bv, 39, 1);
775 CFBitVectorSetBitAtIndex(mut_bv, 40, 1);
776 CFBitVectorSetBitAtIndex(mut_bv, 41, 1);
777 CFBitVectorSetBitAtIndex(mut_bv, 43, 1);
778 CFBitVectorSetBitAtIndex(mut_bv, 47, 1);
779
780 Molecule *molecule = [Molecule new];
781
782 Class myclass = NSClassFromString(@"NSValue");
783 Class myclass2 = [str0 class];
784 Class myclass3 = [molecule class];
785 Class myclass4 = NSClassFromString(@"NSMutableArray");
786 Class myclass5 = [nil class];
787
788 NSArray *components = @[ @"usr", @"blah", @"stuff" ];
789 NSString *path = [NSString pathWithComponents:components];
790
791 [molecule addObserver:[My_KVO_Observer new]
792 forKeyPath:@"atoms"
793 options:0
794 context:NULL]; // Set break point at this line.
795 [newMutableDictionary addObserver:[My_KVO_Observer new]
796 forKeyPath:@"weirdKeyToKVO"
797 options:NSKeyValueObservingOptionNew
798 context:NULL];
799
800 [molecule setAtoms:nil];
801 [molecule setAtoms:[NSMutableArray new]];
802
803 [pool drain];
804 return 0;
805}
806

source code of lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m