Overview
Context
Changes
Modified src/OFArray.m
from [cdeeda612a]
to [4847514de9].
︙ | | |
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
|
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
|
-
-
+
+
-
-
-
+
-
-
+
-
+
+
+
+
+
|
@try {
OFAutoreleasePool *pool, *pool2;
OFEnumerator *enumerator;
OFXMLElement *child;
pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
enumerator = [[element
enumerator = [[element children] objectEnumerator];
elementsForName: @"object"
namespace: OF_SERIALIZATION_NS] objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((child = [enumerator nextObject]) != nil) {
id object = [child objectByDeserializing];
id object;
if (![[child namespace] isEqual: OF_SERIALIZATION_NS])
continue;
object = [child objectByDeserializing];
[array addItem: &object];
[object retain];
[pool2 releaseObjects];
}
[pool release];
|
︙ | | |
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
|
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
|
+
-
+
-
-
+
+
-
+
-
-
+
-
+
+
+
-
+
+
+
+
|
*/
ret->isa = [OFString class];
return ret;
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFAutoreleasePool *pool;
OFAutoreleasePool *pool2;
OFXMLElement *element;
id <OFSerialization> *cArray = [array cArray];
size_t i, count = [array count];
element = [OFXMLElement elementWithName: @"object"
namespace: OF_SERIALIZATION_NS];
element = [[OFXMLElement alloc] initWithName: [self className]
namespace: OF_SERIALIZATION_NS];
pool = [[OFAutoreleasePool alloc] init];
pool2 = [[OFAutoreleasePool alloc] init];
[element addAttributeWithName: @"class"
stringValue: [self className]];
for (i = 0; i < count; i++) {
[element addChild: [cArray[i] XMLElementBySerializing]];
[pool releaseObjects];
[pool2 releaseObjects];
}
[element retain];
@try {
[pool release];
[pool release];
} @finally {
[element autorelease];
}
return element;
}
- (void)makeObjectsPerformSelector: (SEL)selector
{
id *cArray = [array cArray];
|
︙ | | |
Modified src/OFDate.m
from [914a225e3e]
to [884edb1d64].
︙ | | |
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
|
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
|
-
+
-
-
+
+
-
-
-
+
-
-
-
+
+
-
-
+
-
-
+
+
|
- initWithSerialization: (OFXMLElement*)element
{
self = [super init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *secondsElement, *microsecondsElement;
OFXMLAttribute *secondsAttribute, *microsecondsAttribute;
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
secondsElement = [element elementForName: @"seconds"
secondsAttribute = [element attributeForName: @"seconds"];
namespace: OF_SERIALIZATION_NS];
microsecondsElement = [element
elementForName: @"microseconds"
microsecondsAttribute =
[element attributeForName: @"microseconds"];
namespace: OF_SERIALIZATION_NS];
if (secondsElement == nil || microsecondsElement == nil)
if (secondsAttribute == nil || microsecondsAttribute == nil)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
seconds = (int64_t)[secondsElement decimalValue];
microseconds = (uint32_t)[microsecondsElement decimalValue];
seconds = (int64_t)[secondsAttribute decimalValue];
microseconds = (uint32_t)[microsecondsAttribute decimalValue];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
-
+
+
-
+
+
+
+
-
-
-
+
+
+
+
+
-
-
+
+
+
-
-
-
-
+
+
-
-
-
-
-
+
-
|
- (OFString*)description
{
return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
OFString *secondsString, *microsecondsString;
element = [OFXMLElement elementWithName: @"object"
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS];
secondsString = [OFString stringWithFormat: @"%" @PRId64, seconds];
microsecondsString = [OFString stringWithFormat: @"%" @PRId64,
microseconds];
pool = [[OFAutoreleasePool alloc] init];
[element addAttributeWithName: @"class"
stringValue: [self className]];
[element addAttributeWithName: @"seconds"
stringValue: secondsString];
[element addAttributeWithName: @"microseconds"
stringValue: microsecondsString];
[element addChild:
[OFXMLElement elementWithName: @"seconds"
[element retain];
@try {
[pool release];
namespace: OF_SERIALIZATION_NS
stringValue: [OFString stringWithFormat:
@"%" @PRId64, seconds]]];
[element addChild:
} @finally {
[element autorelease];
[OFXMLElement elementWithName: @"microseconds"
namespace: OF_SERIALIZATION_NS
stringValue: [OFString stringWithFormat:
@"%" @PRIu32, microseconds]]];
}
[pool release];
return element;
}
- (uint32_t)microsecond
{
return microseconds;
|
︙ | | |
Modified src/OFDictionary.m
from [ec22393fcd]
to [b73da14229].
︙ | | |
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
+
|
#import "OFArray.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
#import "macros.h"
struct of_dictionary_bucket of_dictionary_deleted_bucket = {};
#define DELETED &of_dictionary_deleted_bucket
|
︙ | | |
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
|
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
|
+
-
+
-
-
-
+
+
+
-
-
-
-
+
+
-
-
+
-
-
+
+
+
+
+
+
+
-
+
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
-
-
+
-
-
-
+
+
+
-
-
-
-
+
-
-
-
-
+
-
-
-
|
return self;
}
- initWithSerialization: (OFXMLElement*)element
{
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFAutoreleasePool *pool, *pool2;
OFAutoreleasePool *pool2;
OFMutableDictionary *dictionary;
OFArray *pairs;
OFEnumerator *enumerator;
OFXMLElement *pair;
OFArray *keys, *objects;
OFEnumerator *keyEnumerator, *objectEnumerator;
OFXMLElement *keyElement, *objectElement;
pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
dictionary = [OFMutableDictionary dictionary];
pairs = [element elementsForName: @"pair"
namespace: OF_SERIALIZATION_NS];
keys = [element elementsForName: @"key"
namespace: OF_SERIALIZATION_NS];
objects = [element elementsForName: @"object"
namespace: OF_SERIALIZATION_NS];
if ([keys count] != [objects count])
@throw [OFInvalidFormatException newWithClass: isa];
enumerator = [pairs objectEnumerator];
keyEnumerator = [keys objectEnumerator];
objectEnumerator = [objects objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((keyElement = [keyEnumerator nextObject]) != nil &&
while ((pair = [enumerator nextObject]) != nil) {
OFXMLElement *keyElement, *valueElement;
(objectElement = [objectEnumerator nextObject]) != nil) {
OFXMLElement *key, *object;
id <OFSerialization, OFCopying> key;
id <OFSerialization> object;
keyElement = [pair elementForName: @"key"
namespace: OF_SERIALIZATION_NS];
valueElement = [pair
key = [[keyElement elementsForNamespace:
OF_SERIALIZATION_NS] firstObject];
object = [[objectElement elementsForNamespace:
elementForName: @"value"
namespace: OF_SERIALIZATION_NS];
OF_SERIALIZATION_NS] firstObject];
if (keyElement == nil || valueElement == nil)
@throw [OFInvalidArgumentException
newWithClass: isa
if (key == nil || object == nil)
@throw [OFInvalidFormatException
newWithClass: isa];
selector: _cmd];
key = [[keyElement elementForName: @"object"
namespace: OF_SERIALIZATION_NS]
objectByDeserializing];
[dictionary setObject: [object objectByDeserializing]
object = [[valueElement
elementForName: @"object"
namespace: OF_SERIALIZATION_NS]
objectByDeserializing];
forKey: [key objectByDeserializing]];
[dictionary setObject: object
forKey: key];
[pool2 releaseObjects];
}
self = [self initWithDictionary: dictionary];
[pool release];
|
︙ | | |
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
|
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
|
+
-
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
-
+
+
+
+
|
*/
ret->isa = [OFString class];
return ret;
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFAutoreleasePool *pool, *pool2;
OFAutoreleasePool *pool2;
OFXMLElement *element;
OFEnumerator *keyEnumerator, *objectEnumerator;
id <OFSerialization> key, object;
element = [OFXMLElement elementWithName: @"object"
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS];
pool = [[OFAutoreleasePool alloc] init];
[element addAttributeWithName: @"class"
stringValue: [self className]];
keyEnumerator = [self keyEnumerator];
objectEnumerator = [self objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
OFXMLElement *pair, *keyElement, *valueElement;
OFXMLElement *keyElement, *objectElement;
pair = [OFXMLElement elementWithName: @"pair"
namespace: OF_SERIALIZATION_NS];
keyElement = [OFXMLElement
elementWithName: @"key"
namespace: OF_SERIALIZATION_NS];
[keyElement addChild: [key XMLElementBySerializing]];
[pair addChild: keyElement];
valueElement = [OFXMLElement
elementWithName: @"value"
objectElement = [OFXMLElement
elementWithName: @"object"
namespace: OF_SERIALIZATION_NS];
[valueElement addChild: [object XMLElementBySerializing]];
[objectElement addChild: [object XMLElementBySerializing]];
[pair addChild: valueElement];
[element addChild: pair];
[element addChild: keyElement];
[element addChild: objectElement];
[pool2 releaseObjects];
}
[element retain];
@try {
[pool release];
[pool release];
} @finally {
[element autorelease];
}
return element;
}
@end
@implementation OFDictionaryEnumerator
- initWithDictionary: (OFDictionary*)dictionary_
|
︙ | | |
Modified src/OFList.m
from [8deaa7a6b1]
to [037aaf69fa].
︙ | | |
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
67
68
69
70
|
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
67
|
+
-
+
-
-
-
-
+
+
-
-
-
+
-
-
+
-
+
+
-
+
|
}
- initWithSerialization: (OFXMLElement*)element
{
self = [self init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFAutoreleasePool *pool, *pool2;
OFAutoreleasePool *pool2;
OFEnumerator *enumerator;
OFXMLElement *child;
pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
enumerator = [[element
enumerator = [[element children] objectEnumerator];
elementsForName: @"object"
namespace: OF_SERIALIZATION_NS] objectEnumerator];
pool2 = [[OFAutoreleasePool alloc] init];
while ((child = [enumerator nextObject]) != nil) {
id object = [child objectByDeserializing];
if (![[child namespace] isEqual: OF_SERIALIZATION_NS])
continue;
[self appendObject: object];
[self appendObject: [child objectByDeserializing]];
[pool2 releaseObjects];
}
[pool release];
} @catch (id e) {
[self release];
|
︙ | | |
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
+
-
+
-
+
-
+
-
-
+
-
+
+
+
-
+
+
+
+
|
*/
ret->isa = [OFString class];
return ret;
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFAutoreleasePool *pool;
OFAutoreleasePool *pool2;
OFXMLElement *element;
of_list_object_t *iter;
element = [OFXMLElement elementWithName: @"object"
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS];
pool = [[OFAutoreleasePool alloc] init];
pool2 = [[OFAutoreleasePool alloc] init];
[element addAttributeWithName: @"class"
stringValue: [self className]];
for (iter = firstListObject; iter != NULL; iter = iter->next) {
[element addChild: [iter->object XMLElementBySerializing]];
[pool releaseObjects];
[pool2 releaseObjects];
}
[element retain];
@try {
[pool release];
[pool release];
} @finally {
[element autorelease];
}
return element;
}
- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
objects: (id*)objects
count: (int)count_
|
︙ | | |
Modified src/OFNull.m
from [28d217dbf3]
to [5534adc13a].
︙ | | |
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
-
-
+
+
-
-
+
-
+
+
-
-
+
+
+
+
+
+
|
{
OFAutoreleasePool *pool;
[self release];
pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
[pool release];
return [OFNull null];
}
- (OFString*)description
{
return @"<null>";
}
- copy
{
return self;
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"object"
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS];
[element addAttributeWithName: @"class"
stringValue: [self className]];
[element retain];
@try {
[pool release];
} @finally {
[element autorelease];
}
return element;
}
- autorelease
{
return self;
|
︙ | | |
Modified src/OFNumber.m
from [a47eecf9ee]
to [a3610e7d0e].
︙ | | |
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
|
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
|
-
-
+
+
-
-
|
{
self = [super init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *typeString;
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
typeString = [[element attributeForName: @"type"] stringValue];
if ([typeString isEqual: @"boolean"]) {
type = OF_NUMBER_BOOL;
|
︙ | | |
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
|
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
|
-
+
-
-
+
+
-
-
-
-
-
+
-
|
default:
@throw [OFInvalidFormatException newWithClass: isa];
}
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"object"
namespace: OF_SERIALIZATION_NS];
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS
pool = [[OFAutoreleasePool alloc] init];
[element addAttributeWithName: @"class"
stringValue: [self className]];
stringValue: [self description]];
[element setStringValue: [self description]];
switch (type) {
case OF_NUMBER_BOOL:
[element addAttributeWithName: @"type"
stringValue: @"boolean"];
break;
case OF_NUMBER_UCHAR:
|
︙ | | |
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
|
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
|
+
+
-
+
+
+
+
|
[OFString stringWithFormat: @"%" PRIX64, d.i]];
break;
default:
@throw [OFInvalidFormatException newWithClass: isa];
}
[element retain];
@try {
[pool release];
[pool release];
} @finally {
[element autorelease];
}
return element;
}
@end
|
Modified src/OFObject+Serialization.m
from [3d621a2dfd]
to [dc7ca94ebf].
︙ | | |
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
+
+
-
+
-
-
+
+
-
+
|
selector: @selector(stringBySerializing)];
pool = [[OFAutoreleasePool alloc] init];
element = [(id)self XMLElementBySerializing];
root = [OFXMLElement elementWithName: @"serialization"
namespace: OF_SERIALIZATION_NS];
[root addAttributeWithName: @"version"
stringValue: @"0"];
[root addChild: element];
ret = [@"<?xml version='1.0' encoding='UTF-8'?>\n"
stringByAppendingString: [root XMLStringWithIndentation: 2]];
[ret retain];
[ret retain];
@try {
[pool release];
} @catch (id e) {
[ret release];
} @finally {
[ret autorelease];
}
return [ret autorelease];
return ret;
}
@end
|
Modified src/OFString+Serialization.m
from [4e08e43153]
to [9bfc5b2d3f].
︙ | | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
-
+
-
|
- (id)objectByDeserializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *root = [OFXMLElement elementWithXMLString: self];
OFArray *elements;
id object;
elements = [root elementsForName: @"object"
elements = [root elementsForNamespace: OF_SERIALIZATION_NS];
namespace: OF_SERIALIZATION_NS];
if ([elements count] != 1)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
object = [[[elements firstObject] objectByDeserializing] retain];
|
︙ | | |
Modified src/OFString.m
from [e237ea2567]
to [88ca1bcd74].
︙ | | |
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
|
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
|
-
-
+
+
-
-
|
}
- initWithSerialization: (OFXMLElement*)element
{
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
self = [self initWithString: [element stringValue]];
[pool release];
} @catch (id e) {
|
︙ | | |
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
|
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
|
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
-
-
+
-
|
- (OFString*)description
{
return [[self copy] autorelease];
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
OFString *className;
if ([self isKindOfClass: [OFConstantString class]])
className = @"OFString";
else
className = [self className];
element = [OFXMLElement elementWithName: @"object"
element = [OFXMLElement elementWithName: className
namespace: OF_SERIALIZATION_NS
stringValue: self];
pool = [[OFAutoreleasePool alloc] init];
if ([self isKindOfClass: [OFConstantString class]])
[element addAttributeWithName: @"class"
stringValue: @"OFString"];
else
[element addAttributeWithName: @"class"
[element retain];
@try {
[pool release];
} @finally {
[element autorelease];
stringValue: [self className]];
}
[pool release];
return element;
}
- (of_unichar_t)characterAtIndex: (size_t)index
{
of_unichar_t c;
|
︙ | | |
Modified src/OFURL.m
from [83b3387d68]
to [e46fcb96eb].
︙ | | |
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
-
-
+
+
-
-
|
}
- initWithSerialization: (OFXMLElement*)element
{
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
self = [self initWithString: [element stringValue]];
[pool release];
} @catch (id e) {
|
︙ | | |
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
-
+
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
-
|
- (OFString*)description
{
return [self string];
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"object"
namespace: OF_SERIALIZATION_NS];
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS
stringValue: [self string]];
pool = [[OFAutoreleasePool alloc] init];
[element addAttributeWithName: @"class"
stringValue: [self className]];
[element setStringValue: [self string]];
[element retain];
@try {
[pool release];
} @finally {
[element autorelease];
}
[pool release];
return element;
}
@end
|
Modified src/OFXMLAttribute.m
from [6b3b878926]
to [836db12fdb].
︙ | | |
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
-
-
+
+
-
-
-
-
+
+
-
-
+
-
-
-
-
+
+
+
-
|
- initWithSerialization: (OFXMLElement*)element
{
self = [super init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
name = [[[element
elementForName: @"name"
name = [[[element attributeForName: @"name"] stringValue]
copy];
namespace: OF_SERIALIZATION_NS] stringValue] retain];
ns = [[[element
ns = [[[element attributeForName: @"namespace"] stringValue]
elementForName: @"namespace"
namespace: OF_SERIALIZATION_NS] stringValue] retain];
stringValue = [[[element
elementForName: @"stringValue"
copy];
stringValue = [[[element attributeForName: @"stringValue"]
stringValue] copy];
namespace: OF_SERIALIZATION_NS] stringValue] retain];
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
|
︙ | | |
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
-
+
-
+
-
-
-
-
+
+
-
-
-
-
-
+
-
-
-
-
-
+
+
+
-
-
+
+
+
-
+
+
+
+
|
OF_HASH_FINALIZE(hash);
return hash;
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"object"
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS];
pool = [[OFAutoreleasePool alloc] init];
[element addAttributeWithName: @"class"
stringValue: [self className]];
[element addAttributeWithName: @"name"
stringValue: name];
[element addChild:
[OFXMLElement elementWithName: @"name"
namespace: OF_SERIALIZATION_NS
stringValue: name]];
if (ns != nil)
[element addChild:
[element addAttributeWithName: @"namespace"
[OFXMLElement elementWithName: @"namespace"
namespace: OF_SERIALIZATION_NS
stringValue: ns]];
[element addChild:
[OFXMLElement elementWithName: @"stringValue"
stringValue: ns];
[element addAttributeWithName: @"stringValue"
namespace: OF_SERIALIZATION_NS
stringValue: stringValue]];
stringValue: stringValue];
[element retain];
@try {
[pool release];
[pool release];
} @finally {
[element autorelease];
}
return element;
}
@end
|
Modified src/OFXMLElement+Serialization.m
from [7fc442d7ba]
to [7e2dfe5b27].
︙ | | |
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
67
68
69
70
71
72
73
74
75
|
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
67
|
-
-
-
-
-
-
-
+
-
-
-
+
+
-
-
+
|
int _OFXMLElement_Serialization_reference;
@implementation OFXMLElement (Serialization)
- (id)objectByDeserializing
{
OFAutoreleasePool *pool;
OFString *className;
Class class;
id <OFSerialization> object;
pool = [[OFAutoreleasePool alloc] init];
className = [[self attributeForName: @"class"] stringValue];
if (className == nil)
@throw [OFNotImplementedException
newWithClass: nil
selector: @selector(initWithSerialization:)];
class = objc_lookUpClass([className cString]);
if ((class = objc_lookUpClass([name cString])) == Nil)
if (class == Nil)
@throw [OFNotImplementedException newWithClass: Nil];
if (![class conformsToProtocol: @protocol(OFSerialization)])
@throw [OFNotImplementedException
newWithClass: class
selector: @selector(initWithSerialization:)];
object = [[class alloc] initWithSerialization: self];
@try {
[pool release];
} @catch (id e) {
[object release];
} @finally {
[object autorelease];
@throw e;
}
return [object autorelease];
return object;
}
@end
|
Modified src/OFXMLElement.m
from [de3d68907d]
to [4687f4ccbd].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
+
|
#import "OFDictionary.h"
#import "OFXMLAttribute.h"
#import "OFXMLParser.h"
#import "OFXMLElementBuilder.h"
#import "OFAutoreleasePool.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFMalformedXMLException.h"
#import "OFNotImplementedException.h"
#import "OFUnboundNamespaceException.h"
#import "macros.h"
/* References for static linking */
|
︙ | | |
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
-
-
+
+
-
-
-
+
-
-
-
+
-
-
-
-
+
+
+
-
-
+
-
-
+
+
+
-
+
-
-
-
+
+
-
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
-
|
self = [super init];
@try {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *attributesElement, *namespacesElement;
OFXMLElement *childrenElement;
if (![[element name] isEqual: @"object"] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
![[[element attributeForName: @"class"] stringValue]
isEqual: [self className]])
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
name = [[[element
name = [[[element attributeForName: @"name"] stringValue] copy];
elementForName: @"name"
namespace: OF_SERIALIZATION_NS] stringValue] copy];
ns = [[[element
ns = [[[element attributeForName: @"namespace"] stringValue]
elementForName: @"namespace"
namespace: OF_SERIALIZATION_NS] stringValue] copy];
defaultNamespace = [[[element
elementForName: @"defaultNamespace"
copy];
defaultNamespace = [[[element attributeForName:
@"defaultNamespace"] stringValue] copy];
namespace: OF_SERIALIZATION_NS] stringValue] copy];
characters = [[[element
elementForName: @"characters"
namespace: OF_SERIALIZATION_NS] stringValue] copy];
CDATA = [[[element
elementForName: @"CDATA"
namespace: OF_SERIALIZATION_NS] stringValue] copy];
comment = [[[element
elementForName: @"comment"
namespace: OF_SERIALIZATION_NS] stringValue] copy];
attributesElement = [element
attributesElement = [[[element
elementForName: @"attributes"
namespace: OF_SERIALIZATION_NS];
namespacesElement = [element
namespace: OF_SERIALIZATION_NS] elementsForNamespace:
OF_SERIALIZATION_NS] firstObject];
namespacesElement = [[[element
elementForName: @"namespaces"
namespace: OF_SERIALIZATION_NS];
namespace: OF_SERIALIZATION_NS] elementsForNamespace:
childrenElement = [element elementForName: @"children"
namespace: OF_SERIALIZATION_NS];
OF_SERIALIZATION_NS] firstObject];
childrenElement = [[[element
attributes = [[[attributesElement
elementForName: @"object"
namespace: OF_SERIALIZATION_NS] objectByDeserializing]
elementForName: @"children"
namespace: OF_SERIALIZATION_NS] elementsForNamespace:
retain];
namespaces = [[[namespacesElement
elementForName: @"object"
namespace: OF_SERIALIZATION_NS] objectByDeserializing]
retain];
children = [[[childrenElement
elementForName: @"object"
namespace: OF_SERIALIZATION_NS] objectByDeserializing]
OF_SERIALIZATION_NS] firstObject];
attributes = [[attributesElement objectByDeserializing] copy];
namespaces = [[namespacesElement objectByDeserializing] copy];
children = [[childrenElement objectByDeserializing] copy];
retain];
if (!((name != nil || ns != nil || defaultNamespace != nil ||
[attributes count] > 0 || [namespaces count] > 0 ||
[children count] > 0) ^ (characters != nil) ^
(CDATA != nil) ^ (comment != nil)))
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
|
︙ | | |
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
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
|
724
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
|
-
+
-
+
-
-
-
-
-
-
+
-
-
-
+
-
+
-
-
-
+
-
-
+
-
-
+
|
- (OFString*)description
{
return [self XMLStringWithIndentation: 2];
}
- (OFXMLElement*)XMLElementBySerializing
{
OFAutoreleasePool *pool;
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"object"
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS];
pool = [[OFAutoreleasePool alloc] init];
[element addAttributeWithName: @"class"
stringValue: [self className]];
if (name != nil)
[element addChild:
[element addAttributeWithName: @"name"
[OFXMLElement elementWithName: @"name"
namespace: OF_SERIALIZATION_NS
stringValue: name]];
stringValue: name];
if (ns != nil)
[element addChild:
[element addAttributeWithName: @"namespace"
[OFXMLElement elementWithName: @"namespace"
namespace: OF_SERIALIZATION_NS
stringValue: ns]];
stringValue: ns];
if (defaultNamespace != nil)
[element addChild:
[OFXMLElement elementWithName: @"defaultNamespace"
[element addAttributeWithName: @"defaultNamespace"
namespace: OF_SERIALIZATION_NS
stringValue: defaultNamespace]];
stringValue: defaultNamespace];
if (attributes != nil) {
OFXMLElement *attributesElement;
attributesElement =
[OFXMLElement elementWithName: @"attributes"
namespace: OF_SERIALIZATION_NS];
|
︙ | | |
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
|
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
|
-
-
+
+
-
-
+
+
+
+
+
+
-
+
+
+
+
|
if (characters != nil)
[element addChild:
[OFXMLElement elementWithName: @"characters"
namespace: OF_SERIALIZATION_NS
stringValue: characters]];
if (CDATA != nil)
[element addChild:
if (CDATA != nil) {
OFXMLElement *CDATAElement =
[OFXMLElement elementWithName: @"CDATA"
namespace: OF_SERIALIZATION_NS
stringValue: CDATA]];
namespace: OF_SERIALIZATION_NS];
[CDATAElement addChild: [OFXMLElement elementWithCDATA: CDATA]];
[element addChild: CDATAElement];
}
if (comment != nil)
[element addChild:
[OFXMLElement elementWithName: @"comment"
namespace: OF_SERIALIZATION_NS
stringValue: comment]];
[element retain];
@try {
[pool release];
[pool release];
} @finally {
[element autorelease];
}
return element;
}
- (void)addAttribute: (OFXMLAttribute*)attribute
{
if (name == nil)
|
︙ | | |
Modified tests/OFSerializationTests.m
from [527ae62e46]
to [eec9b3e1a8].
︙ | | |
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
+
-
+
|
forKey: a];
[d setObject: @"B\"la"
forKey: @"Blub"];
[l appendObject: @"Hello"];
[l appendObject: @"Wo\rld!\nHow are you?"];
[l appendObject: [OFURL URLWithString: @"https://webkeks.org/"]];
[l appendObject:
[l appendObject: [OFXMLElement elementWithXMLString: @"<x><y/></x>"]];
[OFXMLElement elementWithXMLString: @"<x><y/><![CDATA[<]]></x>"]];
[d setObject: @"list"
forKey: l];
TEST(@"-[stringBySerializing]",
(s = [d stringBySerializing]) && [s isEqual:
[OFString stringWithContentsOfFile: @"serialization.xml"]])
|
︙ | | |
Modified tests/serialization.xml
from [df9f9a2c48]
to [7e037e6365].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
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
|
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
-
-
-
+
-
-
-
-
-
-
-
-
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
-
-
-
-
-
+
-
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
-
+
+
+
|
<?xml version='1.0' encoding='UTF-8'?>
<serialization xmlns='https://webkeks.org/objfw/serialization'>
<object class='OFMutableDictionary'>
<serialization xmlns='https://webkeks.org/objfw/serialization' version='0'>
<OFMutableDictionary>
<pair>
<key>
<object class='OFArray'>
<object class='OFString'>Qu"xbar
test</object>
<object class='OFNumber' type='signed'>1234</object>
<object class='OFMutableString'>asd</object>
<key>
<OFArray>
<OFString>Qu"xbar
test</OFString>
<OFNumber type='signed'>1234</OFNumber>
<OFMutableString>asd</OFMutableString>
<object class='OFDate'>
<seconds>1234</seconds>
<microseconds>5678</microseconds>
<OFDate seconds='1234' microseconds='5678'/>
</object>
</object>
</key>
</OFArray>
<value>
<object class='OFString'>Hello</object>
</value>
</pair>
<pair>
<key>
<object class='OFString'>Blub</object>
</key>
</key>
<value>
<object class='OFString'>B"la</object>
</value>
</pair>
<object>
<OFString>Hello</OFString>
</object>
<pair>
<key>
<object class='OFList'>
<object class='OFString'>Hello</object>
<object class='OFString'>Wo
ld!
How are you?</object>
<object class='OFURL'>https://webkeks.org/</object>
<object class='OFXMLElement'>
<key>
<OFList>
<OFString>Hello</OFString>
<OFString>Wo
ld!
How are you?</OFString>
<OFURL>https://webkeks.org/</OFURL>
<OFXMLElement name='x'>
<name>x</name>
<namespaces>
<object class='OFMutableDictionary'>
<namespaces>
<OFMutableDictionary>
<pair>
<key>
<object class='OFString'>http://www.w3.org/2000/xmlns/</object>
</key>
<key>
<OFString>http://www.w3.org/2000/xmlns/</OFString>
</key>
<value>
<object class='OFString'>xmlns</object>
</value>
<object>
<OFString>xmlns</OFString>
</object>
<key>
<OFString>http://www.w3.org/XML/1998/namespace</OFString>
</pair>
<pair>
<key>
<object class='OFString'>http://www.w3.org/XML/1998/namespace</object>
</key>
</key>
<value>
<object class='OFString'>xml</object>
<object>
</value>
</pair>
<OFString>xml</OFString>
</object>
</OFMutableDictionary>
</namespaces>
<children>
<object class='OFMutableArray'>
<object class='OFXMLElement'>
</namespaces>
<children>
<OFMutableArray>
<OFXMLElement name='y'>
<name>y</name>
<namespaces>
<object class='OFMutableDictionary'>
<namespaces>
<OFMutableDictionary>
<pair>
<key>
<object class='OFString'>http://www.w3.org/2000/xmlns/</object>
</key>
<value>
<object class='OFString'>xmlns</object>
<key>
<OFString>http://www.w3.org/2000/xmlns/</OFString>
</key>
<object>
<OFString>xmlns</OFString>
</object>
<key>
<OFString>http://www.w3.org/XML/1998/namespace</OFString>
</key>
<object>
<OFString>xml</OFString>
</value>
</pair>
<pair>
<key>
<object class='OFString'>http://www.w3.org/XML/1998/namespace</object>
</key>
<value>
<object class='OFString'>xml</object>
</value>
</pair>
</object>
</OFMutableDictionary>
</namespaces>
</object>
</object>
</children>
</object>
</object>
</key>
</namespaces>
</OFXMLElement>
<OFXMLElement>
<CDATA><![CDATA[<]]></CDATA>
</OFXMLElement>
</OFMutableArray>
</children>
</OFXMLElement>
</OFList>
</key>
<object>
<OFString>list</OFString>
</object>
<key>
<OFString>Blub</OFString>
</key>
<value>
<object class='OFString'>list</object>
<object>
</value>
</pair>
</object>
<OFString>B"la</OFString>
</object>
</OFMutableDictionary>
</serialization>
|