ObjFW  Check-in [92ca1cd5ba]

Overview
Comment:Implement -[description] for OFList.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 92ca1cd5ba3337818d8ba8591a476c6ed04f90e6199a0fcbd37f8818731fe9b5
User & Date: js on 2010-11-25 21:00:08
Other Links: manifest | tags
Context
2010-11-28
16:02
Rename +[streamObserver] to +[observer] in OFStreamObserver. check-in: 4d013fb14a user: js tags: trunk
2010-11-25
21:00
Implement -[description] for OFList. check-in: 92ca1cd5ba user: js tags: trunk
2010-11-24
19:45
Documentation improvements. check-in: 0769e074eb user: js tags: trunk
Changes

Modified src/OFList.m from [39a49b7b3f] to [75abc74933].

10
11
12
13
14
15
16


17
18
19
20
21
22
23
 */

#include "config.h"

#include "assert.h"

#import "OFList.h"


#import "OFExceptions.h"
#import "macros.h"

@implementation OFList
+ list
{
	return [[[self alloc] init] autorelease];







>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 */

#include "config.h"

#include "assert.h"

#import "OFList.h"
#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

@implementation OFList
+ list
{
	return [[[self alloc] init] autorelease];
252
253
254
255
256
257
258
























259
260
261
262
263
264
265
		OF_HASH_ADD(hash, h & 0xFF);
	}

	OF_HASH_FINALIZE(hash);

	return hash;
}

























- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	of_list_object_t **list_obj = (of_list_object_t**)state->extra;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
290
291
		OF_HASH_ADD(hash, h & 0xFF);
	}

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFString*)description
{
	OFMutableString *ret = [OFMutableString stringWithString: @"["];
	OFAutoreleasePool *pool;
	of_list_object_t *iter;

	pool = [[OFAutoreleasePool alloc] init];

	for (iter = firstListObject; iter != NULL; iter = iter->next) {
		[ret appendString: [iter->object description]];

		if (iter->next != NULL)
			[ret appendString: @", "];

		[pool releaseObjects];
	}

	[ret appendString: @"]"];

	[pool release];

	return ret;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	of_list_object_t **list_obj = (of_list_object_t**)state->extra;

Modified tests/OFListTests.m from [fb3fe334cc] to [5d968fdd9a].

75
76
77
78
79
80
81



82
83
84
85
86
87
88
	TEST(@"-[copy]", (list = [[list copy] autorelease]) &&
	    [[list firstListObject]->object isEqual: strings[0]] &&
	    [[list firstListObject]->next->object isEqual: strings[1]] &&
	    [[list lastListObject]->object isEqual: strings[2]])

	TEST(@"-[isEqual:]", [list isEqual: [[list copy] autorelease]])




	TEST(@"-[objectEnumerator]", (enumerator = [list objectEnumerator]))

	loe = [list firstListObject];
	i = 0;
	ok = YES;
	while ((obj = [enumerator nextObject]) != nil) {
		if (![obj isEqual: loe->object])







>
>
>







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
	TEST(@"-[copy]", (list = [[list copy] autorelease]) &&
	    [[list firstListObject]->object isEqual: strings[0]] &&
	    [[list firstListObject]->next->object isEqual: strings[1]] &&
	    [[list lastListObject]->object isEqual: strings[2]])

	TEST(@"-[isEqual:]", [list isEqual: [[list copy] autorelease]])

	TEST(@"-[description]",
	    [[list description] isEqual: @"[Foo, Bar, Baz]"])

	TEST(@"-[objectEnumerator]", (enumerator = [list objectEnumerator]))

	loe = [list firstListObject];
	i = 0;
	ok = YES;
	while ((obj = [enumerator nextObject]) != nil) {
		if (![obj isEqual: loe->object])