@@ -45,16 +45,11 @@ #endif of_run_loop_mode_t of_run_loop_mode_default = @"of_run_loop_mode_default"; static OFRunLoop *mainRunLoop = nil; -@interface OFRunLoop () -- (OFRunLoop_State *)of_stateForMode: (of_run_loop_mode_t)mode - create: (bool)create; -@end - -@interface OFRunLoop_State: OFObject +@interface OFRunLoopState: OFObject #ifdef OF_HAVE_SOCKETS #endif { @public @@ -68,22 +63,27 @@ #elif defined(OF_HAVE_THREADS) OFCondition *_condition; #endif } @end + +@interface OFRunLoop () +- (OFRunLoopState *)of_stateForMode: (of_run_loop_mode_t)mode + create: (bool)create; +@end #ifdef OF_HAVE_SOCKETS -@interface OFRunLoop_QueueItem: OFObject +@interface OFRunLoopQueueItem: OFObject { @public id _delegate; } - (bool)handleObject: (id)object; @end -@interface OFRunLoop_ReadQueueItem: OFRunLoop_QueueItem +@interface OFRunLoopReadQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS of_stream_async_read_block_t _block; # endif @@ -90,11 +90,11 @@ void *_buffer; size_t _length; } @end -@interface OFRunLoop_ExactReadQueueItem: OFRunLoop_QueueItem +@interface OFRunLoopExactReadQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS of_stream_async_read_block_t _block; # endif @@ -101,21 +101,21 @@ void *_buffer; size_t _exactLength, _readLength; } @end -@interface OFRunLoop_ReadLineQueueItem: OFRunLoop_QueueItem +@interface OFRunLoopReadLineQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS of_stream_async_read_line_block_t _block; # endif of_string_encoding_t _encoding; } @end -@interface OFRunLoop_WriteDataQueueItem: OFRunLoop_QueueItem +@interface OFRunLoopWriteDataQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS of_stream_async_write_data_block_t _block; # endif @@ -122,11 +122,11 @@ OFData *_data; size_t _writtenLength; } @end -@interface OFRunLoop_WriteStringQueueItem: OFRunLoop_QueueItem +@interface OFRunLoopWriteStringQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS of_stream_async_write_string_block_t _block; # endif @@ -135,24 +135,24 @@ size_t _writtenLength; } @end # if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) -@interface OFRunLoop_ConnectQueueItem: OFRunLoop_QueueItem +@interface OFRunLoopConnectQueueItem: OFRunLoopQueueItem @end # endif -@interface OFRunLoop_AcceptQueueItem: OFRunLoop_QueueItem +@interface OFRunLoopAcceptQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS of_tcp_socket_async_accept_block_t _block; # endif } @end -@interface OFRunLoop_UDPReceiveQueueItem: OFRunLoop_QueueItem +@interface OFRunLoopUDPReceiveQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS of_udp_socket_async_receive_block_t _block; # endif @@ -159,11 +159,11 @@ void *_buffer; size_t _length; } @end -@interface OFRunLoop_UDPSendQueueItem: OFRunLoop_QueueItem +@interface OFRunLoopUDPSendQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS of_udp_socket_async_send_data_block_t _block; # endif @@ -171,11 +171,11 @@ of_socket_address_t _receiver; } @end #endif -@implementation OFRunLoop_State +@implementation OFRunLoopState - (instancetype)init { self = [super init]; @try { @@ -217,11 +217,11 @@ { /* * Retain the queue so that it doesn't disappear from us because the * handler called -[cancelAsyncRequests]. */ - OFList OF_GENERIC(OF_KINDOF(OFRunLoop_ReadQueueItem *)) *queue = + OFList OF_GENERIC(OF_KINDOF(OFRunLoopReadQueueItem *)) *queue = [[_readQueues objectForKey: object] retain]; assert(queue != nil); @try { @@ -301,11 +301,11 @@ } #endif @end #ifdef OF_HAVE_SOCKETS -@implementation OFRunLoop_QueueItem +@implementation OFRunLoopQueueItem - (bool)handleObject: (id)object { OF_UNRECOGNIZED_SELECTOR } @@ -315,11 +315,11 @@ [super dealloc]; } @end -@implementation OFRunLoop_ReadQueueItem +@implementation OFRunLoopReadQueueItem - (bool)handleObject: (id)object { size_t length; id exception = nil; @@ -357,11 +357,11 @@ [super dealloc]; } # endif @end -@implementation OFRunLoop_ExactReadQueueItem +@implementation OFRunLoopExactReadQueueItem - (bool)handleObject: (id)object { size_t length; id exception = nil; @@ -413,11 +413,11 @@ [super dealloc]; } # endif @end -@implementation OFRunLoop_ReadLineQueueItem +@implementation OFRunLoopReadLineQueueItem - (bool)handleObject: (id)object { OFString *line; id exception = nil; @@ -456,11 +456,11 @@ [super dealloc]; } # endif @end -@implementation OFRunLoop_WriteDataQueueItem +@implementation OFRunLoopWriteDataQueueItem - (bool)handleObject: (id)object { size_t length; id exception = nil; size_t dataLength = _data.count * _data.itemSize; @@ -528,11 +528,11 @@ [super dealloc]; } @end -@implementation OFRunLoop_WriteStringQueueItem +@implementation OFRunLoopWriteStringQueueItem - (bool)handleObject: (id)object { size_t length; id exception = nil; size_t cStringLength = [_string cStringLengthWithEncoding: _encoding]; @@ -603,11 +603,11 @@ [super dealloc]; } @end # if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) -@implementation OFRunLoop_ConnectQueueItem +@implementation OFRunLoopConnectQueueItem - (bool)handleObject: (id)object { id exception = nil; int errNo; @@ -626,11 +626,11 @@ return false; } @end # endif -@implementation OFRunLoop_AcceptQueueItem +@implementation OFRunLoopAcceptQueueItem - (bool)handleObject: (id)object { OFTCPSocket *acceptedSocket; id exception = nil; @@ -666,11 +666,11 @@ [super dealloc]; } # endif @end -@implementation OFRunLoop_UDPReceiveQueueItem +@implementation OFRunLoopUDPReceiveQueueItem - (bool)handleObject: (id)object { size_t length; of_socket_address_t address; id exception = nil; @@ -711,11 +711,11 @@ [super dealloc]; } # endif @end -@implementation OFRunLoop_UDPSendQueueItem +@implementation OFRunLoopUDPSendQueueItem - (bool)handleObject: (id)object { id exception = nil; OFData *newData, *oldData; @@ -799,12 +799,12 @@ #ifdef OF_HAVE_SOCKETS # define NEW_READ(type, object, mode) \ void *pool = objc_autoreleasePoolPush(); \ OFRunLoop *runLoop = [self currentRunLoop]; \ - OFRunLoop_State *state = [runLoop of_stateForMode: mode \ - create: true]; \ + OFRunLoopState *state = [runLoop of_stateForMode: mode \ + create: true]; \ OFList *queue = [state->_readQueues objectForKey: object]; \ type *queueItem; \ \ if (queue == nil) { \ queue = [OFList list]; \ @@ -818,12 +818,12 @@ \ queueItem = [[[type alloc] init] autorelease]; # define NEW_WRITE(type, object, mode) \ void *pool = objc_autoreleasePoolPush(); \ OFRunLoop *runLoop = [self currentRunLoop]; \ - OFRunLoop_State *state = [runLoop of_stateForMode: mode \ - create: true]; \ + OFRunLoopState *state = [runLoop of_stateForMode: mode \ + create: true]; \ OFList *queue = [state->_writeQueues objectForKey: object]; \ type *queueItem; \ \ if (queue == nil) { \ queue = [OFList list]; \ @@ -849,11 +849,11 @@ # ifdef OF_HAVE_BLOCKS block: (of_stream_async_read_block_t)block # endif delegate: (id )delegate { - NEW_READ(OFRunLoop_ReadQueueItem, stream, mode) + NEW_READ(OFRunLoopReadQueueItem, stream, mode) queueItem->_delegate = [delegate retain]; # ifdef OF_HAVE_BLOCKS queueItem->_block = [block copy]; # endif @@ -871,11 +871,11 @@ # ifdef OF_HAVE_BLOCKS block: (of_stream_async_read_block_t)block # endif delegate: (id )delegate { - NEW_READ(OFRunLoop_ExactReadQueueItem, stream, mode) + NEW_READ(OFRunLoopExactReadQueueItem, stream, mode) queueItem->_delegate = [delegate retain]; # ifdef OF_HAVE_BLOCKS queueItem->_block = [block copy]; # endif @@ -892,11 +892,11 @@ # ifdef OF_HAVE_BLOCKS block: (of_stream_async_read_line_block_t)block # endif delegate: (id )delegate { - NEW_READ(OFRunLoop_ReadLineQueueItem, stream, mode) + NEW_READ(OFRunLoopReadLineQueueItem, stream, mode) queueItem->_delegate = [delegate retain]; # ifdef OF_HAVE_BLOCKS queueItem->_block = [block copy]; # endif @@ -912,11 +912,11 @@ # ifdef OF_HAVE_BLOCKS block: (of_stream_async_write_data_block_t)block # endif delegate: (id )delegate { - NEW_WRITE(OFRunLoop_WriteDataQueueItem, stream, mode) + NEW_WRITE(OFRunLoopWriteDataQueueItem, stream, mode) queueItem->_delegate = [delegate retain]; # ifdef OF_HAVE_BLOCKS queueItem->_block = [block copy]; # endif @@ -933,11 +933,11 @@ # ifdef OF_HAVE_BLOCKS block: (of_stream_async_write_string_block_t)block # endif delegate: (id )delegate { - NEW_WRITE(OFRunLoop_WriteStringQueueItem, stream, mode) + NEW_WRITE(OFRunLoopWriteStringQueueItem, stream, mode) queueItem->_delegate = [delegate retain]; # ifdef OF_HAVE_BLOCKS queueItem->_block = [block copy]; # endif @@ -951,11 +951,11 @@ + (void)of_addAsyncConnectForTCPSocket: (OFTCPSocket *)stream mode: (of_run_loop_mode_t)mode delegate: (id ) delegate { - NEW_WRITE(OFRunLoop_ConnectQueueItem, stream, mode) + NEW_WRITE(OFRunLoopConnectQueueItem, stream, mode) queueItem->_delegate = [delegate retain]; QUEUE_ITEM } @@ -966,11 +966,11 @@ # ifdef OF_HAVE_BLOCKS block: (of_tcp_socket_async_accept_block_t)block # endif delegate: (id )delegate { - NEW_READ(OFRunLoop_AcceptQueueItem, stream, mode) + NEW_READ(OFRunLoopAcceptQueueItem, stream, mode) queueItem->_delegate = [delegate retain]; # ifdef OF_HAVE_BLOCKS queueItem->_block = [block copy]; # endif @@ -986,11 +986,11 @@ block: (of_udp_socket_async_receive_block_t) block # endif delegate: (id )delegate { - NEW_READ(OFRunLoop_UDPReceiveQueueItem, sock, mode) + NEW_READ(OFRunLoopUDPReceiveQueueItem, sock, mode) queueItem->_delegate = [delegate retain]; # ifdef OF_HAVE_BLOCKS queueItem->_block = [block copy]; # endif @@ -1008,11 +1008,11 @@ block: (of_udp_socket_async_send_data_block_t) block # endif delegate: (id )delegate { - NEW_WRITE(OFRunLoop_UDPSendQueueItem, sock, mode) + NEW_WRITE(OFRunLoopUDPSendQueueItem, sock, mode) queueItem->_delegate = [delegate retain]; # ifdef OF_HAVE_BLOCKS queueItem->_block = [block copy]; # endif @@ -1028,12 +1028,12 @@ + (void)of_cancelAsyncRequestsForObject: (id)object mode: (of_run_loop_mode_t)mode { void *pool = objc_autoreleasePoolPush(); OFRunLoop *runLoop = [self currentRunLoop]; - OFRunLoop_State *state = [runLoop of_stateForMode: mode - create: false]; + OFRunLoopState *state = [runLoop of_stateForMode: mode + create: false]; OFList *queue; if (state == nil) return; @@ -1070,15 +1070,15 @@ - (instancetype)init { self = [super init]; @try { - OFRunLoop_State *state; + OFRunLoopState *state; _states = [[OFMutableDictionary alloc] init]; - state = [[OFRunLoop_State alloc] init]; + state = [[OFRunLoopState alloc] init]; @try { [_states setObject: state forKey: of_run_loop_mode_default]; } @finally { [state release]; @@ -1103,23 +1103,23 @@ #endif [super dealloc]; } -- (OFRunLoop_State *)of_stateForMode: (of_run_loop_mode_t)mode - create: (bool)create +- (OFRunLoopState *)of_stateForMode: (of_run_loop_mode_t)mode + create: (bool)create { - OFRunLoop_State *state; + OFRunLoopState *state; #ifdef OF_HAVE_THREADS [_statesMutex lock]; @try { #endif state = [_states objectForKey: mode]; if (create && state == nil) { - state = [[OFRunLoop_State alloc] init]; + state = [[OFRunLoopState alloc] init]; @try { [_states setObject: state forKey: mode]; } @finally { [state release]; @@ -1141,12 +1141,12 @@ } - (void)addTimer: (OFTimer *)timer forMode: (of_run_loop_mode_t)mode { - OFRunLoop_State *state = [self of_stateForMode: mode - create: true]; + OFRunLoopState *state = [self of_stateForMode: mode + create: true]; #ifdef OF_HAVE_THREADS [state->_timersQueueMutex lock]; @try { #endif @@ -1168,12 +1168,12 @@ } - (void)of_removeTimer: (OFTimer *)timer forMode: (of_run_loop_mode_t)mode { - OFRunLoop_State *state = [self of_stateForMode: mode - create: false]; + OFRunLoopState *state = [self of_stateForMode: mode + create: false]; if (state == nil) return; #ifdef OF_HAVE_THREADS @@ -1214,12 +1214,12 @@ - (void)runMode: (of_run_loop_mode_t)mode beforeDate: (OFDate *)deadline { void *pool = objc_autoreleasePoolPush(); of_run_loop_mode_t previousMode = _currentMode; - OFRunLoop_State *state = [self of_stateForMode: mode - create: false]; + OFRunLoopState *state = [self of_stateForMode: mode + create: false]; if (state == nil) return; _currentMode = mode; @@ -1330,12 +1330,12 @@ } } - (void)stop { - OFRunLoop_State *state = [self of_stateForMode: of_run_loop_mode_default - create: false]; + OFRunLoopState *state = [self of_stateForMode: of_run_loop_mode_default + create: false]; _stop = true; if (state == nil) return;