Overview
Comment: | OFStreamSocket: Rework blocks-based API |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
34b4d743ad5c85bb154a31628d6ce493 |
User & Date: | js on 2024-10-27 17:59:38 |
Other Links: | manifest | tags |
Context
2024-10-27
| ||
18:10 | OFTCPSocket: Rework blocks-based API check-in: 9611851a89 user: js tags: trunk | |
17:59 | OFStreamSocket: Rework blocks-based API check-in: 34b4d743ad user: js tags: trunk | |
17:45 | OFStream: Rework blocks-based API check-in: 9808f35fb3 user: js tags: trunk | |
Changes
Modified src/OFINIFile.h from [e05af431e8] to [2c5cdeb94f].
︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | /** * @brief All sections in the INI file. */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFINISection *) *sections; /** * @brief All sections in the INI file. */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFINISection *) *categories OF_DEPRECATED(ObjFW, 1, 2, "Use -[sections] instead"); /** * @brief Creates a new OFINIFile with the contents of the specified file. * | > > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | /** * @brief All sections in the INI file. */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFINISection *) *sections; /** * @brief All sections in the INI file. * * @deprecated Use @ref sections instead. */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFINISection *) *categories OF_DEPRECATED(ObjFW, 1, 2, "Use -[sections] instead"); /** * @brief Creates a new OFINIFile with the contents of the specified file. * |
︙ | ︙ | |||
115 116 117 118 119 120 121 122 123 124 125 126 127 128 | * * @return An @ref OFINISection for the section with the specified name */ - (OFINISection *)sectionForName: (OFString *)name; /** * @brief Returns an @ref OFINISection for the section with the specified name. * * @param name The name of the section for which an @ref OFINISection should be * returned * * @return An @ref OFINISection for the section with the specified name */ - (OFINISection *)categoryForName: (OFString *)name | > > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | * * @return An @ref OFINISection for the section with the specified name */ - (OFINISection *)sectionForName: (OFString *)name; /** * @brief Returns an @ref OFINISection for the section with the specified name. * * @deprecated Use @ref sectionForName: instead. * * @param name The name of the section for which an @ref OFINISection should be * returned * * @return An @ref OFINISection for the section with the specified name */ - (OFINISection *)categoryForName: (OFString *)name |
︙ | ︙ |
Modified src/OFIRIHandler.h from [c30168a6cb] to [e1f63122b7].
︙ | ︙ | |||
316 317 318 319 320 321 322 | * scheme * @throw OFNotImplementedException Getting extended attributes is not * implemented for the specified item */ - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI OF_DEPRECATED(ObjFW, 1, 1, | | | 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | * scheme * @throw OFNotImplementedException Getting extended attributes is not * implemented for the specified item */ - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI OF_DEPRECATED(ObjFW, 1, 1, "Use -[getExtendedAttributeData:andType:forName:ofItemAtIRI:] instead"); /** * @brief Gets the extended attribute data and type for the specified name * of the item at the specified IRI. * * This method is not available for all IRIs. * |
︙ | ︙ | |||
367 368 369 370 371 372 373 | * @throw OFNotImplementedException Setting extended attributes is not * implemented for the specified item */ - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI OF_DEPRECATED(ObjFW, 1, 1, | | | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | * @throw OFNotImplementedException Setting extended attributes is not * implemented for the specified item */ - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI OF_DEPRECATED(ObjFW, 1, 1, "Use -[setExtendedAttributeData:andType:forName:ofItemAtIRI:] instead"); /** * @brief Sets the extended attribute data and type for the specified name of * the item at the specified IRI. * * This method is not available for all IRIs. * Not all IRIs support a non-nil type. |
︙ | ︙ |
Modified src/OFLocale.h from [5301ba1a04] to [b90305cc3a].
︙ | ︙ | |||
146 147 148 149 150 151 152 | /** * @brief Adds a directory to scan for localizations. * * @param IRI The IRI to the directory to scan for localizations */ + (void)addLocalizationDirectoryIRI: (OFIRI *)IRI; | | > > | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | /** * @brief Adds a directory to scan for localizations. * * @param IRI The IRI to the directory to scan for localizations */ + (void)addLocalizationDirectoryIRI: (OFIRI *)IRI; - (instancetype)init OF_DEPRECATED(ObjFW, 1, 1, "Manually creating an OFLocale is no longer necessary. " "Use +[OFLocale currentLocale] instead."); /** * @brief Adds a directory to scan for localizations. * * @param IRI The IRI to the directory to scan for localizations */ - (void)addLocalizationDirectoryIRI: (OFIRI *)IRI; |
︙ | ︙ |
Modified src/OFRunLoop.m from [61bab8a258] to [f9f262d775].
︙ | ︙ | |||
845 846 847 848 849 850 851 | acceptedSocket = nil; exception = e; } # ifdef OF_HAVE_BLOCKS if (_handler != NULL) { if ([object isKindOfClass: [OFStreamSocket class]]) | | | | 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | acceptedSocket = nil; exception = e; } # ifdef OF_HAVE_BLOCKS if (_handler != NULL) { if ([object isKindOfClass: [OFStreamSocket class]]) return ((OFStreamSocketAcceptedHandler) _handler)(object, acceptedSocket, exception); else if ([object isKindOfClass: [OFSequencedPacketSocket class]]) return ((OFSequencedPacketSocketAcceptedHandler) _handler)(object, acceptedSocket, exception); else OFEnsure(0); } else { |
︙ | ︙ |
Modified src/OFStreamSocket.h from [79ca101934] to [e36082946d].
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /** @file */ @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 (^OFStreamSocketAsyncAcceptBlock)(OFStreamSocket *acceptedSocket, | > > | > > > > > > > > > > > > > > | 25 26 27 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 | /** @file */ @class OFStreamSocket; #ifdef OF_HAVE_BLOCKS /** * @brief A block which is called when the socket accepted a connection. * * @deprecated Use OFStreamSocketAcceptedHandler instead. * * @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 (^OFStreamSocketAsyncAcceptBlock)(OFStreamSocket *acceptedSocket, id _Nullable exception) OF_DEPRECATED(ObjFW, 1, 2, "Use OFStreamSocketAcceptedHandler instead"); /** * @brief A handler 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 handler should be used for the next incoming * connection */ typedef bool (^OFStreamSocketAcceptedHandler)(OFStreamSocket *socket, OFStreamSocket *acceptedSocket, id _Nullable exception); #endif /** * @protocol OFStreamSocketDelegate OFStreamSocket.h ObjFW/ObjFW.h * * A delegate for OFStreamSocket. */ |
︙ | ︙ | |||
147 148 149 150 151 152 153 154 155 156 157 158 | * @param runLoopMode The run loop mode in which to perform the async accept */ - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously accept an incoming connection. * * @param block The block to execute when a new connection has been accepted. * Returns whether the next incoming connection should be accepted * by the specified block as well. */ | > > | > > > > > > > > > > > > | > > > > > > > > > > > > > | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | * @param runLoopMode The run loop mode in which to perform the async accept */ - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously accept an incoming connection. * * @deprecated Use @ref asyncAcceptWithHandler: instead. * * @param block The block to execute when a new connection has been accepted. * Returns whether the next incoming connection should be accepted * by the specified block as well. */ - (void)asyncAcceptWithBlock: (OFStreamSocketAsyncAcceptBlock)block OF_DEPRECATED(ObjFW, 1, 2, "Use -[asyncAcceptWithHandler:] instead"); /** * @brief Asynchronously accept an incoming connection. * * @param handler The handler to execute when a new connection has been * accepted. Returns whether the next incoming connection should * be accepted by the specified handler as well. */ - (void)asyncAcceptWithHandler: (OFStreamSocketAcceptedHandler)handler; /** * @brief Asynchronously accept an incoming connection. * * @deprecated Use @ref asyncAcceptWithRunLoopMode:handler: instead. * * @param runLoopMode The run loop mode in which to perform the async accept * @param block The block to execute when a new connection has been accepted. * Returns whether the next incoming connection should be accepted * by the specified block as well. */ - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode block: (OFStreamSocketAsyncAcceptBlock)block OF_DEPRECATED(ObjFW, 1, 2, "Use -[asyncAcceptWithRunLoopMode:handler:] instead"); /** * @brief Asynchronously accept an incoming connection. * * @param runLoopMode The run loop mode in which to perform the async accept * @param handler The handler to execute when a new connection has been * accepted. Returns whether the next incoming connection * should be accepted by the specified handler as well. */ - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode handler: (OFStreamSocketAcceptedHandler)handler; #endif /** * @brief Releases the socket from the current thread. * * This is necessary on some platforms in order to allow a different thread to * use the socket, e.g. on AmigaOS, but you should call it on all operating |
︙ | ︙ |
Modified src/OFStreamSocket.m from [b741fa5166] to [0c4a622463].
︙ | ︙ | |||
336 337 338 339 340 341 342 | handler: NULL delegate: _delegate]; } #ifdef OF_HAVE_BLOCKS - (void)asyncAcceptWithBlock: (OFStreamSocketAsyncAcceptBlock)block { | > > > > > | > > > > > > > > > > > > > > > > > > > | | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | handler: NULL delegate: _delegate]; } #ifdef OF_HAVE_BLOCKS - (void)asyncAcceptWithBlock: (OFStreamSocketAsyncAcceptBlock)block { OFStreamSocketAcceptedHandler handler = ^ (OFStreamSocket *socket, OFStreamSocket *acceptedSocket, id exception) { return block(acceptedSocket, exception); }; [self asyncAcceptWithRunLoopMode: OFDefaultRunLoopMode handler: handler]; } - (void)asyncAcceptWithHandler: (OFStreamSocketAcceptedHandler)handler { [self asyncAcceptWithRunLoopMode: OFDefaultRunLoopMode handler: handler]; } - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode block: (OFStreamSocketAsyncAcceptBlock)block { OFStreamSocketAcceptedHandler handler = ^ (OFStreamSocket *socket, OFStreamSocket *acceptedSocket, id exception) { return block(acceptedSocket, exception); }; [self asyncAcceptWithRunLoopMode: runLoopMode handler: handler]; } - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode handler: (OFStreamSocketAcceptedHandler)handler { [OFRunLoop of_addAsyncAcceptForSocket: self mode: runLoopMode handler: handler delegate: nil]; } #endif - (const OFSocketAddress *)remoteAddress { if (_socket == OFInvalidSocketHandle) |
︙ | ︙ |