ObjFW  Check-in [ba62f00fac]

Overview
Comment:Clean up optional protocols

Now that we can require GCC >= 4.6, we no longer need to have a category
on OFObject that adds the optional protocol to it.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ba62f00faca3833a745b94527e123fa0ac55b5ccf215a72ab6ae6aa112e431f7
User & Date: js on 2015-11-29 14:20:53
Other Links: manifest | tags
Context
2015-11-29
14:23
Clean up class extensions check-in: 2aca549d60 user: js tags: trunk
14:20
Clean up optional protocols check-in: ba62f00fac user: js tags: trunk
14:02
Make use of fast enumeration check-in: 6b13727ce0 user: js tags: trunk
Changes

Modified src/OFApplication.h from [91ca5aaec7] to [3d009b0fda].

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
41
42
43
44
45
46
47

48

49
50
51
52
53
54
55







-

-







@protocol OFApplicationDelegate <OFObject>
/*!
 * @brief A method which is called when the application was initialized and is
 *	  running now.
 */
- (void)applicationDidFinishLaunching;

#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
/*!
 * @brief A method which is called when the application will terminate.
 */
- (void)applicationWillTerminate;

/*!
 * @brief A method which is called when the application received a SIGINT.
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
216
217
218
219
220
221
222



223
224
225
226
227
228
229
230
231
232







-
-
-










 * @brief Terminates the application with the specified status.
 *
 * @param status The status with which the application will terminate
 */
- (void)terminateWithStatus: (int)status OF_NO_RETURN;
@end

@interface OFObject (OFApplicationDelegate) <OFApplicationDelegate>
@end

#ifdef __cplusplus
extern "C" {
#endif
extern int of_application_main(int *_Nonnull, char *_Nonnull *_Nonnull[],
    Class);
#ifdef __cplusplus
}
#endif

OF_ASSUME_NONNULL_END

Modified src/OFHTTPClient.h from [ed0609a453] to [b45a098c16].

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
32
33
34
35
36
37
38

39

40
41
42
43
44
45
46







-

-








/*!
 * @protocol OFHTTPClientDelegate OFHTTPClient.h ObjFW/OFHTTPClient.h
 *
 * @brief A delegate for OFHTTPClient.
 */
@protocol OFHTTPClientDelegate <OFObject>
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
/*!
 * @brief A callback which is called when an OFHTTPClient creates a socket.
 *
 * This is useful if the connection is using HTTPS and the server requires a
 * client certificate. This callback can then be used to tell the TLS socket
 * about the certificate. Another use case is to tell the socket about a SOCKS5
 * proxy it should use for this connection.
147
148
149
150
151
152
153
154
155
156
157
145
146
147
148
149
150
151



152







-
-
-


/*!
 * @brief Closes connections that are still open due to keep-alive.
 */
- (void)close;
@end

@interface OFObject (OFHTTPClientDelegate) <OFHTTPClientDelegate>
@end

OF_ASSUME_NONNULL_END

Modified src/OFHTTPServer.h from [c2a9a2ca01] to [3703de943a].

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
42
43
44
45
46
47
48

49

50
51
52
53
54
55
56







-

-







 * @param request The request the HTTP server received
 * @param response The response the server will send to the client
 */
-      (void)server: (OFHTTPServer*)server
  didReceiveRequest: (OFHTTPRequest*)request
	   response: (OFHTTPResponse*)response;

#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
/*!
 * @brief This method is called when the HTTP server's listening socket
 *	  encountered an exception.
 *
 * @param server The HTTP server which encountered an exception
 * @param exception The exception which occurred on the HTTP server's listening
 *		    socket
114
115
116
117
118
119
120
121
122
123
124
112
113
114
115
116
117
118



119







-
-
-

 * @brief Stops the HTTP server, meaning it will not accept any new incoming
 *	  connections, but still handle existing connections until they are
 *	  finished or timed out.
 */
- (void)stop;
@end

@interface OFObject (OFHTTPServerDelegate) <OFHTTPServerDelegate>
@end

OF_ASSUME_NONNULL_END

Modified src/OFKernelEventObserver.h from [9901acfc70] to [44498ce7a3].

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
32
33
34
35
36
37
38

39

40
41
42
43
44
45
46







-

-







 * @protocol OFKernelEventObserverDelegate
 *	     OFKernelEventObserver.h ObjFW/OFKernelEventObserver.h
 *
 * @brief A protocol that needs to be implemented by delegates for
 *	  OFKernelEventObserver.
 */
@protocol OFKernelEventObserverDelegate <OFObject>
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
/*!
 * @brief This callback is called when an object did get ready for reading.
 *
 * @note If the object is a subclass of @ref OFStream and
 *	 @ref OFStream::tryReadLine or @ref OFStream::tryReadTillDelimiter: has
 *	 been called on the stream, this callback will not be called again
 *	 until new data has been received, even though there is still data in
211
212
213
214
215
216
217
218
219
220
221
222
209
210
211
212
213
214
215




216







-
-
-
-

 * This is automatically done when a new object is added or removed by another
 * thread, but in some circumstances, it might be desirable for a thread to
 * manually stop the observe running in another thread.
 */
- (void)cancel;
@end

@interface OFObject (OFKernelEventObserverDelegate)
    <OFKernelEventObserverDelegate>
@end

OF_ASSUME_NONNULL_END

Modified src/OFRunLoop.h from [0b6d167631] to [0570a5632d].

34
35
36
37
38
39
40



41
42
43
44
45
46
47
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50







+
+
+








/*!
 * @class OFRunLoop OFRunLoop.h ObjFW/OFRunLoop.h
 *
 * @brief A class providing a run loop for the application and its processes.
 */
@interface OFRunLoop: OFObject
#ifdef OF_HAVE_SOCKETS
    <OFKernelEventObserverDelegate>
#endif
{
	OFSortedList *_timersQueue;
#ifdef OF_HAVE_THREADS
	OFMutex *_timersQueueLock;
#endif
#if defined(OF_HAVE_SOCKETS)
	OFKernelEventObserver *_kernelEventObserver;

Modified src/OFTLSSocket.h from [991f7cbecd] to [48c2664a3c].

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
24
25
26
27
28
29
30

31

32
33
34
35
36
37
38







-

-








/*!
 * @protocol OFTLSSocketDelegate OFTLSSocket.h ObjFW/OFTLSSocket.h
 *
 * @brief A delegate for classes implementing the OFTLSSocket protocol.
 */
@protocol OFTLSSocketDelegate
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
/*!
 * @brief This callback is called when the TLS socket wants to know if it
 *	  should accept the received certificate.
 *
 * @note This is only used to verify certain fields of a certificate to allow
 *	 for protocol specific verification. The certificate chain is verified
 *	 using the specified CAs, or the system's CAs if no CAs have been

Modified src/OFXMLElement.m from [767015e338] to [0e6e8212ad].

43
44
45
46
47
48
49

50
51
52
53
54
55
56
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57







+







	_OFXMLElement_Serialization_reference = 1;
}

static Class charactersClass = Nil;
static Class CDATAClass = Nil;

@interface OFXMLElement_OFXMLElementBuilderDelegate: OFObject
    <OFXMLElementBuilderDelegate>
{
@public
	OFXMLElement *_element;
}
@end

@implementation OFXMLElement_OFXMLElementBuilderDelegate

Modified src/OFXMLElementBuilder.h from [697471ead5] to [849e97808f].

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
40
41
42
43
44
45
46

47


48
49
50
51
52
53
54







-

-
-







 *
 * @param builder The builder which built an OFXMLElement
 * @param element The OFXMLElement the OFXMLElementBuilder built
 */
- (void)elementBuilder: (OFXMLElementBuilder*)builder
       didBuildElement: (OFXMLElement*)element;

#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif

/*!
 * @brief This callback is called when the OFXMLElementBuilder built an
 *	  OFXMLNode which is not inside an element.
 *
 * This is usually called for comments or whitespace character data before the
 * root element.
 *
122
123
124
125
126
127
128
129
130
131
132
119
120
121
122
123
124
125



126







-
-
-

 * @brief Creates a new element builder.
 *
 * @return A new, autoreleased OFXMLElementBuilder
 */
+ (instancetype)elementBuilder;
@end

@interface OFObject (OFXMLElementBuilderDelegate) <OFXMLElementBuilderDelegate>
@end

OF_ASSUME_NONNULL_END

Modified src/OFXMLParser.h from [2c5b933e84] to [76cf63d8b1].

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
31
32
33
34
35
36
37

38

39
40
41
42
43
44
45







-

-








/*!
 * @protocol OFXMLParserDelegate OFXMLParser.h ObjFW/OFXMLParser.h
 *
 * @brief A protocol that needs to be implemented by delegates for OFXMLParser.
 */
@protocol OFXMLParserDelegate <OFObject>
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
/*!
 * @brief This callback is called when the XML parser found processing
 *	  instructions.
 *
 * @param parser The parser which found processing instructions
 * @param pi The processing instructions
 */
241
242
243
244
245
246
247
248
249
250
251
239
240
241
242
243
244
245



246







-
-
-

 * @brief Returns whether the XML parser has finished parsing.
 *
 * @return Whether the XML parser has finished parsing
 */
- (bool)hasFinishedParsing;
@end

@interface OFObject (OFXMLParserDelegate) <OFXMLParserDelegate>
@end

OF_ASSUME_NONNULL_END

Modified tests/OFKernelEventObserverTests.m from [c39307bdbd] to [87b1a72a6f].

37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51







-
+








#import "TestsAppDelegate.h"

#define EXPECTED_EVENTS 3

static OFString *module;

@interface ObserverTest: OFObject
@interface ObserverTest: OFObject <OFKernelEventObserverDelegate>
{
@public
	TestsAppDelegate *_testsAppDelegate;
	OFKernelEventObserver *_observer;
	OFTCPSocket *_server, *_client, *_accepted;
	size_t _events;
}

Modified tests/TestsAppDelegate.h from [7b05c7a3ed] to [95d00013c4].

196
197
198
199
200
201
202
203


204
205
196
197
198
199
200
201
202

203
204
205
206







-
+
+


- (void)XMLElementBuilderTests;
@end

@interface TestsAppDelegate (OFXMLNodeTests)
- (void)XMLNodeTests;
@end

@interface TestsAppDelegate (OFXMLParserTests) <OFXMLElementBuilderDelegate>
@interface TestsAppDelegate (OFXMLParserTests)
    <OFXMLParserDelegate, OFXMLElementBuilderDelegate>
- (void)XMLParserTests;
@end

Modified utils/ofhttp/OFHTTP.m from [bdce356a5d] to [545bac3fa9].

45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
45
46
47
48
49
50
51

52
53
54
55
56
57
58
59







-
+








#import "ProgressBar.h"

#define GIBIBYTE (1024 * 1024 * 1024)
#define MEBIBYTE (1024 * 1024)
#define KIBIBYTE (1024)

@interface OFHTTP: OFObject
@interface OFHTTP: OFObject <OFHTTPClientDelegate>
{
	OFArray OF_GENERIC(OFString*) *_URLs;
	size_t _URLIndex;
	int _errorCode;
	OFString *_outputPath;
	bool _continue, _detectFileName, _quiet, _verbose;
	OFDataArray *_body;