ObjFW  Diff

Differences From Artifact [2217f932b7]:

To Artifact [3bdc0c658c]:


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
			  prefix: attributePrefix];

	[attribute->ns release];
	attribute->ns = [attributeNS retain];
}

@implementation OFXMLParser
#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
@synthesize processingInstructionsHandler, elementStartHandler;
@synthesize elementEndHandler, charactersHandler, CDATAHandler, commentHandler;
@synthesize unknownEntityHandler;
#endif

+ (void)initialize
{
	size_t i;

	const SEL selectors_[] = {
		@selector(_parseOutsideTagWithBuffer:i:last:),
		@selector(_parseTagOpenedWithBuffer:i:last:),







<
<
<
<
<
<







124
125
126
127
128
129
130






131
132
133
134
135
136
137
			  prefix: attributePrefix];

	[attribute->ns release];
	attribute->ns = [attributeNS retain];
}

@implementation OFXMLParser






+ (void)initialize
{
	size_t i;

	const SEL selectors_[] = {
		@selector(_parseOutsideTagWithBuffer:i:last:),
		@selector(_parseTagOpenedWithBuffer:i:last:),
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
	[name release];
	[prefix release];
	[namespaces release];
	[attributes release];
	[attributeName release];
	[attributePrefix release];
	[previous release];
#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
	[elementStartHandler release];
	[elementEndHandler release];
	[charactersHandler release];
	[CDATAHandler release];
	[commentHandler release];
	[unknownEntityHandler release];
#endif

	[super dealloc];
}

- (id <OFXMLParserDelegate>)delegate
{
	OF_GETTER(delegate, YES)







<
<
<
<
<
<
<
<







209
210
211
212
213
214
215








216
217
218
219
220
221
222
	[name release];
	[prefix release];
	[namespaces release];
	[attributes release];
	[attributeName release];
	[attributePrefix release];
	[previous release];









	[super dealloc];
}

- (id <OFXMLParserDelegate>)delegate
{
	OF_GETTER(delegate, YES)
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
	if ([cache count] > 0) {
		OFString *characters;
		OFAutoreleasePool *pool;

		pool = [[OFAutoreleasePool alloc] init];
		characters = transform_string(cache, 0, YES, self);

#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
		if (charactersHandler != NULL)
			charactersHandler(self, characters);
		else
#endif
			[delegate parser: self
			 foundCharacters: characters];

		[pool release];
	}

	[cache removeNItems: [cache count]];

	*last = *i + 1;







<
<
<
<
<
|
|







316
317
318
319
320
321
322





323
324
325
326
327
328
329
330
331
	if ([cache count] > 0) {
		OFString *characters;
		OFAutoreleasePool *pool;

		pool = [[OFAutoreleasePool alloc] init];
		characters = transform_string(cache, 0, YES, self);






		[delegate parser: self
		 foundCharacters: characters];

		[pool release];
	}

	[cache removeNItems: [cache count]];

	*last = *i + 1;
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
		if (prefix != nil && ns == nil)
			@throw
			    [OFUnboundNamespaceException newWithClass: isa
							       prefix: prefix];

		pool2 = [[OFAutoreleasePool alloc] init];

#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
		if (elementStartHandler != NULL)
			elementStartHandler(self, name, prefix, ns, nil);
		else
#endif
			[delegate parser: self
			 didStartElement: name
			      withPrefix: prefix
			       namespace: ns
			      attributes: nil];

		if (buffer[*i] == '/') {
#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
			if (elementEndHandler != NULL)
				elementEndHandler(self, name, prefix, ns);
			else
#endif
				[delegate parser: self
				   didEndElement: name
				      withPrefix: prefix
				       namespace: ns];

			if ([previous count] == 0)
				finishedParsing = YES;
		} else
			[previous addObject: cacheString];

		[pool2 release];







<
<
<
<
<
|
|
|
|
|


<
<
<
<
<
|
|
|
|







542
543
544
545
546
547
548





549
550
551
552
553
554
555





556
557
558
559
560
561
562
563
564
565
566
		if (prefix != nil && ns == nil)
			@throw
			    [OFUnboundNamespaceException newWithClass: isa
							       prefix: prefix];

		pool2 = [[OFAutoreleasePool alloc] init];






		[delegate parser: self
		 didStartElement: name
		      withPrefix: prefix
		       namespace: ns
		      attributes: nil];

		if (buffer[*i] == '/') {





			[delegate parser: self
			   didEndElement: name
			      withPrefix: prefix
			       namespace: ns];

			if ([previous count] == 0)
				finishedParsing = YES;
		} else
			[previous addObject: cacheString];

		[pool2 release];
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
	[cache removeNItems: [cache count]];

	ns = namespace_for_prefix(prefix, namespaces);
	if (prefix != nil && ns == nil)
		@throw [OFUnboundNamespaceException newWithClass: isa
							  prefix: prefix];

#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
	if (elementEndHandler != NULL)
		elementEndHandler(self, name, prefix, ns);
	else
#endif
		[delegate parser: self
		   didEndElement: name
		      withPrefix: prefix
		       namespace: ns];

	[pool release];

	[namespaces removeLastObject];
	[name release];
	[prefix release];
	name = prefix = nil;







<
<
<
<
<
|
|
|
|







633
634
635
636
637
638
639





640
641
642
643
644
645
646
647
648
649
650
	[cache removeNItems: [cache count]];

	ns = namespace_for_prefix(prefix, namespaces);
	if (prefix != nil && ns == nil)
		@throw [OFUnboundNamespaceException newWithClass: isa
							  prefix: prefix];






	[delegate parser: self
	   didEndElement: name
	      withPrefix: prefix
	       namespace: ns];

	[pool release];

	[namespaces removeLastObject];
	[name release];
	[prefix release];
	name = prefix = nil;
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759

	for (j = 0; j < attributesCount; j++)
		resolve_attribute_namespace(attributesCArray[j], namespaces,
		    isa);

	pool = [[OFAutoreleasePool alloc] init];

#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
	if (elementStartHandler != NULL)
		elementStartHandler(self, name, prefix, ns, attributes);
	else
#endif
		[delegate parser: self
		 didStartElement: name
		      withPrefix: prefix
		       namespace: ns
		      attributes: attributes];

	if (buffer[*i] == '/') {
#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
		if (elementEndHandler != NULL)
			elementEndHandler(self, name, prefix, ns);
		else
#endif
			[delegate parser: self
			   didEndElement: name
			      withPrefix: prefix
			       namespace: ns];

		if ([previous count] == 0)
			finishedParsing = YES;

		[namespaces removeLastObject];
	} else if (prefix != nil) {
		OFString *str = [OFString stringWithFormat: @"%@:%@",







<
<
<
<
<
|
|
|
|
|


<
<
<
<
<
|
|
|
|







691
692
693
694
695
696
697





698
699
700
701
702
703
704





705
706
707
708
709
710
711
712
713
714
715

	for (j = 0; j < attributesCount; j++)
		resolve_attribute_namespace(attributesCArray[j], namespaces,
		    isa);

	pool = [[OFAutoreleasePool alloc] init];






	[delegate parser: self
	 didStartElement: name
	      withPrefix: prefix
	       namespace: ns
	      attributes: attributes];

	if (buffer[*i] == '/') {





		[delegate parser: self
		   didEndElement: name
		      withPrefix: prefix
		       namespace: ns];

		if ([previous count] == 0)
			finishedParsing = YES;

		[namespaces removeLastObject];
	} else if (prefix != nil) {
		OFString *str = [OFString stringWithFormat: @"%@:%@",
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
	}

	pool = [[OFAutoreleasePool alloc] init];

	cache_append(cache, buffer + *last, encoding, *i - *last);
	CDATA = transform_string(cache, 2, NO, nil);

#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
	if (CDATAHandler != NULL)
		CDATAHandler(self, CDATA);
	else
#endif
		[delegate parser: self
		      foundCDATA: CDATA];

	[pool release];

	[cache removeNItems: [cache count]];

	*last = *i + 1;
	state = OF_XMLPARSER_OUTSIDE_TAG;







<
<
<
<
<
|
|







938
939
940
941
942
943
944





945
946
947
948
949
950
951
952
953
	}

	pool = [[OFAutoreleasePool alloc] init];

	cache_append(cache, buffer + *last, encoding, *i - *last);
	CDATA = transform_string(cache, 2, NO, nil);






	[delegate parser: self
	      foundCDATA: CDATA];

	[pool release];

	[cache removeNItems: [cache count]];

	*last = *i + 1;
	state = OF_XMLPARSER_OUTSIDE_TAG;
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
						      parser: self];

	pool = [[OFAutoreleasePool alloc] init];

	cache_append(cache, buffer + *last, encoding, *i - *last);
	comment = transform_string(cache, 2, NO, nil);

#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
	if (commentHandler != NULL)
		commentHandler(self, comment);
	else
#endif
		[delegate parser: self
		    foundComment: comment];

	[pool release];

	[cache removeNItems: [cache count]];

	*last = *i + 1;
	state = OF_XMLPARSER_OUTSIDE_TAG;







<
<
<
<
<
|
|







992
993
994
995
996
997
998





999
1000
1001
1002
1003
1004
1005
1006
1007
						      parser: self];

	pool = [[OFAutoreleasePool alloc] init];

	cache_append(cache, buffer + *last, encoding, *i - *last);
	comment = transform_string(cache, 2, NO, nil);






	[delegate parser: self
	    foundComment: comment];

	[pool release];

	[cache removeNItems: [cache count]];

	*last = *i + 1;
	state = OF_XMLPARSER_OUTSIDE_TAG;
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
{
	return finishedParsing;
}

-	   (OFString*)string: (OFString*)string
  containsUnknownEntityNamed: (OFString*)entity
{
#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS)
	if (unknownEntityHandler != NULL)
		return unknownEntityHandler(self, entity);
#endif

	return [delegate parser: self
	foundUnknownEntityNamed: entity];
}
@end

@implementation OFObject (OFXMLParserDelegate)
-		 (void)parser: (OFXMLParser*)parser







<
<
<
<
<







1040
1041
1042
1043
1044
1045
1046





1047
1048
1049
1050
1051
1052
1053
{
	return finishedParsing;
}

-	   (OFString*)string: (OFString*)string
  containsUnknownEntityNamed: (OFString*)entity
{





	return [delegate parser: self
	foundUnknownEntityNamed: entity];
}
@end

@implementation OFObject (OFXMLParserDelegate)
-		 (void)parser: (OFXMLParser*)parser