ObjFW  Diff

Differences From Artifact [0862e86c30]:

To Artifact [d620b3bd51]:


32
33
34
35
36
37
38
39

40
41
42
43
44
45
46
32
33
34
35
36
37
38

39
40
41
42
43
44
45
46







-
+







#import "OFUndefinedKeyException.h"

static struct {
	Class isa;
} placeholder;

@interface OFDictionary ()
- (OFString *)OF_JSONRepresentationWithOptions: (int)options
- (OFString *)of_JSONRepresentationWithOptions: (int)options
					 depth: (size_t)depth;
@end

@interface OFDictionary_placeholder: OFDictionary
@end

@implementation OFDictionary_placeholder
612
613
614
615
616
617
618
619

620
621
622
623
624
625

626
627
628
629
630


631
632
633
634
635
636
637
612
613
614
615
616
617
618

619
620
621
622
623
624

625
626
627
628


629
630
631
632
633
634
635
636
637







-
+





-
+



-
-
+
+







	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}

- (OFString *)JSONRepresentation
{
	return [self OF_JSONRepresentationWithOptions: 0
	return [self of_JSONRepresentationWithOptions: 0
						depth: 0];
}

- (OFString *)JSONRepresentationWithOptions: (int)options
{
	return [self OF_JSONRepresentationWithOptions: options
	return [self of_JSONRepresentationWithOptions: options
						depth: 0];
}

- (OFString *)OF_JSONRepresentationWithOptions: (int)options
					depth: (size_t)depth
- (OFString *)of_JSONRepresentationWithOptions: (int)options
					 depth: (size_t)depth
{
	OFMutableString *JSON = [OFMutableString stringWithString: @"{"];
	void *pool = objc_autoreleasePoolPush();
	OFEnumerator *keyEnumerator = [self keyEnumerator];
	OFEnumerator *objectEnumerator = [self objectEnumerator];
	size_t i, count = [self count];
	id key, object;
653
654
655
656
657
658
659
660

661
662
663
664

665
666
667
668
669
670
671
653
654
655
656
657
658
659

660
661
662
663

664
665
666
667
668
669
670
671







-
+



-
+








			if (![key isKindOfClass: [OFString class]])
				@throw [OFInvalidArgumentException exception];

			[JSON appendString: indentation];
			[JSON appendString: @"\t"];
			[JSON appendString: [key
			    OF_JSONRepresentationWithOptions: identifierOptions
			    of_JSONRepresentationWithOptions: identifierOptions
						       depth: depth + 1]];
			[JSON appendString: @": "];
			[JSON appendString: [object
			    OF_JSONRepresentationWithOptions: options
			    of_JSONRepresentationWithOptions: options
						       depth: depth + 1]];

			if (++i < count)
				[JSON appendString: @",\n"];
			else
				[JSON appendString: @"\n"];

681
682
683
684
685
686
687
688

689
690
691
692

693
694
695
696
697
698
699
681
682
683
684
685
686
687

688
689
690
691

692
693
694
695
696
697
698
699







-
+



-
+







			int identifierOptions =
			    options | OF_JSON_REPRESENTATION_IDENTIFIER;

			if (![key isKindOfClass: [OFString class]])
				@throw [OFInvalidArgumentException exception];

			[JSON appendString: [key
			    OF_JSONRepresentationWithOptions: identifierOptions
			    of_JSONRepresentationWithOptions: identifierOptions
						       depth: depth + 1]];
			[JSON appendString: @":"];
			[JSON appendString: [object
			    OF_JSONRepresentationWithOptions: options
			    of_JSONRepresentationWithOptions: options
						       depth: depth + 1]];

			if (++i < count)
				[JSON appendString: @","];

			objc_autoreleasePoolPop(pool2);
		}