ObjFW  Check-in [79e1893b40]

Overview
Comment:Introduce OFMutableCopying protocol.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 79e1893b40d9b3bdcef7c8a764de33baecf381776fbd4502d4db59778118a070
User & Date: js on 2009-05-18 18:15:31
Other Links: manifest | tags
Context
2009-05-18
18:24
Remove useless convenience method. check-in: 577023d300 user: js tags: trunk
18:15
Introduce OFMutableCopying protocol. check-in: 79e1893b40 user: js tags: trunk
18:09
More separation for OFString and OFMutableString. check-in: e7e8efd297 user: js tags: trunk
Changes

Modified src/OFArray.h from [46dcbcf5e6] to [5f3c2228b9].

11
12
13
14
15
16
17
18

19
20
21
22
23
24
25
11
12
13
14
15
16
17

18
19
20
21
22
23
24
25







-
+








#import "OFObject.h"
#import "OFDataArray.h"

/**
 * The OFArray class provides a class for storing objects in an array.
 */
@interface OFArray: OFObject <OFCopying>
@interface OFArray: OFObject <OFCopying, OFMutableCopying>
{
	OFDataArray *array;
}

/**
 * \return A new autoreleased OFArray
 */

Modified src/OFArray.m from [f1d02c7bd0] to [bacc2fea00].

50
51
52
53
54
55
56


















57
58
59
60
61
62
63
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







}

- (id)copy
{
	OFArray *new = [OFArray array];
	OFObject **objs;
	size_t len, i;

	objs = [array data];
	len = [array count];

	[new->array addNItems: len
		   fromCArray: objs];

	for (i = 0; i < len; i++)
		[objs[i] retain];

	return new;
}

- (id)mutableCopy
{
	OFArray *new = [OFMutableArray array];
	OFObject **objs;
	size_t len, i;

	objs = [array data];
	len = [array count];

	[new->array addNItems: len
		   fromCArray: objs];

Modified src/OFObject.h from [9afbf70556] to [ee8a3d67d3].

218
219
220
221
222
223
224











218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235







+
+
+
+
+
+
+
+
+
+
+
 */
@protocol OFCopying
/**
 * \return A copy of the object
 */
- (id)copy;
@end

/**
 * This protocol is implemented by objects that can be mutable and immutable
 * and allows returning a mutable copy.
 */
@protocol OFMutableCopying
/**
 * \return A copy of the object
 */
- (id)mutableCopy;
@end

Modified src/OFString.h from [b7ca2d5c06] to [99a279b1da].

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
30







-
+







#import "OFArray.h"

extern int of_string_check_utf8(const char *str, size_t len);

/**
 * A class for managing strings.
 */
@interface OFString: OFObject <OFCopying>
@interface OFString: OFObject <OFCopying, OFMutableCopying>
{
	char	     *string;
#ifdef __objc_INCLUDE_GNU
	unsigned int length;
#else
	int	     length;
#if __LP64__

Modified src/OFString.m from [b1b2906cfa] to [eb70c8a2e9].

248
249
250
251
252
253
254





255
256
257
258
259
260
261
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266







+
+
+
+
+







	return length;
}

- (id)copy
{
	return [OFString stringWithCString: string];
}

- (id)mutableCopy
{
	return [OFMutableString stringWithCString: string];
}

- (BOOL)isEqual: (id)obj
{
	if (![obj isKindOf: [OFString class]])
		return NO;
	if (strcmp(string, [obj cString]))
		return NO;