Index: src/OFHTTPClient.h ================================================================== --- src/OFHTTPClient.h +++ src/OFHTTPClient.h @@ -21,11 +21,10 @@ #endif OF_ASSUME_NONNULL_BEGIN @class OFDictionary OF_GENERIC(KeyType, ObjectType); -@class OFException; @class OFHTTPClient; @class OFHTTPRequest; @class OFHTTPResponse; @class OFTCPSocket; @class OFURL; Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -564,11 +564,11 @@ context: nil]; } - (void)socketDidConnect: (OFTCPSocket *)socket context: (id)context - exception: (OFException *)exception + exception: (id)exception { if ([_client->_delegate respondsToSelector: @selector(client:didCreateSocket:forRequest:)]) [_client->_delegate client: _client didCreateSocket: socket Index: src/OFHTTPServer.h ================================================================== --- src/OFHTTPServer.h +++ src/OFHTTPServer.h @@ -24,11 +24,10 @@ @class OFHTTPServer; @class OFHTTPRequest; @class OFHTTPResponse; @class OFTCPSocket; -@class OFException; /*! * @protocol OFHTTPServerDelegate OFHTTPServer.h ObjFW/OFHTTPServer.h * * @brief A delegate for OFHTTPServer. @@ -57,11 +56,11 @@ * @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; + didReceiveExceptionOnListeningSocket: (id)exception; /*! * @brief This method is called when a client socket encountered an exception. * * This can happen when the OFHTTPServer tries to properly close the @@ -76,11 +75,11 @@ * @param exception The exception which occurred */ - (void)server: (OFHTTPServer *)server didReceiveExceptionForResponse: (OFHTTPResponse *)response request: (OFHTTPRequest *)request - exception: (OFException *)exception; + exception: (id)exception; @end /*! * @class OFHTTPServer OFHTTPServer.h ObjFW/OFHTTPServer.h * Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -48,11 +48,11 @@ @interface OFHTTPServer () - (bool)of_socket: (OFTCPSocket *)socket didAcceptSocket: (OFTCPSocket *)clientSocket context: (id)context - exception: (OFException *)exception; + exception: (id)exception; @end static const char * statusCodeToString(short code) { @@ -342,18 +342,18 @@ - initWithSocket: (OFTCPSocket *)socket server: (OFHTTPServer *)server; - (bool)socket: (OFTCPSocket *)socket didReadLine: (OFString *)line context: (id)context - exception: (OFException *)exception; + exception: (id)exception; - (bool)parseProlog: (OFString *)line; - (bool)parseHeaders: (OFString *)line; - (bool)socket: (OFTCPSocket *)socket didReadIntoBuffer: (char *)buffer length: (size_t)length context: (id)context - exception: (OFException *)exception; + exception: (id)exception; - (bool)sendErrorAndClose: (short)statusCode; - (void)createResponse; @end @implementation OFHTTPServer_Connection @@ -397,11 +397,11 @@ } - (bool)socket: (OFTCPSocket *)socket didReadLine: (OFString *)line context: (id)context - exception: (OFException *)exception + exception: (id)exception { if (line == nil || exception != nil) return false; @try { @@ -577,11 +577,11 @@ - (bool)socket: (OFTCPSocket *)socket didReadIntoBuffer: (char *)buffer length: (size_t)length context: (id)context - exception: (OFException *)exception + exception: (id)exception { if ([socket isAtEndOfStream] || exception != nil) return false; [_body addItems: buffer @@ -742,11 +742,11 @@ } - (bool)of_socket: (OFTCPSocket *)socket didAcceptSocket: (OFTCPSocket *)clientSocket context: (id)context - exception: (OFException *)exception + exception: (id)exception { OFHTTPServer_Connection *connection; if (exception != nil) { if ([_delegate respondsToSelector: Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -120,28 +120,27 @@ @implementation OFRunLoop_ReadQueueItem - (bool)handleForObject: (id)object { size_t length; - OFException *exception = nil; + id exception = nil; @try { length = [object readIntoBuffer: _buffer length: _length]; - } @catch (OFException *e) { + } @catch (id e) { length = 0; exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, _buffer, length, exception); else { # endif - bool (*func)(id, SEL, OFStream *, void *, size_t, id, - OFException *) = (bool (*)(id, SEL, OFStream *, void *, - size_t, id, OFException *)) + bool (*func)(id, SEL, OFStream *, void *, size_t, id, id) = + (bool (*)(id, SEL, OFStream *, void *, size_t, id, id)) [_target methodForSelector: _selector]; return func(_target, _selector, object, _buffer, length, _context, exception); # ifdef OF_HAVE_BLOCKS @@ -161,16 +160,16 @@ @implementation OFRunLoop_ExactReadQueueItem - (bool)handleForObject: (id)object { size_t length; - OFException *exception = nil; + id exception = nil; @try { length = [object readIntoBuffer: (char *)_buffer + _readLength length: _exactLength - _readLength]; - } @catch (OFException *e) { + } @catch (id e) { length = 0; exception = e; } _readLength += length; @@ -186,13 +185,12 @@ _readLength = 0; return true; } else { # endif - bool (*func)(id, SEL, OFStream *, void *, size_t, id, - OFException *) = (bool (*)(id, SEL, OFStream *, void *, - size_t, id, OFException *)) + bool (*func)(id, SEL, OFStream *, void *, size_t, id, id) = + (bool (*)(id, SEL, OFStream *, void *, size_t, id, id)) [_target methodForSelector: _selector]; if (!func(_target, _selector, object, _buffer, _readLength, _context, exception)) return false; @@ -216,15 +214,15 @@ @implementation OFRunLoop_ReadLineQueueItem - (bool)handleForObject: (id)object { OFString *line; - OFException *exception = nil; + id exception = nil; @try { line = [object tryReadLineWithEncoding: _encoding]; - } @catch (OFException *e) { + } @catch (id e) { line = nil; exception = e; } if (line == nil && ![object isAtEndOfStream] && exception == nil) @@ -233,13 +231,13 @@ # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, line, exception); else { # endif - bool (*func)(id, SEL, OFStream *, OFString *, id, - OFException *) = (bool (*)(id, SEL, OFStream *, OFString *, - id, OFException *))[_target methodForSelector: _selector]; + bool (*func)(id, SEL, OFStream *, OFString *, id, id) = + (bool (*)(id, SEL, OFStream *, OFString *, id, id)) + [_target methodForSelector: _selector]; return func(_target, _selector, object, line, _context, exception); # ifdef OF_HAVE_BLOCKS } @@ -258,27 +256,26 @@ @implementation OFRunLoop_AcceptQueueItem - (bool)handleForObject: (id)object { OFTCPSocket *newSocket; - OFException *exception = nil; + id exception = nil; @try { newSocket = [object accept]; - } @catch (OFException *e) { + } @catch (id e) { newSocket = nil; exception = e; } # ifdef OF_HAVE_BLOCKS if (_block != NULL) return _block(object, newSocket, exception); else { # endif - bool (*func)(id, SEL, OFTCPSocket *, OFTCPSocket *, id, - OFException *) = (bool (*)(id, SEL, OFTCPSocket *, - OFTCPSocket *, id, OFException *)) + bool (*func)(id, SEL, OFTCPSocket *, OFTCPSocket *, id, id) = + (bool (*)(id, SEL, OFTCPSocket *, OFTCPSocket *, id, id)) [_target methodForSelector: _selector]; return func(_target, _selector, object, newSocket, _context, exception); # ifdef OF_HAVE_BLOCKS @@ -299,17 +296,17 @@ @implementation OFRunLoop_UDPReceiveQueueItem - (bool)handleForObject: (id)object { size_t length; of_udp_socket_address_t address; - OFException *exception = nil; + id exception = nil; @try { length = [object receiveIntoBuffer: _buffer length: _length sender: &address]; - } @catch (OFException *e) { + } @catch (id e) { length = 0; exception = e; } # ifdef OF_HAVE_BLOCKS @@ -316,13 +313,13 @@ if (_block != NULL) return _block(object, _buffer, length, address, exception); else { # endif bool (*func)(id, SEL, OFUDPSocket *, void *, size_t, - of_udp_socket_address_t address, id, OFException *) = + of_udp_socket_address_t address, id, id) = (bool (*)(id, SEL, OFUDPSocket *, void *, size_t, - of_udp_socket_address_t, id, OFException *)) + of_udp_socket_address_t, id, id)) [_target methodForSelector: _selector]; return func(_target, _selector, object, _buffer, length, address, _context, exception); # ifdef OF_HAVE_BLOCKS Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -33,11 +33,10 @@ /*! @file */ @class OFStream; @class OFData; -@class OFException; #if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_BLOCKS) /*! * @brief A block which is called when data was read from the stream. * @@ -47,11 +46,11 @@ * @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 *_Nullable exception); + size_t length, id _Nullable 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 @@ -60,11 +59,11 @@ * @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 *_Nullable line, OFException *_Nullable exception); + OFString *_Nullable line, id _Nullable exception); #endif /*! * @class OFStream OFStream.h ObjFW/OFStream.h * @@ -167,11 +166,11 @@ * data has been received. If you want the next method in the * queue to handle the data received next, you need to return * false from the method. * @param selector The selector to call on the target. The signature must be * `bool (OFStream *stream, void *buffer, size_t length, - * id context, OFException *exception)`. + * id context, id exception)`. */ - (void)asyncReadIntoBuffer: (void *)buffer length: (size_t)length target: (id)target selector: (SEL)selector @@ -198,11 +197,11 @@ * data has been received. If you want the next method in the * queue to handle the data received next, you need to return * false from the method. * @param selector The selector to call on the target. The signature must be * `bool (OFStream *stream, void *buffer, size_t size, - * id context, OFException *exception)`. + * id context, id exception)`. */ - (void)asyncReadIntoBuffer: (void *)buffer exactLength: (size_t)length target: (id)target selector: (SEL)selector @@ -622,11 +621,11 @@ * again when the next line has been received. If you want the * next method in the queue to handle the next line, you need to * return false from the method * @param selector The selector to call on the target. The signature must be * `bool (OFStream *stream, OFString *line, id context, - * OFException *exception)`. + * id exception)`. */ - (void)asyncReadLineWithTarget: (id)target selector: (SEL)selector context: (nullable id)context; @@ -642,12 +641,12 @@ * been received. If the method returns true, it will be called * again when the next line has been received. If you want the * next method in the queue to handle the next line, you need to * return false from the method * @param selector The selector to call on the target. The signature must be - * `bool (OFStream *stream, OFString *line, - * id context, OFException *exception)`. + * `bool (OFStream *stream, OFString *line, id context, + * id exception)`. */ - (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding target: (id)target selector: (SEL)selector context: (nullable id)context; @@ -773,11 +772,11 @@ - (void)flushWriteBuffer; /*! * @brief Writes from a buffer into the stream. * - * @param buffer The buffer from which the data is written to the stream + * @param buffer The buffer from which the data is written into the stream * @param length The length of the data that should be written */ - (void)writeBuffer: (const void *)buffer length: (size_t)length; Index: src/OFTCPSocket.h ================================================================== --- src/OFTCPSocket.h +++ src/OFTCPSocket.h @@ -32,11 +32,11 @@ * @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, - OFException *_Nullable exception); + id _Nullable exception); /*! * @brief A block which is called when the socket accepted a connection. * * @param socket The socket which accepted the connection @@ -45,11 +45,11 @@ * `nil` on success * @return A bool whether the same block should be used for the next incoming * connection */ typedef bool (^of_tcp_socket_async_accept_block_t)(OFTCPSocket *socket, - OFTCPSocket *acceptedSocket, OFException *_Nullable exception); + OFTCPSocket *acceptedSocket, id _Nullable exception); #endif /*! * @class OFTCPSocket OFTCPSocket.h ObjFW/OFTCPSocket.h * @@ -125,12 +125,11 @@ * @param host The host to connect to * @param port The port on the host to connect to * @param target The target on which to call the selector once the connection * has been established * @param selector The selector to call on the target. The signature must be - * `void (OFTCPSocket *socket, id context, - * OFException *exception)`. + * `void (OFTCPSocket *socket, id context, id exception)`. */ - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port target: (id)target selector: (SEL)selector @@ -188,11 +187,11 @@ * connection has been accepted. The method returns whether the * next incoming connection should be accepted by the specified * block as well. * @param selector The selector to call on the target. The signature must be * `bool (OFTCPSocket *socket, OFTCPSocket *acceptedSocket, - * id context, OFException *exception)`. + * id context, id exception)`. */ - (void)asyncAcceptWithTarget: (id)target selector: (SEL)selector context: (nullable id)context; Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -76,11 +76,11 @@ SEL _selector; id _context; # ifdef OF_HAVE_BLOCKS of_tcp_socket_async_connect_block_t _block; # endif - OFException *_exception; + id _exception; } - initWithSourceThread: (OFThread *)sourceThread socket: (OFTCPSocket *)socket host: (OFString *)host @@ -170,12 +170,12 @@ # ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(_socket, _exception); else { # endif - void (*func)(id, SEL, OFTCPSocket *, id, OFException *) = - (void (*)(id, SEL, OFTCPSocket *, id, OFException *)) + void (*func)(id, SEL, OFTCPSocket *, id, id) = + (void (*)(id, SEL, OFTCPSocket *, id, id)) [_target methodForSelector: _selector]; func(_target, _selector, _socket, _context, _exception); # ifdef OF_HAVE_BLOCKS } @@ -187,11 +187,11 @@ void *pool = objc_autoreleasePoolPush(); @try { [_socket connectToHost: _host port: _port]; - } @catch (OFException *e) { + } @catch (id e) { _exception = [e retain]; } [self performSelector: @selector(didConnect) onThread: _sourceThread Index: src/OFUDPSocket.h ================================================================== --- src/OFUDPSocket.h +++ src/OFUDPSocket.h @@ -22,11 +22,10 @@ OF_ASSUME_NONNULL_BEGIN /*! @file */ @class OFUDPSocket; -@class OFException; /*! * @struct of_udp_socket_address_t OFUDPSocket.h ObjFW/OFUDPSocket.h * * @brief A struct which represents a host / port pair for a UDP socket. @@ -46,12 +45,11 @@ * @param address The address of the resolved host / port pair * @param exception An exception which occurred while resolving or `nil` on * success */ typedef void (^of_udp_socket_async_resolve_block_t)(OFString *host, - uint16_t port, of_udp_socket_address_t address, - OFException *_Nullable exception); + uint16_t port, of_udp_socket_address_t address, id _Nullable exception); /*! * @brief A block which is called when a packet has been received. * * @param socket The UDP which received a packet @@ -62,11 +60,11 @@ * success * @return A bool whether the same block should be used for the next receive */ typedef bool (^of_udp_socket_async_receive_block_t)(OFUDPSocket *socket, void *buffer, size_t length, of_udp_socket_address_t sender, - OFException *_Nullable exception); + id _Nullable exception); #endif /*! * @class OFUDPSocket OFUDPSocket.h ObjFW/OFUDPSocket.h * @@ -125,12 +123,11 @@ * @param port The port for the resulting address * @param target The target on which to call the selector once the host has been * resolved * @param selector The selector to call on the target. The signature must be * `void (OFString *host, uint16_t port, - * of_udp_socket_address_t address, id context, - * OFException *exception)`. + * of_udp_socket_address_t address, id context, id exception)`. */ + (void)asyncResolveAddressForHost: (OFString *)host port: (uint16_t)port target: (id)target selector: (SEL)selector @@ -205,12 +202,11 @@ * when more datagrams have been received. If you want the next * method in the queue to handle the datagram received next, you * need to return false from the method. * @param selector The selector to call on the target. The signature must be * `bool (OFUDPSocket *socket, void *buffer, size_t length, - * of_udp_socket_address_t, id context, - * OFException *exception)`. + * of_udp_socket_address_t, id context, id exception)`. */ - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length target: (id)target selector: (SEL)selector Index: src/OFUDPSocket.m ================================================================== --- src/OFUDPSocket.m +++ src/OFUDPSocket.m @@ -54,11 +54,11 @@ id _context; # ifdef OF_HAVE_BLOCKS of_udp_socket_async_resolve_block_t _block; # endif of_udp_socket_address_t _address; - OFException *_exception; + id _exception; } - initWithSourceThread: (OFThread *)sourceThread host: (OFString *)host port: (uint16_t)port @@ -142,13 +142,13 @@ if (_block != NULL) _block(_host, _port, _address, _exception); else { # endif void (*func)(id, SEL, OFString *, uint16_t, - of_udp_socket_address_t, id, OFException *) = + of_udp_socket_address_t, id, id) = (void (*)(id, SEL, OFString *, uint16_t, - of_udp_socket_address_t, id, OFException *)) + of_udp_socket_address_t, id, id)) [_target methodForSelector: _selector]; func(_target, _selector, _host, _port, _address, _context, _exception); # ifdef OF_HAVE_BLOCKS @@ -162,11 +162,11 @@ @try { [OFUDPSocket resolveAddressForHost: _host port: _port address: &_address]; - } @catch (OFException *e) { + } @catch (id e) { _exception = e; } [self performSelector: @selector(didResolve) onThread: _sourceThread