ObjFW  Check-in [f886f21ad5]

Overview
Comment:Rename OFConcreteData -> OFAdjacentData
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f886f21ad58ab7a6b4f401f2e063bad7e91fb96ccbc7ff53ca1f625e8ddd4f32
User & Date: js on 2023-08-08 09:41:48
Other Links: manifest | tags
Context
2023-08-08
15:32
A few minor cleanups check-in: a6f520157a user: js tags: trunk
09:41
Rename OFConcreteData -> OFAdjacentData check-in: f886f21ad5 user: js tags: trunk
09:36
OFData: Fix a brain fart check-in: 9706b6199d user: js tags: trunk
Changes

Modified src/Makefile from [ee4f124e3c] to [a2abd7caf7].

172
173
174
175
176
177
178

179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

197
198
199
200
201
202
203
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

187
188
189
190
191
192
193
194
195

196
197
198
199
200
201
202
203







+







-









-
+







	    macros.h				\
	    objfw-defs.h			\
	    platform.h				\
	    ${USE_INCLUDES_ATOMIC}

SRCS += OFASPrintF.m			\
	OFAdjacentArray.m		\
	OFAdjacentData.m		\
	OFAdjacentSubarray.m		\
	OFArchiveIRIHandler.m		\
	OFBase64.m			\
	OFBitSetCharacterSet.m		\
	OFBytesValue.m			\
	OFCRC16.m			\
	OFCRC32.m			\
	OFConcreteData.m		\
	OFCountedMapTableSet.m		\
	OFEmbeddedIRIHandler.m		\
	OFHuffmanTree.m			\
	OFINIFileSettings.m		\
	OFInvertedCharacterSet.m	\
	OFLHADecompressingStream.m	\
	OFMapTableDictionary.m		\
	OFMapTableSet.m			\
	OFMutableAdjacentArray.m	\
	OFMutableConcreteData.m		\
	OFMutableAdjacentData.m		\
	OFMutableMapTableDictionary.m	\
	OFMutableMapTableSet.m		\
	OFMutableUTF8String.m		\
	OFNonretainedObjectValue.m	\
	OFPointValue.m			\
	OFPointerValue.m		\
	OFRangeCharacterSet.m		\

Renamed and modified src/OFConcreteData.h [7c0b340f55] to src/OFAdjacentData.h [9ef5f95f67].

13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
13
14
15
16
17
18
19

20
21
22
23
24
25
26
27
28
29







-
+









 * file.
 */

#import "OFData.h"

OF_ASSUME_NONNULL_BEGIN

@interface OFConcreteData: OFData
@interface OFAdjacentData: OFData
{
	unsigned char *_Nullable _items;
	size_t _capacity, _count, _itemSize;
	bool _freeWhenDone;
	OFData *_Nullable _parentData;
}
@end

OF_ASSUME_NONNULL_END

Renamed and modified src/OFConcreteData.m [228c900b27] to src/OFAdjacentData.m [35583b4857].

14
15
16
17
18
19
20
21

22
23
24
25
26

27
28
29
30
31
32
33
14
15
16
17
18
19
20

21
22
23
24
25

26
27
28
29
30
31
32
33







-
+




-
+







 */

#include "config.h"

#include <limits.h>
#include <string.h>

#import "OFConcreteData.h"
#import "OFAdjacentData.h"

#import "OFInvalidArgumentException.h"
#import "OFOutOfRangeException.h"

@implementation OFConcreteData
@implementation OFAdjacentData
- (instancetype)init
{
	return [self initWithItemSize: 1];
}

- (instancetype)initWithItemSize: (size_t)itemSize
{
116
117
118
119
120
121
122
123

124
125
126
127
128
129

130
131
132
133
134
135
136
137
138
116
117
118
119
120
121
122

123
124
125
126
127
128

129
130
131
132
133
134
135
136
137
138







-
+





-
+









- (const void *)items
{
	return _items;
}

- (OFData *)subdataWithRange: (OFRange)range
{
	OFConcreteData *ret;
	OFAdjacentData *ret;

	if (range.length > SIZE_MAX - range.location ||
	    range.location + range.length > _count)
		@throw [OFOutOfRangeException exception];

	ret = [OFConcreteData
	ret = [OFAdjacentData
	    dataWithItemsNoCopy: _items + (range.location * _itemSize)
			  count: range.length
		       itemSize: _itemSize
		   freeWhenDone: false];
	ret->_parentData = [(_parentData != nil ? _parentData : self) copy];

	return ret;
}
@end

Modified src/OFData.m from [b2f1d97df1] to [daaae842d6].

16
17
18
19
20
21
22
23
24


25
26
27
28
29
30
31
16
17
18
19
20
21
22


23
24
25
26
27
28
29
30
31







-
-
+
+







#include "config.h"

#include <stdlib.h>
#include <string.h>
#include <limits.h>

#import "OFData.h"
#import "OFBase64.h"
#import "OFConcreteData.h"
#import "OFAdjacentData.h"
#import "OFBase64.h"
#import "OFDictionary.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
# import "OFFileManager.h"
#endif
#import "OFIRI.h"
#import "OFIRIHandler.h"
55
56
57
58
59
60
61
62

63
64
65
66
67

68
69
70
71
72

73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
88

89
90
91
92
93
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
122
123
124

125
126
127
128
129
130
131
55
56
57
58
59
60
61

62
63
64
65
66

67
68
69
70
71

72
73
74
75
76
77
78

79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
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
122
123

124
125
126
127
128
129
130
131







-
+




-
+




-
+






-
+








-
+









-
+








-
+





-
+




-
+





-
+







	_OFData_CryptographicHashing_reference = 1;
	_OFData_MessagePackParsing_reference = 1;
}

@implementation OFDataPlaceholder
- (instancetype)init
{
	return (id)[[OFConcreteData alloc] init];
	return (id)[[OFAdjacentData alloc] init];
}

- (instancetype)initWithItemSize: (size_t)itemSize
{
	return (id)[[OFConcreteData alloc] initWithItemSize: itemSize];
	return (id)[[OFAdjacentData alloc] initWithItemSize: itemSize];
}

- (instancetype)initWithItems: (const void *)items count: (size_t)count
{
	return (id)[[OFConcreteData alloc] initWithItems: items count: count];
	return (id)[[OFAdjacentData alloc] initWithItems: items count: count];
}

- (instancetype)initWithItems: (const void *)items
			count: (size_t)count
		     itemSize: (size_t)itemSize
{
	return (id)[[OFConcreteData alloc] initWithItems: items
	return (id)[[OFAdjacentData alloc] initWithItems: items
						   count: count
						itemSize: itemSize];
}

- (instancetype)initWithItemsNoCopy: (void *)items
			      count: (size_t)count
		       freeWhenDone: (bool)freeWhenDone
{
	return (id)[[OFConcreteData alloc] initWithItemsNoCopy: items
	return (id)[[OFAdjacentData alloc] initWithItemsNoCopy: items
							 count: count
						  freeWhenDone: freeWhenDone];
}

- (instancetype)initWithItemsNoCopy: (void *)items
			      count: (size_t)count
			   itemSize: (size_t)itemSize
		       freeWhenDone: (bool)freeWhenDone
{
	return (id)[[OFConcreteData alloc] initWithItemsNoCopy: items
	return (id)[[OFAdjacentData alloc] initWithItemsNoCopy: items
							 count: count
						      itemSize: itemSize
						  freeWhenDone: freeWhenDone];
}

#ifdef OF_HAVE_FILES
- (instancetype)initWithContentsOfFile: (OFString *)path
{
	return (id)[[OFConcreteData alloc] initWithContentsOfFile: path];
	return (id)[[OFAdjacentData alloc] initWithContentsOfFile: path];
}
#endif

- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
{
	return (id)[[OFConcreteData alloc] initWithContentsOfIRI: IRI];
	return (id)[[OFAdjacentData alloc] initWithContentsOfIRI: IRI];
}

- (instancetype)initWithStringRepresentation: (OFString *)string
{
	return (id)[[OFConcreteData alloc]
	return (id)[[OFAdjacentData alloc]
	    initWithStringRepresentation: string];
}

- (instancetype)initWithBase64EncodedString: (OFString *)string
{
	return (id)[[OFConcreteData alloc] initWithBase64EncodedString: string];
	return (id)[[OFAdjacentData alloc] initWithBase64EncodedString: string];
}
@end

@implementation OFData
+ (void)initialize
{
	if (self == [OFData class])

Renamed and modified src/OFMutableConcreteData.h [2a0d338a69] to src/OFMutableAdjacentData.h [3610a15f14].

13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28
29
13
14
15
16
17
18
19

20
21
22
23
24
25
26
27
28
29







-
+









 * file.
 */

#import "OFMutableData.h"

OF_ASSUME_NONNULL_BEGIN

@interface OFMutableConcreteData: OFMutableData
@interface OFMutableAdjacentData: OFMutableData
{
	unsigned char *_Nullable _items;
	size_t _capacity, _count, _itemSize;
	bool _freeWhenDone;
	OFData *_Nullable _parentData;
}
@end

OF_ASSUME_NONNULL_END

Renamed and modified src/OFMutableConcreteData.m [bbba29f5a7] to src/OFMutableAdjacentData.m [dbdac00eff].

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
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







-
-
+
+





-
+


-
-
+
+







 */

#include "config.h"

#include <limits.h>
#include <string.h>

#import "OFMutableConcreteData.h"
#import "OFConcreteData.h"
#import "OFMutableAdjacentData.h"
#import "OFAdjacentData.h"

#import "OFInvalidArgumentException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"

@implementation OFMutableConcreteData
@implementation OFMutableAdjacentData
+ (void)initialize
{
	if (self == [OFMutableConcreteData class])
		[self inheritMethodsFromClass: [OFConcreteData class]];
	if (self == [OFMutableAdjacentData class])
		[self inheritMethodsFromClass: [OFAdjacentData class]];
}

- (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity
{
	self = [super init];

	@try {
180
181
182
183
184
185
186
187

188
189
180
181
182
183
184
185
186

187
188
189







-
+


			_items = OFResizeMemory(_items, _count, _itemSize);
			_capacity = _count;
		} @catch (OFOutOfMemoryException *e) {
			/* We don't care, as we only made it smaller */
		}
	}

	object_setClass(self, [OFConcreteData class]);
	object_setClass(self, [OFAdjacentData class]);
}
@end

Modified src/OFMutableData.m from [fb095843a4] to [cdf5f88dbb].

16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
35
36
37

38
39
40
41
42

43
44
45
46
47

48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71
72
73
74
75

76
77
78
79
80
81
82
83
84
85

86
87
88
89
90
91

92
93
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
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39
40
41

42
43
44
45
46

47
48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90

91
92
93
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







-
+













-
+




-
+




-
+







-
+








-
+










-
+









-
+





-
+




-
+





-
+





-
+




-
+







#include "config.h"

#include <stdlib.h>
#include <string.h>
#include <limits.h>

#import "OFMutableData.h"
#import "OFMutableConcreteData.h"
#import "OFMutableAdjacentData.h"

#import "OFOutOfRangeException.h"

static struct {
	Class isa;
} placeholder;

@interface OFMutableDataPlaceholder: OFMutableData
@end

@implementation OFMutableDataPlaceholder
- (instancetype)init
{
	return (id)[[OFMutableConcreteData alloc] init];
	return (id)[[OFMutableAdjacentData alloc] init];
}

- (instancetype)initWithItemSize: (size_t)itemSize
{
	return (id)[[OFMutableConcreteData alloc] initWithItemSize: itemSize];
	return (id)[[OFMutableAdjacentData alloc] initWithItemSize: itemSize];
}

- (instancetype)initWithItems: (const void *)items count: (size_t)count
{
	return (id)[[OFMutableConcreteData alloc] initWithItems: items
	return (id)[[OFMutableAdjacentData alloc] initWithItems: items
							  count: count];
}

- (instancetype)initWithItems: (const void *)items
			count: (size_t)count
		     itemSize: (size_t)itemSize
{
	return (id)[[OFMutableConcreteData alloc] initWithItems: items
	return (id)[[OFMutableAdjacentData alloc] initWithItems: items
							  count: count
						       itemSize: itemSize];
}

- (instancetype)initWithItemsNoCopy: (void *)items
			      count: (size_t)count
		       freeWhenDone: (bool)freeWhenDone
{
	return (id)[[OFMutableConcreteData alloc]
	return (id)[[OFMutableAdjacentData alloc]
	    initWithItemsNoCopy: items
			  count: count
		   freeWhenDone: freeWhenDone];
}

- (instancetype)initWithItemsNoCopy: (void *)items
			      count: (size_t)count
			   itemSize: (size_t)itemSize
		       freeWhenDone: (bool)freeWhenDone
{
	return (id)[[OFMutableConcreteData alloc]
	return (id)[[OFMutableAdjacentData alloc]
	    initWithItemsNoCopy: items
			  count: count
		       itemSize: itemSize
		   freeWhenDone: freeWhenDone];
}

#ifdef OF_HAVE_FILES
- (instancetype)initWithContentsOfFile: (OFString *)path
{
	return (id)[[OFMutableConcreteData alloc] initWithContentsOfFile: path];
	return (id)[[OFMutableAdjacentData alloc] initWithContentsOfFile: path];
}
#endif

- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
{
	return (id)[[OFMutableConcreteData alloc] initWithContentsOfIRI: IRI];
	return (id)[[OFMutableAdjacentData alloc] initWithContentsOfIRI: IRI];
}

- (instancetype)initWithStringRepresentation: (OFString *)string
{
	return (id)[[OFMutableConcreteData alloc]
	return (id)[[OFMutableAdjacentData alloc]
	    initWithStringRepresentation: string];
}

- (instancetype)initWithBase64EncodedString: (OFString *)string
{
	return (id)[[OFMutableConcreteData alloc]
	return (id)[[OFMutableAdjacentData alloc]
	    initWithBase64EncodedString: string];
}

- (instancetype)initWithCapacity: (size_t)capacity
{
	return (id)[[OFMutableConcreteData alloc] initWithCapacity: capacity];
	return (id)[[OFMutableAdjacentData alloc] initWithCapacity: capacity];
}

- (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity
{
	return (id)[[OFMutableConcreteData alloc] initWithItemSize: itemSize
	return (id)[[OFMutableAdjacentData alloc] initWithItemSize: itemSize
							  capacity: capacity];
}
@end

@implementation OFMutableData
+ (void)initialize
{