summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@heap.zone>2017-11-19 12:04:22 +0100
committerJonathan Schleifer <js@heap.zone>2017-11-19 12:04:22 +0100
commit1e17567dd8e42ea99fa9c51166f3b3c576232c93 (patch)
treeadee6659f7fd66e488feea08c43e8610b8b001be
parent5308b1ccb713d0c79d2fe25907e647036b0ddd75 (diff)
Do not conform to OFReadyFor*Observing by default
Instead of letting OFStream conform to it, which itself does not really conform to it, let all the subclasses that actually do conform to it.
-rw-r--r--configure.ac1
-rw-r--r--extra.mk.in1
-rw-r--r--src/Makefile12
-rw-r--r--src/OFFile.h4
-rw-r--r--src/OFHTTPClient.m3
-rw-r--r--src/OFHTTPServer.m2
-rw-r--r--src/OFInflateStream.h8
-rw-r--r--src/OFKernelEventObserver.h6
-rw-r--r--src/OFProcess.h4
-rw-r--r--src/OFProcess.m10
-rw-r--r--src/OFRunLoop+Private.h24
-rw-r--r--src/OFRunLoop.m24
-rw-r--r--src/OFStdIOStream.h4
-rw-r--r--src/OFStream.h56
-rw-r--r--src/OFStream.m40
-rw-r--r--src/OFStreamSocket.h3
-rw-r--r--src/OFTarArchive.h13
-rw-r--r--src/OFTarArchive.m11
18 files changed, 138 insertions, 88 deletions
diff --git a/configure.ac b/configure.ac
index f44722bb..7aacdbdd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -906,7 +906,6 @@ AC_ARG_ENABLE(files,
AS_IF([test x"$enable_files" != x"no"], [
AC_DEFINE(OF_HAVE_FILES, 1, [Whether we have files])
AC_SUBST(USE_SRCS_FILES, '${SRCS_FILES}')
- AC_SUBST(USE_SRCS_FILES_NOINCLUDE, '${SRCS_FILES_NOINCLUDE}')
AC_SUBST(OFHASH, "ofhash")
AC_SUBST(OFZIP, "ofzip")
diff --git a/extra.mk.in b/extra.mk.in
index a513b4ad..06ed5f1d 100644
--- a/extra.mk.in
+++ b/extra.mk.in
@@ -66,7 +66,6 @@ TESTS_OBJCFLAGS = @TESTS_OBJCFLAGS@
UNICODE_M = @UNICODE_M@
USE_INCLUDES_ATOMIC = @USE_INCLUDES_ATOMIC@
USE_SRCS_FILES = @USE_SRCS_FILES@
-USE_SRCS_FILES_NOINCLUDE = @USE_SRCS_FILES_NOINCLUDE@
USE_SRCS_PLUGINS = @USE_SRCS_PLUGINS@
USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@
USE_SRCS_THREADS = @USE_SRCS_THREADS@
diff --git a/src/Makefile b/src/Makefile
index dc1ad7ef..3591e92a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -116,11 +116,9 @@ SRCS_FILES = OFFile.m \
OFINICategory.m \
OFINIFile.m \
OFSettings.m
-SRCS_FILES_NOINCLUDE = OFURLHandler_file.m
SRCS_PLUGINS = OFPlugin.m
SRCS_SOCKETS = OFHTTPClient.m \
OFHTTPServer.m \
- OFKernelEventObserver.m \
OFStreamSocket.m \
OFTCPSocket.m \
OFUDPSocket.m \
@@ -143,6 +141,7 @@ INCLUDES := ${SRCS:.m=.h} \
OFCollection.h \
OFCryptoHash.h \
OFJSONRepresentation.h \
+ OFKernelEventObserver.h \
OFKeyValueCoding.h \
OFLocking.h \
OFMessagePackRepresentation.h \
@@ -173,10 +172,11 @@ SRCS += OFArray_adjacent.m \
OFString_UTF8.m \
${AUTORELEASE_M} \
${FOUNDATION_COMPAT_M} \
- ${INSTANCE_M} \
- ${USE_SRCS_FILES_NOINCLUDE}
-SRCS_FILES += OFSettings_INIFile.m
-SRCS_SOCKETS += ${OFKERNELEVENTOBSERVER_EPOLL_M} \
+ ${INSTANCE_M}
+SRCS_FILES += OFSettings_INIFile.m \
+ OFURLHandler_file.m
+SRCS_SOCKETS += OFKernelEventObserver.m \
+ ${OFKERNELEVENTOBSERVER_EPOLL_M} \
${OFKERNELEVENTOBSERVER_KQUEUE_M} \
${OFKERNELEVENTOBSERVER_POLL_M} \
${OFKERNELEVENTOBSERVER_SELECT_M} \
diff --git a/src/OFFile.h b/src/OFFile.h
index 4691a540..aa46d3ab 100644
--- a/src/OFFile.h
+++ b/src/OFFile.h
@@ -15,6 +15,7 @@
*/
#import "OFSeekableStream.h"
+#import "OFKernelEventObserver.h"
#ifndef OF_MORPHOS
# define OF_FILE_HANDLE_IS_FD
@@ -38,6 +39,9 @@ OF_ASSUME_NONNULL_BEGIN
* @brief A class which provides methods to read and write files.
*/
@interface OFFile: OFSeekableStream
+#ifdef OF_FILE_HANDLE_IS_FD
+ <OFReadyForReadingObserving, OFReadyForWritingObserving>
+#endif
{
of_file_handle_t _handle;
bool _atEndOfStream;
diff --git a/src/OFHTTPClient.m b/src/OFHTTPClient.m
index 8396f2cf..8e33be4b 100644
--- a/src/OFHTTPClient.m
+++ b/src/OFHTTPClient.m
@@ -26,6 +26,7 @@
#import "OFDictionary.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
+#import "OFKernelEventObserver.h"
#import "OFNumber.h"
#import "OFString.h"
#import "OFTCPSocket.h"
@@ -65,7 +66,7 @@
- (void)closeAndReconnect;
@end
-@interface OFHTTPClientResponse: OFHTTPResponse
+@interface OFHTTPClientResponse: OFHTTPResponse <OFReadyForReadingObserving>
{
OFTCPSocket *_socket;
bool _hasContentLength, _chunked, _keepAlive, _atEndOfStream;
diff --git a/src/OFHTTPServer.m b/src/OFHTTPServer.m
index 766e59d2..ed4e7441 100644
--- a/src/OFHTTPServer.m
+++ b/src/OFHTTPServer.m
@@ -173,7 +173,7 @@ normalizedKey(OFString *key)
freeWhenDone: true];
}
-@interface OFHTTPServerResponse: OFHTTPResponse
+@interface OFHTTPServerResponse: OFHTTPResponse <OFReadyForWritingObserving>
{
OFTCPSocket *_socket;
OFHTTPServer *_server;
diff --git a/src/OFInflateStream.h b/src/OFInflateStream.h
index 80a7463b..1f0cc16c 100644
--- a/src/OFInflateStream.h
+++ b/src/OFInflateStream.h
@@ -15,6 +15,7 @@
*/
#import "OFStream.h"
+#import "OFKernelEventObserver.h"
OF_ASSUME_NONNULL_BEGIN
@@ -23,15 +24,18 @@ OF_ASSUME_NONNULL_BEGIN
/*!
* @class OFInflateStream OFInflateStream.h ObjFW/OFInflateStream.h
*
+ * @note This class only conforms to OFReadyForReadingObserving if the
+ * underlying stream does so, too.
+ *
* @brief A class that handles Deflate decompression transparently for an
* underlying stream.
*/
-@interface OFInflateStream: OFStream
+@interface OFInflateStream: OFStream <OFReadyForReadingObserving>
{
#ifdef OF_INFLATE_STREAM_M
@public
#endif
- OFStream *_stream;
+ OF_KINDOF(OFStream *) _stream;
uint8_t _buffer[OF_INFLATE_STREAM_BUFFER_SIZE];
uint16_t _bufferIndex, _bufferLength;
uint8_t _byte;
diff --git a/src/OFKernelEventObserver.h b/src/OFKernelEventObserver.h
index 01e2d0f6..d7324bce 100644
--- a/src/OFKernelEventObserver.h
+++ b/src/OFKernelEventObserver.h
@@ -16,7 +16,9 @@
#import "OFObject.h"
-#import "socket.h"
+#ifdef OF_HAVE_SOCKETS
+# import "socket.h"
+#endif
OF_ASSUME_NONNULL_BEGIN
@@ -90,6 +92,7 @@ OF_ASSUME_NONNULL_BEGIN
@property (readonly, nonatomic) int fileDescriptorForWriting;
@end
+#ifdef OF_HAVE_SOCKETS
/*!
* @class OFKernelEventObserver
* OFKernelEventObserver.h ObjFW/OFKernelEventObserver.h
@@ -205,5 +208,6 @@ OF_ASSUME_NONNULL_BEGIN
*/
- (void)cancel;
@end
+#endif
OF_ASSUME_NONNULL_END
diff --git a/src/OFProcess.h b/src/OFProcess.h
index a21fcff0..b99634f9 100644
--- a/src/OFProcess.h
+++ b/src/OFProcess.h
@@ -28,6 +28,7 @@
#endif
#import "OFStream.h"
+#import "OFKernelEventObserver.h"
#import "OFString.h"
#ifdef OF_WINDOWS
@@ -45,6 +46,9 @@ OF_ASSUME_NONNULL_BEGIN
* @brief A class for stream-like communication with a newly created process.
*/
@interface OFProcess: OFStream
+#ifndef OF_WINDOWS
+ <OFReadyForReadingObserving, OFReadyForWritingObserving>
+#endif
{
#ifndef OF_WINDOWS
pid_t _pid;
diff --git a/src/OFProcess.m b/src/OFProcess.m
index cd6b9997..87ca4c3b 100644
--- a/src/OFProcess.m
+++ b/src/OFProcess.m
@@ -527,23 +527,17 @@ extern char **environ;
return (size_t)bytesWritten;
}
+#ifndef OF_WINDOWS
- (int)fileDescriptorForReading
{
-#ifndef OF_WINDOWS
return _readPipe[0];
-#else
- OF_UNRECOGNIZED_SELECTOR
-#endif
}
- (int)fileDescriptorForWriting
{
-#ifndef OF_WINDOWS
return _writePipe[1];
-#else
- OF_UNRECOGNIZED_SELECTOR
-#endif
}
+#endif
- (void)closeForWriting
{
diff --git a/src/OFRunLoop+Private.h b/src/OFRunLoop+Private.h
index 7de3f021..017318f6 100644
--- a/src/OFRunLoop+Private.h
+++ b/src/OFRunLoop+Private.h
@@ -25,24 +25,28 @@ OF_ASSUME_NONNULL_BEGIN
@interface OFRunLoop ()
+ (void)of_setMainRunLoop: (OFRunLoop *)runLoop;
#ifdef OF_HAVE_SOCKETS
-+ (void)of_addAsyncReadForStream: (OFStream *)stream
++ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
buffer: (void *)buffer
length: (size_t)length
target: (id)target
selector: (SEL)selector
context: (nullable id)context;
-+ (void)of_addAsyncReadForStream: (OFStream *)stream
++ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
buffer: (void *)buffer
exactLength: (size_t)length
target: (id)target
selector: (SEL)selector
context: (nullable id)context;
-+ (void)of_addAsyncReadLineForStream: (OFStream *)stream
++ (void)of_addAsyncReadLineForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
encoding: (of_string_encoding_t)encoding
target: (id)target
selector: (SEL)selector
context: (nullable id)context;
-+ (void)of_addAsyncWriteForStream: (OFStream *)stream
++ (void)of_addAsyncWriteForStream: (OFStream <OFReadyForWritingObserving> *)
+ stream
buffer: (const void *)buffer
length: (size_t)length
target: (id)target
@@ -66,18 +70,22 @@ OF_ASSUME_NONNULL_BEGIN
selector: (SEL)selector
context: (nullable id)context;
# ifdef OF_HAVE_BLOCKS
-+ (void)of_addAsyncReadForStream: (OFStream *)stream
++ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
buffer: (void *)buffer
length: (size_t)length
block: (of_stream_async_read_block_t)block;
-+ (void)of_addAsyncReadForStream: (OFStream *)stream
++ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
buffer: (void *)buffer
exactLength: (size_t)length
block: (of_stream_async_read_block_t)block;
-+ (void)of_addAsyncReadLineForStream: (OFStream *)stream
++ (void)of_addAsyncReadLineForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
encoding: (of_string_encoding_t)encoding
block: (of_stream_async_read_line_block_t)block;
-+ (void)of_addAsyncWriteForStream: (OFStream *)stream
++ (void)of_addAsyncWriteForStream: (OFStream <OFReadyForWritingObserving> *)
+ stream
buffer: (const void *)buffer
length: (size_t)length
block: (of_stream_async_write_block_t)block;
diff --git a/src/OFRunLoop.m b/src/OFRunLoop.m
index 94bcb85e..70dbd450 100644
--- a/src/OFRunLoop.m
+++ b/src/OFRunLoop.m
@@ -529,7 +529,8 @@ static OFRunLoop *mainRunLoop = nil;
\
objc_autoreleasePoolPop(pool);
-+ (void)of_addAsyncReadForStream: (OFStream *)stream
++ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
buffer: (void *)buffer
length: (size_t)length
target: (id)target
@@ -545,7 +546,8 @@ static OFRunLoop *mainRunLoop = nil;
})
}
-+ (void)of_addAsyncReadForStream: (OFStream *)stream
++ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
buffer: (void *)buffer
exactLength: (size_t)exactLength
target: (id)target
@@ -561,7 +563,8 @@ static OFRunLoop *mainRunLoop = nil;
})
}
-+ (void)of_addAsyncReadLineForStream: (OFStream *)stream
++ (void)of_addAsyncReadLineForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
encoding: (of_string_encoding_t)encoding
target: (id)target
selector: (SEL)selector
@@ -575,7 +578,8 @@ static OFRunLoop *mainRunLoop = nil;
})
}
-+ (void)of_addAsyncWriteForStream: (OFStream *)stream
++ (void)of_addAsyncWriteForStream: (OFStream <OFReadyForWritingObserving> *)
+ stream
buffer: (const void *)buffer
length: (size_t)length
target: (id)target
@@ -638,7 +642,8 @@ static OFRunLoop *mainRunLoop = nil;
}
# ifdef OF_HAVE_BLOCKS
-+ (void)of_addAsyncReadForStream: (OFStream *)stream
++ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
buffer: (void *)buffer
length: (size_t)length
block: (of_stream_async_read_block_t)block
@@ -650,7 +655,8 @@ static OFRunLoop *mainRunLoop = nil;
})
}
-+ (void)of_addAsyncReadForStream: (OFStream *)stream
++ (void)of_addAsyncReadForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
buffer: (void *)buffer
exactLength: (size_t)exactLength
block: (of_stream_async_read_block_t)block
@@ -662,7 +668,8 @@ static OFRunLoop *mainRunLoop = nil;
})
}
-+ (void)of_addAsyncReadLineForStream: (OFStream *)stream
++ (void)of_addAsyncReadLineForStream: (OFStream <OFReadyForReadingObserving> *)
+ stream
encoding: (of_string_encoding_t)encoding
block: (of_stream_async_read_line_block_t)block
{
@@ -672,7 +679,8 @@ static OFRunLoop *mainRunLoop = nil;
})
}
-+ (void)of_addAsyncWriteForStream: (OFStream *)stream
++ (void)of_addAsyncWriteForStream: (OFStream <OFReadyForWritingObserving> *)
+ stream
buffer: (const void *)buffer
length: (size_t)length
block: (of_stream_async_write_block_t)block
diff --git a/src/OFStdIOStream.h b/src/OFStdIOStream.h
index 560f9dde..d7a5f77b 100644
--- a/src/OFStdIOStream.h
+++ b/src/OFStdIOStream.h
@@ -15,6 +15,7 @@
*/
#import "OFStream.h"
+#import "OFKernelEventObserver.h"
#ifdef OF_MORPHOS
# define BOOL EXEC_BOOL
@@ -36,6 +37,9 @@ OF_ASSUME_NONNULL_BEGIN
OF_SUBCLASSING_RESTRICTED
#endif
@interface OFStdIOStream: OFStream
+#if !defined(OF_WINDOWS) && !defined(OF_MORPHOS)
+ <OFReadyForReadingObserving, OFReadyForWritingObserving>
+#endif
{
#ifndef OF_MORPHOS
int _fd;
diff --git a/src/OFStream.h b/src/OFStream.h
index 5b0526a9..d1957f79 100644
--- a/src/OFStream.h
+++ b/src/OFStream.h
@@ -104,11 +104,7 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
* override these methods without the `lowlevel` prefix, you *will* break
* caching and get broken results!
*/
-@interface OFStream: OFObject <
-#ifdef OF_HAVE_SOCKETS
- OFReadyForReadingObserving, OFReadyForWritingObserving,
-#endif
- OFCopying>
+@interface OFStream: OFObject <OFCopying>
{
#if !defined(OF_SEEKABLE_STREAM_M) && !defined(OF_TCP_SOCKET_M)
@private
@@ -145,16 +141,6 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
@property (readonly, nonatomic, getter=isBlocking) bool blocking;
/*!
- * @brief The file descriptor for the read end of the stream.
- */
-@property (readonly, nonatomic) int fileDescriptorForReading;
-
-/*!
- * @brief The file descriptor for the write end of the stream.
- */
-@property (readonly, nonatomic) int fileDescriptorForWriting;
-
-/*!
* @brief Reads *at most* size bytes from the stream into a buffer.
*
* On network streams, this might read less than the specified number of bytes.
@@ -200,8 +186,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
* read can even return 0 bytes - this does not necessarily mean that the
* stream ended, so you still need to check @ref atEndOfStream.
*
- * @note The stream must implement @ref fileDescriptorForReading and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForReadingObserving in order
+ * for this to work!
*
* @param buffer The buffer into which the data is read.
* The buffer must not be freed before the async read completed!
@@ -233,8 +219,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
* instead, it waits until it got exactly the specified length, the stream has
* ended or an exception occurred.
*
- * @note The stream must implement @ref fileDescriptorForReading and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForReadingObserving in order
+ * for this to work!
*
* @param buffer The buffer into which the data is read
* @param length The length of the data that should be read.
@@ -267,8 +253,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
* return 0 bytes - this does not necessarily mean that the stream ended, so
* you still need to check @ref atEndOfStream.
*
- * @note The stream must implement @ref fileDescriptorForReading and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForReadingObserving in order
+ * for this to work!
*
* @param buffer The buffer into which the data is read.
* The buffer must not be freed before the async read completed!
@@ -293,8 +279,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
* waits until it got exactly the specified length, the stream has ended or an
* exception occurred.
*
- * @note The stream must implement @ref fileDescriptorForReading and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForReadingObserving in order
+ * for this to work!
*
* @param buffer The buffer into which the data is read
* @param length The length of the data that should be read.
@@ -662,8 +648,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
* @brief Asynchronously reads until a newline, `\0`, end of stream or an
* exception occurs.
*
- * @note The stream must implement @ref fileDescriptorForReading and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForReadingObserving in order
+ * for this to work!
*
* @param target The target on which to call the selector when the data has
* been received. If the method returns true, it will be called
@@ -683,8 +669,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
* @brief Asynchronously reads with the specified encoding until a newline,
* `\0`, end of stream or an exception occurs.
*
- * @note The stream must implement @ref fileDescriptorForReading and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForReadingObserving in order
+ * for this to work!
*
* @param encoding The encoding used by the stream
* @param target The target on which to call the selector when the data has
@@ -707,8 +693,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
* @brief Asynchronously reads until a newline, `\0`, end of stream or an
* exception occurs.
*
- * @note The stream must implement @ref fileDescriptorForReading and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForReadingObserving in order
+ * for this to work!
*
* @param block The block to call when the data has been received.
* If the block returns true, it will be called again when the next
@@ -722,8 +708,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
* @brief Asynchronously reads with the specified encoding until a newline,
* `\0`, end of stream or an exception occurs.
*
- * @note The stream must implement @ref fileDescriptorForReading and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForReadingObserving in order
+ * for this to work!
*
* @param encoding The encoding used by the stream
* @param block The block to call when the data has been received.
@@ -823,8 +809,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
/*!
* @brief Asynchronously writes a buffer into the stream.
*
- * @note The stream must implement @ref fileDescriptorForWriting and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForWritingObserving in order
+ * for this to work!
*
* @param buffer The buffer from which the data is written into the stream. The
* buffer needs to be valid until the write request is completed!
@@ -850,8 +836,8 @@ typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
/*!
* @brief Asynchronously writes a buffer into the stream.
*
- * @note The stream must implement @ref fileDescriptorForWriting and return a
- * valid file descriptor in order for this to work!
+ * @note The stream must conform to @ref OFReadyForWritingObserving in order
+ * for this to work!
*
* @param buffer The buffer from which the data is written into the stream. The
* buffer needs to be valid until the write request is completed!
diff --git a/src/OFStream.m b/src/OFStream.m
index 1fd03d46..3a7e1976 100644
--- a/src/OFStream.m
+++ b/src/OFStream.m
@@ -195,7 +195,10 @@
selector: (SEL)selector
context: (id)context
{
- [OFRunLoop of_addAsyncReadForStream: self
+ OFStream <OFReadyForReadingObserving> *stream =
+ (OFStream <OFReadyForReadingObserving> *)self;
+
+ [OFRunLoop of_addAsyncReadForStream: stream
buffer: buffer
length: length
target: target
@@ -209,7 +212,10 @@
selector: (SEL)selector
context: (id)context
{
- [OFRunLoop of_addAsyncReadForStream: self
+ OFStream <OFReadyForReadingObserving> *stream =
+ (OFStream <OFReadyForReadingObserving> *)self;
+
+ [OFRunLoop of_addAsyncReadForStream: stream
buffer: buffer
exactLength: length
target: target
@@ -222,7 +228,10 @@
length: (size_t)length
block: (of_stream_async_read_block_t)block
{
- [OFRunLoop of_addAsyncReadForStream: self
+ OFStream <OFReadyForReadingObserving> *stream =
+ (OFStream <OFReadyForReadingObserving> *)self;
+
+ [OFRunLoop of_addAsyncReadForStream: stream
buffer: buffer
length: length
block: block];
@@ -232,7 +241,10 @@
exactLength: (size_t)length
block: (of_stream_async_read_block_t)block
{
- [OFRunLoop of_addAsyncReadForStream: self
+ OFStream <OFReadyForReadingObserving> *stream =
+ (OFStream <OFReadyForReadingObserving> *)self;
+
+ [OFRunLoop of_addAsyncReadForStream: stream
buffer: buffer
exactLength: length
block: block];
@@ -830,7 +842,10 @@
selector: (SEL)selector
context: (id)context
{
- [OFRunLoop of_addAsyncReadLineForStream: self
+ OFStream <OFReadyForReadingObserving> *stream =
+ (OFStream <OFReadyForReadingObserving> *)self;
+
+ [OFRunLoop of_addAsyncReadLineForStream: stream
encoding: encoding
target: target
selector: selector
@@ -847,7 +862,10 @@
- (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding
block: (of_stream_async_read_line_block_t)block
{
- [OFRunLoop of_addAsyncReadLineForStream: self
+ OFStream <OFReadyForReadingObserving> *stream =
+ (OFStream <OFReadyForReadingObserving> *)self;
+
+ [OFRunLoop of_addAsyncReadLineForStream: stream
encoding: encoding
block: block];
}
@@ -1079,7 +1097,10 @@
selector: (SEL)selector
context: (id)context
{
- [OFRunLoop of_addAsyncWriteForStream: self
+ OFStream <OFReadyForWritingObserving> *stream =
+ (OFStream <OFReadyForWritingObserving> *)self;
+
+ [OFRunLoop of_addAsyncWriteForStream: stream
buffer: buffer
length: length
target: target
@@ -1092,7 +1113,10 @@
length: (size_t)length
block: (of_stream_async_write_block_t)block
{
- [OFRunLoop of_addAsyncWriteForStream: self
+ OFStream <OFReadyForWritingObserving> *stream =
+ (OFStream <OFReadyForWritingObserving> *)self;
+
+ [OFRunLoop of_addAsyncWriteForStream: stream
buffer: buffer
length: length
block: block];
diff --git a/src/OFStreamSocket.h b/src/OFStreamSocket.h
index 8ee8d52b..996520a9 100644
--- a/src/OFStreamSocket.h
+++ b/src/OFStreamSocket.h
@@ -25,7 +25,8 @@ OF_ASSUME_NONNULL_BEGIN
*
* @brief A class which provides methods to create and use stream sockets.
*/
-@interface OFStreamSocket: OFStream
+@interface OFStreamSocket: OFStream <OFReadyForReadingObserving,
+ OFReadyForWritingObserving>
{
of_socket_t _socket;
bool _atEndOfStream;
diff --git a/src/OFTarArchive.h b/src/OFTarArchive.h
index 19cd37b7..d3a5ef15 100644
--- a/src/OFTarArchive.h
+++ b/src/OFTarArchive.h
@@ -15,6 +15,7 @@
*/
#import "OFObject.h"
+#import "OFKernelEventObserver.h"
#import "OFTarArchiveEntry.h"
OF_ASSUME_NONNULL_BEGIN
@@ -42,8 +43,12 @@ OF_ASSUME_NONNULL_BEGIN
* @brief A stream for reading the current entry
*
* @note This is only available in read mode.
+ *
+ * @note The returned stream only conforms to @ref OFReadyForReadingObserving if
+ * the underlying stream does so, too.
*/
-@property (readonly, nonatomic) OFStream *streamForReadingCurrentEntry;
+@property (readonly, nonatomic)
+ OFStream <OFReadyForReadingObserving> *streamForReadingCurrentEntry;
/*!
* @brief Creates a new OFTarArchive object with the specified stream.
@@ -123,6 +128,9 @@ OF_ASSUME_NONNULL_BEGIN
*
* @note This is only available in write and append mode.
*
+ * @note The returned stream only conforms to @ref OFReadyForWritingObserving if
+ * the underlying stream does so, too.
+ *
* @warning Calling @ref nextEntry will invalidate all streams returned by
* @ref streamForReadingCurrentEntry or
* @ref streamForWritingEntry:! Reading from or writing to an
@@ -132,7 +140,8 @@ OF_ASSUME_NONNULL_BEGIN
* @param entry The entry for which a stream for writing should be returned
* @return A stream for writing the specified entry
*/
-- (OFStream *)streamForWritingEntry: (OFTarArchiveEntry *)entry;
+- (OFStream <OFReadyForWritingObserving> *)
+ streamForWritingEntry: (OFTarArchiveEntry *)entry;
/*!
* @brief Closes the OFTarArchive.
diff --git a/src/OFTarArchive.m b/src/OFTarArchive.m
index c2a67229..99334284 100644
--- a/src/OFTarArchive.m
+++ b/src/OFTarArchive.m
@@ -33,7 +33,7 @@
#import "OFTruncatedDataException.h"
#import "OFWriteFailedException.h"
-@interface OFTarArchive_FileReadStream: OFStream
+@interface OFTarArchive_FileReadStream: OFStream <OFReadyForReadingObserving>
{
OFTarArchiveEntry *_entry;
OF_KINDOF(OFStream *) _stream;
@@ -46,10 +46,10 @@
- (void)of_skip;
@end
-@interface OFTarArchive_FileWriteStream: OFStream
+@interface OFTarArchive_FileWriteStream: OFStream <OFReadyForWritingObserving>
{
OFTarArchiveEntry *_entry;
- OFStream *_stream;
+ OF_KINDOF(OFStream *) _stream;
uint64_t _toWrite;
}
@@ -203,7 +203,7 @@
return entry;
}
-- (OFStream *)streamForReadingCurrentEntry
+- (OFStream <OFReadyForReadingObserving> *)streamForReadingCurrentEntry
{
if (_mode != OF_TAR_ARCHIVE_MODE_READ)
@throw [OFInvalidArgumentException exception];
@@ -214,7 +214,8 @@
return [[_lastReturnedStream retain] autorelease];
}
-- (OFStream *)streamForWritingEntry: (OFTarArchiveEntry *)entry
+- (OFStream <OFReadyForWritingObserving> *)
+ streamForWritingEntry: (OFTarArchiveEntry *)entry
{
void *pool;