ObjFW  Check-in [7214a2c7af]

Overview
Comment:OFEnumerator: Remove -[reset]

It's not very useful and is a problem for the Foundation bridge, as
NSEnumerator does not have it.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7214a2c7af1a211fe36fd1aef30b71289b12cbf6c78b46133afe1d00ef053ff9
User & Date: js on 2019-06-19 00:45:05
Other Links: manifest | tags
Context
2019-06-19
00:54
OFEnumerator: Conform to OFFastEnumeration check-in: f18b5db636 user: js tags: trunk
00:45
OFEnumerator: Remove -[reset] check-in: 7214a2c7af user: js tags: trunk
00:36
OFDictionary: Add default for fast enumeration check-in: eeec8af349 user: js tags: trunk
Changes

Modified src/OFArray.m from [297edbd879] to [b12c539371].

960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
960
961
962
963
964
965
966









967







-
-
-
-
-
-
-
-
-

		    exceptionWithObject: _array];

	if (_position < _count)
		return [_array objectAtIndex: _position++];

	return nil;
}

- (void)reset
{
	if (_mutationsPtr != NULL && *_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithObject: _array];

	_position = 0;
}
@end

Modified src/OFDNSResolver.m from [a2fc2aa0b5] to [088c1eb5e1].

1586
1587
1588
1589
1590
1591
1592
1593
1594


1595
1596
1597
1598
1599
1600
1601
1586
1587
1588
1589
1590
1591
1592


1593
1594
1595
1596
1597
1598
1599
1600
1601







-
-
+
+







	}
}
#endif

- (void)of_reloadSystemConfig
{
	/*
	 * TODO: Rather than reparsing every, check what actually changed
	 * (mtime) and only reset those.
	 * TODO: Rather than reparsing every time, check what actually changed
	 *	 (mtime) and only reset those.
	 */

	if (_lastConfigReload != nil && _configReloadInterval > 0 &&
	    _lastConfigReload.timeIntervalSinceNow < _configReloadInterval)
		return;

	[_staticHosts release];

Modified src/OFEnumerator.h from [3064d9daa6] to [fb1ecf6b18].

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
55
56
57
58
59
60
61






62
63
64
65
66
67
68







-
-
-
-
-
-








/*!
 * @brief Returns an array of all remaining objects in the collection.
 *
 * @return An array of all remaining objects in the collection.
 */
- (OFArray OF_GENERIC(ObjectType) *)allObjects;

/*!
 * @brief Resets the enumerator, so the next call to nextObject returns the
 *	  first object again.
 */
- (void)reset;
#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
# undef ObjectType
#endif
@end

/*
 * This needs to be exactly like this because it's hard-coded in the compiler.

Modified src/OFEnumerator.m from [71eb73c7cb] to [cc0c7b76c2].

54
55
56
57
58
59
60
61
62
63
64
65
66
54
55
56
57
58
59
60





61







-
-
-
-
-


	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return ret;
}

- (void)reset
{
	OF_UNRECOGNIZED_SELECTOR
}
@end

Modified src/OFList.m from [b8390d9c24] to [146f486f61].

441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
441
442
443
444
445
446
447









448







-
-
-
-
-
-
-
-
-

		return nil;

	ret = _current->object;
	_current = _current->next;

	return ret;
}

- (void)reset
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithObject: _list];

	_current = _list.firstListObject;
}
@end

Modified src/OFMapTable.h from [094ec6866a] to [1f1f29d31e].

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






258
259
260







-
-
-
-
-
-



/*!
 * @brief Returns a pointer to the next object, or NULL if the enumeration
 *	  finished.
 *
 * @return The next object
 */
- (void *_Nullable *_Nullable)nextObject;

/*!
 * @brief Resets the enumerator, so the next call to @ref nextObject returns the
 *	  first object again.
 */
- (void)reset;
@end

OF_ASSUME_NONNULL_END

Modified src/OFMapTable.m from [916c94f96d] to [889ef07313].

677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
677
678
679
680
681
682
683









684
685
686
687
688
689
690







-
-
-
-
-
-
-
-
-







	[super dealloc];
}

- (void **)nextObject
{
	OF_UNRECOGNIZED_SELECTOR
}

- (void)reset
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException
		    exceptionWithObject: _mapTable];

	_position = 0;
}
@end

@implementation OFMapTableKeyEnumerator
- (void **)nextObject
{
	if (*_mutationsPtr != _mutations)
		@throw [OFEnumerationMutationException
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
749
750
751
752
753
754
755










756







-
-
-
-
-
-
-
-
-
-

	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithObject: _object];
	}

	return (id)*objectPtr;
}

- (void)reset
{
	@try {
		[_enumerator reset];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithObject: _object];
	}
}
@end

Modified tests/OFArrayTests.m from [e635773d52] to [501a7abef0].

290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
290
291
292
293
294
295
296

297
298
299
300
301
302
303







-







	}

	if (m[0].count != i)
		ok = false;

	TEST(@"OFEnumerator's -[nextObject]", ok)

	[enumerator reset];
	[m[0] removeObjectAtIndex: 0];

	EXPECT_EXCEPTION(@"Detection of mutation during enumeration",
	    OFEnumerationMutationException, [enumerator nextObject])

	m[0] = [[a[0] mutableCopy] autorelease];
	ok = true;

Modified tests/OFDictionaryTests.m from [c3a18a2f55] to [71910a92f2].

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

225
226
227
228
229
230
231







-







	    [[keyEnumerator nextObject] isEqual: keys[0]] &&
	    [[objectEnumerator nextObject] isEqual: values[0]] &&
	    [[keyEnumerator nextObject] isEqual: keys[1]] &&
	    [[objectEnumerator nextObject] isEqual: values[1]] &&
	    [keyEnumerator nextObject] == nil &&
	    [objectEnumerator nextObject] == nil)

	[keyEnumerator reset];
	[mutDict removeObjectForKey: keys[0]];

	EXPECT_EXCEPTION(@"Detection of mutation during enumeration",
	    OFEnumerationMutationException, [keyEnumerator nextObject]);

	[mutDict setObject: values[0]
		    forKey: keys[0]];

Modified tests/OFListTests.m from [c2851ea215] to [0f5664c086].

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
105
106
107
108
109
110
111

112
113
114
115
116
117
118







-







	}

	if (list.count != i)
		ok = false;

	TEST(@"OFEnumerator's -[nextObject]", ok);

	[enumerator reset];
	[list removeListObject: list.firstListObject];

	EXPECT_EXCEPTION(@"Detection of mutation during enumeration",
	    OFEnumerationMutationException, [enumerator nextObject])

	[list prependObject: strings[0]];