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