Modified .fossil-settings/clean-glob
from [06b87ad48d]
to [0ae1b8a1ac].
︙ | | |
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
-
|
src/tls/Info.plist
tests/DerivedData
tests/EBOOT.PBP
tests/Info.plist
tests/PARAM.SFO
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/testfile_ini.m
tests/tests
tests/tests.3dsx
tests/tests.arm9
tests/tests.nds
|
︙ | | |
Modified .fossil-settings/ignore-glob
from [23cb69850b]
to [eed8ea3523].
︙ | | |
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
|
tests/Info.plist
tests/PARAM.SFO
tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/testfile_ini.m
tests/tests
tests/tests.3dsx
tests/tests.arm9
tests/tests.nds
|
︙ | | |
Modified .gitignore
from [726b780402]
to [9fa51c850c].
︙ | | |
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
|
tests/Info.plist
tests/PARAM.SFO
tests/iOS.xcodeproj/*.pbxuser
tests/iOS.xcodeproj/project.xcworkspace
tests/iOS.xcodeproj/xcuserdata
tests/objc_sync/objc_sync
tests/plugin/Info.plist
tests/serialization_xml.m
tests/terminal/terminal_tests
tests/testfile_bin.m
tests/testfile_ini.m
tests/tests
tests/tests.3dsx
tests/tests.arm9
tests/tests.nds
|
︙ | | |
Modified src/Makefile
from [534f043ed9]
to [3265595cf5].
︙ | | |
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
-
-
-
-
|
OFMutableZIPArchiveEntry.m \
OFNotification.m \
OFNotificationCenter.m \
OFNull.m \
OFNumber.m \
OFObject.m \
OFObject+KeyValueCoding.m \
OFObject+Serialization.m \
OFOnce.m \
OFOptionsParser.m \
OFPBKDF2.m \
OFPair.m \
OFRIPEMD160Hash.m \
OFRunLoop.m \
OFSHA1Hash.m \
OFSHA224Hash.m \
OFSHA224Or256Hash.m \
OFSHA256Hash.m \
OFSHA384Hash.m \
OFSHA384Or512Hash.m \
OFSHA512Hash.m \
OFScrypt.m \
OFSecureData.m \
OFSeekableStream.m \
OFSerialization.m \
OFSet.m \
OFSortedList.m \
OFStdIOStream.m \
OFStream.m \
OFString.m \
OFString+CryptographicHashing.m \
OFString+JSONParsing.m \
OFString+PercentEncoding.m \
OFString+PropertyListParsing.m \
OFString+Serialization.m \
OFString+XMLEscaping.m \
OFString+XMLUnescaping.m \
${OF_SUBPROCESS_M} \
OFSettings.m \
OFSystemInfo.m \
OFTarArchive.m \
OFTarArchiveEntry.m \
OFThread.m \
OFTimer.m \
OFTriple.m \
OFUUID.m \
OFValue.m \
OFXMLAttribute.m \
OFXMLCDATA.m \
OFXMLCharacters.m \
OFXMLComment.m \
OFXMLElement.m \
OFXMLElement+Serialization.m \
OFXMLElementBuilder.m \
OFXMLNode.m \
OFXMLParser.m \
OFXMLProcessingInstruction.m \
OFZIPArchive.m \
OFZIPArchiveEntry.m \
${USE_SRCS_FILES} \
|
︙ | | |
Modified src/OFAdjacentArray.m
from [6f7bf1cc03]
to [3d57d1e63c].
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
|
#include <stdarg.h>
#import "OFAdjacentArray.h"
#import "OFAdjacentSubarray.h"
#import "OFData.h"
#import "OFMutableAdjacentArray.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
@implementation OFAdjacentArray
- (instancetype)init
|
︙ | | |
146
147
148
149
150
151
152
153
154
155
156
157
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
191
192
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
for (size_t i = 0; i < count; i++)
[objects[i] release];
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if ((![element.name isEqual: @"OFArray"] &&
![element.name isEqual: @"OFMutableArray"]) ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *child in
[element elementsForNamespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
id object;
object = child.objectByDeserializing;
[_array addItem: &object];
[object retain];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (size_t)count
{
return _array.count;
}
|
︙ | | |
Modified src/OFArray.h
from [6026515902]
to [3d63ad7d51].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
|
#endif
#include <stdarg.h>
#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
|
︙ | | |
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
-
+
|
* @class OFArray OFArray.h ObjFW/OFArray.h
*
* @brief An abstract class for storing objects in an array.
*
* @note Subclasses must implement @ref count and @ref objectAtIndex:.
*/
@interface OFArray OF_GENERIC(ObjectType): OFObject <OFCopying,
OFMutableCopying, OFCollection, OFSerialization, OFJSONRepresentation,
OFMutableCopying, OFCollection, OFJSONRepresentation,
OFMessagePackRepresentation>
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define ObjectType id
#endif
/**
* @brief The objects of the array as a C array.
*
|
︙ | | |
Modified src/OFArray.m
from [9908191730]
to [79e2c56f24].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
|
#import "OFArray.h"
#import "OFArray+Private.h"
#import "OFAdjacentArray.h"
#import "OFData.h"
#import "OFNull.h"
#import "OFString.h"
#import "OFSubarray.h"
#import "OFXMLElement.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
static struct {
Class isa;
|
︙ | | |
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
-
-
-
-
-
|
- (instancetype)initWithObjects: (id const *)objects
count: (size_t)count
{
return (id)[[OFAdjacentArray alloc] initWithObjects: objects
count: count];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFAdjacentArray alloc] initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
|
︙ | | |
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
-
-
-
-
-
|
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithObjects: (id const *)objects
count: (size_t)count
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OF_INVALID_INIT_METHOD
}
- (size_t)count
{
OF_UNRECOGNIZED_SELECTOR
}
|
︙ | | |
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
|
533
534
535
536
537
538
539
540
541
542
543
544
545
546
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
objc_autoreleasePoolPop(pool);
[ret makeImmutable];
return [ret autorelease];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
if ([self isKindOfClass: [OFMutableArray class]])
element = [OFXMLElement elementWithName: @"OFMutableArray"
namespace: OFSerializationNS];
else
element = [OFXMLElement elementWithName: @"OFArray"
namespace: OFSerializationNS];
for (id <OFSerialization> object in self) {
void *pool2 = objc_autoreleasePoolPush();
[element addChild: object.XMLElementBySerializing];
objc_autoreleasePoolPop(pool2);
}
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
- (OFString *)JSONRepresentationWithOptions:
(OFJSONRepresentationOptions)options
|
︙ | | |
Modified src/OFCountedMapTableSet.m
from [5a8f5db3ac]
to [7a63d8437b].
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-
|
#import "OFCountedMapTableSet.h"
#import "OFArray.h"
#import "OFMapTable.h"
#import "OFMutableMapTableSet.h"
#import "OFString.h"
#import "OFXMLAttribute.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFEnumerationMutationException.h"
#import "OFOutOfRangeException.h"
@implementation OFCountedMapTableSet
|
︙ | | |
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
while ((object = va_arg(arguments, id)) != nil)
[self addObject: object];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if (![element.name isEqual: @"OFCountedSet"] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *objectElement in
[element elementsForName: @"object"
namespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *object;
OFXMLAttribute *countAttribute;
unsigned long long count;
object = [objectElement elementsForNamespace:
OFSerializationNS].firstObject;
countAttribute =
[objectElement attributeForName: @"count"];
if (object == nil || countAttribute == nil)
@throw [OFInvalidFormatException exception];
count = countAttribute.unsignedLongLongValue;
if (count > SIZE_MAX || count > UINTPTR_MAX)
@throw [OFOutOfRangeException exception];
[_mapTable setObject: (void *)(uintptr_t)count
forKey: object.objectByDeserializing];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (size_t)countForObject: (id)object
{
return (size_t)(uintptr_t)[_mapTable objectForKey: object];
}
|
︙ | | |
Modified src/OFCountedSet.m
from [39bc22ff53]
to [2550c38e59].
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-
|
#include <stdlib.h>
#import "OFCountedSet.h"
#import "OFCountedMapTableSet.h"
#import "OFNumber.h"
#import "OFString.h"
#import "OFXMLElement.h"
static struct {
Class isa;
} placeholder;
@interface OFCountedSetPlaceholder: OFCountedSet
@end
|
︙ | | |
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
-
-
-
-
-
-
|
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
return (id)[[OFCountedMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFCountedMapTableSet alloc]
initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
|
︙ | | |
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
}
- (id)mutableCopy
{
return [[OFCountedSet alloc] initWithSet: self];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"OFCountedSet"
namespace: OFSerializationNS];
for (id <OFSerialization> object in self) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *objectElement;
OFString *count;
count =
[OFString stringWithFormat: @"%zu",
[self countForObject: object]];
objectElement = [OFXMLElement
elementWithName: @"object"
namespace: OFSerializationNS];
[objectElement addAttributeWithName: @"count"
stringValue: count];
[objectElement addChild: object.XMLElementBySerializing];
[element addChild: objectElement];
objc_autoreleasePoolPop(pool2);
}
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsAndCountUsingBlock: (OFCountedSetEnumerationBlock)block
{
[self enumerateObjectsUsingBlock: ^ (id object, bool *stop) {
block(object, [self countForObject: object], stop);
}];
}
|
︙ | | |
Modified src/OFData.h
from [72a15add33]
to [c6b9b129b7].
︙ | | |
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
-
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFSerialization.h"
#import "OFMessagePackRepresentation.h"
/*! @file */
OF_ASSUME_NONNULL_BEGIN
@class OFIRI;
|
︙ | | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
-
-
-
-
+
|
OFDataSearchBackwards = 1
} OFDataSearchOptions;
/**
* @class OFData OFData.h ObjFW/OFData.h
*
* @brief A class for storing arbitrary data in an array.
*
* For security reasons, serialization and deserialization is only implemented
* for OFData with item size 1.
*/
@interface OFData: OFObject <OFCopying, OFMutableCopying, OFComparing,
OFSerialization, OFMessagePackRepresentation>
OFMessagePackRepresentation>
{
unsigned char *_Nullable _items;
size_t _count, _itemSize;
bool _freeWhenDone;
@private
OFData *_Nullable _parentData;
OF_RESERVE_IVARS(OFData, 4)
|
︙ | | |
Modified src/OFData.m
from [5fe996c5b2]
to [fedaecf95c].
︙ | | |
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-
|
# import "OFFileManager.h"
#endif
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFStream.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
|
︙ | | |
333
334
335
336
337
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
|
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
if (!mutable)
[(OFMutableData *)self makeImmutable];
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
void *pool = objc_autoreleasePoolPush();
OFString *stringValue;
@try {
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
stringValue = element.stringValue;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithBase64EncodedString: stringValue];
objc_autoreleasePoolPop(pool);
return self;
}
- (void)dealloc
{
if (_freeWhenDone)
OFFreeMemory(_items);
[_parentData release];
|
︙ | | |
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
|
568
569
570
571
572
573
574
575
576
577
578
579
580
581
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
void *pool = objc_autoreleasePoolPush();
[[OFIRIHandler openItemAtIRI: IRI mode: @"w"] writeData: self];
objc_autoreleasePoolPop(pool);
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool;
OFXMLElement *element;
if (_itemSize != 1)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
pool = objc_autoreleasePoolPush();
element = [OFXMLElement
elementWithName: self.className
namespace: OFSerializationNS
stringValue: OFBase64Encode(_items, _count * _itemSize)];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFData *)messagePackRepresentation
{
OFMutableData *data;
if (_itemSize != 1)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
|
︙ | | |
Modified src/OFDate.h
from [e5b2860c38]
to [5d6447d0f7].
︙ | | |
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
|
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
|
-
-
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFMessagePackRepresentation.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
@class OFConstantString;
/**
* @class OFDate OFDate.h ObjFW/OFDate.h
*
* @brief A class for storing, accessing and comparing dates.
*/
#ifndef OF_DATE_M
OF_SUBCLASSING_RESTRICTED
#endif
@interface OFDate: OFObject <OFCopying, OFComparing, OFSerialization,
@interface OFDate: OFObject <OFCopying, OFComparing,
OFMessagePackRepresentation>
{
OFTimeInterval _seconds;
}
#ifdef OF_HAVE_CLASS_PROPERTIES
@property (class, readonly, nonatomic) OFDate *distantFuture;
|
︙ | | |
Modified src/OFDate.m
from [46c76c4869]
to [8b8a822187].
︙ | | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
|
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif
#import "OFStrPTime.h"
#import "OFString.h"
#import "OFSystemInfo.h"
#import "OFXMLAttribute.h"
#import "OFXMLElement.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
|
︙ | | |
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
535
536
537
538
|
491
492
493
494
495
496
497
498
499
500
501
502
503
504
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
seconds = tmAndTzToTime(&tm, tz);
objc_autoreleasePoolPop(pool);
return [self initWithTimeIntervalSince1970: seconds];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OFTimeInterval seconds;
@try {
void *pool = objc_autoreleasePoolPush();
unsigned long long value;
if (![element.name isEqual: @"OFDate"] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
if (![[element attributeForName: @"encoding"].stringValue
isEqual: @"hex"])
@throw [OFInvalidFormatException exception];
value = [element unsignedLongLongValueWithBase: 16];
if (value > UINT64_MAX)
@throw [OFOutOfRangeException exception];
seconds = OFFromBigEndianDouble(OFRawUInt64ToDouble(
OFToBigEndian64(value)));
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return [self initWithTimeIntervalSince1970: seconds];
}
- (bool)isEqual: (id)object
{
OFDate *otherDate;
if (object == self)
return true;
|
︙ | | |
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
549
550
551
552
553
554
555
556
557
558
559
560
561
562
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
}
- (OFString *)description
{
return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"OFDate"
namespace: OFSerializationNS];
[element addAttributeWithName: @"encoding" stringValue: @"hex"];
element.stringValue = [OFString stringWithFormat: @"%016" PRIx64,
OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble(
self.timeIntervalSince1970)))];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFData *)messagePackRepresentation
{
void *pool = objc_autoreleasePoolPush();
OFTimeInterval timeInterval = self.timeIntervalSince1970;
int64_t seconds = (int64_t)timeInterval;
uint32_t nanoseconds =
(uint32_t)((timeInterval - trunc(timeInterval)) * 1000000000);
|
︙ | | |
Modified src/OFDictionary.h
from [8cc1ad5dd1]
to [b2fad599b6].
︙ | | |
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
|
#endif
#include <stdarg.h>
#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
|
︙ | | |
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
-
+
|
* @note Fast enumeration on a dictionary enumerates through the keys of the
* dictionary.
*
* @note Subclasses must implement @ref objectForKey:, @ref count and
* @ref keyEnumerator.
*/
@interface OFDictionary OF_GENERIC(KeyType, ObjectType): OFObject <OFCopying,
OFMutableCopying, OFCollection, OFSerialization, OFJSONRepresentation,
OFMutableCopying, OFCollection, OFJSONRepresentation,
OFMessagePackRepresentation>
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define KeyType id
# define ObjectType id
#endif
/**
* @brief An array of all keys.
|
︙ | | |
Modified src/OFDictionary.m
from [599077ba21]
to [12d43fb634].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-
|
#import "OFDictionary.h"
#import "OFArray.h"
#import "OFCharacterSet.h"
#import "OFData.h"
#import "OFEnumerator.h"
#import "OFMapTableDictionary.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"
#import "OFUndefinedKeyException.h"
static struct {
Class isa;
|
︙ | | |
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
-
-
-
-
-
-
|
- (instancetype)initWithKey: (id <OFCopying>)firstKey
arguments: (va_list)arguments
{
return (id)[[OFMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFMapTableDictionary alloc]
initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
|
︙ | | |
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
-
-
-
-
-
|
va_end(arguments);
return ret;
}
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OF_INVALID_INIT_METHOD
}
- (id)objectForKey: (id)key
{
OF_UNRECOGNIZED_SELECTOR
}
|
︙ | | |
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
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
|
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[ret makeImmutable];
objc_autoreleasePoolPop(pool);
return ret;
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
OFEnumerator *keyEnumerator, *objectEnumerator;
id <OFSerialization> key, object;
if ([self isKindOfClass: [OFMutableDictionary class]])
element = [OFXMLElement elementWithName: @"OFMutableDictionary"
namespace: OFSerializationNS];
else
element = [OFXMLElement elementWithName: @"OFDictionary"
namespace: OFSerializationNS];
keyEnumerator = [self keyEnumerator];
objectEnumerator = [self objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *keyElement, *objectElement;
keyElement = [OFXMLElement
elementWithName: @"key"
namespace: OFSerializationNS];
[keyElement addChild: key.XMLElementBySerializing];
objectElement = [OFXMLElement
elementWithName: @"object"
namespace: OFSerializationNS];
[objectElement addChild: object.XMLElementBySerializing];
[element addChild: keyElement];
[element addChild: objectElement];
objc_autoreleasePoolPop(pool2);
}
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
- (OFString *)JSONRepresentationWithOptions:
(OFJSONRepresentationOptions)options
|
︙ | | |
Modified src/OFIRI.h
from [79cb8c8321]
to [659e656a72].
︙ | | |
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
|
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
|
-
-
+
|
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFCharacterSet.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
@class OFArray OF_GENERIC(ObjectType);
@class OFDictionary OF_GENERIC(KeyType, ObjectType);
@class OFNumber;
@class OFPair OF_GENERIC(FirstType, SecondType);
@class OFString;
/**
* @class OFIRI OFIRI.h ObjFW/OFIRI.h
*
* @brief A class for representing IRIs, URIs, URLs and URNs, for parsing them
* as well as accessing parts of them.
*
* This class follows RFC 3976 and RFC 3987.
*/
@interface OFIRI: OFObject <OFCopying, OFMutableCopying, OFSerialization>
@interface OFIRI: OFObject <OFCopying, OFMutableCopying>
{
OFString *_scheme;
OFString *_Nullable _percentEncodedHost;
OFNumber *_Nullable _port;
OFString *_Nullable _percentEncodedUser;
OFString *_Nullable _percentEncodedPassword;
OFString *_percentEncodedPath;
|
︙ | | |
Modified src/OFIRI.m
from [ee22df9601]
to [fdb5d156bf].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
|
# import "OFFileManager.h"
# import "OFFileIRIHandler.h"
#endif
#import "OFNumber.h"
#import "OFOnce.h"
#import "OFPair.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfMemoryException.h"
@interface OFIRIAllowedCharacterSetBase: OFCharacterSet
@end
|
︙ | | |
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
|
952
953
954
955
956
957
958
959
960
961
962
963
964
965
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
}
- (instancetype)of_init
{
return [super init];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
void *pool = objc_autoreleasePoolPush();
OFString *stringValue;
@try {
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
stringValue = element.stringValue;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithString: stringValue];
objc_autoreleasePoolPop(pool);
return self;
}
- (void)dealloc
{
[_scheme release];
[_percentEncodedHost release];
[_port release];
[_percentEncodedUser release];
[_percentEncodedPassword release];
|
︙ | | |
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
|
1366
1367
1368
1369
1370
1371
1372
1373
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@: %@>",
self.class, self.string];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: self.className
namespace: OFSerializationNS
stringValue: self.string];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
@end
|
Modified src/OFList.h
from [58011ed2c8]
to [e9e426b5c4].
︙ | | |
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
-
|
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
/*
* Make clang's -Wdocumentation shut about about using @struct on someting it
|
︙ | | |
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-
+
-
|
#endif
/**
* @class OFList OFList.h ObjFW/OFList.h
*
* @brief A class which provides easy to use double-linked lists.
*/
@interface OFList OF_GENERIC(ObjectType): OFObject <OFCopying, OFCollection,
@interface OFList OF_GENERIC(ObjectType): OFObject <OFCopying, OFCollection>
OFSerialization>
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define ObjectType id
#endif
{
OFListItem _Nullable _firstListItem;
OFListItem _Nullable _lastListItem;
size_t _count;
|
︙ | | |
Modified src/OFList.m
from [f8495d68a7]
to [9b79071582].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
|
#include "config.h"
#include <string.h>
#import "OFList.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFArray.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
struct _OFListItem {
struct _OFListItem *previous, *next;
|
︙ | | |
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
@synthesize firstListItem = _firstListItem, lastListItem = _lastListItem;
+ (instancetype)list
{
return [[[self alloc] init] autorelease];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *child in
[element elementsForNamespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
[self appendObject: child.objectByDeserializing];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
OFListItem next;
for (OFListItem iter = _firstListItem; iter != NULL; iter = next) {
[iter->object release];
next = iter->next;
|
︙ | | |
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
396
397
398
399
400
|
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[ret appendString: @"\n]"];
[ret makeImmutable];
return ret;
}
- (OFXMLElement *)XMLElementBySerializing
{
OFXMLElement *element =
[OFXMLElement elementWithName: self.className
namespace: OFSerializationNS];
for (OFListItem iter = _firstListItem;
iter != NULL; iter = iter->next) {
void *pool = objc_autoreleasePoolPush();
[element addChild: [iter->object XMLElementBySerializing]];
objc_autoreleasePoolPop(pool);
}
return element;
}
- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
objects: (id *)objects
count: (int)count
{
OFListItem listItem;
memcpy(&listItem, state->extra, sizeof(listItem));
|
︙ | | |
Modified src/OFMapTableDictionary.m
from [4b446060bf]
to [7d4c6241d2].
︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-
|
#import "OFMapTableDictionary.h"
#import "OFArray.h"
#import "OFMapTable+Private.h"
#import "OFMapTable.h"
#import "OFMutableMapTableDictionary.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
static void *
copy(void *object)
|
︙ | | |
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
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[_mapTable setObject: object forKey: key];
}
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
OFArray *keys, *objects;
OFEnumerator *keyEnumerator, *objectEnumerator;
OFXMLElement *keyElement, *objectElement;
keys = [element elementsForName: @"key"
namespace: OFSerializationNS];
objects = [element elementsForName: @"object"
namespace: OFSerializationNS];
if (keys.count != objects.count)
@throw [OFInvalidFormatException exception];
_mapTable = [[OFMapTable alloc]
initWithKeyFunctions: keyFunctions
objectFunctions: objectFunctions
capacity: keys.count];
keyEnumerator = [keys objectEnumerator];
objectEnumerator = [objects objectEnumerator];
while ((keyElement = [keyEnumerator nextObject]) != nil &&
(objectElement = [objectEnumerator nextObject]) != nil) {
void *pool2 = objc_autoreleasePoolPush();
OFXMLElement *key, *object;
key = [keyElement elementsForNamespace:
OFSerializationNS].firstObject;
object = [objectElement elementsForNamespace:
OFSerializationNS].firstObject;
if (key == nil || object == nil)
@throw [OFInvalidFormatException exception];
[_mapTable setObject: object.objectByDeserializing
forKey: key.objectByDeserializing];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_mapTable release];
|
︙ | | |
Modified src/OFMapTableSet.m
from [bdcf63f37b]
to [c087e53711].
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
|
#import "OFMapTableSet.h"
#import "OFArray.h"
#import "OFCountedMapTableSet.h"
#import "OFMapTable.h"
#import "OFMapTable+Private.h"
#import "OFMutableMapTableSet.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFEnumerationMutationException.h"
static void *
retain(void *object)
{
|
︙ | | |
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
while ((object = va_arg(arguments, id)) != nil)
[_mapTable setObject: (void *)1 forKey: object];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [self init];
@try {
void *pool = objc_autoreleasePoolPush();
if ((![element.name isEqual: @"OFSet"] &&
![element.name isEqual: @"OFMutableSet"]) ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
for (OFXMLElement *child in
[element elementsForNamespace: OFSerializationNS]) {
void *pool2 = objc_autoreleasePoolPush();
[_mapTable setObject: (void *)1
forKey: [child objectByDeserializing]];
objc_autoreleasePoolPop(pool2);
}
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_mapTable release];
|
︙ | | |
Modified src/OFMutableArray.m
from [72393f4e8d]
to [0c37234313].
︙ | | |
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
-
-
-
-
-
-
|
- (instancetype)initWithObjects: (id const *)objects count: (size_t)count
{
return (id)[[OFMutableAdjacentArray alloc] initWithObjects: objects
count: count];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFMutableAdjacentArray alloc]
initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
|
︙ | | |
Modified src/OFMutableDictionary.m
from [6575efa5e7]
to [4bd030691a].
︙ | | |
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
-
-
-
-
-
-
|
- (instancetype)initWithKey: (id)firstKey arguments: (va_list)arguments
{
return (id)[[OFMutableMapTableDictionary alloc] initWithKey: firstKey
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFMutableMapTableDictionary alloc]
initWithSerialization: element];
}
- (instancetype)initWithCapacity: (size_t)capacity
{
return (id)[[OFMutableMapTableDictionary alloc]
initWithCapacity: capacity];
}
- (instancetype)retain
|
︙ | | |
Modified src/OFMutableSet.m
from [da878db78b]
to [f395937f21].
︙ | | |
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
-
-
-
-
-
|
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
return (id)[[OFMutableMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFMutableMapTableSet alloc]
initWithSerialization: element];
}
- (instancetype)initWithCapacity: (size_t)capacity
{
return (id)[[OFMutableMapTableSet alloc] initWithCapacity: capacity];
}
- (instancetype)retain
{
|
︙ | | |
Modified src/OFMutableString.m
from [de2a5d81a3]
to [6babdf726b].
︙ | | |
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
-
-
-
-
-
|
encoding: (OFStringEncoding)encoding
{
return (id)[[OFMutableUTF8String alloc]
initWithContentsOfIRI: IRI
encoding: encoding];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFMutableUTF8String alloc] initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
|
︙ | | |
Modified src/OFNull.h
from [cb7890ed23]
to [08105d85ed].
︙ | | |
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
|
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
|
-
-
+
|
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
/**
* @class OFNull OFNull.h ObjFW/OFNull.h
*
* @brief A class for representing null values in collections.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFNull: OFObject <OFCopying, OFSerialization, OFJSONRepresentation,
@interface OFNull: OFObject <OFCopying, OFJSONRepresentation,
OFMessagePackRepresentation>
/**
* @brief Returns an OFNull singleton.
*
* @return An OFNull singleton
*/
+ (OFNull *)null;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFNull.m
from [e3e5d7be35]
to [820a727986].
︙ | | |
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-
+
-
-
+
|
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFNull.h"
#import "OFString.h"
#import "OFData.h"
#import "OFXMLElement.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
@interface OFNull ()
- (OFString *)
of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options
depth: (size_t)depth;
|
︙ | | |
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
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
}
+ (OFNull *)null
{
return null;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
void *pool;
[self release];
pool = objc_autoreleasePoolPush();
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
objc_autoreleasePoolPop(pool);
return [OFNull null];
}
- (OFString *)description
{
return @"<null>";
}
- (id)copy
{
return self;
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: self.className
namespace: OFSerializationNS];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
- (OFString *)JSONRepresentationWithOptions:
(OFJSONRepresentationOptions)options
|
︙ | | |
Modified src/OFNumber.h
from [7dac2a8920]
to [bb1eda01eb].
︙ | | |
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
|
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
|
-
-
-
+
+
|
#ifdef OF_HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#import "OFJSONRepresentation.h"
#import "OFMessagePackRepresentation.h"
#import "OFSerialization.h"
#import "OFValue.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
/**
* @class OFNumber OFNumber.h ObjFW/OFNumber.h
*
* @brief Provides a way to store a number in an object.
*/
#ifndef OF_NUMBER_M
OF_SUBCLASSING_RESTRICTED
#endif
@interface OFNumber: OFValue <OFComparing, OFSerialization,
OFJSONRepresentation, OFMessagePackRepresentation>
@interface OFNumber: OFValue <OFComparing, OFJSONRepresentation,
OFMessagePackRepresentation>
{
union {
double float_;
long long signed_;
unsigned long long unsigned_;
} _value;
const char *_typeEncoding;
|
︙ | | |
Modified src/OFNumber.m
from [7ed514fdca]
to [b9b4334494].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
+
-
-
-
+
|
#define OF_NUMBER_M
#include "config.h"
#include <math.h>
#import "OFNumber.h"
#import "OFString.h"
#import "OFData.h"
#import "OFXMLElement.h"
#import "OFXMLAttribute.h"
#import "OFData.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
@interface OFNumber ()
+ (instancetype)of_alloc;
|
︙ | | |
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
-
-
-
-
-
|
static OFOnceControl onceControl = OFOnceControlInitValue;
OFOnce(&onceControl, doubleZeroNumberInit);
return (id)doubleZeroNumber;
}
return (id)[[OFNumber of_alloc] initWithDouble: value];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFNumber of_alloc] initWithSerialization: element];
}
#ifdef __clang__
# pragma clang diagnostic pop
#endif
@end
@implementation OFNumberSingleton
- (instancetype)autorelease
|
︙ | | |
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
814
815
816
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
|
773
774
775
776
777
778
779
780
781
782
783
784
785
786
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
_value.float_ = value;
_typeEncoding = @encode(double);
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [super init];
@try {
void *pool = objc_autoreleasePoolPush();
OFString *typeString;
if (![element.name isEqual: @"OFNumber"] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
typeString = [element attributeForName: @"type"].stringValue;
if ([typeString isEqual: @"bool"]) {
OFString *stringValue = element.stringValue;
if ([stringValue isEqual: @"true"])
self = [self initWithBool: true];
else if ([stringValue isEqual: @"false"])
self = [self initWithBool: false];
else
@throw [OFInvalidArgumentException exception];
} else if ([typeString isEqual: @"float"]) {
unsigned long long value =
[element unsignedLongLongValueWithBase: 16];
if (value > UINT64_MAX)
@throw [OFOutOfRangeException exception];
self = [self initWithDouble: OFFromBigEndianDouble(
OFRawUInt64ToDouble(OFToBigEndian64(value)))];
} else if ([typeString isEqual: @"signed"])
self = [self initWithLongLong: element.longLongValue];
else if ([typeString isEqual: @"unsigned"])
self = [self initWithUnsignedLongLong:
element.unsignedLongLongValue];
else
@throw [OFInvalidArgumentException exception];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (const char *)objCType
{
return _typeEncoding;
}
- (void)getValue: (void *)value size: (size_t)size
{
|
︙ | | |
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
|
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
if (isUnsigned(self))
return [OFString stringWithFormat: @"%llu",
self.unsignedLongLongValue];
@throw [OFInvalidFormatException exception];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: @"OFNumber"
namespace: OFSerializationNS
stringValue: self.description];
if (*self.objCType == 'B')
[element addAttributeWithName: @"type" stringValue: @"bool"];
else if (isFloat(self)) {
[element addAttributeWithName: @"type" stringValue: @"float"];
element.stringValue = [OFString
stringWithFormat: @"%016" PRIx64,
OFFromBigEndian64(OFDoubleToRawUInt64(OFToBigEndianDouble(
self.doubleValue)))];
} else if (isSigned(self))
[element addAttributeWithName: @"type" stringValue: @"signed"];
else if (isUnsigned(self))
[element addAttributeWithName: @"type"
stringValue: @"unsigned"];
else
@throw [OFInvalidFormatException exception];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
- (OFString *)JSONRepresentationWithOptions:
(OFJSONRepresentationOptions)options
|
︙ | | |
Deleted src/OFObject+Serialization.h version [5e089b5333].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFObject_Serialization_reference;
#ifdef __cplusplus
}
#endif
@interface OFObject (OFSerialization)
/**
* @brief The object serialized as a string.
*/
@property (readonly, nonatomic) OFString *stringBySerializing;
@end
OF_ASSUME_NONNULL_END
|
Deleted src/OFObject+Serialization.m version [da843a6733].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <stdlib.h>
#import "OFObject.h"
#import "OFObject+Serialization.h"
#import "OFSerialization.h"
#import "OFString.h"
#import "OFXMLElement.h"
int _OFObject_Serialization_reference;
@implementation OFObject (Serialization)
- (OFString *)stringBySerializing
{
void *pool;
OFXMLElement *element;
OFXMLElement *root;
OFString *ret;
if (![self conformsToProtocol: @protocol(OFSerialization)]) {
[self doesNotRecognizeSelector: _cmd];
abort();
}
pool = objc_autoreleasePoolPush();
element = ((id <OFSerialization>)self).XMLElementBySerializing;
root = [OFXMLElement elementWithName: @"serialization"
namespace: OFSerializationNS];
[root addAttributeWithName: @"version" stringValue: @"1"];
[root addChild: element];
ret = [@"<?xml version='1.0' encoding='UTF-8'?>\n"
stringByAppendingString: [root XMLStringWithIndentation: 2]];
[ret retain];
objc_autoreleasePoolPop(pool);
return [ret autorelease];
}
@end
|
Modified src/OFObject.h
from [38cdbbc21b]
to [3ddfbc785d].
︙ | | |
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
|
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
|
-
|
OF_ASSUME_NONNULL_END
#include "OFBlock.h"
#ifdef __OBJC__
# import "OFObject+KeyValueCoding.h"
# import "OFObject+Serialization.h"
#endif
#endif
|
Modified src/OFObject.m
from [d0e1cba71d]
to [6fb92dcbb6].
︙ | | |
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
-
|
}
/* References for static linking */
void
_references_to_categories_of_OFObject(void)
{
_OFObject_KeyValueCoding_reference = 1;
_OFObject_Serialization_reference = 1;
}
@implementation OFObject
+ (void)load
{
#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
objc_setUncaughtExceptionHandler(uncaughtExceptionHandler);
|
︙ | | |
Modified src/OFSecureData.h
from [7365f05648]
to [5deb9cb9cd].
︙ | | |
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
-
|
freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE;
#ifdef OF_HAVE_FILES
- (instancetype)initWithContentsOfFile: (OFString *)path OF_UNAVAILABLE;
#endif
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI OF_UNAVAILABLE;
- (instancetype)initWithStringRepresentation: (OFString *)string OF_UNAVAILABLE;
- (instancetype)initWithBase64EncodedString: (OFString *)string OF_UNAVAILABLE;
- (instancetype)initWithSerialization: (OFXMLElement *)element OF_UNAVAILABLE;
/**
* @brief Returns a specific item of the OFSecureData.
*
* Modifying the returned item directly is allowed and will change the contents
* of the data array.
*
|
︙ | | |
184
185
186
187
188
189
190
191
192
193
194
195
|
183
184
185
186
187
188
189
190
191
192
193
|
-
|
- (OFString *)stringRepresentation OF_UNAVAILABLE;
- (OFString *)stringByBase64Encoding OF_UNAVAILABLE;
#ifdef OF_HAVE_FILES
- (void)writeToFile: (OFString *)path OF_UNAVAILABLE;
#endif
- (void)writeToIRI: (OFIRI *)IRI OF_UNAVAILABLE;
- (OFXMLElement *)XMLElementBySerializing OF_UNAVAILABLE;
- (OFData *)messagePackRepresentation OF_UNAVAILABLE;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFSecureData.m
from [6e16784ba9]
to [47b9727f66].
︙ | | |
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
|
510
511
512
513
514
515
516
517
518
519
520
521
522
523
|
-
-
-
-
-
|
}
- (instancetype)initWithBase64EncodedString: (OFString *)string
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OF_INVALID_INIT_METHOD
}
- (void)dealloc
{
[self zero];
#if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON)
if (!_allowsSwappableMemory) {
size_t pageSize = [OFSystemInfo pageSize];
|
︙ | | |
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
|
-
-
-
-
-
|
{
OF_UNRECOGNIZED_SELECTOR
}
#endif
- (void)writeToIRI: (OFIRI *)IRI
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFXMLElement *)XMLElementBySerializing
{
OF_UNRECOGNIZED_SELECTOR
}
- (OFData *)messagePackRepresentation
{
OF_UNRECOGNIZED_SELECTOR
}
@end
|
Deleted src/OFSerialization.h version [81b4f05430].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
OF_ASSUME_NONNULL_BEGIN
@class OFConstantString;
@class OFXMLElement;
/**
* @protocol OFSerialization OFSerialization.h ObjFW/OFSerialization.h
*
* @brief A protocol for serializing objects.
*/
@protocol OFSerialization
/**
* @brief The object serialized into an XML element.
*/
@property (readonly, nonatomic) OFXMLElement *XMLElementBySerializing;
/**
* @brief Initializes the object with the specified XML element serialization.
*
* @param element An OFXMLElement with the serialized object
* @return An initialized object
* @throw OFInvalidFormatException The specified element is not of the correct
* serialization format
*/
- (instancetype)initWithSerialization: (OFXMLElement *)element;
@end
#ifdef __cplusplus
extern "C" {
#endif
extern OFConstantString *const OFSerializationNS;
#ifdef __cplusplus
}
#endif
OF_ASSUME_NONNULL_END
|
Deleted src/OFSerialization.m version [d41532d0bc].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFSerialization.h"
#import "OFString.h"
OFConstantString *const OFSerializationNS =
@"https://objfw.nil.im/serialization";
|
Modified src/OFSet.h
from [e408900b6b]
to [b6b0fc8990].
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
-
|
# define __STDC_CONSTANT_MACROS
#endif
#include <stdarg.h>
#import "OFObject.h"
#import "OFCollection.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
@class OFArray OF_GENERIC(ObjectType);
|
︙ | | |
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
-
+
|
* @warning Do not mutate objects that are in a set! Changing the hash of
* objects in a set breaks the internal representation of the set!
*
* @note Subclasses must implement @ref count, @ref containsObject: and
* @ref objectEnumerator.
*/
@interface OFSet OF_GENERIC(ObjectType): OFObject <OFCollection, OFCopying,
OFMutableCopying, OFSerialization>
OFMutableCopying>
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# define ObjectType id
#endif
/**
* @brief An array of all objects in the set.
*/
@property (readonly, nonatomic) OFArray OF_GENERIC(ObjectType) *allObjects;
|
︙ | | |
Modified src/OFSet.m
from [c24561f595]
to [a5c8b76a0d].
︙ | | |
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
|
#include <stdlib.h>
#import "OFSet.h"
#import "OFArray.h"
#import "OFMapTableSet.h"
#import "OFNull.h"
#import "OFString.h"
#import "OFXMLElement.h"
static struct {
Class isa;
} placeholder;
@interface OFSetPlaceholder: OFSet
@end
|
︙ | | |
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
-
-
-
-
-
|
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
return (id)[[OFMapTableSet alloc] initWithObject: firstObject
arguments: arguments];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFMapTableSet alloc] initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
|
︙ | | |
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
-
-
-
-
-
|
va_end(arguments);
return ret;
}
- (instancetype)initWithObject: (id)firstObject arguments: (va_list)arguments
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OF_INVALID_INIT_METHOD
}
- (size_t)count
{
OF_UNRECOGNIZED_SELECTOR
}
|
︙ | | |
358
359
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
396
|
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
for (id object in self)
if ([set containsObject: object])
return true;
return false;
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
if ([self isKindOfClass: [OFMutableSet class]])
element = [OFXMLElement elementWithName: @"OFMutableSet"
namespace: OFSerializationNS];
else
element = [OFXMLElement elementWithName: @"OFSet"
namespace: OFSerializationNS];
for (id <OFSerialization> object in self) {
void *pool2 = objc_autoreleasePoolPush();
[element addChild: object.XMLElementBySerializing];
objc_autoreleasePoolPop(pool2);
}
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFSet *)setByAddingObjectsFromSet: (OFSet *)set
{
OFMutableSet *new = [[self mutableCopy] autorelease];
[new unionSet: set];
[new makeImmutable];
return new;
}
|
︙ | | |
Deleted src/OFString+Serialization.h version [562111770b].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFString.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_Serialization_reference;
#ifdef __cplusplus
}
#endif
@interface OFString (Serialization)
/**
* @brief The string interpreted as serialization and parsed as an object.
*
* @throw OFMalformedXMLException The XML was malformed
* @throw OFUnboundNamespaceException A prefix was used that was not bound to
* any namespace
* @throw OFInvalidEncodingException The XML is not in the encoding it specified
* @throw OFUnsupportedVersionException The serialization is in an unsupported
* version
*/
@property (readonly, nonatomic) id objectByDeserializing;
@end
OF_ASSUME_NONNULL_END
|
Deleted src/OFString+Serialization.m version [814c47790a].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFString.h"
#import "OFString+Serialization.h"
#import "OFSerialization.h"
#import "OFArray.h"
#import "OFXMLElement.h"
#import "OFXMLAttribute.h"
#import "OFInvalidArgumentException.h"
#import "OFMalformedXMLException.h"
#import "OFUnboundNamespaceException.h"
#import "OFUnsupportedVersionException.h"
int _OFString_Serialization_reference;
@implementation OFString (Serialization)
- (id)objectByDeserializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *root;
OFString *version;
OFArray *elements;
id object;
root = [OFXMLElement elementWithXMLString: self];
version = [root attributeForName: @"version"].stringValue;
if (version == nil)
@throw [OFInvalidArgumentException exception];
if (version.unsignedLongLongValue != 1)
@throw [OFUnsupportedVersionException
exceptionWithVersion: version];
elements = [root elementsForNamespace: OFSerializationNS];
if (elements.count != 1)
@throw [OFInvalidArgumentException exception];
object = [[elements.firstObject objectByDeserializing] retain];
objc_autoreleasePoolPop(pool);
return [object autorelease];
}
@end
|
Modified src/OFString.h
from [0d179dd073]
to [55ba0a041b].
︙ | | |
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
-
|
#include <stdint.h>
#ifdef OF_HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include "OFObject.h"
#ifdef __OBJC__
# import "OFSerialization.h"
# import "OFJSONRepresentation.h"
# import "OFMessagePackRepresentation.h"
#endif
OF_ASSUME_NONNULL_BEGIN
/** @file */
|
︙ | | |
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
-
+
|
/**
* @class OFString OFString.h ObjFW/OFString.h
*
* @brief A class for handling strings.
*/
@interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing,
OFSerialization, OFJSONRepresentation, OFMessagePackRepresentation>
OFJSONRepresentation, OFMessagePackRepresentation>
/**
* @brief The length of the string in Unicode codepoints.
*/
@property (readonly, nonatomic) size_t length;
/**
* @brief The OFString as a UTF-8 encoded C string.
|
︙ | | |
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
|
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
|
-
|
# import "OFString+CryptographicHashing.h"
# import "OFString+JSONParsing.h"
# ifdef OF_HAVE_FILES
# import "OFString+PathAdditions.h"
# endif
# import "OFString+PercentEncoding.h"
# import "OFString+PropertyListParsing.h"
# import "OFString+Serialization.h"
# import "OFString+XMLEscaping.h"
# import "OFString+XMLUnescaping.h"
#endif
#if defined(__OBJC__) && !defined(NSINTEGER_DEFINED) && !__has_feature(modules)
/*
* Very *ugly* hack required for string boxing literals to work.
|
︙ | | |
Modified src/OFString.m
from [9e1175061f]
to [6c5b7de32e].
︙ | | |
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
|
#import "OFIRI.h"
#import "OFIRIHandler.h"
#import "OFLocale.h"
#import "OFStream.h"
#import "OFSystemInfo.h"
#import "OFUTF8String.h"
#import "OFUTF8String+Private.h"
#import "OFXMLElement.h"
#import "OFGetItemAttributesFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFNotImplementedException.h"
|
︙ | | |
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
-
|
_OFString_CryptographicHashing_reference = 1;
_OFString_JSONParsing_reference = 1;
#ifdef OF_HAVE_FILES
_OFString_PathAdditions_reference = 1;
#endif
_OFString_PercentEncoding_reference = 1;
_OFString_PropertyListParsing_reference = 1;
_OFString_Serialization_reference = 1;
_OFString_XMLEscaping_reference = 1;
_OFString_XMLUnescaping_reference = 1;
}
void
_reference_to_OFConstantString(void)
{
|
︙ | | |
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
|
588
589
590
591
592
593
594
595
596
597
598
599
600
601
|
-
-
-
-
-
|
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
encoding: (OFStringEncoding)encoding
{
return (id)[[OFUTF8String alloc] initWithContentsOfIRI: IRI
encoding: encoding];
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
return (id)[[OFUTF8String alloc] initWithSerialization: element];
}
- (instancetype)retain
{
return self;
}
- (instancetype)autorelease
{
|
︙ | | |
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
|
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
if (encoding == OFStringEncodingAutodetect)
encoding = OFStringEncodingUTF8;
self = [self initWithCString: data.items
encoding: encoding
length: data.count * data.itemSize];
objc_autoreleasePoolPop(pool);
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
void *pool = objc_autoreleasePoolPush();
OFString *stringValue;
@try {
if (![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
if ([self isKindOfClass: [OFMutableString class]]) {
if (![element.name isEqual: @"OFMutableString"])
@throw [OFInvalidArgumentException exception];
} else {
if (![element.name isEqual: @"OFString"])
@throw [OFInvalidArgumentException exception];
}
stringValue = element.stringValue;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithString: stringValue];
objc_autoreleasePoolPop(pool);
return self;
}
- (size_t)of_getCString: (char *)cString
maxLength: (size_t)maxLength
|
︙ | | |
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
|
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
}
- (OFString *)description
{
return [[self copy] autorelease];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
OFString *className;
if ([self isKindOfClass: [OFMutableString class]])
className = @"OFMutableString";
else
className = @"OFString";
element = [OFXMLElement elementWithName: className
namespace: OFSerializationNS
stringValue: self];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)JSONRepresentation
{
return [self of_JSONRepresentationWithOptions: 0 depth: 0];
}
- (OFString *)JSONRepresentationWithOptions:
(OFJSONRepresentationOptions)options
|
︙ | | |
Modified src/OFUUID.h
from [9269e86a14]
to [ac563eb1fe].
︙ | | |
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
|
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
|
-
-
+
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
@class OFString;
/**
* @class OFUUID OFUUID.h ObjFW/OFUUID.h
*
* @brief A UUID conforming to RFC 4122.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFUUID: OFObject <OFCopying, OFComparing, OFSerialization>
@interface OFUUID: OFObject <OFCopying, OFComparing>
{
unsigned char _bytes[16];
}
/**
* @brief The UUID as a string.
*/
|
︙ | | |
Modified src/OFUUID.m
from [9c0ce1a511]
to [81553fcc1d].
︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-
|
*/
#include "config.h"
#import "OFUUID.h"
#import "OFArray.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"
#define bytesSize 16
|
︙ | | |
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
void *pool = objc_autoreleasePoolPush();
OFString *UUIDString;
@try {
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
UUIDString = element.stringValue;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithUUIDString: UUIDString];
objc_autoreleasePoolPop(pool);
return self;
}
- (bool)isEqual: (id)object
{
OFUUID *UUID;
if (![object isKindOfClass: [OFUUID class]])
return false;
|
︙ | | |
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
207
208
209
210
211
212
213
214
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
_bytes[12], _bytes[13], _bytes[14], _bytes[15]];
}
- (OFString *)description
{
return self.UUIDString;
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element = [OFXMLElement elementWithName: self.className
namespace: OFSerializationNS
stringValue: self.UUIDString];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
@end
|
Modified src/OFXMLAttribute.h
from [a0373a3fcd]
to [ad0369cec2].
︙ | | |
88
89
90
91
92
93
94
95
96
97
98
99
|
88
89
90
91
92
93
94
95
96
97
|
-
-
|
* @param nameSpace The namespace of the attribute
* @param stringValue The string value of the attribute
* @return An initialized OFXMLAttribute with the specified parameters
*/
- (instancetype)initWithName: (OFString *)name
namespace: (nullable OFString *)nameSpace
stringValue: (OFString *)stringValue OF_DESIGNATED_INITIALIZER;
- (instancetype)initWithSerialization: (OFXMLElement *)element;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFXMLAttribute.m
from [b0ce591345]
to [5c47193c55].
︙ | | |
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
|
#include "config.h"
#import "OFXMLAttribute.h"
#import "OFXMLNode+Private.h"
#import "OFString.h"
#import "OFDictionary.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
@implementation OFXMLAttribute
@synthesize name = _name, namespace = _namespace;
+ (instancetype)attributeWithName: (OFString *)name
|
︙ | | |
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
_namespace = [namespace copy];
_stringValue = [stringValue copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
void *pool;
OFString *name, *namespace, *stringValue;
@try {
pool = objc_autoreleasePoolPush();
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
name = [element attributeForName: @"name"].stringValue;
namespace = [element attributeForName: @"namespace"]
.stringValue;
stringValue = [element attributeForName: @"stringValue"]
.stringValue;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithName: name
namespace: namespace
stringValue: stringValue];
@try {
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_name release];
[_namespace release];
|
︙ | | |
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
191
192
193
194
195
196
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
OFHashAddHash(&hash, _stringValue.hash);
OFHashFinalize(&hash);
return hash;
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: self.className
namespace: OFSerializationNS];
[element addAttributeWithName: @"name" stringValue: _name];
if (_namespace != nil)
[element addAttributeWithName: @"namespace"
stringValue: _namespace];
[element addAttributeWithName: @"stringValue"
stringValue: _stringValue];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@: name=%@, namespace=%@, "
@"stringValue=%@>",
self.class, _name, _namespace,
_stringValue];
}
@end
|
Modified src/OFXMLCDATA.h
from [cbe6268a21]
to [0b1ca7487a].
︙ | | |
39
40
41
42
43
44
45
46
47
48
49
50
|
39
40
41
42
43
44
45
46
47
48
|
-
-
|
/**
* @brief Initializes an already allocated OFXMLCDATA with the specified string.
*
* @param string The string value for the CDATA
* @return An initialized OFXMLCDATA
*/
- (instancetype)initWithString: (OFString *)string;
- (instancetype)initWithSerialization: (OFXMLElement *)element;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFXMLCDATA.m
from [782cf60cb2]
to [b5a30e1981].
︙ | | |
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
|
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
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
*/
#include "config.h"
#import "OFXMLCDATA.h"
#import "OFXMLNode+Private.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
@implementation OFXMLCDATA
+ (instancetype)CDATAWithString: (OFString *)string
{
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithString: (OFString *)string
{
self = [super of_init];
@try {
_CDATA = [string copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [super of_init];
@try {
void *pool = objc_autoreleasePoolPush();
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
_CDATA = [element.stringValue copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_CDATA release];
|
︙ | | |
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
93
94
95
96
97
98
99
100
|
-
-
-
-
-
-
-
-
-
-
|
return [ret autorelease];
}
- (OFString *)description
{
return self.XMLString;
}
- (OFXMLElement *)XMLElementBySerializing
{
OFXMLElement *element =
[OFXMLElement elementWithName: self.className
namespace: OFSerializationNS];
[element addChild: self];
return element;
}
@end
|
Modified src/OFXMLCharacters.h
from [01b164c13a]
to [d7b0cc572e].
︙ | | |
40
41
42
43
44
45
46
47
48
49
50
51
|
40
41
42
43
44
45
46
47
48
49
|
-
-
|
* @brief Initializes an already allocated OFXMLCharacters with the specified
* string.
*
* @param string The string value for the characters
* @return An initialized OFXMLCharacters
*/
- (instancetype)initWithString: (OFString *)string;
- (instancetype)initWithSerialization: (OFXMLElement *)element;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFXMLCharacters.m
from [0f7714df74]
to [d4a7b166de].
︙ | | |
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
|
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
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
*/
#include "config.h"
#import "OFXMLCharacters.h"
#import "OFXMLNode+Private.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
@implementation OFXMLCharacters
+ (instancetype)charactersWithString: (OFString *)string
{
return [[[self alloc] initWithString: string] autorelease];
}
- (instancetype)initWithString: (OFString *)string
{
self = [super of_init];
@try {
_characters = [string copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [super of_init];
@try {
void *pool = objc_autoreleasePoolPush();
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
_characters = [element.stringValue copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_characters release];
|
︙ | | |
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
85
86
87
88
89
90
91
92
|
-
-
-
-
-
-
-
|
return _characters.stringByXMLEscaping;
}
- (OFString *)description
{
return self.XMLString;
}
- (OFXMLElement *)XMLElementBySerializing
{
return [OFXMLElement elementWithName: self.className
namespace: OFSerializationNS
stringValue: _characters];
}
@end
|
Modified src/OFXMLComment.h
from [ccfce93aa5]
to [0ac62de2c0].
︙ | | |
45
46
47
48
49
50
51
52
53
54
55
56
|
45
46
47
48
49
50
51
52
53
54
|
-
-
|
* @brief Initializes an already allocated OFXMLComment with the specified
* text.
*
* @param text The text for the comment
* @return An initialized OFXMLComment
*/
- (instancetype)initWithText: (OFString *)text;
- (instancetype)initWithSerialization: (OFXMLElement *)element;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFXMLComment.m
from [11b3b9f1cf]
to [72a694fdfc].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
|
#include "config.h"
#include <string.h>
#import "OFXMLComment.h"
#import "OFXMLNode+Private.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFInvalidArgumentException.h"
@implementation OFXMLComment
@synthesize text = _text;
+ (instancetype)commentWithText: (OFString *)text
|
︙ | | |
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
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
@try {
_text = [text copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
self = [super of_init];
@try {
void *pool = objc_autoreleasePoolPush();
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
_text = [element.stringValue copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_text release];
|
︙ | | |
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
82
83
84
85
86
87
88
89
|
-
-
-
-
-
-
-
|
return [OFString stringWithFormat: @"<!--%@-->", _text];
}
- (OFString *)description
{
return self.XMLString;
}
- (OFXMLElement *)XMLElementBySerializing
{
return [OFXMLElement elementWithName: self.className
namespace: OFSerializationNS
stringValue: _text];
}
@end
|
Deleted src/OFXMLElement+Serialization.h version [fe095a2964].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFXMLElement.h"
OF_ASSUME_NONNULL_BEGIN
#ifdef __cplusplus
extern "C" {
#endif
extern int _OFXMLElement_Serialization_reference;
#ifdef __cplusplus
}
#endif
@interface OFXMLElement (OFSerialization)
/**
* @brief The XML element interpreted as serialization and parsed into an
* object.
*/
@property (readonly, nonatomic) id objectByDeserializing;
@end
OF_ASSUME_NONNULL_END
|
Deleted src/OFXMLElement+Serialization.m version [e7e3d1e4e8].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFXMLElement.h"
#import "OFXMLElement+Serialization.h"
#import "OFSerialization.h"
#import "OFString.h"
#import "OFInvalidArgumentException.h"
int _OFXMLElement_Serialization_reference;
@implementation OFXMLElement (Serialization)
- (id)objectByDeserializing
{
void *pool = objc_autoreleasePoolPush();
Class class;
id object;
if ((class = objc_getClass([_name cStringWithEncoding:
OFStringEncodingASCII])) == Nil)
@throw [OFInvalidArgumentException exception];
if (![class conformsToProtocol: @protocol(OFSerialization)])
@throw [OFInvalidArgumentException exception];
object = [[class alloc] initWithSerialization: self];
objc_autoreleasePoolPop(pool);
return [object autorelease];
}
@end
|
Modified src/OFXMLElement.h
from [88a9b5d1f0]
to [30ce632507].
︙ | | |
430
431
432
433
434
435
436
437
438
|
430
431
432
433
434
435
436
|
-
-
|
* needs a prefix
*/
- (OFString *)XMLStringWithDefaultNamespace: (OFString *)defaultNS
indentation: (unsigned int)indentation;
@end
OF_ASSUME_NONNULL_END
#import "OFXMLElement+Serialization.h"
|
Modified src/OFXMLElement.m
from [c4955d77b3]
to [b73068b828].
︙ | | |
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
-
-
-
-
-
-
-
|
#import "OFXMLParser.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFMalformedXMLException.h"
#import "OFUnboundNamespaceException.h"
/* References for static linking */
void
_references_to_categories_of_OFXMLElement(void)
{
_OFXMLElement_Serialization_reference = 1;
}
@interface OFXMLElementElementBuilderDelegate: OFObject
<OFXMLElementBuilderDelegate>
{
@public
OFXMLElement *_element;
}
@end
|
︙ | | |
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
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
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
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
[_attributes release];
_attributes = [element->_attributes retain];
[_namespaces release];
_namespaces = [element->_namespaces retain];
[_children release];
_children = [element->_children retain];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
void *pool;
OFString *name, *namespace;
@try {
pool = objc_autoreleasePoolPush();
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
name = [element attributeForName: @"name"].stringValue;
namespace =
[element attributeForName: @"namespace"].stringValue;
} @catch (id e) {
[self release];
@throw e;
}
self = [self initWithName: name namespace: namespace];
@try {
OFXMLElement *attributesElement, *namespacesElement;
OFXMLElement *childrenElement;
OFEnumerator *keyEnumerator, *objectEnumerator;
OFString *key, *object;
attributesElement = [[element
elementForName: @"attributes"
namespace: OFSerializationNS]
elementsForNamespace: OFSerializationNS].firstObject;
namespacesElement = [[element
elementForName: @"namespaces"
namespace: OFSerializationNS]
elementsForNamespace: OFSerializationNS].firstObject;
childrenElement = [[element
elementForName: @"children"
namespace: OFSerializationNS]
elementsForNamespace: OFSerializationNS].firstObject;
[_attributes release];
_attributes = nil;
_attributes = [attributesElement.objectByDeserializing
mutableCopy];
[_namespaces release];
_namespaces = nil;
_namespaces = [namespacesElement.objectByDeserializing
mutableCopy];
[_children release];
_children = nil;
_children = [childrenElement.objectByDeserializing
mutableCopy];
/* Sanity checks */
if ((_attributes != nil && ![_attributes isKindOfClass:
[OFMutableArray class]]) || (_namespaces != nil &&
![_namespaces isKindOfClass:
[OFMutableDictionary class]]) || (_children != nil &&
![_children isKindOfClass: [OFMutableArray class]]))
@throw [OFInvalidArgumentException exception];
for (OFXMLAttribute *attribute in _attributes)
if (![attribute isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
keyEnumerator = [_namespaces keyEnumerator];
objectEnumerator = [_namespaces objectEnumerator];
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil)
if (![key isKindOfClass: [OFString class]] ||
![object isKindOfClass: [OFString class]])
@throw [OFInvalidArgumentException exception];
for (object in _children)
if (![object isKindOfClass: [OFXMLNode class]])
@throw [OFInvalidArgumentException exception];
if (_namespaces == nil)
_namespaces = [[OFMutableDictionary alloc] init];
[_namespaces
setObject: @"xml"
forKey: @"http://www.w3.org/XML/1998/namespace"];
[_namespaces setObject: @"xmlns"
forKey: @"http://www.w3.org/2000/xmlns/"];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
|
︙ | | |
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
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
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
|
559
560
561
562
563
564
565
566
567
568
569
570
571
572
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
{
return [self of_XMLStringWithDefaultNS: defaultNS
namespaces: nil
indentation: indentation
level: 0];
}
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: self.className
namespace: OFSerializationNS];
if (_name != nil)
[element addAttributeWithName: @"name" stringValue: _name];
if (_namespace != nil)
[element addAttributeWithName: @"namespace"
stringValue: _namespace];
if (_attributes != nil) {
OFXMLElement *attributesElement;
attributesElement =
[OFXMLElement elementWithName: @"attributes"
namespace: OFSerializationNS];
[attributesElement addChild:
_attributes.XMLElementBySerializing];
[element addChild: attributesElement];
}
if (_namespaces != nil) {
OFXMLElement *namespacesElement;
OFMutableDictionary *namespacesCopy =
[[_namespaces mutableCopy] autorelease];
[namespacesCopy removeObjectForKey:
@"http://www.w3.org/XML/1998/namespace"];
[namespacesCopy removeObjectForKey:
@"http://www.w3.org/2000/xmlns/"];
if (namespacesCopy.count > 0) {
namespacesElement =
[OFXMLElement elementWithName: @"namespaces"
namespace: OFSerializationNS];
[namespacesElement addChild:
namespacesCopy.XMLElementBySerializing];
[element addChild: namespacesElement];
}
}
if (_children != nil) {
OFXMLElement *childrenElement;
childrenElement =
[OFXMLElement elementWithName: @"children"
namespace: OFSerializationNS];
[childrenElement addChild: _children.XMLElementBySerializing];
[element addChild: childrenElement];
}
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (void)addAttribute: (OFXMLAttribute *)attribute
{
if (![attribute isKindOfClass: [OFXMLAttribute class]])
@throw [OFInvalidArgumentException exception];
if (_attributes == nil)
_attributes = [[OFMutableArray alloc] init];
|
︙ | | |
Modified src/OFXMLNode.h
from [b1cf55fec8]
to [ed1c4fdaa7].
︙ | | |
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
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
-
-
-
-
+
|
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFObject.h"
#import "OFSerialization.h"
OF_ASSUME_NONNULL_BEGIN
@class OFXMLElement;
/**
* @class OFXMLNode OFXMLNode.h ObjFW/OFXMLNode.h
*
* @brief A class which stores an XML element.
*/
@interface OFXMLNode: OFObject <OFCopying, OFSerialization>
@interface OFXMLNode: OFObject <OFCopying>
{
OF_RESERVE_IVARS(OFXMLNode, 4)
}
/**
* @brief The contents of the node as a string value.
*
|
︙ | | |
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
-
|
* @throw OFUnboundNamespaceException The node uses a namespace that was not
* bound to a prefix in a context where it
* needs a prefix
*/
@property (readonly, nonatomic) OFString *XMLString;
- (instancetype)init OF_UNAVAILABLE;
- (instancetype)initWithSerialization: (OFXMLElement *)element OF_UNAVAILABLE;
/**
* @brief The contents of the receiver as a `long long` value in the specified
* base.
*
* @param base The base to use. If the base is 0, base 16 is assumed if the
* string starts with 0x (after stripping white spaces). If the
|
︙ | | |
Modified src/OFXMLNode.m
from [dcf0255e3f]
to [db9f6871fb].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-
-
-
-
-
|
}
- (instancetype)init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
OF_INVALID_INIT_METHOD
}
- (OFString *)stringValue
{
OF_UNRECOGNIZED_SELECTOR
}
- (void)setStringValue: (OFString *)stringValue
{
|
︙ | | |
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
75
76
77
78
79
80
81
82
83
84
85
86
|
-
-
-
-
-
|
}
- (OFString *)description
{
return self.XMLString;
}
- (OFXMLElement *)XMLElementBySerializing
{
OF_UNRECOGNIZED_SELECTOR
}
- (id)copy
{
return [self retain];
}
@end
|
Modified src/OFXMLProcessingInstruction.h
from [5592054efd]
to [ea520587d0].
︙ | | |
56
57
58
59
60
61
62
63
64
65
66
67
|
56
57
58
59
60
61
62
63
64
65
|
-
-
|
*
* @param target The target for the processing instruction
* @param text The text for the processing instruction
* @return An initialized OFXMLProcessingInstruction
*/
- (instancetype)initWithTarget: (OFString *)target
text: (OFString *)text OF_DESIGNATED_INITIALIZER;
- (instancetype)initWithSerialization: (OFXMLElement *)element;
@end
OF_ASSUME_NONNULL_END
|
Modified src/OFXMLProcessingInstruction.m
from [444877ce0f]
to [44d4bf9d3c].
︙ | | |
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-
|
#include "config.h"
#include <string.h>
#import "OFXMLProcessingInstruction.h"
#import "OFString.h"
#import "OFXMLAttribute.h"
#import "OFXMLElement.h"
#import "OFXMLNode+Private.h"
#import "OFInvalidArgumentException.h"
@implementation OFXMLProcessingInstruction
@synthesize target = _target, text = _text;
|
︙ | | |
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
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
_target = [target copy];
_text = [text copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (instancetype)initWithSerialization: (OFXMLElement *)element
{
@try {
void *pool = objc_autoreleasePoolPush();
OFXMLAttribute *targetAttr;
if (![element.name isEqual: self.className] ||
![element.namespace isEqual: OFSerializationNS])
@throw [OFInvalidArgumentException exception];
targetAttr = [element attributeForName: @"target"
namespace: OFSerializationNS];
if (targetAttr.stringValue.length == 0)
@throw [OFInvalidArgumentException exception];
self = [self initWithTarget: targetAttr.stringValue
text: element.stringValue];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_target release];
[_text release];
|
︙ | | |
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
106
107
108
109
110
111
112
113
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
return [OFString stringWithFormat: @"<?%@?>", _target];
}
- (OFString *)description
{
return self.XMLString;
}
- (OFXMLElement *)XMLElementBySerializing
{
OFXMLElement *ret = [OFXMLElement elementWithName: self.className
namespace: OFSerializationNS
stringValue: _text];
void *pool = objc_autoreleasePoolPush();
[ret addAttribute: [OFXMLAttribute attributeWithName: @"target"
stringValue: _target]];
objc_autoreleasePoolPop(pool);
return ret;
}
@end
|
Modified tests/Makefile
from [331c812adc]
to [2beb632548].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
-
|
include ../extra.mk
SUBDIRS = ${TESTPLUGIN} \
${OBJC_SYNC} \
terminal
CLEAN = EBOOT.PBP \
boot.dol \
${PROG_NOINST}.arm9 \
${PROG_NOINST}.nds \
${PROG_NOINST}.nro \
${PROG_NOINST}.rpx \
serialization_xml.m \
testfile_bin.m \
testfile_ini.m
DISTCLEAN = Info.plist
PROG_NOINST = tests${PROG_SUFFIX}
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = ForwardingTests.m \
|
︙ | | |
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
|
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
|
-
-
|
OFRIPEMD160HashTests.m \
OFSHA1HashTests.m \
OFSHA224HashTests.m \
OFSHA256HashTests.m \
OFSHA384HashTests.m \
OFSHA512HashTests.m \
OFScryptTests.m \
OFSerializationTests.m \
OFSetTests.m \
OFStreamTests.m \
OFStringTests.m \
OFSystemInfoTests.m \
OFValueTests.m \
OFXMLElementBuilderTests.m \
OFXMLNodeTests.m \
OFXMLParserTests.m \
RuntimeTests.m \
${RUNTIME_ARC_TESTS_M} \
TestsAppDelegate.m \
${USE_SRCS_FILES} \
${USE_SRCS_PLUGINS} \
${USE_SRCS_SOCKETS} \
${USE_SRCS_THREADS} \
${USE_SRCS_WINDOWS} \
serialization_xml.m \
testfile_bin.m \
testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m
SRCS_SOCKETS = OFDNSResolverTests.m \
${OF_HTTP_CLIENT_TESTS_M} \
OFHTTPCookieTests.m \
OFHTTPCookieManagerTests.m \
|
︙ | | |
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
-
-
|
SRCS_WINDOWS = OFWindowsRegistryKeyTests.m
IOS_USER ?= mobile
IOS_TMP ?= /tmp/objfw-test
include ../buildsys.mk
serialization_xml.m: serialization.xml
${SHELL} ../utils/objfw-embed serialization.xml serialization.xml $@
testfile_bin.m: testfile.bin
${SHELL} ../utils/objfw-embed testfile.bin testfile.bin $@
testfile_ini.m: testfile.ini
${SHELL} ../utils/objfw-embed testfile.ini testfile.ini $@
.PHONY: run run-on-ios run-on-android
run:
|
︙ | | |
Deleted tests/OFSerializationTests.m version [8955c90831].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "TestsAppDelegate.h"
static OFString *const module = @"OFSerialization";
@implementation TestsAppDelegate (OFSerializationTests)
- (void)serializationTests
{
void *pool = objc_autoreleasePoolPush();
OFMutableDictionary *dict = [OFMutableDictionary dictionary];
OFMutableArray *array = [OFMutableArray array];
OFList *list = [OFList list];
OFData *data;
OFString *string;
OFUUID *UUID;
[array addObject: @"Qu\"xbar\ntest"];
[array addObject: [OFNumber numberWithInt: 1234]];
[array addObject: [OFNumber numberWithDouble: 1234.5678]];
[array addObject: [OFMutableString stringWithString: @"asd"]];
[array addObject: [OFDate dateWithTimeIntervalSince1970: 1234.5678]];
[dict setObject: @"Hello" forKey: array];
[dict setObject: @"B\"la" forKey: @"Blub"];
[list appendObject: @"Hello"];
[list appendObject: @"Wo\rld!\nHow are you?"];
[list appendObject: [OFIRI IRIWithString: @"https://objfw.nil.im/"]];
[list appendObject:
[OFXMLElement elementWithXMLString: @"<x><y/><![CDATA[<]]></x>"]];
[list appendObject:
[OFSet setWithObjects: @"foo", @"foo", @"bar", nil]];
[list appendObject:
[OFCountedSet setWithObjects: @"foo", @"foo", @"bar", nil]];
[dict setObject: @"list" forKey: list];
data = [OFData dataWithItems: "0123456789:;<ABCDEFGHJIKLMNOPQRSTUVWXYZ"
count: 39];
[dict setObject: @"data" forKey: data];
UUID = [OFUUID
UUIDWithUUIDString: @"01234567-89AB-CDEF-FEDC-BA9876543210"];
[dict setObject: @"uuid" forKey: UUID];
TEST(@"-[stringBySerializing]",
(string = dict.stringBySerializing) && [string isEqual:
[OFString stringWithContentsOfIRI:
[OFIRI IRIWithString: @"embedded:serialization.xml"]]])
TEST(@"-[objectByDeserializing]",
[string.objectByDeserializing isEqual: dict])
objc_autoreleasePoolPop(pool);
}
@end
|
Modified tests/TestsAppDelegate.h
from [2856569726]
to [c08d2cfc07].
︙ | | |
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
-
-
-
-
|
- (void)SPXSocketTests;
@end
@interface TestsAppDelegate (OFSPXStreamSocketTests)
- (void)SPXStreamSocketTests;
@end
@interface TestsAppDelegate (OFSerializationTests)
- (void)serializationTests;
@end
@interface TestsAppDelegate (OFSetTests)
- (void)setTests;
@end
@interface TestsAppDelegate (OFSystemInfoTests)
- (void)systemInfoTests;
@end
|
︙ | | |
Modified tests/TestsAppDelegate.m
from [188b6037b1]
to [252b4a628c].
︙ | | |
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
436
437
438
439
440
441
442
443
444
445
446
447
448
449
|
-
|
#ifdef OF_HAVE_SOCKETS
[self HTTPCookieTests];
[self HTTPCookieManagerTests];
#endif
[self XMLParserTests];
[self XMLNodeTests];
[self XMLElementBuilderTests];
[self serializationTests];
[self JSONTests];
[self propertyListTests];
[self matrix4x4Tests];
#if defined(OF_HAVE_PLUGINS)
[self pluginTests];
#endif
|
︙ | | |
Modified tests/iOS.xcodeproj/project.pbxproj
from [b5cdee4708]
to [ac2dd7d645].
︙ | | |
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-
|
/* Begin PBXBuildFile section */
4B6AB9CD202BA431007BAC7D /* TestPlugin.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B6AB9CA202BA408007BAC7D /* TestPlugin.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4BC7FD07201394F300280496 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC7FD06201394F300280496 /* ObjFW.framework */; };
4BC7FD092013954B00280496 /* tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC7FD082013954B00280496 /* tests.a */; };
4BC7FD0B2013956D00280496 /* ObjFW.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4BC7FD06201394F300280496 /* ObjFW.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4BC7FD102013960600280496 /* testfile.txt in Resources */ = {isa = PBXBuildFile; fileRef = 4BC7FD0C2013960600280496 /* testfile.txt */; };
4BC7FD112013960600280496 /* testfile.bin in Resources */ = {isa = PBXBuildFile; fileRef = 4BC7FD0D2013960600280496 /* testfile.bin */; };
4BC7FD122013960600280496 /* serialization.xml in Resources */ = {isa = PBXBuildFile; fileRef = 4BC7FD0E2013960600280496 /* serialization.xml */; };
4BC7FD132013960600280496 /* testfile.ini in Resources */ = {isa = PBXBuildFile; fileRef = 4BC7FD0F2013960600280496 /* testfile.ini */; };
4BEBFB6E2013934E002E8710 /* ImportTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BEBFB6D2013934E002E8710 /* ImportTest.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
4B6AB9CC202BA428007BAC7D /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
|
︙ | | |
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
|
/* Begin PBXFileReference section */
4B6AB9CA202BA408007BAC7D /* TestPlugin.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = TestPlugin.bundle; path = plugin/TestPlugin.bundle; sourceTree = "<group>"; };
4BC7FD06201394F300280496 /* ObjFW.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjFW.framework; path = ../src/ObjFW.framework; sourceTree = "<group>"; };
4BC7FD082013954B00280496 /* tests.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = tests.a; sourceTree = "<group>"; };
4BC7FD0C2013960600280496 /* testfile.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = testfile.txt; sourceTree = "<group>"; };
4BC7FD0D2013960600280496 /* testfile.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = testfile.bin; sourceTree = "<group>"; };
4BC7FD0E2013960600280496 /* serialization.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = serialization.xml; sourceTree = "<group>"; };
4BC7FD0F2013960600280496 /* testfile.ini */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = testfile.ini; sourceTree = "<group>"; };
4BEBFB5B2013934E002E8710 /* tests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = tests.app; sourceTree = BUILT_PRODUCTS_DIR; };
4BEBFB6C2013934E002E8710 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
4BEBFB6D2013934E002E8710 /* ImportTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImportTest.m; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
|
︙ | | |
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
-
|
sourceTree = "<group>";
};
4BEBFB5D2013934E002E8710 /* tests */ = {
isa = PBXGroup;
children = (
4BEBFB6C2013934E002E8710 /* Info.plist */,
4BEBFB6D2013934E002E8710 /* ImportTest.m */,
4BC7FD0E2013960600280496 /* serialization.xml */,
4BC7FD0D2013960600280496 /* testfile.bin */,
4BC7FD0F2013960600280496 /* testfile.ini */,
4BC7FD0C2013960600280496 /* testfile.txt */,
);
name = tests;
sourceTree = "<group>";
};
|
︙ | | |
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
-
|
/* Begin PBXResourcesBuildPhase section */
4BEBFB592013934E002E8710 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4BC7FD102013960600280496 /* testfile.txt in Resources */,
4BC7FD122013960600280496 /* serialization.xml in Resources */,
4BC7FD132013960600280496 /* testfile.ini in Resources */,
4BC7FD112013960600280496 /* testfile.bin in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
|
︙ | | |
Deleted tests/serialization.xml version [41f0bf4f05].
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
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
<?xml version='1.0' encoding='UTF-8'?>
<serialization xmlns='https://objfw.nil.im/serialization' version='1'>
<OFMutableDictionary>
<key>
<OFUUID>01234567-89ab-cdef-fedc-ba9876543210</OFUUID>
</key>
<object>
<OFString>uuid</OFString>
</object>
<key>
<OFString>Blub</OFString>
</key>
<object>
<OFString>B"la</OFString>
</object>
<key>
<OFList>
<OFString>Hello</OFString>
<OFString>Wo
ld!
How are you?</OFString>
<OFIRI>https://objfw.nil.im/</OFIRI>
<OFXMLElement name='x'>
<children>
<OFMutableArray>
<OFXMLElement name='y'/>
<OFXMLCDATA><![CDATA[<]]></OFXMLCDATA>
</OFMutableArray>
</children>
</OFXMLElement>
<OFSet>
<OFString>bar</OFString>
<OFString>foo</OFString>
</OFSet>
<OFCountedSet>
<object count='1'>
<OFString>bar</OFString>
</object>
<object count='2'>
<OFString>foo</OFString>
</object>
</OFCountedSet>
</OFList>
</key>
<object>
<OFString>list</OFString>
</object>
<key>
<OFData>MDEyMzQ1Njc4OTo7PEFCQ0RFRkdISklLTE1OT1BRUlNUVVZXWFla</OFData>
</key>
<object>
<OFString>data</OFString>
</object>
<key>
<OFArray>
<OFString>Qu"xbar
test</OFString>
<OFNumber type='signed'>1234</OFNumber>
<OFNumber type='float'>40934a456d5cfaad</OFNumber>
<OFMutableString>asd</OFMutableString>
<OFDate encoding='hex'>40934a456d5cfaad</OFDate>
</OFArray>
</key>
<object>
<OFString>Hello</OFString>
</object>
</OFMutableDictionary>
</serialization>
|