ObjFW  Check-in [d763a9ff86]

Overview
Comment:propertyListValue -> objectByParsingPropertyList
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d763a9ff865d0babd6775661bee0225763d6d2bc4156ff905c93f9aa32877e75
User & Date: js on 2020-08-13 22:46:28
Other Links: manifest | tags
Context
2020-08-13
22:50
Adjust generators to recent changes check-in: 728c7fb73e user: js tags: trunk
22:46
propertyListValue -> objectByParsingPropertyList check-in: d763a9ff86 user: js tags: trunk
22:29
OFData: ASN1DERValue -> objectByParsingASN1DER check-in: e479cef7b3 user: js tags: trunk
Changes

Modified src/Makefile from [75472655f7] to [02fc344718].

83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
83
84
85
86
87
88
89

90
91
92
93
94
95
96
97







-
+







       OFSHA512Hash.m			\
       OFSortedList.m			\
       OFStdIOStream.m			\
       OFStream.m			\
       OFString.m			\
       OFString+CryptoHashing.m		\
       OFString+JSONParsing.m		\
       OFString+PropertyListValue.m	\
       OFString+PropertyListParsing.m	\
       OFString+Serialization.m		\
       OFString+URLEncoding.m		\
       OFString+XMLEscaping.m		\
       OFString+XMLUnescaping.m		\
       OFSystemInfo.m			\
       OFTarArchive.m			\
       OFTarArchiveEntry.m		\

Renamed and modified src/OFString+PropertyListValue.h [6c64f3e60f] to src/OFString+PropertyListParsing.h [e83b475868].

18
19
20
21
22
23
24
25

26
27
28
29
30

31
32
33
34
35
36

37
38
39
18
19
20
21
22
23
24

25
26
27
28
29

30
31
32
33
34
35

36
37
38
39







-
+




-
+





-
+



#import "OFString.h"

OF_ASSUME_NONNULL_BEGIN

#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_PropertyListValue_reference;
extern int _OFString_PropertyListParsing_reference;
#ifdef __cplusplus
}
#endif

@interface OFString (PropertyListValue)
@interface OFString (PropertyListParsing)
/*!
 * @brief The string interpreted as a property list and parsed as an object.
 *
 * @note This only supports XML property lists!
 */
@property (readonly, nonatomic) id propertyListValue;
@property (readonly, nonatomic) id objectByParsingPropertyList;
@end

OF_ASSUME_NONNULL_END

Renamed and modified src/OFString+PropertyListValue.m [05bf1a86e4] to src/OFString+PropertyListParsing.m [3c0b0b5b63].

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
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.
 */

#include "config.h"

#import "OFString+PropertyListValue.h"
#import "OFString+PropertyListParsing.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFXMLAttribute.h"
#import "OFXMLElement.h"

#import "OFInvalidFormatException.h"
#import "OFUnsupportedVersionException.h"

int _OFString_PropertyListValue_reference;
int _OFString_PropertyListParsing_reference;

static id parseElement(OFXMLElement *element);

static OFArray *
parseArrayElement(OFXMLElement *element)
{
	OFMutableArray *ret = [OFMutableArray array];
172
173
174
175
176
177
178
179
180


181
182
183
184
185
186
187
172
173
174
175
176
177
178


179
180
181
182
183
184
185
186
187







-
-
+
+







		return parseRealElement(element);
	else if ([elementName isEqual: @"integer"])
		return parseIntegerElement(element);
	else
		@throw [OFInvalidFormatException exception];
}

@implementation OFString (PropertyListValue)
- (id)propertyListValue
@implementation OFString (PropertyListParsing)
- (id)objectByParsingPropertyList
{
	void *pool = objc_autoreleasePoolPush();
	OFXMLElement *rootElement = [OFXMLElement elementWithXMLString: self];
	OFXMLAttribute *versionAttribute;
	OFArray OF_GENERIC(OFXMLElement *) *elements;
	id ret;

Modified src/OFString.h from [2923bf31dc] to [7689800b1d].

1280
1281
1282
1283
1284
1285
1286
1287

1288
1289
1290
1291
1292
1293
1294
1280
1281
1282
1283
1284
1285
1286

1287
1288
1289
1290
1291
1292
1293
1294







-
+







#include "OFMutableString.h"
#ifdef __OBJC__
# import "OFString+CryptoHashing.h"
# import "OFString+JSONParsing.h"
# ifdef OF_HAVE_FILES
#  import "OFString+PathAdditions.h"
# endif
# import "OFString+PropertyListValue.h"
# import "OFString+PropertyListParsing.h"
# import "OFString+Serialization.h"
# import "OFString+URLEncoding.h"
# import "OFString+XMLEscaping.h"
# import "OFString+XMLUnescaping.h"
#endif

#if defined(__OBJC__) && !defined(NSINTEGER_DEFINED) && !__has_feature(modules)

Modified src/OFString.m from [6889fff2f5] to [25f4cd81db].

130
131
132
133
134
135
136
137

138
139
140
141
142
143
144
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144







-
+







_references_to_categories_of_OFString(void)
{
	_OFString_CryptoHashing_reference = 1;
	_OFString_JSONParsing_reference = 1;
#ifdef OF_HAVE_FILES
	_OFString_PathAdditions_reference = 1;
#endif
	_OFString_PropertyListValue_reference = 1;
	_OFString_PropertyListParsing_reference = 1;
	_OFString_Serialization_reference = 1;
	_OFString_URLEncoding_reference = 1;
	_OFString_XMLEscaping_reference = 1;
	_OFString_XMLUnescaping_reference = 1;
}

void

Modified src/OFSystemInfo.m from [0f92abda7c] to [4e15025453].

148
149
150
151
152
153
154
155

156
157
158
159
160
161
162
148
149
150
151
152
153
154

155
156
157
158
159
160
161
162







-
+







#if defined(OF_IOS) || defined(OF_MACOS)
# ifdef OF_HAVE_FILES
	void *pool = objc_autoreleasePoolPush();

	@try {
		OFDictionary *propertyList = [OFString stringWithContentsOfFile:
		    @"/System/Library/CoreServices/SystemVersion.plist"]
		    .propertyListValue;
		    .objectByParsingPropertyList;

		operatingSystemVersion = [[propertyList
		    objectForKey: @"ProductVersion"] copy];
	} @finally {
		objc_autoreleasePoolPop(pool);
	}
# endif

Modified tests/OFPropertyListTests.m from [709f5222a8] to [0566a8c454].

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


116
117
118
119
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

116
117
118
119
120
121







-
-
+
+

-
-
+
+

-
-
+
+





-
+



-
+


-
+

-
+


-
+

-
+


-
+

-
+


-
+

-
+
+


-
+

-
+
+




	    [OFDate dateWithTimeIntervalSince1970: 1521030896],
	    [OFNumber numberWithBool: true],
	    [OFNumber numberWithBool: false],
	    [OFNumber numberWithFloat: 12.25],
	    [OFNumber numberWithInt: -10],
	    nil];

	TEST(@"-[propertyListValue:] #1",
	    [PLIST1.propertyListValue isEqual: @"Hello"])
	TEST(@"-[objectByParsingPropertyList:] #1",
	    [PLIST1.objectByParsingPropertyList isEqual: @"Hello"])

	TEST(@"-[propertyListValue:] #2",
	    [PLIST2.propertyListValue isEqual: array])
	TEST(@"-[objectByParsingPropertyList:] #2",
	    [PLIST2.objectByParsingPropertyList isEqual: array])

	TEST(@"-[propertyListValue:] #3",
	    [PLIST3.propertyListValue isEqual:
	TEST(@"-[objectByParsingPropertyList:] #3",
	    [PLIST3.objectByParsingPropertyList isEqual:
	    [OFDictionary dictionaryWithKeysAndObjects:
	    @"array", array,
	    @"foo", @"bar",
	    nil]])

	EXPECT_EXCEPTION(@"-[propertyListValue] detecting unsupported version",
	EXPECT_EXCEPTION(@"Detecting unsupported version",
	    OFUnsupportedVersionException,
	    [[PLIST(@"<string/>") stringByReplacingOccurrencesOfString: @"1.0"
							    withString: @"1.1"]
	    propertyListValue])
	    objectByParsingPropertyList])

	EXPECT_EXCEPTION(
	    @"-[propertyListValue] detecting invalid format #1",
	    @"-[objectByParsingPropertyList] detecting invalid format #1",
	    OFInvalidFormatException,
	    [PLIST(@"<string x='b'/>") propertyListValue])
	    [PLIST(@"<string x='b'/>") objectByParsingPropertyList])

	EXPECT_EXCEPTION(
	    @"-[propertyListValue] detecting invalid format #2",
	    @"-[objectByParsingPropertyList] detecting invalid format #2",
	    OFInvalidFormatException,
	    [PLIST(@"<string xmlns='foo'/>") propertyListValue])
	    [PLIST(@"<string xmlns='foo'/>") objectByParsingPropertyList])

	EXPECT_EXCEPTION(
	    @"-[propertyListValue] detecting invalid format #3",
	    @"-[objectByParsingPropertyList] detecting invalid format #3",
	    OFInvalidFormatException,
	    [PLIST(@"<dict count='0'/>") propertyListValue])
	    [PLIST(@"<dict count='0'/>") objectByParsingPropertyList])

	EXPECT_EXCEPTION(
	    @"-[propertyListValue] detecting invalid format #4",
	    @"-[objectByParsingPropertyList] detecting invalid format #4",
	    OFInvalidFormatException,
	    [PLIST(@"<dict><key/><string/><key/></dict>") propertyListValue])
	    [PLIST(@"<dict><key/><string/><key/></dict>")
	    objectByParsingPropertyList])

	EXPECT_EXCEPTION(
	    @"-[propertyListValue] detecting invalid format #5",
	    @"-[objectByParsingPropertyList] detecting invalid format #5",
	    OFInvalidFormatException,
	    [PLIST(@"<dict><key x='x'/><string/></dict>") propertyListValue])
	    [PLIST(@"<dict><key x='x'/><string/></dict>")
	    objectByParsingPropertyList])

	objc_autoreleasePoolPop(pool);
}
@end