ObjFW  Check-in [e8473b9db8]

Overview
Comment:Document the block types.

This also removes "bool *stop" from some blocks where it does not make
sense.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e8473b9db87ee5ba6e7ed6c4867c5627188d96635d63d51ddaa38f06f62ef5e5
User & Date: js on 2013-03-08 22:44:07
Other Links: manifest | tags
Context
2013-03-08
23:00
Take advantage of realloc(NULL, n) being defined. check-in: e8d6ca16e7 user: js tags: trunk
22:44
Document the block types. check-in: e8473b9db8 user: js tags: trunk
2013-03-04
18:32
Make old GCCs happy. check-in: 0bb3fc850a user: js tags: trunk
Changes

Modified src/OFArray.h from [ecde9fadf5] to [b961e68793].

25
26
27
28
29
30
31


32
33
34
35
36
37
38
39








40
41








42








43








44
45
46
47
48
49
50

#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFBinaryPackRepresentation.h"



@class OFString;

enum {
	OF_SORT_OPTIONS_DESCENDING = 1
};

#ifdef OF_HAVE_BLOCKS








typedef void (^of_array_enumeration_block_t)(id object, size_t index,
    bool *stop);








typedef bool (^of_array_filter_block_t)(id odject, size_t index);








typedef id (^of_array_map_block_t)(id object, size_t index);








typedef id (^of_array_fold_block_t)(id left, id right);
#endif

/*!
 * @brief An abstract class for storing objects in an array.
 */
@interface OFArray: OFObject <OFCopying, OFMutableCopying, OFCollection,







>
>








>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

#import "OFObject.h"
#import "OFCollection.h"
#import "OFEnumerator.h"
#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFBinaryPackRepresentation.h"

/*! @file */

@class OFString;

enum {
	OF_SORT_OPTIONS_DESCENDING = 1
};

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block for enumerating an OFArray.
 *
 * @param object The current object
 * @param index The index of the current object
 * @param stop A pointer to a variable that can be set to true to stop the
 *	       enumeration
 */
typedef void (^of_array_enumeration_block_t)(id object, size_t index,
    bool *stop);

/*!
 * @brief A block for filtering an OFArray.
 *
 * @param object The object to inspect
 * @param index The index of the object to inspect
 * @return Whether the object should be in the filtered array
 */
typedef bool (^of_array_filter_block_t)(id object, size_t index);

/*!
 * @brief A block for mapping objects to objects in an OFArray.
 *
 * @param object The object to map
 * @param index The index of the object to map
 * @return The object to map to
 */
typedef id (^of_array_map_block_t)(id object, size_t index);

/*!
 * @brief A block for folding an OFArray.
 *
 * @param left The object to which the object has been folded so far
 * @param right The object that should be added to the left object
 * @return The left and right side folded into one object
 */
typedef id (^of_array_fold_block_t)(id left, id right);
#endif

/*!
 * @brief An abstract class for storing objects in an array.
 */
@interface OFArray: OFObject <OFCopying, OFMutableCopying, OFCollection,

Modified src/OFCountedSet.h from [6a5aa970ef] to [749e359563].

11
12
13
14
15
16
17
18


19








20
21
22
23
24
25
26
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFSet.h"



#ifdef OF_HAVE_BLOCKS








typedef void (^of_counted_set_enumeration_block_t)(id object, size_t count,
    bool *stop);
#endif

/*!
 * @brief An abstract class for a mutable unordered set of objects, counting how
 *	  often it contains an object.








>
>

>
>
>
>
>
>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFSet.h"

/*! @file */

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block for enumerating an OFCountedSet.
 *
 * @param object The current object
 * @param count The count of the object
 * @param stop A pointer to a variable that can be set to true to stop the
 *	       enumeration
 */
typedef void (^of_counted_set_enumeration_block_t)(id object, size_t count,
    bool *stop);
#endif

/*!
 * @brief An abstract class for a mutable unordered set of objects, counting how
 *	  often it contains an object.

Modified src/OFHTTPServer.h from [37d7fcda08] to [ffe70c28fb].

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@optional
#endif
/*!
 * @brief This method is called when the HTTP server's listening socket
 *	  encountered an exception.
 *
 * @param server The HTTP server which encountered an exception
 * @param exception The exception that occurred on the HTTP server's listening
 *		    socket
 * @return Whether to continue listening. If you return false, existing
 *	   connections will still be handled and you can start accepting new
 *	   connections again by calling @ref OFHTTPServer::start again.
 */
-			  (bool)server: (OFHTTPServer*)server
  didReceiveExceptionOnListeningSocket: (OFException*)exception;







|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@optional
#endif
/*!
 * @brief This method is called when the HTTP server's listening socket
 *	  encountered an exception.
 *
 * @param server The HTTP server which encountered an exception
 * @param exception The exception which occurred on the HTTP server's listening
 *		    socket
 * @return Whether to continue listening. If you return false, existing
 *	   connections will still be handled and you can start accepting new
 *	   connections again by calling @ref OFHTTPServer::start again.
 */
-			  (bool)server: (OFHTTPServer*)server
  didReceiveExceptionOnListeningSocket: (OFException*)exception;

Modified src/OFMapTable.h from [e819467858] to [aa28d14053].

13
14
15
16
17
18
19


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34








35
36








37
38
39
40
41
42
43
44
45
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"
#import "OFEnumerator.h"



/**
 * @brief A struct describing the functions to be used by the map table.
 */
typedef struct of_map_table_functions_t {
	/// The function to retain keys / values
	void* (*retain)(void *value);
	/// The function to release keys / values
	void (*release)(void *value);
	/// The function to hash keys
	uint32_t (*hash)(void *value);
	/// The function to compare keys / values
	bool (*equal)(void *value1, void *value2);
} of_map_table_functions_t;

#ifdef OF_HAVE_BLOCKS








typedef void (^of_map_table_enumeration_block_t)(void *key, void *value,
    bool *stop);








typedef void* (^of_map_table_replace_block_t)(void *key, void *value,
    bool *stop);
#endif

@class OFMapTableEnumerator;

/**
 * @brief A class similar to OFDictionary, but providing more options how keys
 *	  and values should be retained, released, compared and hashed.







>
>















>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
|
<







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"
#import "OFEnumerator.h"

/*! @file */

/**
 * @brief A struct describing the functions to be used by the map table.
 */
typedef struct of_map_table_functions_t {
	/// The function to retain keys / values
	void* (*retain)(void *value);
	/// The function to release keys / values
	void (*release)(void *value);
	/// The function to hash keys
	uint32_t (*hash)(void *value);
	/// The function to compare keys / values
	bool (*equal)(void *value1, void *value2);
} of_map_table_functions_t;

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block for enumerating an OFMapTable.
 *
 * @param key The current key
 * @param value The current value
 * @param stop A pointer to a variable that can be set to true to stop the
 *	       enumeration
 */
typedef void (^of_map_table_enumeration_block_t)(void *key, void *value,
    bool *stop);

/*!
 * @brief A block for replacing values in an OFMapTable.
 *
 * @param key The key of the value to replace
 * @param value The value to replace
 * @return The value to replace the value with
 */
typedef void* (^of_map_table_replace_block_t)(void *key, void *value);

#endif

@class OFMapTableEnumerator;

/**
 * @brief A class similar to OFDictionary, but providing more options how keys
 *	  and values should be retained, released, compared and hashed.

Modified src/OFMapTable.m from [f2d7d60333] to [7caa69a7b0].

595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621

622
623

624
625
626
627
628
629
630
			block(_buckets[i]->key, _buckets[i]->value, &stop);
	}
}

- (void)replaceValuesUsingBlock: (of_map_table_replace_block_t)block
{
	size_t i;
	bool stop = false;
	unsigned long mutations = _mutations;

	for (i = 0; i < _capacity && !stop; i++) {
		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		if (_buckets[i] != NULL && _buckets[i] != &deleted) {
			void *old, *new;

			new = block(_buckets[i]->key, _buckets[i]->value,
			    &stop);
			if (new == NULL)
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];

			old = _buckets[i]->value;

			_buckets[i]->value = _valueFunctions.retain(new);
			_valueFunctions.release(old);

		}
	}
}
#endif

- (of_map_table_functions_t)keyFunctions
{







<


|






|

|
<





|
>
|
|
>







595
596
597
598
599
600
601

602
603
604
605
606
607
608
609
610
611
612
613

614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
			block(_buckets[i]->key, _buckets[i]->value, &stop);
	}
}

- (void)replaceValuesUsingBlock: (of_map_table_replace_block_t)block
{
	size_t i;

	unsigned long mutations = _mutations;

	for (i = 0; i < _capacity; i++) {
		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		if (_buckets[i] != NULL && _buckets[i] != &deleted) {
			void *new;

			new = block(_buckets[i]->key, _buckets[i]->value);

			if (new == NULL)
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]
					      selector: _cmd];

			if (new != _buckets[i]->value) {
				_valueFunctions.release(_buckets[i]->value);
				_buckets[i]->value =
				    _valueFunctions.retain(new);
			}
		}
	}
}
#endif

- (of_map_table_functions_t)keyFunctions
{

Modified src/OFMutableArray.h from [48e9f64998] to [6fa55f9480].

11
12
13
14
15
16
17
18


19







20
21
22
23
24
25
26
27
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFArray.h"



#ifdef OF_HAVE_BLOCKS







typedef id (^of_array_replace_block_t)(id obj, size_t idx, bool *stop);
#endif

/*!
 * @brief An abstract class for storing, adding and removing objects in an
 *	  array.
 */
@interface OFMutableArray: OFArray








>
>

>
>
>
>
>
>
>
|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFArray.h"

/*! @file */

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block for replacing values in an OFMutableArray.
 *
 * @param object The object to replace
 * @param index The index of the object to replace
 * @return The object to replace the object with
 */
typedef id (^of_array_replace_block_t)(id object, size_t index);
#endif

/*!
 * @brief An abstract class for storing, adding and removing objects in an
 *	  array.
 */
@interface OFMutableArray: OFArray

Modified src/OFMutableArray.m from [53f13e2987] to [f511e7126a].

372
373
374
375
376
377
378



379
380
381
382
383
384
385
386
387
}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
	    bool *stop) {



		[self replaceObjectAtIndex: index
				withObject: block(object, index, stop)];
	}];
}
#endif

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
{







>
>
>
|
|







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
	    bool *stop) {
		id new = block(object, index);

		if (new != object)
			[self replaceObjectAtIndex: index
					withObject: new];
	}];
}
#endif

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
{

Modified src/OFMutableArray_adjacent.m from [1c467efbfe] to [4bdaba029a].

348
349
350
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

376
377
378
379
380
381
382
383
384
	}
}

- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	id *objects = [_array items];
	size_t i, count = [_array count];
	bool stop = false;
	unsigned long mutations = _mutations;

	for (i = 0; i < count && !stop; i++) {
		id newObject;

		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		newObject = block(objects[i], i, &stop);

		if (newObject == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		[newObject retain];
		[objects[i] release];
		objects[i] = newObject;

	}
}
#endif

- (void)makeImmutable
{
	object_setClass(self, [OFArray_adjacent class]);
}
@end







<


|
|






|

|




|
|
|
>









348
349
350
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
376
377
378
379
380
381
382
383
384
	}
}

- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	id *objects = [_array items];
	size_t i, count = [_array count];

	unsigned long mutations = _mutations;

	for (i = 0; i < count; i++) {
		id new;

		if (_mutations != mutations)
			@throw [OFEnumerationMutationException
			    exceptionWithClass: [self class]
					object: self];

		new = block(objects[i], i);

		if (new == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		if (new != objects[i]) {
			[objects[i] release];
			objects[i] = [new retain];
		}
	}
}
#endif

- (void)makeImmutable
{
	object_setClass(self, [OFArray_adjacent class]);
}
@end

Modified src/OFMutableDictionary.h from [87d84a54c5] to [478ab9b477].

11
12
13
14
15
16
17
18


19







20
21
22
23
24
25
26
27
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFDictionary.h"



#ifdef OF_HAVE_BLOCKS







typedef id (^of_dictionary_replace_block_t)(id key, id object, bool *stop);
#endif

/*!
 * @brief An abstract class for storing and changing objects in a dictionary.
 */
@interface OFMutableDictionary: OFDictionary
/*!








>
>

>
>
>
>
>
>
>
|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFDictionary.h"

/*! @file */

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block for replacing objects in an OFMutableDictionary.
 *
 * @param key The key of the object to replace
 * @param object The object to replace
 * @return The object to replace the object with
 */
typedef id (^of_dictionary_replace_block_t)(id key, id object);
#endif

/*!
 * @brief An abstract class for storing and changing objects in a dictionary.
 */
@interface OFMutableDictionary: OFDictionary
/*!

Modified src/OFMutableDictionary.m from [e6fd44030a] to [c0b80ff39c].

196
197
198
199
200
201
202



203
204

205
206
207
208
209
210
211
212
}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    bool *stop) {



		[self setObject: block(key, object, stop)
			 forKey: key];

	}];
}
#endif

- (void)makeImmutable
{
}
@end







>
>
>
|
|
>








196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    bool *stop) {
		id new = block(key, object);

		if (new != object) {
			[self setObject: block(key, object)
				 forKey: key];
		}
	}];
}
#endif

- (void)makeImmutable
{
}
@end

Modified src/OFMutableDictionary_hashtable.m from [09bf9855b2] to [e4b0cd098c].

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
	@try {
		[_mapTable replaceValuesUsingBlock:
		    ^ void* (void *key, void *value, bool *stop) {
			return block(key, value, stop);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: self];
	}
}







|
|







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
}

#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
	@try {
		[_mapTable replaceValuesUsingBlock:
		    ^ void* (void *key, void *value) {
			return block(key, value);
		}];
	} @catch (OFEnumerationMutationException *e) {
		@throw [OFEnumerationMutationException
		    exceptionWithClass: [self class]
				object: self];
	}
}

Modified src/OFSet.h from [bbf8e3f8e2] to [a277fd200b].

22
23
24
25
26
27
28


29
30
31
32







33







34
35
36
37
38
39
40
#endif

#include <stdarg.h>

#import "OFObject.h"
#import "OFCollection.h"
#import "OFSerialization.h"



@class OFArray;

#ifdef OF_HAVE_BLOCKS







typedef void (^of_set_enumeration_block_t)(id object, bool *stop);







typedef bool (^of_set_filter_block_t)(id object);
#endif

/*!
 * @brief An abstract class for an unordered set of unique objects.
 *
 * @warning Do not mutate objects that are in a set! Changing the hash of







>
>




>
>
>
>
>
>
>

>
>
>
>
>
>
>







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#endif

#include <stdarg.h>

#import "OFObject.h"
#import "OFCollection.h"
#import "OFSerialization.h"

/*! @file */

@class OFArray;

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block for enumerating an OFSet.
 *
 * @param object The current object
 * @param stop A pointer to a variable that can be set to true to stop the
 *             enumeration
 */
typedef void (^of_set_enumeration_block_t)(id object, bool *stop);

/*!
 * @brief A block for filtering an OFSet.
 *
 * @param object The object to inspect
 * @return Whether the object should be in the filtered set
 */
typedef bool (^of_set_filter_block_t)(id object);
#endif

/*!
 * @brief An abstract class for an unordered set of unique objects.
 *
 * @warning Do not mutate objects that are in a set! Changing the hash of

Modified src/OFStream.h from [d1cbeea7d2] to [05795f4687].

21
22
23
24
25
26
27


28
29
30
31
32
33









34
35









36
37
38
39
40
41
42
43
44
# define __STDC_CONSTANT_MACROS
#endif

#include <stdarg.h>

#import "OFObject.h"
#import "OFString.h"



@class OFStream;
@class OFDataArray;
@class OFException;

#ifdef OF_HAVE_BLOCKS









typedef bool (^of_stream_async_read_block_t)(OFStream*, void*, size_t,
    OFException*);









typedef bool (^of_stream_async_read_line_block_t)(OFStream*, OFString*,
    OFException*);
#endif

/*!
 * @brief A base class for different types of streams.
 *
 * @warning Even though the OFCopying protocol is implemented, it does *not*
 *	    return an independent copy of the stream, but instead retains it.







>
>






>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
|
|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# define __STDC_CONSTANT_MACROS
#endif

#include <stdarg.h>

#import "OFObject.h"
#import "OFString.h"

/*! @file */

@class OFStream;
@class OFDataArray;
@class OFException;

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block which is called when data was read from the stream.
 *
 * @param stream The stream on which data was read
 * @param buffer A buffer with the data that has been read
 * @param length The length of the data that has been read
 * @param exception An exception which occurred while reading or nil on success
 * @return A bool whether the same block should be used for the next read
 */
typedef bool (^of_stream_async_read_block_t)(OFStream *stream, void *buffer,
    size_t length, OFException *exception);

/*!
 * @brief A block which is called when a line was read from the stream.
 *
 * @param stream The stream on which a line was read
 * @param line The line which has been read
 * @param exception An exception which occurred while reading or nil on success
 * @return A bool whether the same block should be used for the next read
 */
typedef bool (^of_stream_async_read_line_block_t)(OFStream *stream,
    OFString *line, OFException *exception);
#endif

/*!
 * @brief A base class for different types of streams.
 *
 * @warning Even though the OFCopying protocol is implemented, it does *not*
 *	    return an independent copy of the stream, but instead retains it.

Modified src/OFString+XMLUnescaping.h from [f82a708982] to [42752e55c6].

11
12
13
14
15
16
17


18
19
20
21
22
23
24
25
26
27








28
29
30
31
32
33
34
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFString.h"



#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_XMLUnescaping_reference;
#ifdef __cplusplus
}
#endif

#ifdef OF_HAVE_BLOCKS








typedef OFString* (^of_string_xml_unescaping_block_t)(OFString *string,
    OFString *entity);
#endif

/*!
 * @brief A protocol that needs to be implemented by delegates for
 *	  stringByXMLUnescapingWithHandler:.







>
>










>
>
>
>
>
>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFString.h"

/*! @file */

#ifdef __cplusplus
extern "C" {
#endif
extern int _OFString_XMLUnescaping_reference;
#ifdef __cplusplus
}
#endif

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block which is called to replace unknown XML entities in an XML
 *	  string.
 *
 * @param string The XML string which contains an unknown entity
 * @param entity The XML entity which is unknown
 * @return A replacement string for the unknown entity
 */
typedef OFString* (^of_string_xml_unescaping_block_t)(OFString *string,
    OFString *entity);
#endif

/*!
 * @brief A protocol that needs to be implemented by delegates for
 *	  stringByXMLUnescapingWithHandler:.

Modified src/OFString.h from [855049f2d1] to [7dbf74822f].

24
25
26
27
28
29
30


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdarg.h>
#include <inttypes.h>

#import "OFObject.h"
#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFBinaryPackRepresentation.h"



@class OFConstantString;

#if defined(__cplusplus) && __cplusplus >= 201103L
typedef char16_t of_char16_t;
typedef char32_t of_char32_t;
#else
typedef uint_least16_t of_char16_t;
typedef uint_least32_t of_char32_t;
#endif
typedef of_char32_t of_unichar_t;

/*! @file */

/*!
 * @brief The encoding of a string.
 */
typedef enum of_string_encoding_t {
	/*! UTF-8 */
	OF_STRING_ENCODING_UTF_8,
	/*! ASCII */







>
>












<
<







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44


45
46
47
48
49
50
51
#include <stdarg.h>
#include <inttypes.h>

#import "OFObject.h"
#import "OFSerialization.h"
#import "OFJSONRepresentation.h"
#import "OFBinaryPackRepresentation.h"

/*! @file */

@class OFConstantString;

#if defined(__cplusplus) && __cplusplus >= 201103L
typedef char16_t of_char16_t;
typedef char32_t of_char32_t;
#else
typedef uint_least16_t of_char16_t;
typedef uint_least32_t of_char32_t;
#endif
typedef of_char32_t of_unichar_t;



/*!
 * @brief The encoding of a string.
 */
typedef enum of_string_encoding_t {
	/*! UTF-8 */
	OF_STRING_ENCODING_UTF_8,
	/*! ASCII */
65
66
67
68
69
70
71







72
73
74
75
76
77
78
	OF_STRING_SKIP_EMPTY	   = 2
};

/* FIXME */
#define OF_STRING_ENCODING_NATIVE OF_STRING_ENCODING_UTF_8

#ifdef OF_HAVE_BLOCKS







typedef void (^of_string_line_enumeration_block_t)(OFString *line, bool *stop);
#endif

@class OFArray;
@class OFURL;

/*!







>
>
>
>
>
>
>







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
	OF_STRING_SKIP_EMPTY	   = 2
};

/* FIXME */
#define OF_STRING_ENCODING_NATIVE OF_STRING_ENCODING_UTF_8

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block for enumerating the lines of a string.
 *
 * @param line The current line
 * @param stop A pointer to a variable that can be set to true to stop the
 *	       enumeration
 */
typedef void (^of_string_line_enumeration_block_t)(OFString *line, bool *stop);
#endif

@class OFArray;
@class OFURL;

/*!

Modified src/OFTCPSocket.h from [b4d76328d1] to [efe8886d8a].

28
29
30
31
32
33
34


35
36
37
38
39







40












41
42
43
44
45
46
47
48
49
#endif

#import "OFStreamSocket.h"

#ifdef _WIN32
# include <ws2tcpip.h>
#endif



@class OFTCPSocket;
@class OFString;

#ifdef OF_HAVE_BLOCKS







typedef void (^of_tcpsocket_async_connect_block_t)(OFTCPSocket*, OFException*);












typedef bool (^of_tcpsocket_async_accept_block_t)(OFTCPSocket*, OFTCPSocket*,
    OFException*);
#endif

/*!
 * @brief A class which provides functions to create and use TCP sockets.
 *
 * To connect to a server, create a socket and connect it.
 * To create a server, create a socket, bind it and listen on it.







>
>





>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#endif

#import "OFStreamSocket.h"

#ifdef _WIN32
# include <ws2tcpip.h>
#endif

/*! @file */

@class OFTCPSocket;
@class OFString;

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block which is called when the socket connected.
 *
 * @param socket The socket which connected
 * @param exception An exception which occurred while connecting the socket or
 *		    nil on success
 */
typedef void (^of_tcpsocket_async_connect_block_t)(OFTCPSocket *socket,
    OFException *exception);

/*!
 * @brief A block which is called when the socket accepted a connection.
 *
 * @param socket The socket which accepted the connection
 * @param acceptedSocket The socket which has been accepted
 * @param exception An exception which occurred while accepting the socket or
 *		    nil on success
 * @return A bool whether the same block should be used for the next incoming
 *	   connection
 */
typedef bool (^of_tcpsocket_async_accept_block_t)(OFTCPSocket *socket,
    OFTCPSocket *acceptedSocket, OFException *exception);
#endif

/*!
 * @brief A class which provides functions to create and use TCP sockets.
 *
 * To connect to a server, create a socket and connect it.
 * To create a server, create a socket, bind it and listen on it.

Modified src/OFThread.h from [abb9dc92a6] to [b48c7d5a0b].

19
20
21
22
23
24
25


26
27
28
29
30
31





32
33
34
35
36
37
38

#import "threading.h"

/* Haiku used to define this for some unknown reason which causes trouble */
#ifdef protected
# undef protected
#endif



@class OFDate;
@class OFSortedList;
@class OFRunLoop;

#ifdef OF_HAVE_BLOCKS





typedef id (^of_thread_block_t)(void);
#endif

/*!
 * @brief A class which provides portable threads.
 *
 * To use it, you should create a new class derived from it and reimplement







>
>






>
>
>
>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

#import "threading.h"

/* Haiku used to define this for some unknown reason which causes trouble */
#ifdef protected
# undef protected
#endif

/*! @file */

@class OFDate;
@class OFSortedList;
@class OFRunLoop;

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block to be executed in a new thread.
 *
 * @return The object which should be returned when the thread is joined
 */
typedef id (^of_thread_block_t)(void);
#endif

/*!
 * @brief A class which provides portable threads.
 *
 * To use it, you should create a new class derived from it and reimplement

Modified src/OFThreadPool.h from [0db8d807f8] to [0f1bb8fc11].

11
12
13
14
15
16
17
18


19



20
21
22
23
24
25
26
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"



#ifdef OF_HAVE_BLOCKS



typedef void (^of_thread_pool_block_t)(void);
#endif

@class OFMutableArray;
@class OFList;
@class OFCondition;
@class OFThreadPoolJob;








>
>

>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"

/*! @file */

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block for a job which should be executed in a thread pool.
 */
typedef void (^of_thread_pool_block_t)(void);
#endif

@class OFMutableArray;
@class OFList;
@class OFCondition;
@class OFThreadPoolJob;

Modified src/OFTimer.h from [eafb8bd36e] to [ca397382d3].

11
12
13
14
15
16
17


18
19
20
21
22
23
24
25
26





27
28
29
30
31
32
33
34
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"



@class OFTimer;
@class OFDate;
@class OFRunLoop;
#ifdef OF_HAVE_THREADS
@class OFCondition;
#endif

#ifdef OF_HAVE_BLOCKS





typedef void (^of_timer_block_t)(OFTimer*);
#endif

/*!
 * @brief A class for creating and firing timers.
 */
@interface OFTimer: OFObject <OFComparing>
{







>
>









>
>
>
>
>
|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"

/*! @file */

@class OFTimer;
@class OFDate;
@class OFRunLoop;
#ifdef OF_HAVE_THREADS
@class OFCondition;
#endif

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block to execute when a timer fires.
 *
 * @param timer The timer which fired
 */
typedef void (^of_timer_block_t)(OFTimer *timer);
#endif

/*!
 * @brief A class for creating and firing timers.
 */
@interface OFTimer: OFObject <OFComparing>
{

Modified src/exceptions/OFException.h from [8f2a6df5f9] to [20ad317438].

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 *
 * @param class_ The class of the object which caused the exception
 * @return An initialized OFException
 */
- initWithClass: (Class)class_;

/*!
 * @brief Returns the class of the object in which the exception happened.
 *
 * @return The class of the object in which the exception happened
 */
- (Class)inClass;

/*!
 * @brief Returns a description of the exception.
 *
 * @return A description of the exception
 */
- (OFString*)description;
@end







|

|










46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 *
 * @param class_ The class of the object which caused the exception
 * @return An initialized OFException
 */
- initWithClass: (Class)class_;

/*!
 * @brief Returns the class of the object in which the exception occurred.
 *
 * @return The class of the object in which the exception occurred
 */
- (Class)inClass;

/*!
 * @brief Returns a description of the exception.
 *
 * @return A description of the exception
 */
- (OFString*)description;
@end

Modified tests/OFArrayTests.m from [4c7095914c] to [4b9f82311d].

275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)
	}

	TEST(@"-[replaceObjectsUsingBlock:]",
	    R([m[0] replaceObjectsUsingBlock:
	    ^ id (id obj, size_t idx, bool *stop) {
		switch (idx) {
		case 0:
			return @"foo";
		case 1:
			return @"bar";
		}








|
<







275
276
277
278
279
280
281
282

283
284
285
286
287
288
289
		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)
	}

	TEST(@"-[replaceObjectsUsingBlock:]",
	    R([m[0] replaceObjectsUsingBlock: ^ id (id obj, size_t idx) {

		switch (idx) {
		case 0:
			return @"foo";
		case 1:
			return @"bar";
		}

Modified tests/OFDictionaryTests.m from [e04f963308] to [d16af2dca7].

159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)

		[dict removeObjectForKey: @""];
	}

	TEST(@"-[replaceObjectsUsingBlock:]",
	    R([dict replaceObjectsUsingBlock:
	    ^ id (id key, id obj, bool *stop) {
		if ([key isEqual: keys[0]])
			return @"value_1";
		if ([key isEqual: keys[1]])
			return @"value_2";

		return nil;
	    }]) && [[dict objectForKey: keys[0]] isEqual: @"value_1"] &&







|
<







159
160
161
162
163
164
165
166

167
168
169
170
171
172
173
		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)

		[dict removeObjectForKey: @""];
	}

	TEST(@"-[replaceObjectsUsingBlock:]",
	    R([dict replaceObjectsUsingBlock: ^ id (id key, id obj) {

		if ([key isEqual: keys[0]])
			return @"value_1";
		if ([key isEqual: keys[1]])
			return @"value_2";

		return nil;
	    }]) && [[dict objectForKey: keys[0]] isEqual: @"value_1"] &&