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