ObjFW  Diff

Differences From Artifact [b812da9162]:

To Artifact [f508012563]:


12
13
14
15
16
17
18

19
20
21
22
23
24
25
#include "config.h"

#include <stdarg.h>

#import "OFArray.h"
#import "OFDataArray.h"
#import "OFString.h"

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

@implementation OFArray
+ array
{
	return [[[self alloc] init] autorelease];







>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "config.h"

#include <stdarg.h>

#import "OFArray.h"
#import "OFDataArray.h"
#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

@implementation OFArray
+ array
{
	return [[[self alloc] init] autorelease];
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
{
	return [self objectsFromIndex: range.start
			      toIndex: range.start + range.length];
}

- (OFString*)componentsJoinedByString: (OFString*)separator
{

	OFString *str;
	OFString **objs = [array cArray];
	size_t i, count = [array count];
	Class cls;
	IMP append;

	if (count == 0)
		return @"";
	if (count == 1)
		return [objs[0] retain];

	str = [OFMutableString string];
	cls = [OFString class];
	append = [str methodForSelector: @selector(appendString:)];



	for (i = 0; i < count - 1; i++) {
		if (![objs[i] isKindOfClass: cls])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		append(str, @selector(appendString:), objs[i]);
		append(str, @selector(appendString:), separator);
	}


	append(str, @selector(appendString:), objs[i]);



	return str;
}

- (BOOL)isEqual: (id)obj
{
	id *objs, *objs2;







>















>
>





|

|
>
>

>
>







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
{
	return [self objectsFromIndex: range.start
			      toIndex: range.start + range.length];
}

- (OFString*)componentsJoinedByString: (OFString*)separator
{
	OFAutoreleasePool *pool;
	OFString *str;
	OFString **objs = [array cArray];
	size_t i, count = [array count];
	Class cls;
	IMP append;

	if (count == 0)
		return @"";
	if (count == 1)
		return [objs[0] retain];

	str = [OFMutableString string];
	cls = [OFString class];
	append = [str methodForSelector: @selector(appendString:)];

	pool = [[OFAutoreleasePool alloc] init];

	for (i = 0; i < count - 1; i++) {
		if (![objs[i] isKindOfClass: cls])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		append(str, @selector(appendString:), [objs[i] description]);
		append(str, @selector(appendString:), separator);

		[pool releaseObjects];
	}
	append(str, @selector(appendString:), objs[i]);

	[pool release];

	return str;
}

- (BOOL)isEqual: (id)obj
{
	id *objs, *objs2;
343
344
345
346
347
348
349











350
351
352
353
354
355
356
		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_
{
	size_t count = [array count];








>
>
>
>
>
>
>
>
>
>
>







351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
		OF_HASH_ADD(hash, h & 0xFF);
	}

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFString*)description
{
	OFMutableString *ret;

	ret = (OFMutableString*)[self componentsJoinedByString: @", "];
	[ret prependString: @"("];
	[ret appendString: @")"];

	return ret;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	size_t count = [array count];