ObjFW  Check-in [9d6716470e]

Overview
Comment:Fix Objective C++ compatibility.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9d6716470ee059b82f674efd2d40b7cd437e1e4b6e5fe0fde7b118f0c10e6742
User & Date: js on 2010-09-08 21:17:46
Other Links: manifest | tags
Context
2010-09-15
15:01
Rename __objc_gnu_init. check-in: eac76c7a30 user: js tags: trunk
2010-09-08
21:17
Fix Objective C++ compatibility. check-in: 9d6716470e user: js tags: trunk
11:15
Include the tests in the Xcode project. check-in: 364b6b20d7 user: js tags: trunk
Changes

Modified src/OFExceptions.h from [258dd6b4db] to [9a0cdb555b].

1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
@end

/**
 * \brief An exception indicating an attempt to use an unbound namespace.
 */
@interface OFUnboundNamespaceException: OFException
{
	OFString *namespace;
	OFString *prefix;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFString *namespace;
@property (readonly, nonatomic) OFString *prefix;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param namespace The namespace which is unbound
 * \return A new unbound namespace exception
 */
+ newWithClass: (Class)class_
     namespace: (OFString*)namespace;

/**
 * \param class_ The class of the object which caused the exception
 * \param prefix The prefix which is unbound
 * \return A new unbound namespace exception
 */
+ newWithClass: (Class)class_
	prefix: (OFString*)prefix;

/**
 * Initializes an already allocated unbound namespace failed exception
 *
 * \param class_ The class of the object which caused the exception
 * \param namespace The namespace which is unbound
 * \return An initialized unbound namespace exception
 */
- initWithClass: (Class)class_
      namespace: (OFString*)namespace;

/**
 * Initializes an already allocated unbound namespace failed exception
 *
 * \param class_ The class of the object which caused the exception
 * \param prefix The prefix which is unbound
 * \return An initialized unbound namespace exception







|




|









|

















|







1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
@end

/**
 * \brief An exception indicating an attempt to use an unbound namespace.
 */
@interface OFUnboundNamespaceException: OFException
{
	OFString *ns;
	OFString *prefix;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic, getter=namespace) OFString *ns;
@property (readonly, nonatomic) OFString *prefix;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param namespace The namespace which is unbound
 * \return A new unbound namespace exception
 */
+ newWithClass: (Class)class_
     namespace: (OFString*)ns;

/**
 * \param class_ The class of the object which caused the exception
 * \param prefix The prefix which is unbound
 * \return A new unbound namespace exception
 */
+ newWithClass: (Class)class_
	prefix: (OFString*)prefix;

/**
 * Initializes an already allocated unbound namespace failed exception
 *
 * \param class_ The class of the object which caused the exception
 * \param namespace The namespace which is unbound
 * \return An initialized unbound namespace exception
 */
- initWithClass: (Class)class_
      namespace: (OFString*)ns;

/**
 * Initializes an already allocated unbound namespace failed exception
 *
 * \param class_ The class of the object which caused the exception
 * \param prefix The prefix which is unbound
 * \return An initialized unbound namespace exception

Modified src/OFExceptions.m from [c2ce5ebc7f] to [7698b64d75].

1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591

	return string;
}
@end

@implementation OFUnboundNamespaceException
+ newWithClass: (Class)class_
     namespace: (OFString*)namespace
{
	return [[self alloc] initWithClass: class_
				 namespace: namespace];
}

+ newWithClass: (Class)class_
	prefix: (OFString*)prefix
{
	return [[self alloc] initWithClass: class_
				    prefix: prefix];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
      namespace: (OFString*)namespace_
{
	self = [super initWithClass: class_];

	namespace = [namespace_ copy];

	return self;
}

- initWithClass: (Class)class_
	 prefix: (OFString*)prefix_
{
	self = [super initWithClass: class_];

	prefix = [prefix_ copy];

	return self;
}

- (void)dealloc
{
	[namespace release];
	[prefix release];

	[super dealloc];
}

- (OFString*)string
{
	if (string != nil)
		return string;

	if (namespace != nil)
		string = [[OFString alloc] initWithFormat:
		    @"The namespace %s is not bound in class %s",
		    [inClass className]];
	else if (prefix != nil)
		string = [[OFString alloc] initWithFormat:
		    @"The prefix %s is not bound to any namespace in %s",
		    [inClass className]];

	return string;
}

- (OFString*)namespace
{
	return namespace;
}

- (OFString*)prefix
{
	return prefix;
}
@end







|


|
















|



|
















|










|













|







1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591

	return string;
}
@end

@implementation OFUnboundNamespaceException
+ newWithClass: (Class)class_
     namespace: (OFString*)ns
{
	return [[self alloc] initWithClass: class_
				 namespace: ns];
}

+ newWithClass: (Class)class_
	prefix: (OFString*)prefix
{
	return [[self alloc] initWithClass: class_
				    prefix: prefix];
}

- initWithClass: (Class)class_
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- initWithClass: (Class)class_
      namespace: (OFString*)ns_
{
	self = [super initWithClass: class_];

	ns = [ns_ copy];

	return self;
}

- initWithClass: (Class)class_
	 prefix: (OFString*)prefix_
{
	self = [super initWithClass: class_];

	prefix = [prefix_ copy];

	return self;
}

- (void)dealloc
{
	[ns release];
	[prefix release];

	[super dealloc];
}

- (OFString*)string
{
	if (string != nil)
		return string;

	if (ns != nil)
		string = [[OFString alloc] initWithFormat:
		    @"The namespace %s is not bound in class %s",
		    [inClass className]];
	else if (prefix != nil)
		string = [[OFString alloc] initWithFormat:
		    @"The prefix %s is not bound to any namespace in %s",
		    [inClass className]];

	return string;
}

- (OFString*)namespace
{
	return ns;
}

- (OFString*)prefix
{
	return prefix;
}
@end

Modified src/OFMutableArray.h from [103c29de74] to [a52014b3ad].

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 * Replaces all objects equivalent to the first specified object with the
 * second specified object.
 *
 * \param old The object to replace
 * \param new The replacement object
 */
- (void)replaceObject: (id)old
	   withObject: (id)new;

/**
 * Replaces the object at the specified index with the specified object.
 *
 * \param index The index of the object to replace
 * \param obj The replacement object
 * \return The old object, autoreleased
 */
- (id)replaceObjectAtIndex: (size_t)index
		withObject: (id)obj;

/**
 * Replaces all objects that have the same address as the first specified object
 * with the second specified object.
 *
 * \param old The object to replace
 * \param new The replacement object
 */
- (void)replaceObjectIdenticalTo: (id)old
		      withObject: (id)new;

/**
 * Removes all objects equivalent to the specified object.
 *
 * \param obj The object to remove
 */
- (void)removeObject: (id)obj;







|



















|







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 * Replaces all objects equivalent to the first specified object with the
 * second specified object.
 *
 * \param old The object to replace
 * \param new The replacement object
 */
- (void)replaceObject: (id)old
	   withObject: (id)new_;

/**
 * Replaces the object at the specified index with the specified object.
 *
 * \param index The index of the object to replace
 * \param obj The replacement object
 * \return The old object, autoreleased
 */
- (id)replaceObjectAtIndex: (size_t)index
		withObject: (id)obj;

/**
 * Replaces all objects that have the same address as the first specified object
 * with the second specified object.
 *
 * \param old The object to replace
 * \param new The replacement object
 */
- (void)replaceObjectIdenticalTo: (id)old
		      withObject: (id)new_;

/**
 * Removes all objects equivalent to the specified object.
 *
 * \param obj The object to remove
 */
- (void)removeObject: (id)obj;

Modified src/OFXMLAttribute.h from [7726e95a54] to [ece2229692].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
 * \brief A representation of an attribute of an XML element as an object.
 */
@interface OFXMLAttribute: OFObject
{
@public
	OFString *name;
	OFString *namespace;
	OFString *stringValue;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain) OFString *name;
@property (readonly, retain) OFString *namespace;
@property (readonly, retain) OFString *stringValue;
#endif

/**
 * \param name The name of the attribute
 * \param ns The namespace of the attribute
 * \param value The string value of the attribute







|





|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
 * \brief A representation of an attribute of an XML element as an object.
 */
@interface OFXMLAttribute: OFObject
{
@public
	OFString *name;
	OFString *ns;
	OFString *stringValue;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain) OFString *name;
@property (readonly, retain, getter=namespace) OFString *ns;
@property (readonly, retain) OFString *stringValue;
#endif

/**
 * \param name The name of the attribute
 * \param ns The namespace of the attribute
 * \param value The string value of the attribute

Modified src/OFXMLAttribute.m from [97f1780df3] to [2b47f3dee2].

22
23
24
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
{
	return [[[self alloc] initWithName: name
				 namespace: ns
			       stringValue: value] autorelease];
}

- initWithName: (OFString*)name_
     namespace: (OFString*)ns
   stringValue: (OFString*)value
{
	self = [super init];

	name = [name_ copy];
	namespace = [ns copy];
	stringValue = [value copy];

	return self;
}

- (void)dealloc
{
	[name release];
	[namespace release];
	[stringValue release];

	[super dealloc];
}

- (OFString*)name
{
	return [[name copy] autorelease];
}

- (OFString*)namespace
{
	return [[namespace copy] autorelease];
}

- (OFString*)stringValue
{
	return [[stringValue copy] autorelease];
}
@end







|





|








|












|







22
23
24
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
{
	return [[[self alloc] initWithName: name
				 namespace: ns
			       stringValue: value] autorelease];
}

- initWithName: (OFString*)name_
     namespace: (OFString*)ns_
   stringValue: (OFString*)value
{
	self = [super init];

	name = [name_ copy];
	ns = [ns_ copy];
	stringValue = [value copy];

	return self;
}

- (void)dealloc
{
	[name release];
	[ns release];
	[stringValue release];

	[super dealloc];
}

- (OFString*)name
{
	return [[name copy] autorelease];
}

- (OFString*)namespace
{
	return [[ns copy] autorelease];
}

- (OFString*)stringValue
{
	return [[stringValue copy] autorelease];
}
@end

Modified src/OFXMLElement.h from [b47f96a6fe] to [9a57ffba3d].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@class OFMutableArray;
@class OFMutableDictionary;
@class OFXMLAttribute;

@interface OFXMLElement: OFObject
{
	OFString *name;
	OFString *namespace;
	OFString *defaultNamespace;
	OFMutableArray *attributes;
	OFMutableDictionary *namespaces;
	OFMutableArray *children;
	OFString *characters;
	OFString *cdata;
	OFMutableString *comment;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy) OFString *name;
@property (readonly, copy) OFString *namespace;
@property (copy) OFString *defaultNamespace;
@property (readonly, copy) OFArray *attributes;
@property (readonly, copy) OFArray *children;
#endif

/**
 * \param name The name for the element







|











|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@class OFMutableArray;
@class OFMutableDictionary;
@class OFXMLAttribute;

@interface OFXMLElement: OFObject
{
	OFString *name;
	OFString *ns;
	OFString *defaultNamespace;
	OFMutableArray *attributes;
	OFMutableDictionary *namespaces;
	OFMutableArray *children;
	OFString *characters;
	OFString *cdata;
	OFMutableString *comment;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy) OFString *name;
@property (readonly, copy, getter=namespace) OFString *ns;
@property (copy) OFString *defaultNamespace;
@property (readonly, copy) OFArray *attributes;
@property (readonly, copy) OFArray *children;
#endif

/**
 * \param name The name for the element

Modified src/OFXMLElement.m from [bd82ff1d44] to [e59c8082fb].

84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
	return [self initWithName: name_
			namespace: nil
		      stringValue: stringval];
}

- initWithName: (OFString*)name_
     namespace: (OFString*)ns
{
	return [self initWithName: name_
			namespace: ns
		      stringValue: nil];
}

- initWithName: (OFString*)name_
     namespace: (OFString*)ns
   stringValue: (OFString*)stringval
{
	self = [super init];

	name = [name_ copy];
	namespace = [ns copy];

	if (stringval != nil) {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];;
		[self addChild:
		    [OFXMLElement elementWithCharacters: stringval]];
		[pool release];
	}







|


|




|





|







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
	return [self initWithName: name_
			namespace: nil
		      stringValue: stringval];
}

- initWithName: (OFString*)name_
     namespace: (OFString*)ns_
{
	return [self initWithName: name_
			namespace: ns_
		      stringValue: nil];
}

- initWithName: (OFString*)name_
     namespace: (OFString*)ns_
   stringValue: (OFString*)stringval
{
	self = [super init];

	name = [name_ copy];
	ns = [ns_ copy];

	if (stringval != nil) {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];;
		[self addChild:
		    [OFXMLElement elementWithCharacters: stringval]];
		[pool release];
	}
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
- (OFString*)name
{
	return [[name copy] autorelease];
}

- (OFString*)namespace
{
	return [[namespace copy] autorelease];
}

- (OFArray*)attributes
{
	return [[attributes copy] autorelease];
}








|







148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
- (OFString*)name
{
	return [[name copy] autorelease];
}

- (OFString*)namespace
{
	return [[ns copy] autorelease];
}

- (OFArray*)attributes
{
	return [[attributes copy] autorelease];
}

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
	i = 0;
	len = [name cStringLength] + 3;
	str_c = [self allocMemoryWithSize: len];

	/* Start of tag */
	str_c[i++] = '<';

	if ((namespace == nil && def_ns != nil) ||
	    (namespace != nil && def_ns == nil) ||
	    (namespace != nil && ![namespace isEqual: def_ns])) {
		if ((prefix = [all_namespaces objectForKey:
		    (namespace != nil ? namespace : (OFString*)@"")]) == nil)
			@throw [OFUnboundNamespaceException
			    newWithClass: isa
			       namespace: namespace];

		len += [prefix cStringLength] + 1;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {
			[self freeMemory: str_c];
			@throw e;







<
|
|

|
|
<
|
<







215
216
217
218
219
220
221

222
223
224
225
226

227

228
229
230
231
232
233
234
	i = 0;
	len = [name cStringLength] + 3;
	str_c = [self allocMemoryWithSize: len];

	/* Start of tag */
	str_c[i++] = '<';


	if ((ns == nil && def_ns != nil) || (ns != nil && def_ns == nil) ||
	    (ns != nil && ![ns isEqual: def_ns])) {
		if ((prefix = [all_namespaces objectForKey:
		    (ns != nil ? ns : (OFString*)@"")]) == nil)
			@throw [OFUnboundNamespaceException newWithClass: isa

							       namespace: ns];

		len += [prefix cStringLength] + 1;
		@try {
			str_c = [self resizeMemory: str_c
					    toSize: len];
		} @catch (OFException *e) {
			[self freeMemory: str_c];
			@throw e;
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
	[self addAttribute: [OFXMLAttribute attributeWithName: name_
						    namespace: nil
						  stringValue: value]];
	[pool release];
}

- (void)addAttributeWithName: (OFString*)name_
		   namespace: (OFString*)ns
		 stringValue: (OFString*)value
{
	OFAutoreleasePool *pool;

	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	pool = [[OFAutoreleasePool alloc] init];
	[self addAttribute: [OFXMLAttribute attributeWithName: name_
						    namespace: ns
						  stringValue: value]];
	[pool release];
}

/* TODO: Replace attribute */
/* TODO: Remove attribute */

- (void)setPrefix: (OFString*)prefix
     forNamespace: (OFString*)ns
{
	if (name == nil || prefix == nil || [prefix isEqual: @""])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
	if (ns == nil)
		ns = @"";

	[namespaces setObject: prefix
		       forKey: ns];
}

- (void)bindPrefix: (OFString*)prefix
      forNamespace: (OFString*)ns
{
	[self setPrefix: prefix
	   forNamespace: ns];
	[self addAttributeWithName: prefix
			 namespace: @"http://www.w3.org/2000/xmlns/"
		       stringValue: ns];
}

- (OFString*)defaultNamespace
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	return [[defaultNamespace retain] autorelease];
}

- (void)setDefaultNamespace: (OFString*)ns
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	OFString *old = defaultNamespace;
	defaultNamespace = [ns copy];
	[old release];
}

- (void)bindDefaultNamespace: (OFString*)ns
{
	[self setDefaultNamespace: ns];
	[self addAttributeWithName: @"xmlns"
		       stringValue: ns];
}

- (void)addChild: (OFXMLElement*)child
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	if (children == nil)
		children = [[OFMutableArray alloc] init];

	[children addObject: child];
}

- (void)dealloc
{
	[name release];
	[namespace release];
	[attributes release];
	[namespaces release];
	[children release];
	[characters release];
	[cdata release];
	[comment release];

	[super dealloc];
}
@end







|










|








|




|
|


|



|


|


|











|






|



|

|

|

















|










389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
	[self addAttribute: [OFXMLAttribute attributeWithName: name_
						    namespace: nil
						  stringValue: value]];
	[pool release];
}

- (void)addAttributeWithName: (OFString*)name_
		   namespace: (OFString*)ns_
		 stringValue: (OFString*)value
{
	OFAutoreleasePool *pool;

	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	pool = [[OFAutoreleasePool alloc] init];
	[self addAttribute: [OFXMLAttribute attributeWithName: name_
						    namespace: ns_
						  stringValue: value]];
	[pool release];
}

/* TODO: Replace attribute */
/* TODO: Remove attribute */

- (void)setPrefix: (OFString*)prefix
     forNamespace: (OFString*)ns_
{
	if (name == nil || prefix == nil || [prefix isEqual: @""])
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
	if (ns_ == nil)
		ns_ = @"";

	[namespaces setObject: prefix
		       forKey: ns_];
}

- (void)bindPrefix: (OFString*)prefix
      forNamespace: (OFString*)ns_
{
	[self setPrefix: prefix
	   forNamespace: ns_];
	[self addAttributeWithName: prefix
			 namespace: @"http://www.w3.org/2000/xmlns/"
		       stringValue: ns_];
}

- (OFString*)defaultNamespace
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	return [[defaultNamespace retain] autorelease];
}

- (void)setDefaultNamespace: (OFString*)ns_
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	OFString *old = defaultNamespace;
	defaultNamespace = [ns_ copy];
	[old release];
}

- (void)bindDefaultNamespace: (OFString*)ns_
{
	[self setDefaultNamespace: ns_];
	[self addAttributeWithName: @"xmlns"
		       stringValue: ns_];
}

- (void)addChild: (OFXMLElement*)child
{
	if (name == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	if (children == nil)
		children = [[OFMutableArray alloc] init];

	[children addObject: child];
}

- (void)dealloc
{
	[name release];
	[ns release];
	[attributes release];
	[namespaces release];
	[children release];
	[characters release];
	[cdata release];
	[comment release];

	[super dealloc];
}
@end

Modified src/OFXMLParser.m from [156503de2d] to [f70ec8d4db].

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
}

static OF_INLINE void
resolve_attr_namespace(OFXMLAttribute *attr, OFString *prefix, OFString *ns,
    OFArray *namespaces, Class isa)
{
	OFString *attr_ns;
	OFString *attr_prefix = attr->namespace;

	if (attr_prefix == nil)
		return;

	attr_ns = namespace_for_prefix(attr_prefix, namespaces);

	if ((attr_prefix != nil && attr_ns == nil))
		@throw [OFUnboundNamespaceException newWithClass: isa
							  prefix: attr_prefix];

	[attr->namespace release];
	attr->namespace = [attr_ns retain];
}

@implementation OFXMLParser
+ parser
{
	return [[[self alloc] init] autorelease];
}







|










|
|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
}

static OF_INLINE void
resolve_attr_namespace(OFXMLAttribute *attr, OFString *prefix, OFString *ns,
    OFArray *namespaces, Class isa)
{
	OFString *attr_ns;
	OFString *attr_prefix = attr->ns;

	if (attr_prefix == nil)
		return;

	attr_ns = namespace_for_prefix(attr_prefix, namespaces);

	if ((attr_prefix != nil && attr_ns == nil))
		@throw [OFUnboundNamespaceException newWithClass: isa
							  prefix: attr_prefix];

	[attr->ns release];
	attr->ns = [attr_ns retain];
}

@implementation OFXMLParser
+ parser
{
	return [[[self alloc] init] autorelease];
}