ObjFW  Diff

Differences From Artifact [b3651305f9]:

To Artifact [25e8cbc1c1]:


457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
	state->mutationsPtr = (unsigned long*)self;

	return (int)count;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFArrayEnumerator alloc]
	    initWithDataArray: array
	     mutationsPointer: NULL] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	id *objs = [array cArray];







|
|
|







457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
	state->mutationsPtr = (unsigned long*)self;

	return (int)count;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFArrayEnumerator alloc] initWithArray: self
					       dataArray: array
					mutationsPointer: NULL] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	id *objs = [array cArray];
554
555
556
557
558
559
560

561
562
563
564
565
566

567
568
569
570
571
572








573
574
575
576
577

578
579
580
581
582
583
584
585
586
587
588

589
590
591
592
	[array release];

	[super dealloc];
}
@end

@implementation OFArrayEnumerator

- initWithDataArray: (OFDataArray*)array_
   mutationsPointer: (unsigned long*)mutationsPtr_;
{
	self = [super init];

	array = array_;

	count = [array_ count];
	mutations = (mutationsPtr_ != NULL ? *mutationsPtr_ : 0);
	mutationsPtr = mutationsPtr_;

	return self;
}









- (id)nextObject
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException newWithClass: isa];


	if (pos < count)
		return *(id*)[array itemAtIndex: pos++];

	return nil;
}

- (void)reset
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException newWithClass: isa];


	pos = 0;
}
@end







>
|
|



|
>
|





>
>
>
>
>
>
>
>




|
>


|







|
>




554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
	[array release];

	[super dealloc];
}
@end

@implementation OFArrayEnumerator
-    initWithArray: (OFArray*)array_
	 dataArray: (OFDataArray*)dataArray_
  mutationsPointer: (unsigned long*)mutationsPtr_;
{
	self = [super init];

	array = [array_ retain];
	dataArray = [dataArray_ retain];
	count = [dataArray count];
	mutations = (mutationsPtr_ != NULL ? *mutationsPtr_ : 0);
	mutationsPtr = mutationsPtr_;

	return self;
}

- (void)dealloc
{
	[array release];
	[dataArray release];

	[super dealloc];
}

- (id)nextObject
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException newWithClass: isa
							     object: array];

	if (pos < count)
		return *(id*)[dataArray itemAtIndex: pos++];

	return nil;
}

- (void)reset
{
	if (mutationsPtr != NULL && *mutationsPtr != mutations)
		@throw [OFEnumerationMutationException newWithClass: isa
							     object: array];

	pos = 0;
}
@end