]> git.saurik.com Git - apple/objc4.git/blob - runtime/runtime.h
objc4-709.tar.gz
[apple/objc4.git] / runtime / runtime.h
1 /*
2 * Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef _OBJC_RUNTIME_H
25 #define _OBJC_RUNTIME_H
26
27 #include <objc/objc.h>
28 #include <stdarg.h>
29 #include <stdint.h>
30 #include <stddef.h>
31 #include <Availability.h>
32 #include <TargetConditionals.h>
33
34 #if TARGET_OS_MAC
35 #include <sys/types.h>
36 #endif
37
38
39 /* Types */
40
41 #if !OBJC_TYPES_DEFINED
42
43 /// An opaque type that represents a method in a class definition.
44 typedef struct objc_method *Method;
45
46 /// An opaque type that represents an instance variable.
47 typedef struct objc_ivar *Ivar;
48
49 /// An opaque type that represents a category.
50 typedef struct objc_category *Category;
51
52 /// An opaque type that represents an Objective-C declared property.
53 typedef struct objc_property *objc_property_t;
54
55 struct objc_class {
56 Class isa OBJC_ISA_AVAILABILITY;
57
58 #if !__OBJC2__
59 Class super_class OBJC2_UNAVAILABLE;
60 const char *name OBJC2_UNAVAILABLE;
61 long version OBJC2_UNAVAILABLE;
62 long info OBJC2_UNAVAILABLE;
63 long instance_size OBJC2_UNAVAILABLE;
64 struct objc_ivar_list *ivars OBJC2_UNAVAILABLE;
65 struct objc_method_list **methodLists OBJC2_UNAVAILABLE;
66 struct objc_cache *cache OBJC2_UNAVAILABLE;
67 struct objc_protocol_list *protocols OBJC2_UNAVAILABLE;
68 #endif
69
70 } OBJC2_UNAVAILABLE;
71 /* Use `Class` instead of `struct objc_class *` */
72
73 #endif
74
75 #ifdef __OBJC__
76 @class Protocol;
77 #else
78 typedef struct objc_object Protocol;
79 #endif
80
81 /// Defines a method
82 struct objc_method_description {
83 SEL name; /**< The name of the method */
84 char *types; /**< The types of the method arguments */
85 };
86
87 /// Defines a property attribute
88 typedef struct {
89 const char *name; /**< The name of the attribute */
90 const char *value; /**< The value of the attribute (usually empty) */
91 } objc_property_attribute_t;
92
93
94 /* Functions */
95
96 /* Working with Instances */
97
98 /**
99 * Returns a copy of a given object.
100 *
101 * @param obj An Objective-C object.
102 * @param size The size of the object \e obj.
103 *
104 * @return A copy of \e obj.
105 */
106 OBJC_EXPORT id object_copy(id obj, size_t size)
107 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0)
108 OBJC_ARC_UNAVAILABLE;
109
110 /**
111 * Frees the memory occupied by a given object.
112 *
113 * @param obj An Objective-C object.
114 *
115 * @return nil
116 */
117 OBJC_EXPORT id object_dispose(id obj)
118 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0)
119 OBJC_ARC_UNAVAILABLE;
120
121 /**
122 * Returns the class of an object.
123 *
124 * @param obj The object you want to inspect.
125 *
126 * @return The class object of which \e object is an instance,
127 * or \c Nil if \e object is \c nil.
128 */
129 OBJC_EXPORT Class object_getClass(id obj)
130 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
131
132 /**
133 * Sets the class of an object.
134 *
135 * @param obj The object to modify.
136 * @param cls A class object.
137 *
138 * @return The previous value of \e object's class, or \c Nil if \e object is \c nil.
139 */
140 OBJC_EXPORT Class object_setClass(id obj, Class cls)
141 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
142
143
144 /**
145 * Returns whether an object is a class object.
146 *
147 * @param obj An Objective-C object.
148 *
149 * @return true if the object is a class or metaclass, false otherwise.
150 */
151 OBJC_EXPORT BOOL object_isClass(id obj)
152 OBJC_AVAILABLE(10.10, 8.0, 9.0, 1.0);
153
154
155 /**
156 * Reads the value of an instance variable in an object.
157 *
158 * @param obj The object containing the instance variable whose value you want to read.
159 * @param ivar The Ivar describing the instance variable whose value you want to read.
160 *
161 * @return The value of the instance variable specified by \e ivar, or \c nil if \e object is \c nil.
162 *
163 * @note \c object_getIvar is faster than \c object_getInstanceVariable if the Ivar
164 * for the instance variable is already known.
165 */
166 OBJC_EXPORT id object_getIvar(id obj, Ivar ivar)
167 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
168
169 /**
170 * Sets the value of an instance variable in an object.
171 *
172 * @param obj The object containing the instance variable whose value you want to set.
173 * @param ivar The Ivar describing the instance variable whose value you want to set.
174 * @param value The new value for the instance variable.
175 *
176 * @note Instance variables with known memory management (such as ARC strong and weak)
177 * use that memory management. Instance variables with unknown memory management
178 * are assigned as if they were unsafe_unretained.
179 * @note \c object_setIvar is faster than \c object_setInstanceVariable if the Ivar
180 * for the instance variable is already known.
181 */
182 OBJC_EXPORT void object_setIvar(id obj, Ivar ivar, id value)
183 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
184
185 /**
186 * Sets the value of an instance variable in an object.
187 *
188 * @param obj The object containing the instance variable whose value you want to set.
189 * @param ivar The Ivar describing the instance variable whose value you want to set.
190 * @param value The new value for the instance variable.
191 *
192 * @note Instance variables with known memory management (such as ARC strong and weak)
193 * use that memory management. Instance variables with unknown memory management
194 * are assigned as if they were strong.
195 * @note \c object_setIvar is faster than \c object_setInstanceVariable if the Ivar
196 * for the instance variable is already known.
197 */
198 OBJC_EXPORT void object_setIvarWithStrongDefault(id obj, Ivar ivar, id value)
199 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0);
200
201 /**
202 * Changes the value of an instance variable of a class instance.
203 *
204 * @param obj A pointer to an instance of a class. Pass the object containing
205 * the instance variable whose value you wish to modify.
206 * @param name A C string. Pass the name of the instance variable whose value you wish to modify.
207 * @param value The new value for the instance variable.
208 *
209 * @return A pointer to the \c Ivar data structure that defines the type and
210 * name of the instance variable specified by \e name.
211 *
212 * @note Instance variables with known memory management (such as ARC strong and weak)
213 * use that memory management. Instance variables with unknown memory management
214 * are assigned as if they were unsafe_unretained.
215 */
216 OBJC_EXPORT Ivar object_setInstanceVariable(id obj, const char *name, void *value)
217 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0)
218 OBJC_ARC_UNAVAILABLE;
219
220 /**
221 * Changes the value of an instance variable of a class instance.
222 *
223 * @param obj A pointer to an instance of a class. Pass the object containing
224 * the instance variable whose value you wish to modify.
225 * @param name A C string. Pass the name of the instance variable whose value you wish to modify.
226 * @param value The new value for the instance variable.
227 *
228 * @return A pointer to the \c Ivar data structure that defines the type and
229 * name of the instance variable specified by \e name.
230 *
231 * @note Instance variables with known memory management (such as ARC strong and weak)
232 * use that memory management. Instance variables with unknown memory management
233 * are assigned as if they were strong.
234 */
235 OBJC_EXPORT Ivar object_setInstanceVariableWithStrongDefault(id obj, const char *name, void *value)
236 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0)
237 OBJC_ARC_UNAVAILABLE;
238
239 /**
240 * Obtains the value of an instance variable of a class instance.
241 *
242 * @param obj A pointer to an instance of a class. Pass the object containing
243 * the instance variable whose value you wish to obtain.
244 * @param name A C string. Pass the name of the instance variable whose value you wish to obtain.
245 * @param outValue On return, contains a pointer to the value of the instance variable.
246 *
247 * @return A pointer to the \c Ivar data structure that defines the type and name of
248 * the instance variable specified by \e name.
249 */
250 OBJC_EXPORT Ivar object_getInstanceVariable(id obj, const char *name, void **outValue)
251 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0)
252 OBJC_ARC_UNAVAILABLE;
253
254
255 /* Obtaining Class Definitions */
256
257 /**
258 * Returns the class definition of a specified class.
259 *
260 * @param name The name of the class to look up.
261 *
262 * @return The Class object for the named class, or \c nil
263 * if the class is not registered with the Objective-C runtime.
264 *
265 * @note \c objc_getClass is different from \c objc_lookUpClass in that if the class
266 * is not registered, \c objc_getClass calls the class handler callback and then checks
267 * a second time to see whether the class is registered. \c objc_lookUpClass does
268 * not call the class handler callback.
269 *
270 * @warning Earlier implementations of this function (prior to OS X v10.0)
271 * terminate the program if the class does not exist.
272 */
273 OBJC_EXPORT Class objc_getClass(const char *name)
274 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
275
276 /**
277 * Returns the metaclass definition of a specified class.
278 *
279 * @param name The name of the class to look up.
280 *
281 * @return The \c Class object for the metaclass of the named class, or \c nil if the class
282 * is not registered with the Objective-C runtime.
283 *
284 * @note If the definition for the named class is not registered, this function calls the class handler
285 * callback and then checks a second time to see if the class is registered. However, every class
286 * definition must have a valid metaclass definition, and so the metaclass definition is always returned,
287 * whether it’s valid or not.
288 */
289 OBJC_EXPORT Class objc_getMetaClass(const char *name)
290 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
291
292 /**
293 * Returns the class definition of a specified class.
294 *
295 * @param name The name of the class to look up.
296 *
297 * @return The Class object for the named class, or \c nil if the class
298 * is not registered with the Objective-C runtime.
299 *
300 * @note \c objc_getClass is different from this function in that if the class is not
301 * registered, \c objc_getClass calls the class handler callback and then checks a second
302 * time to see whether the class is registered. This function does not call the class handler callback.
303 */
304 OBJC_EXPORT Class objc_lookUpClass(const char *name)
305 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
306
307 /**
308 * Returns the class definition of a specified class.
309 *
310 * @param name The name of the class to look up.
311 *
312 * @return The Class object for the named class.
313 *
314 * @note This function is the same as \c objc_getClass, but kills the process if the class is not found.
315 * @note This function is used by ZeroLink, where failing to find a class would be a compile-time link error without ZeroLink.
316 */
317 OBJC_EXPORT Class objc_getRequiredClass(const char *name)
318 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
319
320 /**
321 * Obtains the list of registered class definitions.
322 *
323 * @param buffer An array of \c Class values. On output, each \c Class value points to
324 * one class definition, up to either \e bufferCount or the total number of registered classes,
325 * whichever is less. You can pass \c NULL to obtain the total number of registered class
326 * definitions without actually retrieving any class definitions.
327 * @param bufferCount An integer value. Pass the number of pointers for which you have allocated space
328 * in \e buffer. On return, this function fills in only this number of elements. If this number is less
329 * than the number of registered classes, this function returns an arbitrary subset of the registered classes.
330 *
331 * @return An integer value indicating the total number of registered classes.
332 *
333 * @note The Objective-C runtime library automatically registers all the classes defined in your source code.
334 * You can create class definitions at runtime and register them with the \c objc_addClass function.
335 *
336 * @warning You cannot assume that class objects you get from this function are classes that inherit from \c NSObject,
337 * so you cannot safely call any methods on such classes without detecting that the method is implemented first.
338 */
339 OBJC_EXPORT int objc_getClassList(Class *buffer, int bufferCount)
340 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
341
342 /**
343 * Creates and returns a list of pointers to all registered class definitions.
344 *
345 * @param outCount An integer pointer used to store the number of classes returned by
346 * this function in the list. It can be \c nil.
347 *
348 * @return A nil terminated array of classes. It must be freed with \c free().
349 *
350 * @see objc_getClassList
351 */
352 OBJC_EXPORT Class *objc_copyClassList(unsigned int *outCount)
353 OBJC_AVAILABLE(10.7, 3.1, 9.0, 1.0);
354
355
356 /* Working with Classes */
357
358 /**
359 * Returns the name of a class.
360 *
361 * @param cls A class object.
362 *
363 * @return The name of the class, or the empty string if \e cls is \c Nil.
364 */
365 OBJC_EXPORT const char *class_getName(Class cls)
366 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
367
368 /**
369 * Returns a Boolean value that indicates whether a class object is a metaclass.
370 *
371 * @param cls A class object.
372 *
373 * @return \c YES if \e cls is a metaclass, \c NO if \e cls is a non-meta class,
374 * \c NO if \e cls is \c Nil.
375 */
376 OBJC_EXPORT BOOL class_isMetaClass(Class cls)
377 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
378
379 /**
380 * Returns the superclass of a class.
381 *
382 * @param cls A class object.
383 *
384 * @return The superclass of the class, or \c Nil if
385 * \e cls is a root class, or \c Nil if \e cls is \c Nil.
386 *
387 * @note You should usually use \c NSObject's \c superclass method instead of this function.
388 */
389 OBJC_EXPORT Class class_getSuperclass(Class cls)
390 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
391
392 /**
393 * Sets the superclass of a given class.
394 *
395 * @param cls The class whose superclass you want to set.
396 * @param newSuper The new superclass for cls.
397 *
398 * @return The old superclass for cls.
399 *
400 * @warning You should not use this function.
401 */
402 OBJC_EXPORT Class class_setSuperclass(Class cls, Class newSuper)
403 __OSX_DEPRECATED(10.5, 10.5, "not recommended")
404 __IOS_DEPRECATED(2.0, 2.0, "not recommended")
405 __TVOS_DEPRECATED(9.0, 9.0, "not recommended")
406 __WATCHOS_DEPRECATED(1.0, 1.0, "not recommended");
407
408 /**
409 * Returns the version number of a class definition.
410 *
411 * @param cls A pointer to a \c Class data structure. Pass
412 * the class definition for which you wish to obtain the version.
413 *
414 * @return An integer indicating the version number of the class definition.
415 *
416 * @see class_setVersion
417 */
418 OBJC_EXPORT int class_getVersion(Class cls)
419 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
420
421 /**
422 * Sets the version number of a class definition.
423 *
424 * @param cls A pointer to an Class data structure.
425 * Pass the class definition for which you wish to set the version.
426 * @param version An integer. Pass the new version number of the class definition.
427 *
428 * @note You can use the version number of the class definition to provide versioning of the
429 * interface that your class represents to other classes. This is especially useful for object
430 * serialization (that is, archiving of the object in a flattened form), where it is important to
431 * recognize changes to the layout of the instance variables in different class-definition versions.
432 * @note Classes derived from the Foundation framework \c NSObject class can set the class-definition
433 * version number using the \c setVersion: class method, which is implemented using the \c class_setVersion function.
434 */
435 OBJC_EXPORT void class_setVersion(Class cls, int version)
436 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
437
438 /**
439 * Returns the size of instances of a class.
440 *
441 * @param cls A class object.
442 *
443 * @return The size in bytes of instances of the class \e cls, or \c 0 if \e cls is \c Nil.
444 */
445 OBJC_EXPORT size_t class_getInstanceSize(Class cls)
446 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
447
448 /**
449 * Returns the \c Ivar for a specified instance variable of a given class.
450 *
451 * @param cls The class whose instance variable you wish to obtain.
452 * @param name The name of the instance variable definition to obtain.
453 *
454 * @return A pointer to an \c Ivar data structure containing information about
455 * the instance variable specified by \e name.
456 */
457 OBJC_EXPORT Ivar class_getInstanceVariable(Class cls, const char *name)
458 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
459
460 /**
461 * Returns the Ivar for a specified class variable of a given class.
462 *
463 * @param cls The class definition whose class variable you wish to obtain.
464 * @param name The name of the class variable definition to obtain.
465 *
466 * @return A pointer to an \c Ivar data structure containing information about the class variable specified by \e name.
467 */
468 OBJC_EXPORT Ivar class_getClassVariable(Class cls, const char *name)
469 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
470
471 /**
472 * Describes the instance variables declared by a class.
473 *
474 * @param cls The class to inspect.
475 * @param outCount On return, contains the length of the returned array.
476 * If outCount is NULL, the length is not returned.
477 *
478 * @return An array of pointers of type Ivar describing the instance variables declared by the class.
479 * Any instance variables declared by superclasses are not included. The array contains *outCount
480 * pointers followed by a NULL terminator. You must free the array with free().
481 *
482 * If the class declares no instance variables, or cls is Nil, NULL is returned and *outCount is 0.
483 */
484 OBJC_EXPORT Ivar *class_copyIvarList(Class cls, unsigned int *outCount)
485 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
486
487 /**
488 * Returns a specified instance method for a given class.
489 *
490 * @param cls The class you want to inspect.
491 * @param name The selector of the method you want to retrieve.
492 *
493 * @return The method that corresponds to the implementation of the selector specified by
494 * \e name for the class specified by \e cls, or \c NULL if the specified class or its
495 * superclasses do not contain an instance method with the specified selector.
496 *
497 * @note This function searches superclasses for implementations, whereas \c class_copyMethodList does not.
498 */
499 OBJC_EXPORT Method class_getInstanceMethod(Class cls, SEL name)
500 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
501
502 /**
503 * Returns a pointer to the data structure describing a given class method for a given class.
504 *
505 * @param cls A pointer to a class definition. Pass the class that contains the method you want to retrieve.
506 * @param name A pointer of type \c SEL. Pass the selector of the method you want to retrieve.
507 *
508 * @return A pointer to the \c Method data structure that corresponds to the implementation of the
509 * selector specified by aSelector for the class specified by aClass, or NULL if the specified
510 * class or its superclasses do not contain an instance method with the specified selector.
511 *
512 * @note Note that this function searches superclasses for implementations,
513 * whereas \c class_copyMethodList does not.
514 */
515 OBJC_EXPORT Method class_getClassMethod(Class cls, SEL name)
516 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
517
518 /**
519 * Returns the function pointer that would be called if a
520 * particular message were sent to an instance of a class.
521 *
522 * @param cls The class you want to inspect.
523 * @param name A selector.
524 *
525 * @return The function pointer that would be called if \c [object name] were called
526 * with an instance of the class, or \c NULL if \e cls is \c Nil.
527 *
528 * @note \c class_getMethodImplementation may be faster than \c method_getImplementation(class_getInstanceMethod(cls, name)).
529 * @note The function pointer returned may be a function internal to the runtime instead of
530 * an actual method implementation. For example, if instances of the class do not respond to
531 * the selector, the function pointer returned will be part of the runtime's message forwarding machinery.
532 */
533 OBJC_EXPORT IMP class_getMethodImplementation(Class cls, SEL name)
534 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
535
536 /**
537 * Returns the function pointer that would be called if a particular
538 * message were sent to an instance of a class.
539 *
540 * @param cls The class you want to inspect.
541 * @param name A selector.
542 *
543 * @return The function pointer that would be called if \c [object name] were called
544 * with an instance of the class, or \c NULL if \e cls is \c Nil.
545 */
546 OBJC_EXPORT IMP class_getMethodImplementation_stret(Class cls, SEL name)
547 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0)
548 OBJC_ARM64_UNAVAILABLE;
549
550 /**
551 * Returns a Boolean value that indicates whether instances of a class respond to a particular selector.
552 *
553 * @param cls The class you want to inspect.
554 * @param sel A selector.
555 *
556 * @return \c YES if instances of the class respond to the selector, otherwise \c NO.
557 *
558 * @note You should usually use \c NSObject's \c respondsToSelector: or \c instancesRespondToSelector:
559 * methods instead of this function.
560 */
561 OBJC_EXPORT BOOL class_respondsToSelector(Class cls, SEL sel)
562 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
563
564 /**
565 * Describes the instance methods implemented by a class.
566 *
567 * @param cls The class you want to inspect.
568 * @param outCount On return, contains the length of the returned array.
569 * If outCount is NULL, the length is not returned.
570 *
571 * @return An array of pointers of type Method describing the instance methods
572 * implemented by the class—any instance methods implemented by superclasses are not included.
573 * The array contains *outCount pointers followed by a NULL terminator. You must free the array with free().
574 *
575 * If cls implements no instance methods, or cls is Nil, returns NULL and *outCount is 0.
576 *
577 * @note To get the class methods of a class, use \c class_copyMethodList(object_getClass(cls), &count).
578 * @note To get the implementations of methods that may be implemented by superclasses,
579 * use \c class_getInstanceMethod or \c class_getClassMethod.
580 */
581 OBJC_EXPORT Method *class_copyMethodList(Class cls, unsigned int *outCount)
582 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
583
584 /**
585 * Returns a Boolean value that indicates whether a class conforms to a given protocol.
586 *
587 * @param cls The class you want to inspect.
588 * @param protocol A protocol.
589 *
590 * @return YES if cls conforms to protocol, otherwise NO.
591 *
592 * @note You should usually use NSObject's conformsToProtocol: method instead of this function.
593 */
594 OBJC_EXPORT BOOL class_conformsToProtocol(Class cls, Protocol *protocol)
595 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
596
597 /**
598 * Describes the protocols adopted by a class.
599 *
600 * @param cls The class you want to inspect.
601 * @param outCount On return, contains the length of the returned array.
602 * If outCount is NULL, the length is not returned.
603 *
604 * @return An array of pointers of type Protocol* describing the protocols adopted
605 * by the class. Any protocols adopted by superclasses or other protocols are not included.
606 * The array contains *outCount pointers followed by a NULL terminator. You must free the array with free().
607 *
608 * If cls adopts no protocols, or cls is Nil, returns NULL and *outCount is 0.
609 */
610 OBJC_EXPORT Protocol * __unsafe_unretained *class_copyProtocolList(Class cls, unsigned int *outCount)
611 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
612
613 /**
614 * Returns a property with a given name of a given class.
615 *
616 * @param cls The class you want to inspect.
617 * @param name The name of the property you want to inspect.
618 *
619 * @return A pointer of type \c objc_property_t describing the property, or
620 * \c NULL if the class does not declare a property with that name,
621 * or \c NULL if \e cls is \c Nil.
622 */
623 OBJC_EXPORT objc_property_t class_getProperty(Class cls, const char *name)
624 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
625
626 /**
627 * Describes the properties declared by a class.
628 *
629 * @param cls The class you want to inspect.
630 * @param outCount On return, contains the length of the returned array.
631 * If \e outCount is \c NULL, the length is not returned.
632 *
633 * @return An array of pointers of type \c objc_property_t describing the properties
634 * declared by the class. Any properties declared by superclasses are not included.
635 * The array contains \c *outCount pointers followed by a \c NULL terminator. You must free the array with \c free().
636 *
637 * If \e cls declares no properties, or \e cls is \c Nil, returns \c NULL and \c *outCount is \c 0.
638 */
639 OBJC_EXPORT objc_property_t *class_copyPropertyList(Class cls, unsigned int *outCount)
640 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
641
642 /**
643 * Returns a description of the \c Ivar layout for a given class.
644 *
645 * @param cls The class to inspect.
646 *
647 * @return A description of the \c Ivar layout for \e cls.
648 */
649 OBJC_EXPORT const uint8_t *class_getIvarLayout(Class cls)
650 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
651
652 /**
653 * Returns a description of the layout of weak Ivars for a given class.
654 *
655 * @param cls The class to inspect.
656 *
657 * @return A description of the layout of the weak \c Ivars for \e cls.
658 */
659 OBJC_EXPORT const uint8_t *class_getWeakIvarLayout(Class cls)
660 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
661
662 /**
663 * Adds a new method to a class with a given name and implementation.
664 *
665 * @param cls The class to which to add a method.
666 * @param name A selector that specifies the name of the method being added.
667 * @param imp A function which is the implementation of the new method. The function must take at least two arguments—self and _cmd.
668 * @param types An array of characters that describe the types of the arguments to the method.
669 *
670 * @return YES if the method was added successfully, otherwise NO
671 * (for example, the class already contains a method implementation with that name).
672 *
673 * @note class_addMethod will add an override of a superclass's implementation,
674 * but will not replace an existing implementation in this class.
675 * To change an existing implementation, use method_setImplementation.
676 */
677 OBJC_EXPORT BOOL class_addMethod(Class cls, SEL name, IMP imp,
678 const char *types)
679 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
680
681 /**
682 * Replaces the implementation of a method for a given class.
683 *
684 * @param cls The class you want to modify.
685 * @param name A selector that identifies the method whose implementation you want to replace.
686 * @param imp The new implementation for the method identified by name for the class identified by cls.
687 * @param types An array of characters that describe the types of the arguments to the method.
688 * Since the function must take at least two arguments—self and _cmd, the second and third characters
689 * must be “@:” (the first character is the return type).
690 *
691 * @return The previous implementation of the method identified by \e name for the class identified by \e cls.
692 *
693 * @note This function behaves in two different ways:
694 * - If the method identified by \e name does not yet exist, it is added as if \c class_addMethod were called.
695 * The type encoding specified by \e types is used as given.
696 * - If the method identified by \e name does exist, its \c IMP is replaced as if \c method_setImplementation were called.
697 * The type encoding specified by \e types is ignored.
698 */
699 OBJC_EXPORT IMP class_replaceMethod(Class cls, SEL name, IMP imp,
700 const char *types)
701 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
702
703 /**
704 * Adds a new instance variable to a class.
705 *
706 * @return YES if the instance variable was added successfully, otherwise NO
707 * (for example, the class already contains an instance variable with that name).
708 *
709 * @note This function may only be called after objc_allocateClassPair and before objc_registerClassPair.
710 * Adding an instance variable to an existing class is not supported.
711 * @note The class must not be a metaclass. Adding an instance variable to a metaclass is not supported.
712 * @note The instance variable's minimum alignment in bytes is 1<<align. The minimum alignment of an instance
713 * variable depends on the ivar's type and the machine architecture.
714 * For variables of any pointer type, pass log2(sizeof(pointer_type)).
715 */
716 OBJC_EXPORT BOOL class_addIvar(Class cls, const char *name, size_t size,
717 uint8_t alignment, const char *types)
718 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
719
720 /**
721 * Adds a protocol to a class.
722 *
723 * @param cls The class to modify.
724 * @param protocol The protocol to add to \e cls.
725 *
726 * @return \c YES if the method was added successfully, otherwise \c NO
727 * (for example, the class already conforms to that protocol).
728 */
729 OBJC_EXPORT BOOL class_addProtocol(Class cls, Protocol *protocol)
730 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
731
732 /**
733 * Adds a property to a class.
734 *
735 * @param cls The class to modify.
736 * @param name The name of the property.
737 * @param attributes An array of property attributes.
738 * @param attributeCount The number of attributes in \e attributes.
739 *
740 * @return \c YES if the property was added successfully, otherwise \c NO
741 * (for example, the class already has that property).
742 */
743 OBJC_EXPORT BOOL class_addProperty(Class cls, const char *name, const objc_property_attribute_t *attributes, unsigned int attributeCount)
744 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
745
746 /**
747 * Replace a property of a class.
748 *
749 * @param cls The class to modify.
750 * @param name The name of the property.
751 * @param attributes An array of property attributes.
752 * @param attributeCount The number of attributes in \e attributes.
753 */
754 OBJC_EXPORT void class_replaceProperty(Class cls, const char *name, const objc_property_attribute_t *attributes, unsigned int attributeCount)
755 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
756
757 /**
758 * Sets the Ivar layout for a given class.
759 *
760 * @param cls The class to modify.
761 * @param layout The layout of the \c Ivars for \e cls.
762 */
763 OBJC_EXPORT void class_setIvarLayout(Class cls, const uint8_t *layout)
764 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
765
766 /**
767 * Sets the layout for weak Ivars for a given class.
768 *
769 * @param cls The class to modify.
770 * @param layout The layout of the weak Ivars for \e cls.
771 */
772 OBJC_EXPORT void class_setWeakIvarLayout(Class cls, const uint8_t *layout)
773 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
774
775 /**
776 * Used by CoreFoundation's toll-free bridging.
777 * Return the id of the named class.
778 *
779 * @return The id of the named class, or an uninitialized class
780 * structure that will be used for the class when and if it does
781 * get loaded.
782 *
783 * @warning Do not call this function yourself.
784 */
785 OBJC_EXPORT Class objc_getFutureClass(const char *name)
786 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0)
787 OBJC_ARC_UNAVAILABLE;
788
789
790 /* Instantiating Classes */
791
792 /**
793 * Creates an instance of a class, allocating memory for the class in the
794 * default malloc memory zone.
795 *
796 * @param cls The class that you wish to allocate an instance of.
797 * @param extraBytes An integer indicating the number of extra bytes to allocate.
798 * The additional bytes can be used to store additional instance variables beyond
799 * those defined in the class definition.
800 *
801 * @return An instance of the class \e cls.
802 */
803 OBJC_EXPORT id class_createInstance(Class cls, size_t extraBytes)
804 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0)
805 OBJC_ARC_UNAVAILABLE;
806
807 /**
808 * Creates an instance of a class at the specific location provided.
809 *
810 * @param cls The class that you wish to allocate an instance of.
811 * @param bytes The location at which to allocate an instance of \e cls.
812 * Must point to at least \c class_getInstanceSize(cls) bytes of well-aligned,
813 * zero-filled memory.
814 *
815 * @return \e bytes on success, \c nil otherwise. (For example, \e cls or \e bytes
816 * might be \c nil)
817 *
818 * @see class_createInstance
819 */
820 OBJC_EXPORT id objc_constructInstance(Class cls, void *bytes)
821 OBJC_AVAILABLE(10.6, 3.0, 9.0, 1.0)
822 OBJC_ARC_UNAVAILABLE;
823
824 /**
825 * Destroys an instance of a class without freeing memory and removes any
826 * associated references this instance might have had.
827 *
828 * @param obj The class instance to destroy.
829 *
830 * @return \e obj. Does nothing if \e obj is nil.
831 *
832 * @note CF and other clients do call this under GC.
833 */
834 OBJC_EXPORT void *objc_destructInstance(id obj)
835 OBJC_AVAILABLE(10.6, 3.0, 9.0, 1.0)
836 OBJC_ARC_UNAVAILABLE;
837
838
839 /* Adding Classes */
840
841 /**
842 * Creates a new class and metaclass.
843 *
844 * @param superclass The class to use as the new class's superclass, or \c Nil to create a new root class.
845 * @param name The string to use as the new class's name. The string will be copied.
846 * @param extraBytes The number of bytes to allocate for indexed ivars at the end of
847 * the class and metaclass objects. This should usually be \c 0.
848 *
849 * @return The new class, or Nil if the class could not be created (for example, the desired name is already in use).
850 *
851 * @note You can get a pointer to the new metaclass by calling \c object_getClass(newClass).
852 * @note To create a new class, start by calling \c objc_allocateClassPair.
853 * Then set the class's attributes with functions like \c class_addMethod and \c class_addIvar.
854 * When you are done building the class, call \c objc_registerClassPair. The new class is now ready for use.
855 * @note Instance methods and instance variables should be added to the class itself.
856 * Class methods should be added to the metaclass.
857 */
858 OBJC_EXPORT Class objc_allocateClassPair(Class superclass, const char *name,
859 size_t extraBytes)
860 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
861
862 /**
863 * Registers a class that was allocated using \c objc_allocateClassPair.
864 *
865 * @param cls The class you want to register.
866 */
867 OBJC_EXPORT void objc_registerClassPair(Class cls)
868 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
869
870 /**
871 * Used by Foundation's Key-Value Observing.
872 *
873 * @warning Do not call this function yourself.
874 */
875 OBJC_EXPORT Class objc_duplicateClass(Class original, const char *name, size_t extraBytes)
876 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
877
878 /**
879 * Destroy a class and its associated metaclass.
880 *
881 * @param cls The class to be destroyed. It must have been allocated with
882 * \c objc_allocateClassPair
883 *
884 * @warning Do not call if instances of this class or a subclass exist.
885 */
886 OBJC_EXPORT void objc_disposeClassPair(Class cls)
887 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
888
889
890 /* Working with Methods */
891
892 /**
893 * Returns the name of a method.
894 *
895 * @param m The method to inspect.
896 *
897 * @return A pointer of type SEL.
898 *
899 * @note To get the method name as a C string, call \c sel_getName(method_getName(method)).
900 */
901 OBJC_EXPORT SEL method_getName(Method m)
902 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
903
904 /**
905 * Returns the implementation of a method.
906 *
907 * @param m The method to inspect.
908 *
909 * @return A function pointer of type IMP.
910 */
911 OBJC_EXPORT IMP method_getImplementation(Method m)
912 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
913
914 /**
915 * Returns a string describing a method's parameter and return types.
916 *
917 * @param m The method to inspect.
918 *
919 * @return A C string. The string may be \c NULL.
920 */
921 OBJC_EXPORT const char *method_getTypeEncoding(Method m)
922 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
923
924 /**
925 * Returns the number of arguments accepted by a method.
926 *
927 * @param m A pointer to a \c Method data structure. Pass the method in question.
928 *
929 * @return An integer containing the number of arguments accepted by the given method.
930 */
931 OBJC_EXPORT unsigned int method_getNumberOfArguments(Method m)
932 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
933
934 /**
935 * Returns a string describing a method's return type.
936 *
937 * @param m The method to inspect.
938 *
939 * @return A C string describing the return type. You must free the string with \c free().
940 */
941 OBJC_EXPORT char *method_copyReturnType(Method m)
942 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
943
944 /**
945 * Returns a string describing a single parameter type of a method.
946 *
947 * @param m The method to inspect.
948 * @param index The index of the parameter to inspect.
949 *
950 * @return A C string describing the type of the parameter at index \e index, or \c NULL
951 * if method has no parameter index \e index. You must free the string with \c free().
952 */
953 OBJC_EXPORT char *method_copyArgumentType(Method m, unsigned int index)
954 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
955
956 /**
957 * Returns by reference a string describing a method's return type.
958 *
959 * @param m The method you want to inquire about.
960 * @param dst The reference string to store the description.
961 * @param dst_len The maximum number of characters that can be stored in \e dst.
962 *
963 * @note The method's return type string is copied to \e dst.
964 * \e dst is filled as if \c strncpy(dst, parameter_type, dst_len) were called.
965 */
966 OBJC_EXPORT void method_getReturnType(Method m, char *dst, size_t dst_len)
967 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
968
969 /**
970 * Returns by reference a string describing a single parameter type of a method.
971 *
972 * @param m The method you want to inquire about.
973 * @param index The index of the parameter you want to inquire about.
974 * @param dst The reference string to store the description.
975 * @param dst_len The maximum number of characters that can be stored in \e dst.
976 *
977 * @note The parameter type string is copied to \e dst. \e dst is filled as if \c strncpy(dst, parameter_type, dst_len)
978 * were called. If the method contains no parameter with that index, \e dst is filled as
979 * if \c strncpy(dst, "", dst_len) were called.
980 */
981 OBJC_EXPORT void method_getArgumentType(Method m, unsigned int index,
982 char *dst, size_t dst_len)
983 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
984 OBJC_EXPORT struct objc_method_description *method_getDescription(Method m)
985 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
986
987 /**
988 * Sets the implementation of a method.
989 *
990 * @param m The method for which to set an implementation.
991 * @param imp The implemention to set to this method.
992 *
993 * @return The previous implementation of the method.
994 */
995 OBJC_EXPORT IMP method_setImplementation(Method m, IMP imp)
996 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
997
998 /**
999 * Exchanges the implementations of two methods.
1000 *
1001 * @param m1 Method to exchange with second method.
1002 * @param m2 Method to exchange with first method.
1003 *
1004 * @note This is an atomic version of the following:
1005 * \code
1006 * IMP imp1 = method_getImplementation(m1);
1007 * IMP imp2 = method_getImplementation(m2);
1008 * method_setImplementation(m1, imp2);
1009 * method_setImplementation(m2, imp1);
1010 * \endcode
1011 */
1012 OBJC_EXPORT void method_exchangeImplementations(Method m1, Method m2)
1013 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1014
1015
1016 /* Working with Instance Variables */
1017
1018 /**
1019 * Returns the name of an instance variable.
1020 *
1021 * @param v The instance variable you want to enquire about.
1022 *
1023 * @return A C string containing the instance variable's name.
1024 */
1025 OBJC_EXPORT const char *ivar_getName(Ivar v)
1026 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1027
1028 /**
1029 * Returns the type string of an instance variable.
1030 *
1031 * @param v The instance variable you want to enquire about.
1032 *
1033 * @return A C string containing the instance variable's type encoding.
1034 *
1035 * @note For possible values, see Objective-C Runtime Programming Guide > Type Encodings.
1036 */
1037 OBJC_EXPORT const char *ivar_getTypeEncoding(Ivar v)
1038 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1039
1040 /**
1041 * Returns the offset of an instance variable.
1042 *
1043 * @param v The instance variable you want to enquire about.
1044 *
1045 * @return The offset of \e v.
1046 *
1047 * @note For instance variables of type \c id or other object types, call \c object_getIvar
1048 * and \c object_setIvar instead of using this offset to access the instance variable data directly.
1049 */
1050 OBJC_EXPORT ptrdiff_t ivar_getOffset(Ivar v)
1051 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1052
1053
1054 /* Working with Properties */
1055
1056 /**
1057 * Returns the name of a property.
1058 *
1059 * @param property The property you want to inquire about.
1060 *
1061 * @return A C string containing the property's name.
1062 */
1063 OBJC_EXPORT const char *property_getName(objc_property_t property)
1064 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1065
1066 /**
1067 * Returns the attribute string of a property.
1068 *
1069 * @param property A property.
1070 *
1071 * @return A C string containing the property's attributes.
1072 *
1073 * @note The format of the attribute string is described in Declared Properties in Objective-C Runtime Programming Guide.
1074 */
1075 OBJC_EXPORT const char *property_getAttributes(objc_property_t property)
1076 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1077
1078 /**
1079 * Returns an array of property attributes for a property.
1080 *
1081 * @param property The property whose attributes you want copied.
1082 * @param outCount The number of attributes returned in the array.
1083 *
1084 * @return An array of property attributes; must be free'd() by the caller.
1085 */
1086 OBJC_EXPORT objc_property_attribute_t *property_copyAttributeList(objc_property_t property, unsigned int *outCount)
1087 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1088
1089 /**
1090 * Returns the value of a property attribute given the attribute name.
1091 *
1092 * @param property The property whose attribute value you are interested in.
1093 * @param attributeName C string representing the attribute name.
1094 *
1095 * @return The value string of the attribute \e attributeName if it exists in
1096 * \e property, \c nil otherwise.
1097 */
1098 OBJC_EXPORT char *property_copyAttributeValue(objc_property_t property, const char *attributeName)
1099 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1100
1101
1102 /* Working with Protocols */
1103
1104 /**
1105 * Returns a specified protocol.
1106 *
1107 * @param name The name of a protocol.
1108 *
1109 * @return The protocol named \e name, or \c NULL if no protocol named \e name could be found.
1110 *
1111 * @note This function acquires the runtime lock.
1112 */
1113 OBJC_EXPORT Protocol *objc_getProtocol(const char *name)
1114 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1115
1116 /**
1117 * Returns an array of all the protocols known to the runtime.
1118 *
1119 * @param outCount Upon return, contains the number of protocols in the returned array.
1120 *
1121 * @return A C array of all the protocols known to the runtime. The array contains \c *outCount
1122 * pointers followed by a \c NULL terminator. You must free the list with \c free().
1123 *
1124 * @note This function acquires the runtime lock.
1125 */
1126 OBJC_EXPORT Protocol * __unsafe_unretained *objc_copyProtocolList(unsigned int *outCount)
1127 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1128
1129 /**
1130 * Returns a Boolean value that indicates whether one protocol conforms to another protocol.
1131 *
1132 * @param proto A protocol.
1133 * @param other A protocol.
1134 *
1135 * @return \c YES if \e proto conforms to \e other, otherwise \c NO.
1136 *
1137 * @note One protocol can incorporate other protocols using the same syntax
1138 * that classes use to adopt a protocol:
1139 * \code
1140 * @protocol ProtocolName < protocol list >
1141 * \endcode
1142 * All the protocols listed between angle brackets are considered part of the ProtocolName protocol.
1143 */
1144 OBJC_EXPORT BOOL protocol_conformsToProtocol(Protocol *proto, Protocol *other)
1145 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1146
1147 /**
1148 * Returns a Boolean value that indicates whether two protocols are equal.
1149 *
1150 * @param proto A protocol.
1151 * @param other A protocol.
1152 *
1153 * @return \c YES if \e proto is the same as \e other, otherwise \c NO.
1154 */
1155 OBJC_EXPORT BOOL protocol_isEqual(Protocol *proto, Protocol *other)
1156 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1157
1158 /**
1159 * Returns the name of a protocol.
1160 *
1161 * @param p A protocol.
1162 *
1163 * @return The name of the protocol \e p as a C string.
1164 */
1165 OBJC_EXPORT const char *protocol_getName(Protocol *p)
1166 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1167
1168 /**
1169 * Returns a method description structure for a specified method of a given protocol.
1170 *
1171 * @param p A protocol.
1172 * @param aSel A selector.
1173 * @param isRequiredMethod A Boolean value that indicates whether aSel is a required method.
1174 * @param isInstanceMethod A Boolean value that indicates whether aSel is an instance method.
1175 *
1176 * @return An \c objc_method_description structure that describes the method specified by \e aSel,
1177 * \e isRequiredMethod, and \e isInstanceMethod for the protocol \e p.
1178 * If the protocol does not contain the specified method, returns an \c objc_method_description structure
1179 * with the value \c {NULL, \c NULL}.
1180 *
1181 * @note This function recursively searches any protocols that this protocol conforms to.
1182 */
1183 OBJC_EXPORT struct objc_method_description protocol_getMethodDescription(Protocol *p, SEL aSel, BOOL isRequiredMethod, BOOL isInstanceMethod)
1184 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1185
1186 /**
1187 * Returns an array of method descriptions of methods meeting a given specification for a given protocol.
1188 *
1189 * @param p A protocol.
1190 * @param isRequiredMethod A Boolean value that indicates whether returned methods should
1191 * be required methods (pass YES to specify required methods).
1192 * @param isInstanceMethod A Boolean value that indicates whether returned methods should
1193 * be instance methods (pass YES to specify instance methods).
1194 * @param outCount Upon return, contains the number of method description structures in the returned array.
1195 *
1196 * @return A C array of \c objc_method_description structures containing the names and types of \e p's methods
1197 * specified by \e isRequiredMethod and \e isInstanceMethod. The array contains \c *outCount pointers followed
1198 * by a \c NULL terminator. You must free the list with \c free().
1199 * If the protocol declares no methods that meet the specification, \c NULL is returned and \c *outCount is 0.
1200 *
1201 * @note Methods in other protocols adopted by this protocol are not included.
1202 */
1203 OBJC_EXPORT struct objc_method_description *protocol_copyMethodDescriptionList(Protocol *p, BOOL isRequiredMethod, BOOL isInstanceMethod, unsigned int *outCount)
1204 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1205
1206 /**
1207 * Returns the specified property of a given protocol.
1208 *
1209 * @param proto A protocol.
1210 * @param name The name of a property.
1211 * @param isRequiredProperty \c YES searches for a required property, \c NO searches for an optional property.
1212 * @param isInstanceProperty \c YES searches for an instance property, \c NO searches for a class property.
1213 *
1214 * @return The property specified by \e name, \e isRequiredProperty, and \e isInstanceProperty for \e proto,
1215 * or \c NULL if none of \e proto's properties meets the specification.
1216 */
1217 OBJC_EXPORT objc_property_t protocol_getProperty(Protocol *proto, const char *name, BOOL isRequiredProperty, BOOL isInstanceProperty)
1218 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1219
1220 /**
1221 * Returns an array of the required instance properties declared by a protocol.
1222 *
1223 * @note Identical to
1224 * \code
1225 * protocol_copyPropertyList2(proto, outCount, YES, YES);
1226 * \endcode
1227 */
1228 OBJC_EXPORT objc_property_t *protocol_copyPropertyList(Protocol *proto, unsigned int *outCount)
1229 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1230
1231 /**
1232 * Returns an array of properties declared by a protocol.
1233 *
1234 * @param proto A protocol.
1235 * @param outCount Upon return, contains the number of elements in the returned array.
1236 * @param isRequiredProperty \c YES returns required properties, \c NO returns optional properties.
1237 * @param isInstanceProperty \c YES returns instance properties, \c NO returns class properties.
1238 *
1239 * @return A C array of pointers of type \c objc_property_t describing the properties declared by \e proto.
1240 * Any properties declared by other protocols adopted by this protocol are not included. The array contains
1241 * \c *outCount pointers followed by a \c NULL terminator. You must free the array with \c free().
1242 * If the protocol declares no matching properties, \c NULL is returned and \c *outCount is \c 0.
1243 */
1244 OBJC_EXPORT objc_property_t *protocol_copyPropertyList2(Protocol *proto, unsigned int *outCount, BOOL isRequiredProperty, BOOL isInstanceProperty)
1245 OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0);
1246
1247 /**
1248 * Returns an array of the protocols adopted by a protocol.
1249 *
1250 * @param proto A protocol.
1251 * @param outCount Upon return, contains the number of elements in the returned array.
1252 *
1253 * @return A C array of protocols adopted by \e proto. The array contains \e *outCount pointers
1254 * followed by a \c NULL terminator. You must free the array with \c free().
1255 * If the protocol declares no properties, \c NULL is returned and \c *outCount is \c 0.
1256 */
1257 OBJC_EXPORT Protocol * __unsafe_unretained *protocol_copyProtocolList(Protocol *proto, unsigned int *outCount)
1258 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1259
1260 /**
1261 * Creates a new protocol instance that cannot be used until registered with
1262 * \c objc_registerProtocol()
1263 *
1264 * @param name The name of the protocol to create.
1265 *
1266 * @return The Protocol instance on success, \c nil if a protocol
1267 * with the same name already exists.
1268 * @note There is no dispose method for this.
1269 */
1270 OBJC_EXPORT Protocol *objc_allocateProtocol(const char *name)
1271 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1272
1273 /**
1274 * Registers a newly constructed protocol with the runtime. The protocol
1275 * will be ready for use and is immutable after this.
1276 *
1277 * @param proto The protocol you want to register.
1278 */
1279 OBJC_EXPORT void objc_registerProtocol(Protocol *proto)
1280 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1281
1282 /**
1283 * Adds a method to a protocol. The protocol must be under construction.
1284 *
1285 * @param proto The protocol to add a method to.
1286 * @param name The name of the method to add.
1287 * @param types A C string that represents the method signature.
1288 * @param isRequiredMethod YES if the method is not an optional method.
1289 * @param isInstanceMethod YES if the method is an instance method.
1290 */
1291 OBJC_EXPORT void protocol_addMethodDescription(Protocol *proto, SEL name, const char *types, BOOL isRequiredMethod, BOOL isInstanceMethod)
1292 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1293
1294 /**
1295 * Adds an incorporated protocol to another protocol. The protocol being
1296 * added to must still be under construction, while the additional protocol
1297 * must be already constructed.
1298 *
1299 * @param proto The protocol you want to add to, it must be under construction.
1300 * @param addition The protocol you want to incorporate into \e proto, it must be registered.
1301 */
1302 OBJC_EXPORT void protocol_addProtocol(Protocol *proto, Protocol *addition)
1303 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1304
1305 /**
1306 * Adds a property to a protocol. The protocol must be under construction.
1307 *
1308 * @param proto The protocol to add a property to.
1309 * @param name The name of the property.
1310 * @param attributes An array of property attributes.
1311 * @param attributeCount The number of attributes in \e attributes.
1312 * @param isRequiredProperty YES if the property (accessor methods) is not optional.
1313 * @param isInstanceProperty YES if the property (accessor methods) are instance methods.
1314 * This is the only case allowed fo a property, as a result, setting this to NO will
1315 * not add the property to the protocol at all.
1316 */
1317 OBJC_EXPORT void protocol_addProperty(Protocol *proto, const char *name, const objc_property_attribute_t *attributes, unsigned int attributeCount, BOOL isRequiredProperty, BOOL isInstanceProperty)
1318 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1319
1320
1321 /* Working with Libraries */
1322
1323 /**
1324 * Returns the names of all the loaded Objective-C frameworks and dynamic
1325 * libraries.
1326 *
1327 * @param outCount The number of names returned.
1328 *
1329 * @return An array of C strings of names. Must be free()'d by caller.
1330 */
1331 OBJC_EXPORT const char **objc_copyImageNames(unsigned int *outCount)
1332 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1333
1334 /**
1335 * Returns the dynamic library name a class originated from.
1336 *
1337 * @param cls The class you are inquiring about.
1338 *
1339 * @return The name of the library containing this class.
1340 */
1341 OBJC_EXPORT const char *class_getImageName(Class cls)
1342 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1343
1344 /**
1345 * Returns the names of all the classes within a library.
1346 *
1347 * @param image The library or framework you are inquiring about.
1348 * @param outCount The number of class names returned.
1349 *
1350 * @return An array of C strings representing the class names.
1351 */
1352 OBJC_EXPORT const char **objc_copyClassNamesForImage(const char *image,
1353 unsigned int *outCount)
1354 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1355
1356
1357 /* Working with Selectors */
1358
1359 /**
1360 * Returns the name of the method specified by a given selector.
1361 *
1362 * @param sel A pointer of type \c SEL. Pass the selector whose name you wish to determine.
1363 *
1364 * @return A C string indicating the name of the selector.
1365 */
1366 OBJC_EXPORT const char *sel_getName(SEL sel)
1367 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
1368
1369
1370 /**
1371 * Registers a method with the Objective-C runtime system, maps the method
1372 * name to a selector, and returns the selector value.
1373 *
1374 * @param str A pointer to a C string. Pass the name of the method you wish to register.
1375 *
1376 * @return A pointer of type SEL specifying the selector for the named method.
1377 *
1378 * @note You must register a method name with the Objective-C runtime system to obtain the
1379 * method’s selector before you can add the method to a class definition. If the method name
1380 * has already been registered, this function simply returns the selector.
1381 */
1382 OBJC_EXPORT SEL sel_registerName(const char *str)
1383 OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0);
1384
1385 /**
1386 * Returns a Boolean value that indicates whether two selectors are equal.
1387 *
1388 * @param lhs The selector to compare with rhs.
1389 * @param rhs The selector to compare with lhs.
1390 *
1391 * @return \c YES if \e lhs and \e rhs are equal, otherwise \c NO.
1392 *
1393 * @note sel_isEqual is equivalent to ==.
1394 */
1395 OBJC_EXPORT BOOL sel_isEqual(SEL lhs, SEL rhs)
1396 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1397
1398
1399 /* Objective-C Language Features */
1400
1401 /**
1402 * This function is inserted by the compiler when a mutation
1403 * is detected during a foreach iteration. It gets called
1404 * when a mutation occurs, and the enumerationMutationHandler
1405 * is enacted if it is set up. A fatal error occurs if a handler is not set up.
1406 *
1407 * @param obj The object being mutated.
1408 *
1409 */
1410 OBJC_EXPORT void objc_enumerationMutation(id obj)
1411 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1412
1413 /**
1414 * Sets the current mutation handler.
1415 *
1416 * @param handler Function pointer to the new mutation handler.
1417 */
1418 OBJC_EXPORT void objc_setEnumerationMutationHandler(void (*handler)(id))
1419 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1420
1421 /**
1422 * Set the function to be called by objc_msgForward.
1423 *
1424 * @param fwd Function to be jumped to by objc_msgForward.
1425 * @param fwd_stret Function to be jumped to by objc_msgForward_stret.
1426 *
1427 * @see message.h::_objc_msgForward
1428 */
1429 OBJC_EXPORT void objc_setForwardHandler(void *fwd, void *fwd_stret)
1430 OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0);
1431
1432 /**
1433 * Creates a pointer to a function that will call the block
1434 * when the method is called.
1435 *
1436 * @param block The block that implements this method. Its signature should
1437 * be: method_return_type ^(id self, method_args...).
1438 * The selector is not available as a parameter to this block.
1439 * The block is copied with \c Block_copy().
1440 *
1441 * @return The IMP that calls this block. Must be disposed of with
1442 * \c imp_removeBlock.
1443 */
1444 OBJC_EXPORT IMP imp_implementationWithBlock(id block)
1445 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1446
1447 /**
1448 * Return the block associated with an IMP that was created using
1449 * \c imp_implementationWithBlock.
1450 *
1451 * @param anImp The IMP that calls this block.
1452 *
1453 * @return The block called by \e anImp.
1454 */
1455 OBJC_EXPORT id imp_getBlock(IMP anImp)
1456 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1457
1458 /**
1459 * Disassociates a block from an IMP that was created using
1460 * \c imp_implementationWithBlock and releases the copy of the
1461 * block that was created.
1462 *
1463 * @param anImp An IMP that was created using \c imp_implementationWithBlock.
1464 *
1465 * @return YES if the block was released successfully, NO otherwise.
1466 * (For example, the block might not have been used to create an IMP previously).
1467 */
1468 OBJC_EXPORT BOOL imp_removeBlock(IMP anImp)
1469 OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0);
1470
1471 /**
1472 * This loads the object referenced by a weak pointer and returns it, after
1473 * retaining and autoreleasing the object to ensure that it stays alive
1474 * long enough for the caller to use it. This function would be used
1475 * anywhere a __weak variable is used in an expression.
1476 *
1477 * @param location The weak pointer address
1478 *
1479 * @return The object pointed to by \e location, or \c nil if \e location is \c nil.
1480 */
1481 OBJC_EXPORT id objc_loadWeak(id *location)
1482 OBJC_AVAILABLE(10.7, 5.0, 9.0, 1.0);
1483
1484 /**
1485 * This function stores a new value into a __weak variable. It would
1486 * be used anywhere a __weak variable is the target of an assignment.
1487 *
1488 * @param location The address of the weak pointer itself
1489 * @param obj The new object this weak ptr should now point to
1490 *
1491 * @return The value stored into \e location, i.e. \e obj
1492 */
1493 OBJC_EXPORT id objc_storeWeak(id *location, id obj)
1494 OBJC_AVAILABLE(10.7, 5.0, 9.0, 1.0);
1495
1496
1497 /* Associative References */
1498
1499 /**
1500 * Policies related to associative references.
1501 * These are options to objc_setAssociatedObject()
1502 */
1503 typedef OBJC_ENUM(uintptr_t, objc_AssociationPolicy) {
1504 OBJC_ASSOCIATION_ASSIGN = 0, /**< Specifies a weak reference to the associated object. */
1505 OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1, /**< Specifies a strong reference to the associated object.
1506 * The association is not made atomically. */
1507 OBJC_ASSOCIATION_COPY_NONATOMIC = 3, /**< Specifies that the associated object is copied.
1508 * The association is not made atomically. */
1509 OBJC_ASSOCIATION_RETAIN = 01401, /**< Specifies a strong reference to the associated object.
1510 * The association is made atomically. */
1511 OBJC_ASSOCIATION_COPY = 01403 /**< Specifies that the associated object is copied.
1512 * The association is made atomically. */
1513 };
1514
1515 /**
1516 * Sets an associated value for a given object using a given key and association policy.
1517 *
1518 * @param object The source object for the association.
1519 * @param key The key for the association.
1520 * @param value The value to associate with the key key for object. Pass nil to clear an existing association.
1521 * @param policy The policy for the association. For possible values, see “Associative Object Behaviors.”
1522 *
1523 * @see objc_setAssociatedObject
1524 * @see objc_removeAssociatedObjects
1525 */
1526 OBJC_EXPORT void objc_setAssociatedObject(id object, const void *key, id value, objc_AssociationPolicy policy)
1527 OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0);
1528
1529 /**
1530 * Returns the value associated with a given object for a given key.
1531 *
1532 * @param object The source object for the association.
1533 * @param key The key for the association.
1534 *
1535 * @return The value associated with the key \e key for \e object.
1536 *
1537 * @see objc_setAssociatedObject
1538 */
1539 OBJC_EXPORT id objc_getAssociatedObject(id object, const void *key)
1540 OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0);
1541
1542 /**
1543 * Removes all associations for a given object.
1544 *
1545 * @param object An object that maintains associated objects.
1546 *
1547 * @note The main purpose of this function is to make it easy to return an object
1548 * to a "pristine state”. You should not use this function for general removal of
1549 * associations from objects, since it also removes associations that other clients
1550 * may have added to the object. Typically you should use \c objc_setAssociatedObject
1551 * with a nil value to clear an association.
1552 *
1553 * @see objc_setAssociatedObject
1554 * @see objc_getAssociatedObject
1555 */
1556 OBJC_EXPORT void objc_removeAssociatedObjects(id object)
1557 OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0);
1558
1559
1560 #define _C_ID '@'
1561 #define _C_CLASS '#'
1562 #define _C_SEL ':'
1563 #define _C_CHR 'c'
1564 #define _C_UCHR 'C'
1565 #define _C_SHT 's'
1566 #define _C_USHT 'S'
1567 #define _C_INT 'i'
1568 #define _C_UINT 'I'
1569 #define _C_LNG 'l'
1570 #define _C_ULNG 'L'
1571 #define _C_LNG_LNG 'q'
1572 #define _C_ULNG_LNG 'Q'
1573 #define _C_FLT 'f'
1574 #define _C_DBL 'd'
1575 #define _C_BFLD 'b'
1576 #define _C_BOOL 'B'
1577 #define _C_VOID 'v'
1578 #define _C_UNDEF '?'
1579 #define _C_PTR '^'
1580 #define _C_CHARPTR '*'
1581 #define _C_ATOM '%'
1582 #define _C_ARY_B '['
1583 #define _C_ARY_E ']'
1584 #define _C_UNION_B '('
1585 #define _C_UNION_E ')'
1586 #define _C_STRUCT_B '{'
1587 #define _C_STRUCT_E '}'
1588 #define _C_VECTOR '!'
1589 #define _C_CONST 'r'
1590
1591
1592 /* Obsolete types */
1593
1594 #if !__OBJC2__
1595
1596 #define CLS_GETINFO(cls,infomask) ((cls)->info & (infomask))
1597 #define CLS_SETINFO(cls,infomask) ((cls)->info |= (infomask))
1598
1599 // class is not a metaclass
1600 #define CLS_CLASS 0x1
1601 // class is a metaclass
1602 #define CLS_META 0x2
1603 // class's +initialize method has completed
1604 #define CLS_INITIALIZED 0x4
1605 // class is posing
1606 #define CLS_POSING 0x8
1607 // unused
1608 #define CLS_MAPPED 0x10
1609 // class and subclasses need cache flush during image loading
1610 #define CLS_FLUSH_CACHE 0x20
1611 // method cache should grow when full
1612 #define CLS_GROW_CACHE 0x40
1613 // unused
1614 #define CLS_NEED_BIND 0x80
1615 // methodLists is array of method lists
1616 #define CLS_METHOD_ARRAY 0x100
1617 // the JavaBridge constructs classes with these markers
1618 #define CLS_JAVA_HYBRID 0x200
1619 #define CLS_JAVA_CLASS 0x400
1620 // thread-safe +initialize
1621 #define CLS_INITIALIZING 0x800
1622 // bundle unloading
1623 #define CLS_FROM_BUNDLE 0x1000
1624 // C++ ivar support
1625 #define CLS_HAS_CXX_STRUCTORS 0x2000
1626 // Lazy method list arrays
1627 #define CLS_NO_METHOD_ARRAY 0x4000
1628 // +load implementation
1629 #define CLS_HAS_LOAD_METHOD 0x8000
1630 // objc_allocateClassPair API
1631 #define CLS_CONSTRUCTING 0x10000
1632 // class compiled with bigger class structure
1633 #define CLS_EXT 0x20000
1634
1635
1636 struct objc_method_description_list {
1637 int count;
1638 struct objc_method_description list[1];
1639 };
1640
1641
1642 struct objc_protocol_list {
1643 struct objc_protocol_list *next;
1644 long count;
1645 __unsafe_unretained Protocol *list[1];
1646 };
1647
1648
1649 struct objc_category {
1650 char *category_name OBJC2_UNAVAILABLE;
1651 char *class_name OBJC2_UNAVAILABLE;
1652 struct objc_method_list *instance_methods OBJC2_UNAVAILABLE;
1653 struct objc_method_list *class_methods OBJC2_UNAVAILABLE;
1654 struct objc_protocol_list *protocols OBJC2_UNAVAILABLE;
1655 } OBJC2_UNAVAILABLE;
1656
1657
1658 struct objc_ivar {
1659 char *ivar_name OBJC2_UNAVAILABLE;
1660 char *ivar_type OBJC2_UNAVAILABLE;
1661 int ivar_offset OBJC2_UNAVAILABLE;
1662 #ifdef __LP64__
1663 int space OBJC2_UNAVAILABLE;
1664 #endif
1665 } OBJC2_UNAVAILABLE;
1666
1667 struct objc_ivar_list {
1668 int ivar_count OBJC2_UNAVAILABLE;
1669 #ifdef __LP64__
1670 int space OBJC2_UNAVAILABLE;
1671 #endif
1672 /* variable length structure */
1673 struct objc_ivar ivar_list[1] OBJC2_UNAVAILABLE;
1674 } OBJC2_UNAVAILABLE;
1675
1676
1677 struct objc_method {
1678 SEL method_name OBJC2_UNAVAILABLE;
1679 char *method_types OBJC2_UNAVAILABLE;
1680 IMP method_imp OBJC2_UNAVAILABLE;
1681 } OBJC2_UNAVAILABLE;
1682
1683 struct objc_method_list {
1684 struct objc_method_list *obsolete OBJC2_UNAVAILABLE;
1685
1686 int method_count OBJC2_UNAVAILABLE;
1687 #ifdef __LP64__
1688 int space OBJC2_UNAVAILABLE;
1689 #endif
1690 /* variable length structure */
1691 struct objc_method method_list[1] OBJC2_UNAVAILABLE;
1692 } OBJC2_UNAVAILABLE;
1693
1694
1695 typedef struct objc_symtab *Symtab OBJC2_UNAVAILABLE;
1696
1697 struct objc_symtab {
1698 unsigned long sel_ref_cnt OBJC2_UNAVAILABLE;
1699 SEL *refs OBJC2_UNAVAILABLE;
1700 unsigned short cls_def_cnt OBJC2_UNAVAILABLE;
1701 unsigned short cat_def_cnt OBJC2_UNAVAILABLE;
1702 void *defs[1] /* variable size */ OBJC2_UNAVAILABLE;
1703 } OBJC2_UNAVAILABLE;
1704
1705
1706 typedef struct objc_cache *Cache OBJC2_UNAVAILABLE;
1707
1708 #define CACHE_BUCKET_NAME(B) ((B)->method_name)
1709 #define CACHE_BUCKET_IMP(B) ((B)->method_imp)
1710 #define CACHE_BUCKET_VALID(B) (B)
1711 #ifndef __LP64__
1712 #define CACHE_HASH(sel, mask) (((uintptr_t)(sel)>>2) & (mask))
1713 #else
1714 #define CACHE_HASH(sel, mask) (((unsigned int)((uintptr_t)(sel)>>3)) & (mask))
1715 #endif
1716 struct objc_cache {
1717 unsigned int mask /* total = mask + 1 */ OBJC2_UNAVAILABLE;
1718 unsigned int occupied OBJC2_UNAVAILABLE;
1719 Method buckets[1] OBJC2_UNAVAILABLE;
1720 };
1721
1722
1723 typedef struct objc_module *Module OBJC2_UNAVAILABLE;
1724
1725 struct objc_module {
1726 unsigned long version OBJC2_UNAVAILABLE;
1727 unsigned long size OBJC2_UNAVAILABLE;
1728 const char *name OBJC2_UNAVAILABLE;
1729 Symtab symtab OBJC2_UNAVAILABLE;
1730 } OBJC2_UNAVAILABLE;
1731
1732 #else
1733
1734 struct objc_method_list;
1735
1736 #endif
1737
1738
1739 /* Obsolete functions */
1740
1741 OBJC_EXPORT IMP class_lookupMethod(Class cls, SEL sel)
1742 __OSX_DEPRECATED(10.0, 10.5, "use class_getMethodImplementation instead")
1743 __IOS_DEPRECATED(2.0, 2.0, "use class_getMethodImplementation instead")
1744 __TVOS_DEPRECATED(9.0, 9.0, "use class_getMethodImplementation instead")
1745 __WATCHOS_DEPRECATED(1.0, 1.0, "use class_getMethodImplementation instead");
1746 OBJC_EXPORT BOOL class_respondsToMethod(Class cls, SEL sel)
1747 __OSX_DEPRECATED(10.0, 10.5, "use class_respondsToSelector instead")
1748 __IOS_DEPRECATED(2.0, 2.0, "use class_respondsToSelector instead")
1749 __TVOS_DEPRECATED(9.0, 9.0, "use class_respondsToSelector instead")
1750 __WATCHOS_DEPRECATED(1.0, 1.0, "use class_respondsToSelector instead");
1751 OBJC_EXPORT void _objc_flush_caches(Class cls)
1752 __OSX_DEPRECATED(10.0, 10.5, "not recommended")
1753 __IOS_DEPRECATED(2.0, 2.0, "not recommended")
1754 __TVOS_DEPRECATED(9.0, 9.0, "not recommended")
1755 __WATCHOS_DEPRECATED(1.0, 1.0, "not recommended");
1756
1757 OBJC_EXPORT id object_copyFromZone(id anObject, size_t nBytes, void *z)
1758 __OSX_DEPRECATED(10.0, 10.5, "use object_copy instead")
1759 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
1760 OBJC_ARC_UNAVAILABLE;
1761 OBJC_EXPORT id object_realloc(id anObject, size_t nBytes) OBJC2_UNAVAILABLE;
1762 OBJC_EXPORT id object_reallocFromZone(id anObject, size_t nBytes, void *z) OBJC2_UNAVAILABLE;
1763
1764 #define OBSOLETE_OBJC_GETCLASSES 1
1765 OBJC_EXPORT void *objc_getClasses(void) OBJC2_UNAVAILABLE;
1766 OBJC_EXPORT void objc_addClass(Class myClass) OBJC2_UNAVAILABLE;
1767 OBJC_EXPORT void objc_setClassHandler(int (*)(const char *)) OBJC2_UNAVAILABLE;
1768 OBJC_EXPORT void objc_setMultithreaded (BOOL flag) OBJC2_UNAVAILABLE;
1769
1770 OBJC_EXPORT id class_createInstanceFromZone(Class, size_t idxIvars, void *z)
1771 __OSX_DEPRECATED(10.0, 10.5, "use class_createInstance instead")
1772 __IOS_UNAVAILABLE __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE
1773 OBJC_ARC_UNAVAILABLE;
1774
1775 OBJC_EXPORT void class_addMethods(Class, struct objc_method_list *) OBJC2_UNAVAILABLE;
1776 OBJC_EXPORT void class_removeMethods(Class, struct objc_method_list *) OBJC2_UNAVAILABLE;
1777 OBJC_EXPORT void _objc_resolve_categories_for_class(Class cls) OBJC2_UNAVAILABLE;
1778
1779 OBJC_EXPORT Class class_poseAs(Class imposter, Class original) OBJC2_UNAVAILABLE;
1780
1781 OBJC_EXPORT unsigned int method_getSizeOfArguments(Method m) OBJC2_UNAVAILABLE;
1782 OBJC_EXPORT unsigned method_getArgumentInfo(struct objc_method *m, int arg, const char **type, int *offset) OBJC2_UNAVAILABLE;
1783
1784 OBJC_EXPORT Class objc_getOrigClass(const char *name) OBJC2_UNAVAILABLE;
1785 #define OBJC_NEXT_METHOD_LIST 1
1786 OBJC_EXPORT struct objc_method_list *class_nextMethodList(Class, void **) OBJC2_UNAVAILABLE;
1787 // usage for nextMethodList
1788 //
1789 // void *iterator = 0;
1790 // struct objc_method_list *mlist;
1791 // while ( mlist = class_nextMethodList( cls, &iterator ) )
1792 // ;
1793
1794 OBJC_EXPORT id (*_alloc)(Class, size_t) OBJC2_UNAVAILABLE;
1795 OBJC_EXPORT id (*_copy)(id, size_t) OBJC2_UNAVAILABLE;
1796 OBJC_EXPORT id (*_realloc)(id, size_t) OBJC2_UNAVAILABLE;
1797 OBJC_EXPORT id (*_dealloc)(id) OBJC2_UNAVAILABLE;
1798 OBJC_EXPORT id (*_zoneAlloc)(Class, size_t, void *) OBJC2_UNAVAILABLE;
1799 OBJC_EXPORT id (*_zoneRealloc)(id, size_t, void *) OBJC2_UNAVAILABLE;
1800 OBJC_EXPORT id (*_zoneCopy)(id, size_t, void *) OBJC2_UNAVAILABLE;
1801 OBJC_EXPORT void (*_error)(id, const char *, va_list) OBJC2_UNAVAILABLE;
1802
1803 #endif