ObjFW  Check-in [5116a3709c]

Overview
Comment:runtime.h: Never undefine _Nullable / _Nonnull
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5116a3709c81bdf5eccee8200b2b4e611f7253220050ea653e6522ce1bca7b20
User & Date: js on 2017-05-16 23:22:20
Other Links: manifest | tags
Context
2017-05-17
00:13
Add in_addr_t for MorphOS check-in: c7a45d0140 user: js tags: trunk
2017-05-16
23:22
runtime.h: Never undefine _Nullable / _Nonnull check-in: 5116a3709c user: js tags: trunk
22:58
threading.h: Remove unconditional sched.h include check-in: 510158d026 user: js tags: trunk
Changes

Modified src/runtime/runtime-private.h from [732df9cb69] to [69fcb5506f].

14
15
16
17
18
19
20
21
22
23






24
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
64
65
66





67
68
69
70
71


72
73
74
75
76
77
78
79
80
81


82
83
84
85
86

87
88
89

90
91
92
93
94
95
96


97
98
99
100

101
102
103
104
105
106
107



108
109

110
111
112
113
114
115


116
117
118
119
120
121
122
123
124


125
126

127
128

129
130
131
132
133



134
135
136
137
138
139






140
141
142
143
144
145






146
147
148
149
150
151
152
153
154
155
156









157
158
159
160
161
162
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
14
15
16
17
18
19
20



21
22
23
24
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
64





65
66
67
68
69
70
71
72


73
74
75
76
77
78
79
80
81
82


83
84
85
86
87
88

89
90
91

92
93
94
95
96
97


98
99
100
101
102

103
104
105
106
107



108
109
110
111

112
113
114
115
116


117
118
119
120
121
122
123
124
125


126
127
128

129
130

131
132
133



134
135
136
137





138
139
140
141
142
143
144





145
146
147
148
149
150
151
152









153
154
155
156
157
158
159
160
161
162












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







-
-
-
+
+
+
+
+
+



-
-
-
+
+
+



-
-
-
-
-
-
-
+
+
+
+
+
+
+

-
-
+
+



-
-
+
+




-
+



-
+





-
-
-
-
-
+
+
+
+
+



-
-
+
+








-
-
+
+




-
+


-
+





-
-
+
+



-
+




-
-
-
+
+
+

-
+




-
-
+
+







-
-
+
+

-
+

-
+


-
-
-
+
+
+

-
-
-
-
-
+
+
+
+
+
+

-
-
-
-
-
+
+
+
+
+
+


-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+

-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+

-
+











-
-
+
+







 * file.
 */

#include "config.h"

#include "platform.h"

#if !defined(__has_feature) || !__has_feature(nullability)
# define _Nonnull
# define _Nullable
#if defined(__has_feature) && __has_feature(nullability)
# define OBJC_NONNULL _Nonnull
# define OBJC_NULLABLE _Nullable
#else
# define OBJC_NONNULL
# define OBJC_NULLABLE
#endif

struct objc_abi_class {
	struct objc_abi_class *_Nonnull metaclass;
	const char *_Nullable superclass;
	const char *_Nonnull name;
	struct objc_abi_class *OBJC_NONNULL metaclass;
	const char *OBJC_NULLABLE superclass;
	const char *OBJC_NONNULL name;
	unsigned long version;
	unsigned long info;
	long instance_size;
	void *_Nullable ivars;
	struct objc_abi_method_list *_Nullable methodlist;
	void *_Nullable dtable;
	void *_Nullable subclass_list;
	void *_Nullable sibling_class;
	void *_Nullable protocols;
	void *_Nullable gc_object_type;
	void *OBJC_NULLABLE ivars;
	struct objc_abi_method_list *OBJC_NULLABLE methodlist;
	void *OBJC_NULLABLE dtable;
	void *OBJC_NULLABLE subclass_list;
	void *OBJC_NULLABLE sibling_class;
	void *OBJC_NULLABLE protocols;
	void *OBJC_NULLABLE gc_object_type;
	long abi_version;
	int32_t *_Nonnull *_Nullable ivar_offsets;
	void *_Nullable properties;
	int32_t *OBJC_NONNULL *OBJC_NULLABLE ivar_offsets;
	void *OBJC_NULLABLE properties;
};

struct objc_abi_selector {
	const char *_Nonnull name;
	const char *_Nullable types;
	const char *OBJC_NONNULL name;
	const char *OBJC_NULLABLE types;
};

struct objc_abi_method {
	struct objc_abi_selector sel;
	IMP _Nonnull imp;
	IMP OBJC_NONNULL imp;
};

struct objc_abi_method_list {
	struct objc_abi_method_list *_Nullable next;
	struct objc_abi_method_list *OBJC_NULLABLE next;
	unsigned int count;
	struct objc_abi_method methods[1];
};

struct objc_abi_category {
	const char *_Nonnull category_name;
	const char *_Nonnull class_name;
	struct objc_abi_method_list *_Nullable instance_methods;
	struct objc_abi_method_list *_Nullable class_methods;
	struct objc_protocol_list *_Nullable protocols;
	const char *OBJC_NONNULL category_name;
	const char *OBJC_NONNULL class_name;
	struct objc_abi_method_list *OBJC_NULLABLE instance_methods;
	struct objc_abi_method_list *OBJC_NULLABLE class_methods;
	struct objc_protocol_list *OBJC_NULLABLE protocols;
};

struct objc_abi_method_description {
	const char *_Nonnull name;
	const char *_Nonnull types;
	const char *OBJC_NONNULL name;
	const char *OBJC_NONNULL types;
};

struct objc_abi_method_description_list {
	int count;
	struct objc_abi_method_description list[1];
};

struct objc_abi_static_instances {
	const char *_Nonnull class_name;
	id _Nullable instances[1];
	const char *OBJC_NONNULL class_name;
	id OBJC_NULLABLE instances[1];
};

struct objc_abi_symtab {
	unsigned long unknown;
	struct objc_abi_selector *_Nullable sel_refs;
	struct objc_abi_selector *OBJC_NULLABLE sel_refs;
	uint16_t cls_def_cnt;
	uint16_t cat_def_cnt;
	void *_Nonnull defs[1];
	void *OBJC_NONNULL defs[1];
};

struct objc_abi_module {
	unsigned long version;	/* 9 = non-fragile */
	unsigned long size;
	const char *_Nullable name;
	struct objc_abi_symtab *_Nonnull symtab;
	const char *OBJC_NULLABLE name;
	struct objc_abi_symtab *OBJC_NONNULL symtab;
};

struct objc_hashtable_bucket {
	const void *_Nonnull key, *_Nonnull obj;
	const void *OBJC_NONNULL key, *OBJC_NONNULL obj;
	uint32_t hash;
};

struct objc_hashtable {
	uint32_t (*_Nonnull hash)(const void *_Nonnull key);
	bool (*_Nonnull equal)(const void *_Nonnull key1,
	    const void *_Nonnull key2);
	uint32_t (*OBJC_NONNULL hash)(const void *OBJC_NONNULL key);
	bool (*OBJC_NONNULL equal)(const void *OBJC_NONNULL key1,
	    const void *OBJC_NONNULL key2);
	uint32_t count, size;
	struct objc_hashtable_bucket *_Nonnull *_Nullable data;
	struct objc_hashtable_bucket *OBJC_NONNULL *OBJC_NULLABLE data;
};

struct objc_sparsearray {
	struct objc_sparsearray_data {
		void *_Nullable next[256];
	} *_Nonnull data;
		void *OBJC_NULLABLE next[256];
	} *OBJC_NONNULL data;
	uint8_t index_size;
};

struct objc_dtable {
	struct objc_dtable_level2 {
#ifdef OF_SELUID24
		struct objc_dtable_level3 {
			IMP _Nullable buckets[256];
		} *_Nonnull buckets[256];
			IMP OBJC_NULLABLE buckets[256];
		} *OBJC_NONNULL buckets[256];
#else
		IMP _Nullable buckets[256];
		IMP OBJC_NULLABLE buckets[256];
#endif
	} *_Nonnull buckets[256];
	} *OBJC_NONNULL buckets[256];
};

extern void objc_register_all_categories(struct objc_abi_symtab *_Nonnull);
extern struct objc_category *_Nullable *_Nullable
    objc_categories_for_class(Class _Nonnull);
extern void objc_register_all_categories(struct objc_abi_symtab *OBJC_NONNULL);
extern struct objc_category *OBJC_NULLABLE *OBJC_NULLABLE
    objc_categories_for_class(Class OBJC_NONNULL);
extern void objc_unregister_all_categories(void);
extern void objc_initialize_class(Class _Nonnull);
extern void objc_update_dtable(Class _Nonnull);
extern void objc_register_all_classes(struct objc_abi_symtab *_Nonnull);
extern Class _Nullable objc_classname_to_class(const char *_Nonnull, bool);
extern void objc_unregister_class(Class _Nonnull);
extern void objc_initialize_class(Class OBJC_NONNULL);
extern void objc_update_dtable(Class OBJC_NONNULL);
extern void objc_register_all_classes(struct objc_abi_symtab *OBJC_NONNULL);
extern Class OBJC_NULLABLE objc_classname_to_class(const char *OBJC_NONNULL,
    bool);
extern void objc_unregister_class(Class OBJC_NONNULL);
extern void objc_unregister_all_classes(void);
extern uint32_t objc_hash_string(const void *_Nonnull);
extern bool objc_equal_string(const void *_Nonnull, const void *_Nonnull);
extern struct objc_hashtable *_Nonnull objc_hashtable_new(
    uint32_t (*_Nonnull)(const void *_Nonnull),
    bool (*_Nonnull)(const void *_Nonnull, const void *_Nonnull),
extern uint32_t objc_hash_string(const void *OBJC_NONNULL);
extern bool objc_equal_string(const void *OBJC_NONNULL,
    const void *OBJC_NONNULL);
extern struct objc_hashtable *OBJC_NONNULL objc_hashtable_new(
    uint32_t (*OBJC_NONNULL)(const void *OBJC_NONNULL),
    bool (*OBJC_NONNULL)(const void *OBJC_NONNULL, const void *OBJC_NONNULL),
    uint32_t);
extern struct objc_hashtable_bucket objc_deleted_bucket;
extern void objc_hashtable_set(struct objc_hashtable *_Nonnull,
    const void *_Nonnull, const void *_Nonnull);
extern void *_Nullable objc_hashtable_get(struct objc_hashtable *_Nonnull,
    const void *_Nonnull);
extern void objc_hashtable_delete(struct objc_hashtable *_Nonnull,
    const void *_Nonnull);
extern void objc_hashtable_free(struct objc_hashtable *_Nonnull);
extern void objc_register_selector(struct objc_abi_selector *_Nonnull);
extern void objc_register_all_selectors(struct objc_abi_symtab *_Nonnull);
extern void objc_hashtable_set(struct objc_hashtable *OBJC_NONNULL,
    const void *OBJC_NONNULL, const void *OBJC_NONNULL);
extern void *OBJC_NULLABLE objc_hashtable_get(
    struct objc_hashtable *OBJC_NONNULL, const void *OBJC_NONNULL);
extern void objc_hashtable_delete(struct objc_hashtable *OBJC_NONNULL,
    const void *OBJC_NONNULL);
extern void objc_hashtable_free(struct objc_hashtable *OBJC_NONNULL);
extern void objc_register_selector(struct objc_abi_selector *OBJC_NONNULL);
extern void objc_register_all_selectors(struct objc_abi_symtab *OBJC_NONNULL);
extern void objc_unregister_all_selectors(void);
extern struct objc_sparsearray *_Nonnull objc_sparsearray_new(uint8_t);
extern void *_Nullable objc_sparsearray_get(struct objc_sparsearray *_Nonnull,
    uintptr_t);
extern void objc_sparsearray_set(struct objc_sparsearray *_Nonnull, uintptr_t,
    void *_Nullable);
extern void objc_sparsearray_free(struct objc_sparsearray *_Nonnull);
extern struct objc_dtable *_Nonnull objc_dtable_new(void);
extern void objc_dtable_copy(struct objc_dtable *_Nonnull,
    struct objc_dtable *_Nonnull);
extern void objc_dtable_set(struct objc_dtable *_Nonnull, uint32_t,
    IMP _Nullable);
extern void objc_dtable_free(struct objc_dtable *_Nonnull);
extern struct objc_sparsearray *OBJC_NONNULL objc_sparsearray_new(uint8_t);
extern void *OBJC_NULLABLE objc_sparsearray_get(
    struct objc_sparsearray *OBJC_NONNULL, uintptr_t);
extern void objc_sparsearray_set(struct objc_sparsearray *OBJC_NONNULL,
    uintptr_t, void *OBJC_NULLABLE);
extern void objc_sparsearray_free(struct objc_sparsearray *OBJC_NONNULL);
extern struct objc_dtable *OBJC_NONNULL objc_dtable_new(void);
extern void objc_dtable_copy(struct objc_dtable *OBJC_NONNULL,
    struct objc_dtable *OBJC_NONNULL);
extern void objc_dtable_set(struct objc_dtable *OBJC_NONNULL, uint32_t,
    IMP OBJC_NULLABLE);
extern void objc_dtable_free(struct objc_dtable *OBJC_NONNULL);
extern void objc_dtable_cleanup(void);
extern void objc_init_static_instances(struct objc_abi_symtab *_Nonnull);
extern void objc_init_static_instances(struct objc_abi_symtab *OBJC_NONNULL);
extern void objc_forget_pending_static_instances(void);
#ifdef OF_HAVE_THREADS
extern void objc_global_mutex_lock(void);
extern void objc_global_mutex_unlock(void);
extern void objc_global_mutex_free(void);
#else
# define objc_global_mutex_lock()
# define objc_global_mutex_unlock()
# define objc_global_mutex_free()
#endif

static inline IMP _Nullable
objc_dtable_get(const struct objc_dtable *_Nonnull dtable, uint32_t idx)
static inline IMP OBJC_NULLABLE
objc_dtable_get(const struct objc_dtable *OBJC_NONNULL dtable, uint32_t idx)
{
#ifdef OF_SELUID24
	uint8_t i = idx >> 16;
	uint8_t j = idx >>  8;
	uint8_t k = idx;

	return dtable->buckets[i]->buckets[j]->buckets[k];
218
219
220
221
222
223
224
225
226
227


228
223
224
225
226
227
228
229



230
231








-
-
-
+
+
-
	{								\
		fprintf(stderr, "[objc @ " __FILE__ ":%d] ", __LINE__);	\
		fprintf(stderr, __VA_ARGS__);				\
		fputs("\n", stderr);					\
		abort();						\
	}

#if !defined(__has_feature) || !__has_feature(nullability)
# undef _Nonnull
# undef _Nullable
#undef OBJC_NONNULL
#undef OBJC_NULLABLE
#endif

Modified src/runtime/runtime.h from [c2bf2e5fcb] to [134f947253].

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
64
65
66
67



68
69
70
71
72



73
74
75
76
77
78
79
80
81
82







83
84
85


86
87
88
89
90
91
92
93
94
95
96
97
98
99

100
101
102
103
104

105
106
107
108
109


110
111
112
113
114

115
116
117
118

119
120
121
122
123
124
125
126
127
128





129
130
131
132
133


134
135
136
137
138
139
140
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
64
65
66
67



68
69
70
71
72



73
74
75
76
77
78







79
80
81
82
83
84
85
86


87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

102
103
104
105
106

107
108
109
110


111
112
113
114
115
116

117
118
119
120

121
122
123
124
125
126





127
128
129
130
131
132
133
134


135
136
137
138
139
140
141
142
143







-
-
-
+
+
+
+
+
+

















-
-
-
+
+
+


-
-
-
+
+
+



-
-
-
-
-
-
-
+
+
+
+
+
+
+

-
-
+
+













-
+




-
+



-
-
+
+




-
+



-
+





-
-
-
-
-
+
+
+
+
+



-
-
+
+








#if __has_feature(objc_arc)
# define OBJC_UNSAFE_UNRETAINED __unsafe_unretained
#else
# define OBJC_UNSAFE_UNRETAINED
#endif

#if !__has_feature(nullability)
# define _Nonnull
# define _Nullable
#if __has_feature(nullability)
# define OBJC_NONNULL _Nonnull
# define OBJC_NULLABLE _Nullable
#else
# define OBJC_NONNULL
# define OBJC_NULLABLE
#endif

#if __has_attribute(__objc_root_class__)
# define OBJC_ROOT_CLASS __attribute__((__objc_root_class__))
#else
# define OBJC_ROOT_CLASS
#endif

#define Nil (Class)0
#define nil (id)0
#define YES (BOOL)1
#define NO  (BOOL)0

typedef struct objc_class *Class;
typedef struct objc_object *id;
typedef const struct objc_selector *SEL;
typedef signed char BOOL;
typedef id _Nullable (*IMP)(id _Nonnull, SEL _Nonnull, ...);
typedef void (*objc_uncaught_exception_handler)(id _Nullable);
typedef void (*objc_enumeration_mutation_handler)(id _Nonnull);
typedef id OBJC_NULLABLE (*IMP)(id OBJC_NONNULL, SEL OBJC_NONNULL, ...);
typedef void (*objc_uncaught_exception_handler)(id OBJC_NULLABLE);
typedef void (*objc_enumeration_mutation_handler)(id OBJC_NONNULL);

struct objc_class {
	Class _Nonnull isa;
	Class _Nullable superclass;
	const char *_Nonnull name;
	Class OBJC_NONNULL isa;
	Class OBJC_NULLABLE superclass;
	const char *OBJC_NONNULL name;
	unsigned long version;
	unsigned long info;
	long instance_size;
	struct objc_ivar_list *_Nullable ivars;
	struct objc_method_list *_Nullable methodlist;
	struct objc_dtable *_Nullable dtable;
	Class _Nonnull *_Nullable subclass_list;
	void *_Nullable sibling_class;
	struct objc_protocol_list *_Nullable protocols;
	void *_Nullable gc_object_type;
	struct objc_ivar_list *OBJC_NULLABLE ivars;
	struct objc_method_list *OBJC_NULLABLE methodlist;
	struct objc_dtable *OBJC_NULLABLE dtable;
	Class OBJC_NONNULL *OBJC_NULLABLE subclass_list;
	void *OBJC_NULLABLE sibling_class;
	struct objc_protocol_list *OBJC_NULLABLE protocols;
	void *OBJC_NULLABLE gc_object_type;
	unsigned long abi_version;
	int32_t *_Nonnull *_Nullable ivar_offsets;
	struct objc_property_list *_Nullable properties;
	int32_t *OBJC_NONNULL *OBJC_NULLABLE ivar_offsets;
	struct objc_property_list *OBJC_NULLABLE properties;
};

enum objc_class_info {
	OBJC_CLASS_INFO_CLASS	    = 0x001,
	OBJC_CLASS_INFO_METACLASS   = 0x002,
	OBJC_CLASS_INFO_NEW_ABI	    = 0x010,
	OBJC_CLASS_INFO_SETUP	    = 0x100,
	OBJC_CLASS_INFO_LOADED	    = 0x200,
	OBJC_CLASS_INFO_DTABLE	    = 0x400,
	OBJC_CLASS_INFO_INITIALIZED = 0x800
};

struct objc_object {
	Class _Nonnull isa;
	Class OBJC_NONNULL isa;
};

struct objc_selector {
	uintptr_t uid;
	const char *_Nullable types;
	const char *OBJC_NULLABLE types;
};

struct objc_super {
	id OBJC_UNSAFE_UNRETAINED _Nullable self;
	Class _Nonnull cls;
	id OBJC_UNSAFE_UNRETAINED OBJC_NULLABLE self;
	Class OBJC_NONNULL cls;
};

struct objc_method {
	struct objc_selector sel;
	IMP _Nonnull imp;
	IMP OBJC_NONNULL imp;
};

struct objc_method_list {
	struct objc_method_list *_Nullable next;
	struct objc_method_list *OBJC_NULLABLE next;
	unsigned int count;
	struct objc_method methods[1];
};

struct objc_category {
	const char *_Nonnull category_name;
	const char *_Nonnull class_name;
	struct objc_method_list *_Nullable instance_methods;
	struct objc_method_list *_Nullable class_methods;
	struct objc_protocol_list *_Nullable protocols;
	const char *OBJC_NONNULL category_name;
	const char *OBJC_NONNULL class_name;
	struct objc_method_list *OBJC_NULLABLE instance_methods;
	struct objc_method_list *OBJC_NULLABLE class_methods;
	struct objc_protocol_list *OBJC_NULLABLE protocols;
};

struct objc_ivar {
	const char *_Nonnull name;
	const char *_Nonnull type;
	const char *OBJC_NONNULL name;
	const char *OBJC_NONNULL type;
	unsigned int offset;
};

struct objc_ivar_list {
	unsigned int count;
	struct objc_ivar ivars[1];
};
157
158
159
160
161
162
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239






































240
241
242
243
244





245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
















268
269

270
271

272
273

274
275
276
277


278
279
280
281
282
283
284
285
286
160
161
162
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248




249
250
251
252
253
254
255
256
257
258
259
260
261















262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278

279
280

281
282

283
284
285
286
287
288
289
290
291
292



293









-
+


-
-
+
+





-
+











-
-
-
-
-
+
+
+
+
+








-
+

-
+





-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
-
-
-
+
+
+
+
+








-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
+

-
+

-
+




+
+



-
-
-

-
-
	OBJC_PROPERTY_ATOMIC		=  0x4,
	OBJC_PROPERTY_WEAK		=  0x8,
	OBJC_PROPERTY_STRONG		= 0x10,
	OBJC_PROPERTY_UNSAFE_UNRETAINED = 0x20
};

struct objc_property {
	const char *_Nonnull name;
	const char *OBJC_NONNULL name;
	unsigned char attributes, extended_attributes;
	struct {
		const char *_Nullable name;
		const char *_Nullable type;
		const char *OBJC_NULLABLE name;
		const char *OBJC_NULLABLE type;
	} getter, setter;
};

struct objc_property_list {
	unsigned int count;
	struct objc_property_list *_Nullable next;
	struct objc_property_list *OBJC_NULLABLE next;
	struct objc_property properties[1];
};

#ifdef __OBJC__
OBJC_ROOT_CLASS
@interface Protocol
{
@public
#else
typedef struct {
#endif
	Class _Nonnull isa;
	const char *_Nonnull name;
	struct objc_protocol_list *_Nullable protocol_list;
	struct objc_abi_method_description_list *_Nullable instance_methods;
	struct objc_abi_method_description_list *_Nullable class_methods;
	Class OBJC_NONNULL isa;
	const char *OBJC_NONNULL name;
	struct objc_protocol_list *OBJC_NULLABLE protocol_list;
	struct objc_abi_method_description_list *OBJC_NULLABLE instance_methods;
	struct objc_abi_method_description_list *OBJC_NULLABLE class_methods;
#ifdef __OBJC__
}
@end
#else
} Protocol;
#endif

struct objc_protocol_list {
	struct objc_protocol_list *_Nullable next;
	struct objc_protocol_list *OBJC_NULLABLE next;
	long count;
	Protocol *OBJC_UNSAFE_UNRETAINED _Nonnull list[1];
	Protocol *OBJC_UNSAFE_UNRETAINED OBJC_NONNULL list[1];
};

#ifdef __cplusplus
extern "C" {
#endif
extern SEL _Nonnull sel_registerName(const char *_Nonnull);
extern const char *_Nonnull sel_getName(SEL _Nonnull);
extern bool sel_isEqual(SEL _Nonnull, SEL _Nonnull);
extern Class _Nonnull objc_allocateClassPair(Class _Nullable,
    const char *_Nonnull, size_t);
extern void objc_registerClassPair(Class _Nonnull);
extern id _Nullable objc_lookUpClass(const char *_Nonnull);
extern id _Nullable objc_getClass(const char *_Nonnull);
extern id _Nonnull objc_getRequiredClass(const char *_Nonnull);
extern unsigned int objc_getClassList(Class _Nonnull *_Nullable, unsigned int);
extern Class _Nonnull *_Nonnull objc_copyClassList(unsigned int *_Nullable);
extern bool class_isMetaClass(Class _Nullable);
extern const char *_Nonnull class_getName(Class _Nullable);
extern Class _Nullable class_getSuperclass(Class _Nullable);
extern unsigned long class_getInstanceSize(Class _Nullable);
extern bool class_respondsToSelector(Class _Nullable, SEL _Nonnull);
extern bool class_conformsToProtocol(Class _Nullable, Protocol *_Nonnull);
extern IMP _Nullable class_getMethodImplementation(Class _Nullable,
    SEL _Nonnull);
extern IMP _Nullable class_getMethodImplementation_stret(Class _Nullable,
    SEL _Nonnull);
extern const char *_Nullable class_getMethodTypeEncoding(Class _Nullable,
    SEL _Nonnull);
extern bool class_addMethod(Class _Nonnull, SEL _Nonnull, IMP _Nonnull,
    const char *_Nullable);
extern IMP _Nullable class_replaceMethod(Class _Nonnull, SEL _Nonnull,
    IMP _Nonnull, const char *_Nullable);
extern Class _Nullable object_getClass(id _Nullable);
extern Class _Nullable object_setClass(id _Nullable, Class _Nonnull);
extern const char *_Nonnull object_getClassName(id _Nullable);
extern const char *_Nonnull protocol_getName(Protocol *_Nonnull);
extern bool protocol_isEqual(Protocol *_Nonnull, Protocol *_Nonnull);
extern bool protocol_conformsToProtocol(Protocol *_Nonnull, Protocol *_Nonnull);
extern SEL OBJC_NONNULL sel_registerName(const char *OBJC_NONNULL);
extern const char *OBJC_NONNULL sel_getName(SEL OBJC_NONNULL);
extern bool sel_isEqual(SEL OBJC_NONNULL, SEL OBJC_NONNULL);
extern Class OBJC_NONNULL objc_allocateClassPair(Class OBJC_NULLABLE,
    const char *OBJC_NONNULL, size_t);
extern void objc_registerClassPair(Class OBJC_NONNULL);
extern id OBJC_NULLABLE objc_lookUpClass(const char *OBJC_NONNULL);
extern id OBJC_NULLABLE objc_getClass(const char *OBJC_NONNULL);
extern id OBJC_NONNULL objc_getRequiredClass(const char *OBJC_NONNULL);
extern unsigned int objc_getClassList(Class OBJC_NONNULL *OBJC_NULLABLE,
    unsigned int);
extern Class OBJC_NONNULL *OBJC_NONNULL objc_copyClassList(
    unsigned int *OBJC_NULLABLE);
extern bool class_isMetaClass(Class OBJC_NULLABLE);
extern const char *OBJC_NONNULL class_getName(Class OBJC_NULLABLE);
extern Class OBJC_NULLABLE class_getSuperclass(Class OBJC_NULLABLE);
extern unsigned long class_getInstanceSize(Class OBJC_NULLABLE);
extern bool class_respondsToSelector(Class OBJC_NULLABLE, SEL OBJC_NONNULL);
extern bool class_conformsToProtocol(Class OBJC_NULLABLE,
    Protocol *OBJC_NONNULL);
extern IMP OBJC_NULLABLE class_getMethodImplementation(Class OBJC_NULLABLE,
    SEL OBJC_NONNULL);
extern IMP OBJC_NULLABLE class_getMethodImplementation_stret(
    Class OBJC_NULLABLE, SEL OBJC_NONNULL);
extern const char *OBJC_NULLABLE class_getMethodTypeEncoding(
    Class OBJC_NULLABLE, SEL OBJC_NONNULL);
extern bool class_addMethod(Class OBJC_NONNULL, SEL OBJC_NONNULL,
    IMP OBJC_NONNULL, const char *OBJC_NULLABLE);
extern IMP OBJC_NULLABLE class_replaceMethod(Class OBJC_NONNULL,
    SEL OBJC_NONNULL, IMP OBJC_NONNULL, const char *OBJC_NULLABLE);
extern Class OBJC_NULLABLE object_getClass(id OBJC_NULLABLE);
extern Class OBJC_NULLABLE object_setClass(id OBJC_NULLABLE,
    Class OBJC_NONNULL);
extern const char *OBJC_NONNULL object_getClassName(id OBJC_NULLABLE);
extern const char *OBJC_NONNULL protocol_getName(Protocol *OBJC_NONNULL);
extern bool protocol_isEqual(Protocol *OBJC_NONNULL, Protocol *OBJC_NONNULL);
extern bool protocol_conformsToProtocol(Protocol *OBJC_NONNULL,
    Protocol *OBJC_NONNULL);
extern void objc_exit(void);
extern _Nullable objc_uncaught_exception_handler
    objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler _Nullable);
extern void objc_setForwardHandler(IMP _Nullable, IMP _Nullable);
extern void objc_zero_weak_references(id _Nonnull);
extern OBJC_NULLABLE objc_uncaught_exception_handler
    objc_setUncaughtExceptionHandler(
    objc_uncaught_exception_handler OBJC_NULLABLE);
extern void objc_setForwardHandler(IMP OBJC_NULLABLE, IMP OBJC_NULLABLE);
extern void objc_zero_weak_references(id OBJC_NONNULL);

/*
 * Used by the compiler, but can also be called manually.
 *
 * These declarations are also required to prevent Clang's implicit
 * declarations which include __declspec(dllimport) on Windows.
 */
struct objc_abi_module;
extern void __objc_exec_class(void *_Nonnull);
extern IMP _Nonnull objc_msg_lookup(id _Nullable, SEL _Nonnull);
extern IMP _Nonnull objc_msg_lookup_stret(id _Nullable, SEL _Nonnull);
extern IMP _Nonnull objc_msg_lookup_super(struct objc_super *_Nonnull,
    SEL _Nonnull);
extern IMP _Nonnull objc_msg_lookup_super_stret(struct objc_super *_Nonnull,
    SEL _Nonnull);
extern void objc_exception_throw(id _Nullable);
extern int objc_sync_enter(id _Nullable);
extern int objc_sync_exit(id _Nullable);
extern id _Nullable objc_getProperty(id _Nonnull, SEL _Nonnull, ptrdiff_t,
    BOOL);
extern void objc_setProperty(id _Nonnull, SEL _Nonnull, ptrdiff_t, id _Nullable,
    BOOL, signed char);
extern void objc_getPropertyStruct(void *_Nonnull, const void *_Nonnull,
extern void __objc_exec_class(void *OBJC_NONNULL);
extern IMP OBJC_NONNULL objc_msg_lookup(id OBJC_NULLABLE, SEL OBJC_NONNULL);
extern IMP OBJC_NONNULL objc_msg_lookup_stret(id OBJC_NULLABLE,
    SEL OBJC_NONNULL);
extern IMP OBJC_NONNULL objc_msg_lookup_super(struct objc_super *OBJC_NONNULL,
    SEL OBJC_NONNULL);
extern IMP OBJC_NONNULL objc_msg_lookup_super_stret(
    struct objc_super *OBJC_NONNULL, SEL OBJC_NONNULL);
extern void objc_exception_throw(id OBJC_NULLABLE);
extern int objc_sync_enter(id OBJC_NULLABLE);
extern int objc_sync_exit(id OBJC_NULLABLE);
extern id OBJC_NULLABLE objc_getProperty(id OBJC_NONNULL, SEL OBJC_NONNULL,
    ptrdiff_t, BOOL);
extern void objc_setProperty(id OBJC_NONNULL, SEL OBJC_NONNULL, ptrdiff_t,
    id OBJC_NULLABLE, BOOL, signed char);
extern void objc_getPropertyStruct(void *OBJC_NONNULL, const void *OBJC_NONNULL,
    ptrdiff_t, BOOL, BOOL);
extern void objc_setPropertyStruct(void *_Nonnull, const void *_Nonnull,
extern void objc_setPropertyStruct(void *OBJC_NONNULL, const void *OBJC_NONNULL,
    ptrdiff_t, BOOL, BOOL);
extern void objc_enumerationMutation(id _Nonnull);
extern void objc_enumerationMutation(id OBJC_NONNULL);
extern void objc_setEnumerationMutationHandler(
    objc_enumeration_mutation_handler _Nullable);
    objc_enumeration_mutation_handler OBJC_NULLABLE);
#ifdef __cplusplus
}
#endif

#undef OBJC_NONNULL
#undef OBJC_NULLABLE
#undef OBJC_UNSAFE_UNRETAINED
#undef OBJC_ROOT_CLASS

#if !__has_feature(nullability)
# undef _Nonnull
# undef _Nullable
#endif

#endif