Overview
Comment: | Remove redundant arguments from blocks
Arguments that can just be captured by the block don't need to be |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d7ddb3dbc70606ce23d81a1b97c7c5c5 |
User & Date: | js on 2020-04-26 19:39:06 |
Other Links: | manifest | tags |
Context
2020-04-29
| ||
23:59 | Add OFSPXSocket check-in: 857f8edc09 user: js tags: trunk | |
2020-04-26
| ||
19:39 | Remove redundant arguments from blocks check-in: d7ddb3dbc7 user: js tags: trunk | |
18:10 | Move accept and listen OF{TCP -> Stream}Socket check-in: 13a8f43898 user: js tags: trunk | |
Changes
Modified src/OFDatagramSocket.h from [ed9d7f131c] to [a18e14bea6].
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 |
@class OFData; @class OFDatagramSocket; #ifdef OF_HAVE_BLOCKS /*! * @brief A block which is called when a packet has been received. * * @param socket The datagram socket which received a packet * @param buffer The buffer the packet has been written to * @param length The length of the packet * @param sender The address of the sender of the packet * @param exception An exception which occurred while receiving or `nil` on * success * @return A bool whether the same block should be used for the next receive */ typedef bool (^of_datagram_socket_async_receive_block_t)( OFDatagramSocket *_Nonnull socket, void *_Nonnull buffer, size_t length, const of_socket_address_t *_Nonnull sender, id _Nullable exception); /*! * @brief A block which is called when a packet has been sent. * * @param socket The datagram socket which sent a packet * @param data The data which was sent * @param receiver The receiver for the packet * @param exception An exception which occurred while reading or `nil` on * success * @return The data to repeat the send with or nil if it should not repeat */ typedef OFData *_Nullable (^of_datagram_socket_async_send_data_block_t)( OFDatagramSocket *_Nonnull socket, OFData *_Nonnull data, const of_socket_address_t *_Nonnull receiver, id _Nullable exception); #endif /*! * @protocol OFDatagramSocketDelegate OFDatagramSocket.h \ * ObjFW/OFDatagramSocket.h * * @brief A delegate for OFDatagramSocket. |
< < | | < | | |
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 |
@class OFData; @class OFDatagramSocket; #ifdef OF_HAVE_BLOCKS /*! * @brief A block which is called when a packet has been received. * * @param length The length of the packet * @param sender The address of the sender of the packet * @param exception An exception which occurred while receiving or `nil` on * success * @return A bool whether the same block should be used for the next receive */ typedef bool (^of_datagram_socket_async_receive_block_t)( size_t length, const of_socket_address_t *_Nonnull sender, id _Nullable exception); /*! * @brief A block which is called when a packet has been sent. * * @param data The data which was sent * @param receiver The receiver for the packet * @param exception An exception which occurred while reading or `nil` on * success * @return The data to repeat the send with or nil if it should not repeat */ typedef OFData *_Nullable (^of_datagram_socket_async_send_data_block_t)( OFData *_Nonnull data, const of_socket_address_t *_Nonnull receiver, id _Nullable exception); #endif /*! * @protocol OFDatagramSocketDelegate OFDatagramSocket.h \ * ObjFW/OFDatagramSocket.h * * @brief A delegate for OFDatagramSocket. |
Modified src/OFRunLoop.m from [ae15c876fb] to [964085efa2].
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 ... 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 ... 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 ... 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 ... 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 ... 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 ... 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 ... 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 ... 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 ... 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 |
} @catch (id e) { length = 0; exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, exception); else { # endif if (![_delegate respondsToSelector: @selector(stream:didReadIntoBuffer:length:exception:)]) return false; return [_delegate stream: object ................................................................................ if (_readLength != _exactLength && ![object isAtEndOfStream] && exception == nil) return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) { if (!_block(object, _buffer, _readLength, exception)) return false; _readLength = 0; return true; } else { # endif if (![_delegate respondsToSelector: ................................................................................ } if (line == nil && ![object isAtEndOfStream] && exception == nil) return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, line, exception); else { # endif if (![_delegate respondsToSelector: @selector(stream:didReadLine:exception:)]) return false; return [_delegate stream: object ................................................................................ _writtenLength += length; if (_writtenLength != dataLength && exception == nil) return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) { newData = _block(object, _data, _writtenLength, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; [oldData release]; ................................................................................ _writtenLength += length; if (_writtenLength != cStringLength && exception == nil) return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) { newString = _block(object, _string, _encoding, _writtenLength, exception); if (newString == nil) return false; oldString = _string; _string = [newString copy]; [oldString release]; ................................................................................ exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) { if ([object isKindOfClass: [OFStreamSocket class]]) return ((of_stream_socket_async_accept_block_t) _block)(object, acceptedSocket, exception); else if ([object isKindOfClass: [OFSequencedPacketSocket class]]) return ((of_sequenced_packet_socket_async_accept_block_t) _block)(object, acceptedSocket, exception); else OF_ENSURE(0); } else { # endif if (![_delegate respondsToSelector: @selector(socket:didAcceptSocket:exception:)]) return false; ................................................................................ } @catch (id e) { length = 0; exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, &address, exception); else { # endif if (![_delegate respondsToSelector: @selector( socket:didReceiveIntoBuffer:length:sender:exception:)]) return false; return [_delegate socket: object ................................................................................ receiver: &_receiver]; } @catch (id e) { exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) { newData = _block(object, _data, &_receiver, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; [oldData release]; ................................................................................ } @catch (id e) { length = 0; exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, exception); else { # endif if (![_delegate respondsToSelector: @selector( socket:didReceiveIntoBuffer:length:exception:)]) return false; return [_delegate socket: object ................................................................................ length: _data.count * _data.itemSize]; } @catch (id e) { exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) { newData = _block(object, _data, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; [oldData release]; |
| | | | | < | | | | | | |
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 ... 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 ... 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 ... 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 ... 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 ... 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 ... 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 ... 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 ... 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 ... 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 |
} @catch (id e) { length = 0; exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(length, exception); else { # endif if (![_delegate respondsToSelector: @selector(stream:didReadIntoBuffer:length:exception:)]) return false; return [_delegate stream: object ................................................................................ if (_readLength != _exactLength && ![object isAtEndOfStream] && exception == nil) return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) { if (!_block(_readLength, exception)) return false; _readLength = 0; return true; } else { # endif if (![_delegate respondsToSelector: ................................................................................ } if (line == nil && ![object isAtEndOfStream] && exception == nil) return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(line, exception); else { # endif if (![_delegate respondsToSelector: @selector(stream:didReadLine:exception:)]) return false; return [_delegate stream: object ................................................................................ _writtenLength += length; if (_writtenLength != dataLength && exception == nil) return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) { newData = _block(_data, _writtenLength, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; [oldData release]; ................................................................................ _writtenLength += length; if (_writtenLength != cStringLength && exception == nil) return true; # ifdef OF_HAVE_BLOCKS if (_block != NULL) { newString = _block(_string, _writtenLength, exception); if (newString == nil) return false; oldString = _string; _string = [newString copy]; [oldString release]; ................................................................................ exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) { if ([object isKindOfClass: [OFStreamSocket class]]) return ((of_stream_socket_async_accept_block_t) _block)(acceptedSocket, exception); else if ([object isKindOfClass: [OFSequencedPacketSocket class]]) return ((of_sequenced_packet_socket_async_accept_block_t) _block)(acceptedSocket, exception); else OF_ENSURE(0); } else { # endif if (![_delegate respondsToSelector: @selector(socket:didAcceptSocket:exception:)]) return false; ................................................................................ } @catch (id e) { length = 0; exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(length, &address, exception); else { # endif if (![_delegate respondsToSelector: @selector( socket:didReceiveIntoBuffer:length:sender:exception:)]) return false; return [_delegate socket: object ................................................................................ receiver: &_receiver]; } @catch (id e) { exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) { newData = _block(_data, &_receiver, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; [oldData release]; ................................................................................ } @catch (id e) { length = 0; exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(length, exception); else { # endif if (![_delegate respondsToSelector: @selector( socket:didReceiveIntoBuffer:length:exception:)]) return false; return [_delegate socket: object ................................................................................ length: _data.count * _data.itemSize]; } @catch (id e) { exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) { newData = _block(_data, exception); if (newData == nil) return false; oldData = _data; _data = [newData copy]; [oldData release]; |
Modified src/OFSequencedPacketSocket.h from [c46ceeaf1d] to [a59d130a79].
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 |
@class OFData; @class OFSequencedPacketSocket; #ifdef OF_HAVE_BLOCKS /*! * @brief A block which is called when a packet has been received. * * @param socket The sequenced packet socket which received a packet * @param buffer The buffer the packet has been written to * @param length The length of the packet * @param exception An exception which occurred while receiving or `nil` on * success * @return A bool whether the same block should be used for the next receive */ typedef bool (^of_sequenced_packet_socket_async_receive_block_t)( OFSequencedPacketSocket *_Nonnull socket, void *_Nonnull buffer, size_t length, id _Nullable exception); /*! * @brief A block which is called when a packet has been sent. * * @param socket The sequenced packet socket which sent a packet * @param data The data which was sent * @param exception An exception which occurred while reading or `nil` on * success * @return The data to repeat the send with or nil if it should not repeat */ typedef OFData *_Nullable (^of_sequenced_packet_socket_async_send_data_block_t)( OFSequencedPacketSocket *_Nonnull socket, OFData *_Nonnull data, id _Nullable 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_sequenced_packet_socket_async_accept_block_t)( OFSequencedPacketSocket *socket, OFSequencedPacketSocket *acceptedSocket, id _Nullable exception); #endif /*! * @protocol OFSequencedPacketSocketDelegate OFSequencedPacketSocket.h \ * ObjFW/OFSequencedPacketSocket.h * * @brief A delegate for OFSequencedPacketSocket. |
< < | < | < < | < | < |
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 |
@class OFData; @class OFSequencedPacketSocket; #ifdef OF_HAVE_BLOCKS /*! * @brief A block which is called when a packet has been received. * * @param length The length of the packet * @param exception An exception which occurred while receiving or `nil` on * success * @return A bool whether the same block should be used for the next receive */ typedef bool (^of_sequenced_packet_socket_async_receive_block_t)(size_t length, id _Nullable exception); /*! * @brief A block which is called when a packet has been sent. * * @param data The data which was sent * @param exception An exception which occurred while reading or `nil` on * success * @return The data to repeat the send with or nil if it should not repeat */ typedef OFData *_Nullable (^of_sequenced_packet_socket_async_send_data_block_t)( OFData *_Nonnull data, id _Nullable exception); /*! * @brief A block which is called when the socket accepted a 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_sequenced_packet_socket_async_accept_block_t)( OFSequencedPacketSocket *acceptedSocket, id _Nullable exception); #endif /*! * @protocol OFSequencedPacketSocketDelegate OFSequencedPacketSocket.h \ * ObjFW/OFSequencedPacketSocket.h * * @brief A delegate for OFSequencedPacketSocket. |
Modified src/OFStream.h from [190450d179] to [854f995c5b].
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
@class OFData; #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_BLOCKS) /*! * @brief A block which is called when data was read asynchronously from a * 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 *_Nonnull stream, void *_Nonnull buffer, size_t length, id _Nullable exception); /*! * @brief A block which is called when a line was read asynchronously from a * stream. * * @param stream The stream on which a line was read * @param line The line which has been read or `nil` when the end of stream * occurred * @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 *_Nonnull stream, OFString *_Nullable line, id _Nullable exception); /*! * @brief A block which is called when data was written asynchronously to a * stream. * * @param data The data which was written to the stream * @param bytesWritten The number of bytes which have been written. This ................................................................................ * matches the length of the specified data on the * asynchronous write if no exception was encountered. * @param exception An exception which occurred while writing or `nil` on * success * @return The data to repeat the write with or nil if it should not repeat */ typedef OFData *_Nullable (^of_stream_async_write_data_block_t)( OFStream *_Nonnull stream, OFData *_Nonnull data, size_t bytesWritten, id _Nullable exception); /*! * @brief A block which is called when a string was written asynchronously to a * stream. * * @param string The string which was written to the stream * @param bytesWritten The number of bytes which have been written. This * matches the length of the specified data on the * asynchronous write if no exception was encountered. * @param encoding The encoding in which the string was written * @param exception An exception which occurred while writing or `nil` on * success * @return The string to repeat the write with or nil if it should not repeat */ typedef OFString *_Nullable (^of_stream_async_write_string_block_t)( OFStream *_Nonnull stream, OFString *_Nonnull string, of_string_encoding_t encoding, size_t bytesWritten, id _Nullable exception); #endif /*! * @protocol OFStreamDelegate OFStream.h ObjFW/OFStream.h * * A delegate for OFStream. */ |
<
<
|
|
<
|
|
<
|
<
<
|
|
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
@class OFData; #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_BLOCKS) /*! * @brief A block which is called when data was read asynchronously from a * stream. * * @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)(size_t length, id _Nullable exception); /*! * @brief A block which is called when a line was read asynchronously from a * stream. * * @param line The line which has been read or `nil` when the end of stream * occurred * @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)(OFString *_Nullable line, id _Nullable exception); /*! * @brief A block which is called when data was written asynchronously to a * stream. * * @param data The data which was written to the stream * @param bytesWritten The number of bytes which have been written. This ................................................................................ * matches the length of the specified data on the * asynchronous write if no exception was encountered. * @param exception An exception which occurred while writing or `nil` on * success * @return The data to repeat the write with or nil if it should not repeat */ typedef OFData *_Nullable (^of_stream_async_write_data_block_t)( OFData *_Nonnull data, size_t bytesWritten, id _Nullable exception); /*! * @brief A block which is called when a string was written asynchronously to a * stream. * * @param string The string which was written to the stream * @param bytesWritten The number of bytes which have been written. This * matches the length of the specified data on the * asynchronous write if no exception was encountered. * @param exception An exception which occurred while writing or `nil` on * success * @return The string to repeat the write with or nil if it should not repeat */ typedef OFString *_Nullable (^of_stream_async_write_string_block_t)( OFString *_Nonnull string, size_t bytesWritten, id _Nullable exception); #endif /*! * @protocol OFStreamDelegate OFStream.h ObjFW/OFStream.h * * A delegate for OFStream. */ |
Modified src/OFStreamSocket.h from [40b6afda8c] to [ded40b41a4].
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
@class OFStreamSocket; #ifdef OF_HAVE_BLOCKS /*! * @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_stream_socket_async_accept_block_t)(OFStreamSocket *socket, OFStreamSocket *acceptedSocket, id _Nullable exception); #endif /*! * @protocol OFStreamSocketDelegate OFStreamSocket.h ObjFW/OFStreamSocket.h * * A delegate for OFStreamSocket. |
< | |
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
@class OFStreamSocket; #ifdef OF_HAVE_BLOCKS /*! * @brief A block which is called when the socket accepted a 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_stream_socket_async_accept_block_t)( OFStreamSocket *acceptedSocket, id _Nullable exception); #endif /*! * @protocol OFStreamSocketDelegate OFStreamSocket.h ObjFW/OFStreamSocket.h * * A delegate for OFStreamSocket. |
Modified src/OFTCPSocket.h from [085c9c8662] to [8293d08642].
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
@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_tcp_socket_async_connect_block_t)(OFTCPSocket *socket, id _Nullable exception); #endif /*! * @protocol OFTCPSocketDelegate OFTCPSocket.h ObjFW/OFTCPSocket.h * * A delegate for OFTCPSocket. */ |
< | < |
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
@class OFTCPSocket;
@class OFString;
#ifdef OF_HAVE_BLOCKS
/*!
* @brief A block which is called when the socket connected.
*
* @param exception An exception which occurred while connecting the socket or
* `nil` on success
*/
typedef void (^of_tcp_socket_async_connect_block_t)(id _Nullable exception);
#endif
/*!
* @protocol OFTCPSocketDelegate OFTCPSocket.h ObjFW/OFTCPSocket.h
*
* A delegate for OFTCPSocket.
*/
|
Modified src/OFTCPSocket.m from [bb1a762052] to [36820b9499].
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
- (void)didConnect
{
if (_exception == nil)
_socket.blocking = true;
#ifdef OF_HAVE_BLOCKS
if (_block != NULL)
_block(_socket, _exception);
else {
#endif
_socket.delegate = _delegate;
if ([_delegate respondsToSelector:
@selector(socket:didConnectToHost:port:exception:)])
[_delegate socket: _socket
|
| |
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
- (void)didConnect { if (_exception == nil) _socket.blocking = true; #ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(_exception); else { #endif _socket.delegate = _delegate; if ([_delegate respondsToSelector: @selector(socket:didConnectToHost:port:exception:)]) [_delegate socket: _socket |