ObjFW  Check-in [9e7f4f34b9]

Overview
Comment:OFURLHandler: Make +[handlerForURL:] nonnull
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9e7f4f34b9cc276b9accb4186740bef69d79115da40a602f69e4883fcdbe333c
User & Date: js on 2022-08-11 20:46:11
Other Links: manifest | tags
Context
2022-08-11
20:54
OFURLHandler: Add +[openItemAtURL:mode:] check-in: 338d452f33 user: js tags: trunk
20:46
OFURLHandler: Make +[handlerForURL:] nonnull check-in: 9e7f4f34b9 user: js tags: trunk
2022-08-10
21:38
objfw-new: Add short options check-in: 03227c8a54 user: js tags: trunk
Changes

Modified src/OFURLHandler.h from [0e58f1d36b] to [3680d34e27].

54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
54
55
56
57
58
59
60

61
62
63
64
65
66
67
68







-
+







+ (bool)registerClass: (Class)class_ forScheme: (OFString *)scheme;

/**
 * @brief Returns the handler for the specified URL.
 *
 * @return The handler for the specified URL.
 */
+ (nullable OF_KINDOF(OFURLHandler *))handlerForURL: (OFURL *)URL;
+ (OF_KINDOF(OFURLHandler *))handlerForURL: (OFURL *)URL;

- (instancetype)init OF_UNAVAILABLE;

/**
 * @brief Initializes the handler for the specified scheme.
 *
 * @param scheme The scheme to initialize for

Modified src/OFURLHandler.m from [c3c8bcc62a] to [fd7a23df40].

27
28
29
30
31
32
33


34
35
36
37
38
39
40
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42







+
+







#import "OFEmbeddedFileURLHandler.h"
#ifdef OF_HAVE_FILES
# import "OFFileURLHandler.h"
#endif
#if defined(OF_HAVE_SOCKETS) && defined(OF_HAVE_THREADS)
# import "OFHTTPURLHandler.h"
#endif

#import "OFUnsupportedProtocolException.h"

static OFMutableDictionary OF_GENERIC(OFString *, OFURLHandler *) *handlers;
#ifdef OF_HAVE_THREADS
static OFMutex *mutex;

static void
releaseMutex(void)
105
106
107
108
109
110
111



112
113
114
115
116
117
118
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123







+
+
+







		handler = [handlers objectForKey: URL.scheme];
#ifdef OF_HAVE_THREADS
	} @finally {
		[mutex unlock];
	}
#endif

	if (handler == nil)
		@throw [OFUnsupportedProtocolException exceptionWithURL: URL];

	return handler;
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}