ObjFW  Diff

Differences From Artifact [ff036615fe]:

To Artifact [5780bef1f6]:


25
26
27
28
29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
static OFString *module = @"OFXMLParser";
static int i = 0;

enum event_type {
	TAG_START,
	TAG_END,
	STRING,

	COMMENT
};

@implementation TestsAppDelegate (OFXMLParser)
- (void)xmlParserCallbackWithEventType: (enum event_type)et
				  name: (OFString*)name
				prefix: (OFString*)prefix
			     namespace: (OFString*)ns
			    attributes: (OFArray*)attrs
				string: (OFString*)string
			       comment: (OFString*)comment
{
	OFString *msg;

	i++;
	msg = [OFString stringWithFormat: @"Parsing part #%d", i];

	switch (i) {
	case 1:
		TEST(msg, et == TAG_START && [name isEqual: @"root"] &&
		    prefix == nil && ns == nil && [attrs count] == 0)
		break;
	case 2:
		TEST(msg, et == STRING && [string isEqual: @"\n "])
		break;
	case 3:
		TEST(msg, et == STRING && [string isEqual: @"f<oo"])
		break;
	case 4:
		TEST(msg, et == TAG_START && [name isEqual: @"bar"] &&
		    prefix == nil && ns == nil && attrs == nil)
		break;
	case 5:
		TEST(msg, et == TAG_END && [name isEqual: @"bar"] &&







>




|
|
|
|
|
|
|















|







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
static OFString *module = @"OFXMLParser";
static int i = 0;

enum event_type {
	TAG_START,
	TAG_END,
	STRING,
	CDATA,
	COMMENT
};

@implementation TestsAppDelegate (OFXMLParser)
- (void)parserCallbackWithEventType: (enum event_type)et
			       name: (OFString*)name
			     prefix: (OFString*)prefix
			  namespace: (OFString*)ns
			 attributes: (OFArray*)attrs
			     string: (OFString*)string
			    comment: (OFString*)comment
{
	OFString *msg;

	i++;
	msg = [OFString stringWithFormat: @"Parsing part #%d", i];

	switch (i) {
	case 1:
		TEST(msg, et == TAG_START && [name isEqual: @"root"] &&
		    prefix == nil && ns == nil && [attrs count] == 0)
		break;
	case 2:
		TEST(msg, et == STRING && [string isEqual: @"\n "])
		break;
	case 3:
		TEST(msg, et == CDATA && [string isEqual: @"f<oo"])
		break;
	case 4:
		TEST(msg, et == TAG_START && [name isEqual: @"bar"] &&
		    prefix == nil && ns == nil && attrs == nil)
		break;
	case 5:
		TEST(msg, et == TAG_END && [name isEqual: @"bar"] &&
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271












272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
	case 30:
		TEST(msg, et == TAG_END && [name isEqual: @"root"] &&
		    prefix == nil && ns == nil);
		break;
	}
}

-     (void)xmlParser: (OFXMLParser*)parser
  didStartTagWithName: (OFString*)name
	       prefix: (OFString*)prefix
	    namespace: (OFString*)ns
	   attributes: (OFArray*)attrs
{
	[self xmlParserCallbackWithEventType: TAG_START
					name: name
				      prefix: prefix
				   namespace: ns
				  attributes: attrs
				      string: nil
				     comment: nil];
}

-   (void)xmlParser: (OFXMLParser*)parser
  didEndTagWithName: (OFString*)name
	     prefix: (OFString*)prefix
	  namespace: (OFString*)ns
{
	[self xmlParserCallbackWithEventType: TAG_END
					name: name
				      prefix: prefix
				   namespace: ns
				  attributes: nil
				      string: nil
				     comment: nil];
}

- (void)xmlParser: (OFXMLParser*)parser
    didFindString: (OFString*)string
{
	[self xmlParserCallbackWithEventType: STRING
					name: nil
				      prefix: nil
				   namespace: nil
				  attributes: nil
				      string: string
				     comment: nil];
}

- (void)xmlParser: (OFXMLParser*)parser












   didFindComment: (OFString*)comment
{
	[self xmlParserCallbackWithEventType: COMMENT
					name: nil
				      prefix: nil
				   namespace: nil
				  attributes: nil
				      string: nil
				     comment: comment];
}

-      (OFString*)xmlParser: (OFXMLParser*)parser
  didFindUnknownEntityNamed: (OFString*)entity
{
	if ([entity isEqual: @"foo"])
		return @"foobar";

	return nil;
}








|
|
|
|
|

|
|
|
|
|
|
|


|
|
|
|

|
|
|
|
|
|
|


|
|

|
|
|
|
|
|
|


|
>
>
>
>
>
>
>
>
>
>
>
>
|

|
|
|
|
|
|
|


|
|







224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
	case 30:
		TEST(msg, et == TAG_END && [name isEqual: @"root"] &&
		    prefix == nil && ns == nil);
		break;
	}
}

-    (void)parser: (OFXMLParser*)parser
  didStartElement: (OFString*)name
       withPrefix: (OFString*)prefix
	namespace: (OFString*)ns
       attributes: (OFArray*)attrs
{
	[self parserCallbackWithEventType: TAG_START
				     name: name
				   prefix: prefix
				namespace: ns
			       attributes: attrs
				   string: nil
				  comment: nil];
}

-  (void)parser: (OFXMLParser*)parser
  didEndElement: (OFString*)name
     withPrefix: (OFString*)prefix
      namespace: (OFString*)ns
{
	[self parserCallbackWithEventType: TAG_END
				     name: name
				   prefix: prefix
				namespace: ns
			       attributes: nil
				   string: nil
				  comment: nil];
}

-    (void)parser: (OFXMLParser*)parser
  foundCharacters: (OFString*)string
{
	[self parserCallbackWithEventType: STRING
				     name: nil
				   prefix: nil
				namespace: nil
			       attributes: nil
				   string: string
				  comment: nil];
}

- (void)parser: (OFXMLParser*)parser
    foundCDATA: (OFString*)cdata
{
	[self parserCallbackWithEventType: CDATA
				     name: nil
				   prefix: nil
				namespace: nil
			       attributes: nil
				   string: cdata
				  comment: nil];
}

- (void)parser: (OFXMLParser*)parser
  foundComment: (OFString*)comment
{
	[self parserCallbackWithEventType: COMMENT
				     name: nil
				   prefix: nil
				namespace: nil
			       attributes: nil
				   string: nil
				  comment: comment];
}

-	(OFString*)parser: (OFXMLParser*)parser
  foundUnknownEntityNamed: (OFString*)entity
{
	if ([entity isEqual: @"foo"])
		return @"foobar";

	return nil;
}