@@ -321,26 +321,18 @@ # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, exception); else { # endif - if (exception == nil) { - if (![_delegate respondsToSelector: - @selector(stream:didReadIntoBuffer:length:)]) - return false; - - return [_delegate stream: object - didReadIntoBuffer: _buffer - length: length]; - } else { - if ([_delegate respondsToSelector: - @selector(stream:didFailToReadWithException:)]) - [_delegate stream: object - didFailToReadWithException: exception]; - - return false; - } + if (![_delegate respondsToSelector: + @selector(stream:didReadIntoBuffer:length:exception:)]) + return false; + + return [_delegate stream: object + didReadIntoBuffer: _buffer + length: length + exception: exception]; # ifdef OF_HAVE_BLOCKS } # endif } @@ -381,30 +373,22 @@ _readLength = 0; return true; } else { # endif - if (exception == nil) { - if (![_delegate respondsToSelector: - @selector(stream:didReadIntoBuffer:length:)]) - return false; - - if (![_delegate stream: object - didReadIntoBuffer: _buffer - length: _readLength]) - return false; - - _readLength = 0; - return true; - } else { - if ([_delegate respondsToSelector: - @selector(stream:didFailToReadWithException:)]) - [_delegate stream: object - didFailToReadWithException: exception]; - - return false; - } + if (![_delegate respondsToSelector: + @selector(stream:didReadIntoBuffer:length:exception:)]) + return false; + + if (![_delegate stream: object + didReadIntoBuffer: _buffer + length: _readLength + exception: exception]) + return false; + + _readLength = 0; + return true; # ifdef OF_HAVE_BLOCKS } # endif } @@ -437,25 +421,17 @@ # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, line, exception); else { # endif - if (exception == nil) { - if (![_delegate respondsToSelector: - @selector(stream:didReadLine:)]) - return false; - - return [_delegate stream: object - didReadLine: line]; - } else { - if ([_delegate respondsToSelector: - @selector(stream:didFailToReadWithException:)]) - [_delegate stream: object - didFailToReadWithException: exception]; - - return false; - } + if (![_delegate respondsToSelector: + @selector(stream:didReadLine:exception:)]) + return false; + + return [_delegate stream: object + didReadLine: line + exception: exception]; # ifdef OF_HAVE_BLOCKS } # endif } @@ -497,32 +473,24 @@ _writtenLength = 0; return true; } else { # endif - if (exception == nil) { - if (![_delegate respondsToSelector: - @selector(stream:didWriteBuffer:length:)]) - return false; - - _length = [_delegate stream: object - didWriteBuffer: &_buffer - length: _length]; - - if (_length == 0) - return false; - - _writtenLength = 0; - return true; - } else { - if ([_delegate respondsToSelector: - @selector(stream:didFailToWriteWithException:)]) - [_delegate stream: object - didFailToWriteWithException: exception]; - - return false; - } + if (![_delegate respondsToSelector: + @selector(stream:didWriteBuffer:length:exception:)]) + return false; + + _length = [_delegate stream: object + didWriteBuffer: &_buffer + length: _length + exception: exception]; + + if (_length == 0) + return false; + + _writtenLength = 0; + return true; # ifdef OF_HAVE_BLOCKS } # endif } @@ -574,25 +542,17 @@ # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, acceptedSocket, exception); else { # endif - if (exception == nil) { - if (![_delegate respondsToSelector: - @selector(socket:didAcceptSocket:)]) - return false; - - return [_delegate socket: object - didAcceptSocket: acceptedSocket]; - } else { - if ([_delegate respondsToSelector: - @selector(socket:didFailToAcceptWithException:)]) - [_delegate socket: object - didFailToAcceptWithException: exception]; - - return false; - } + if (![_delegate respondsToSelector: + @selector(socket:didAcceptSocket:exception:)]) + return false; + + return [_delegate socket: object + didAcceptSocket: acceptedSocket + exception: exception]; # ifdef OF_HAVE_BLOCKS } # endif } @@ -625,27 +585,19 @@ # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, address, exception); else { # endif - if (exception == nil) { - if (![_delegate respondsToSelector: @selector(socket: - didReceiveIntoBuffer:length:sender:)]) - return false; - - return [_delegate socket: object - didReceiveIntoBuffer: _buffer - length: length - sender: address]; - } else { - if ([_delegate respondsToSelector: - @selector(socket:didFailToReceiveWithException:)]) - [_delegate socket: object - didFailToReceiveWithException: exception]; - - return false; - } + if (![_delegate respondsToSelector: @selector( + socket:didReceiveIntoBuffer:length:sender:exception:)]) + return false; + + return [_delegate socket: object + didReceiveIntoBuffer: _buffer + length: length + sender: address + exception: exception]; # ifdef OF_HAVE_BLOCKS } # endif } @@ -678,29 +630,21 @@ (exception == nil ? _length : 0), &_receiver, exception); return (_length > 0); } else { # endif - if (exception == nil) { - if (![_delegate respondsToSelector: - @selector(socket:didSendBuffer:length:receiver:)]) - return false; - - _length = [_delegate socket: object - didSendBuffer: &_buffer - length: _length - receiver: &_receiver]; - - return (_length > 0); - } else { - if ([_delegate respondsToSelector: - @selector(socket:didFailToSendWithException:)]) - [_delegate socket: object - didFailToSendWithException: exception]; - - return false; - } + if (![_delegate respondsToSelector: + @selector(socket:didSendBuffer:length:receiver:exception:)]) + return false; + + _length = [_delegate socket: object + didSendBuffer: &_buffer + length: (exception == nil ? _length : 0) + receiver: &_receiver + exception: exception]; + + return (_length > 0); # ifdef OF_HAVE_BLOCKS } # endif }