ObjFW  Check-in [3a6d41c6a3]

Overview
Comment:Add -[makeObjectsPerformSelector:] and friends to OFArray.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3a6d41c6a39ee889fcc23f98c48b880e6f61778f530a21e4071951edebae0074
User & Date: js on 2011-03-25 12:47:39
Other Links: manifest | tags
Context
2011-03-25
14:56
Pass the thread for thread exceptions. check-in: a8113fd82c user: js tags: trunk
12:47
Add -[makeObjectsPerformSelector:] and friends to OFArray. check-in: 3a6d41c6a3 user: js tags: trunk
12:30
Add -[performSelector:] and friends to OFObject. check-in: c3f3576af4 user: js tags: trunk
Changes

Modified src/OFArray.h from [ac4d6f9a1b] to [cdbef7934d].

202
203
204
205
206
207
208


















209
210
211
212
213
214
215
 * Creates a string by joining all objects of the array.
 *
 * \param separator The string with which the objects should be joined
 * \return A string containing all objects joined by the separator
 */
- (OFString*)componentsJoinedByString: (OFString*)separator;



















#ifdef OF_HAVE_BLOCKS
/**
 * Executes a block for each object.
 *
 * \param block The block to execute for each object
 */
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block;







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







202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
 * Creates a string by joining all objects of the array.
 *
 * \param separator The string with which the objects should be joined
 * \return A string containing all objects joined by the separator
 */
- (OFString*)componentsJoinedByString: (OFString*)separator;

/**
 * Performs the specified selector on all objects in the array.
 *
 * \param selector The selector to perform on all objects in the array
 */
- (void)makeObjectsPerformSelector: (SEL)selector;

/**
 * Performs the specified selector on all objects in the array with the
 * specified object.
 *
 * \param selector The selector to perform on all objects in the array
 * \param obj The object to perform the selector with on all objects in the
 *	      array
 */
- (void)makeObjectsPerformSelector: (SEL)selector
			withObject: (id)obj;

#ifdef OF_HAVE_BLOCKS
/**
 * Executes a block for each object.
 *
 * \param block The block to execute for each object
 */
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block;

Modified src/OFArray.m from [4d34bbbbff] to [b3651305f9].

416
417
418
419
420
421
422



















423
424
425
426
427
428
429
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}




















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








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







416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- (void)makeObjectsPerformSelector: (SEL)selector
{
	id *objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)
		((void(*)())[objs[i] methodForSelector: selector])();
}

- (void)makeObjectsPerformSelector: (SEL)selector
			withObject: (id)obj
{
	id *objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)
		((void(*)(id))[objs[i] methodForSelector: selector])(obj);
}

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