Overview
Comment: | runtime: Document all public functions |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
85ff529ac5e78f2b624c6da261a01b72 |
User & Date: | js on 2020-09-26 19:04:42 |
Other Links: | manifest | tags |
References
2020-09-26
| ||
19:15 | • Fixed ticket [e6e31ea81f]: Add documentation for runtime functions plus 4 other changes artifact: b8e7ff9f4a user: js | |
Context
2020-09-26
| ||
21:58 | Don't require __COUNTER__ for OF_RESERVE_IVARS check-in: ef614a225d user: js tags: trunk | |
19:04 | runtime: Document all public functions check-in: 85ff529ac5 user: js tags: trunk | |
2020-08-29
| ||
23:17 | ofhttp: Translate "Error!" message check-in: f79f04f882 user: js tags: trunk | |
Changes
Modified src/runtime/ObjFWRT.h from [439a147585] to [f4b3f5f3f4].
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <stdbool.h> #include <stddef.h> #include <stdint.h> #ifndef __has_feature # define __has_feature(x) 0 #endif #ifndef __has_attribute # define __has_attribute(x) 0 | > > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #include <stdbool.h> #include <stddef.h> #include <stdint.h> /*! @file */ #ifndef __has_feature # define __has_feature(x) 0 #endif #ifndef __has_attribute # define __has_attribute(x) 0 |
︙ | ︙ | |||
75 76 77 78 79 80 81 | * @brief An Objective-C boolean representing false. * * @note This is a legacy from before C had a boolean type. Prefer the standard * C99 false instead! */ #define NO false | < < | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | * @brief An Objective-C boolean representing false. * * @note This is a legacy from before C had a boolean type. Prefer the standard * C99 false instead! */ #define NO false /*! * @brief A pointer to a class. */ typedef struct objc_class *Class; /*! * @brief A pointer to any object. |
︙ | ︙ | |||
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | Class _Nonnull class; #endif }; #ifdef __cplusplus extern "C" { #endif extern SEL _Nonnull sel_registerName(const char *_Nonnull name); extern const char *_Nonnull sel_getName(SEL _Nonnull selector); extern bool sel_isEqual(SEL _Nonnull selector1, SEL _Nonnull selector2); extern Class _Nonnull objc_allocateClassPair(Class _Nullable superclass, const char *_Nonnull name, size_t extraBytes); extern void objc_registerClassPair(Class _Nonnull class_); extern unsigned int objc_getClassList(Class _Nonnull *_Nullable buffer, unsigned int count); extern Class _Nonnull *_Nonnull objc_copyClassList( unsigned int *_Nullable length); extern bool class_isMetaClass(Class _Nullable class_); extern const char *_Nullable class_getName(Class _Nullable class_); extern Class _Nullable class_getSuperclass(Class _Nullable class_); extern unsigned long class_getInstanceSize(Class _Nullable class_); extern bool class_respondsToSelector(Class _Nullable class_, SEL _Nonnull selector); extern bool class_conformsToProtocol(Class _Nullable class_, Protocol *_Nonnull protocol); extern IMP _Nullable class_getMethodImplementation(Class _Nullable class_, SEL _Nonnull selector); extern IMP _Nullable class_getMethodImplementation_stret(Class _Nullable class_, SEL _Nonnull selector); extern Method _Nullable class_getInstanceMethod(Class _Nullable class_, SEL _Nonnull selector); extern bool class_addMethod(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); extern IMP _Nullable class_replaceMethod(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); extern Class _Nullable object_getClass(id _Nullable object); extern Class _Nullable object_setClass(id _Nullable object, Class _Nonnull class_); extern const char *_Nullable object_getClassName(id _Nullable object); extern const char *_Nonnull protocol_getName(Protocol *_Nonnull protocol); extern bool protocol_isEqual(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); extern bool protocol_conformsToProtocol(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); extern Method _Nullable *_Nullable class_copyMethodList(Class _Nullable class_, unsigned int *_Nullable outCount); extern SEL _Nonnull method_getName(Method _Nonnull method); extern const char *_Nullable method_getTypeEncoding(Method _Nonnull method); extern Ivar _Nullable *_Nullable class_copyIvarList(Class _Nullable class_, unsigned int *_Nullable outCount); extern const char *_Nonnull ivar_getName(Ivar _Nonnull ivar); extern const char *_Nonnull ivar_getTypeEncoding(Ivar _Nonnull ivar); extern ptrdiff_t ivar_getOffset(Ivar _Nonnull ivar); extern objc_property_t _Nullable *_Nullable class_copyPropertyList( Class _Nullable class_, unsigned int *_Nullable outCount); extern const char *_Nonnull property_getName(objc_property_t _Nonnull property); extern char *_Nullable property_copyAttributeValue( objc_property_t _Nonnull property, const char *_Nonnull name); extern void objc_exit(void); extern _Nullable objc_uncaught_exception_handler_t objc_setUncaughtExceptionHandler( objc_uncaught_exception_handler_t _Nullable handler); extern void objc_setForwardHandler(IMP _Nullable forward, IMP _Nullable stretForward); extern void objc_setEnumerationMutationHandler( objc_enumeration_mutation_handler_t _Nullable handler); extern id _Nullable objc_constructInstance(Class _Nullable class_, void *_Nullable bytes); extern void *_Nullable objc_destructInstance(id _Nullable object); extern void *_Null_unspecified objc_autoreleasePoolPush(void); extern void objc_autoreleasePoolPop(void *_Null_unspecified pool); extern id _Nullable _objc_rootAutorelease(id _Nullable object); /* * Used by the compiler, but can also be called manually. * * These declarations are also required to prevent Clang's implicit * declarations which include __declspec(dllimport) on Windows. | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | Class _Nonnull class; #endif }; #ifdef __cplusplus extern "C" { #endif /*! * @brief Registers a selector with the specified name with the runtime. * * @param name The name for the selector to register * @return The registered selector */ extern SEL _Nonnull sel_registerName(const char *_Nonnull name); /*! * @brief Returns the name of the specified selector. * * @param selector The selector whose name should be returned * @return The name of the specified selector */ extern const char *_Nonnull sel_getName(SEL _Nonnull selector); /*! * @brief Checks two selectors for equality. * * Selectors are considered equal if they have the same name - any type * encoding is ignored. * * @param selector1 The first selector * @param selector2 The second selector * @return Whether the two selectors are equal */ extern bool sel_isEqual(SEL _Nonnull selector1, SEL _Nonnull selector2); /*! * @brief Allocates a new class and its metaclass. * * @param superclass The superclass for the new class * @param name The name for the new class * @param extraBytes Extra bytes to add to the instance size * @return A new, unregistered class pair */ extern Class _Nonnull objc_allocateClassPair(Class _Nullable superclass, const char *_Nonnull name, size_t extraBytes); /*! * @brief Registers an already allocated class pair. * * @param class_ The class pair to register */ extern void objc_registerClassPair(Class _Nonnull class_); /*! * @brief Gets the list of all classes known to the runtime. * * @param buffer An array of Class to write to. If the buffer does not have * enough space, the result is truncated. * @param count The number of classes for which there is space in `buffer` * @return The number of classes written */ extern unsigned int objc_getClassList(Class _Nonnull *_Nullable buffer, unsigned int count); /*! * @brief Copies the list of all classes known to the runtime. * * This is like @ref objc_getClassList, but allocates a buffer large enough for * all classes. * * @param length An optional pointer to an `unsigned int` that will be set to * the number of classes returned * @return An array of classes, terminated by `Nil`. You need to call `free()` * on it when done. */ extern Class _Nonnull *_Nonnull objc_copyClassList( unsigned int *_Nullable length); /*! * @brief Returns whether the specified class is a metaclass. * * @param class_ The class which should be examined * @return Whether the specified class is a metaclass */ extern bool class_isMetaClass(Class _Nullable class_); /*! * @brief Returns the name of the specified class. * * @param class_ The class whose name should be returned * @return The name of the specified class */ extern const char *_Nullable class_getName(Class _Nullable class_); /*! * @brief Returns the superclass of the specified class. * * @param class_ The class whose superclass should be returned * @return The superclass of the specified class */ extern Class _Nullable class_getSuperclass(Class _Nullable class_); /*! * @brief Returns the instance size of the specified class. * * @param class_ The class whose instance size should be returned * @return The instance size of the specified class */ extern unsigned long class_getInstanceSize(Class _Nullable class_); /*! * @brief Returns whether the specified class responds to the specified * selector. * * @param class_ The class which should be examined * @param selector The selector which should be checked * @return Whether the specified class responds to the specified selector */ extern bool class_respondsToSelector(Class _Nullable class_, SEL _Nonnull selector); /*! * @brief Returns whether the specified class conforms to the specified * protocol. * * @param class_ The class which should be examined * @param protocol The protocol for which conformance should be checked * @return Whether the specified class conforms to the specified protocol */ extern bool class_conformsToProtocol(Class _Nullable class_, Protocol *_Nonnull protocol); /*! * @brief Returns the class's method implementation for the specified selector. * * @warning If the method uses the struct return ABI, you need to use * @ref class_getMethodImplementation_stret instead! Depending on the * ABI, small structs might not use the struct return ABI. * * @param class_ The class whose method implementation should be returned * @param selector The selector for the method whose implementation should be * returned * @return The class's metod implementation for the specified selector */ extern IMP _Nullable class_getMethodImplementation(Class _Nullable class_, SEL _Nonnull selector); /*! * @brief Returns the class's method implementation for the specified selector. * * @warning If the method does not use use the struct return ABI, you need to * use @ref class_getMethodImplementation instead! Depending on the * ABI, small structs might not use the struct return ABI. * * @param class_ The class whose method implementation should be returned * @param selector The selector for the method whose implementation should be * returned * @return The class's metod implementation for the specified selector */ extern IMP _Nullable class_getMethodImplementation_stret(Class _Nullable class_, SEL _Nonnull selector); /*! * @brief Returns the class's instance method for the specified selector * * @param class_ The class whose instance method should be returned * @param selector The selector of the instance method to return * @return The class's instance method for the specified selector */ extern Method _Nullable class_getInstanceMethod(Class _Nullable class_, SEL _Nonnull selector); /*! * @brief Adds the specified method to the class. * * @param class_ The class to which to add the method * @param selector The selector for the method to add * @param implementation The implementation of the method to add * @param typeEncoding The type encoding of the method to add * @return Whether the specified method was added */ extern bool class_addMethod(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); /*! * @brief Replaces or adds the specified method of the class. * * @param class_ The class to which to replace the method * @param selector The selector for the method to replace * @param implementation The implementation of the method to replace * @param typeEncoding The type encoding of the method to replace. Only used if * the method does not exist yet. * @return The old implementation of the method */ extern IMP _Nullable class_replaceMethod(Class _Nonnull class_, SEL _Nonnull selector, IMP _Nonnull implementation, const char *_Nullable typeEncoding); /*! * @brief Returns the object's class. * * @param object The object whose class should be returned * @return The object's class */ extern Class _Nullable object_getClass(id _Nullable object); /*! * @brief Sets the object's class. * * This can be used to swizzle an object's class. * * @param object The object whose class should be set * @param class_ The new class for the object * @return The old class of the object */ extern Class _Nullable object_setClass(id _Nullable object, Class _Nonnull class_); /*! * @brief Returns the object's class name. * * @param object The object whose class name should be returned * @return The object's class name */ extern const char *_Nullable object_getClassName(id _Nullable object); /*! * @brief Returns the name of the specified protocol. * * @param protocol The protocol whose name should be returned * @return The name of the specified protocol */ extern const char *_Nonnull protocol_getName(Protocol *_Nonnull protocol); /*! * @brief Returns whether two protocols are equal. * * @param protocol1 The first protocol * @param protocol2 The second protocol * @return Whether the two protocols are equal */ extern bool protocol_isEqual(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); /*! * @brief Returns whether the first protocol conforms to the second protocol. * * @param protocol1 The first protocol * @param protocol2 The second protocol * @return Whether the first protocol conforms to the second protocol */ extern bool protocol_conformsToProtocol(Protocol *_Nonnull protocol1, Protocol *_Nonnull protocol2); /*! * @brief Copies the method list of the specified class. * * @param class_ The class whose method list should be copied * @param outCount An optional pointer to an `unsigned int` that should be set * to the number of methods returned * @return An array of methods, terminated by `NULL`. You need to call `free()` * on it when done. */ extern Method _Nullable *_Nullable class_copyMethodList(Class _Nullable class_, unsigned int *_Nullable outCount); /*! * @brief Returns the name of the specified method. * * @param method The method whose name should be returned * @return The name of the specified method */ extern SEL _Nonnull method_getName(Method _Nonnull method); /*! * @brief Returns the type encoding of the specified method. * * @param method The method whose type encoding should be returned * @return The type encoding of the specified method */ extern const char *_Nullable method_getTypeEncoding(Method _Nonnull method); /*! * @brief Copies the instance variable list of the specified class. * * @param class_ The class whose instance variable list should be copied * @param outCount An optional pointer to an `unsigned int` that should be set * to the number of instance variables returned * @return An array of instance variables, terminated by `NULL`. You need to * call `free()` on it when done. */ extern Ivar _Nullable *_Nullable class_copyIvarList(Class _Nullable class_, unsigned int *_Nullable outCount); /*! * @brief Returns the name of the specified instance variable. * * @param ivar The instance variable whose name should be returned * @return The name of the specified instance variable */ extern const char *_Nonnull ivar_getName(Ivar _Nonnull ivar); /*! * @brief Returns the type encoding of the specified instance variable. * * @param ivar The instance variable whose type encoding should be returned * @return The type encoding of the specified instance variable */ extern const char *_Nonnull ivar_getTypeEncoding(Ivar _Nonnull ivar); /*! * @brief Returns the offset of the specified instance variable. * * @param ivar The instance variable whose offset should be returned * @return The offset of the specified instance variable */ extern ptrdiff_t ivar_getOffset(Ivar _Nonnull ivar); /*! * @brief Copies the property list of the specified class. * * @param class_ The class whose property list should be copied * @param outCount An optional pointer to an `unsigned int` that should be set * to the number of properties returned * @return An array of properties, terminated by `NULL`. You need to call * `free()` on it when done. */ extern objc_property_t _Nullable *_Nullable class_copyPropertyList( Class _Nullable class_, unsigned int *_Nullable outCount); /*! * @brief Returns the name of the specified property. * * @param property The property whose name should be returned * @return The name of the specified property */ extern const char *_Nonnull property_getName(objc_property_t _Nonnull property); /*! * @brief Copies the specified attribute value. * * @param property The property whose attribute value should be copied * @param name The name of the attribute value to copy * @return A copy of the attribute value. You need to call `free()` on it when * done. */ extern char *_Nullable property_copyAttributeValue( objc_property_t _Nonnull property, const char *_Nonnull name); /*! * @brief Exits the Objective-C runtime. * * This frees all data structures used by the runtime, after which Objective-C * can no longer be used inside the current process. This is only useful for * debugging. */ extern void objc_exit(void); /*! * @brief Sets the handler for uncaught exceptions. * * @param handler The new handler for uncaught exceptions * @return The old handler for uncaught exceptions */ extern _Nullable objc_uncaught_exception_handler_t objc_setUncaughtExceptionHandler( objc_uncaught_exception_handler_t _Nullable handler); /*! * @brief Sets the forwarding handler for unimplemented methods. * * @param forward The forwarding handler for regular methods * @param stretForward The forwarding handler for methods using the struct * return ABI */ extern void objc_setForwardHandler(IMP _Nullable forward, IMP _Nullable stretForward); /*! * @brief Sets the handler for mutations during enumeration. * * @param handler The handler for mutations during enumeration */ extern void objc_setEnumerationMutationHandler( objc_enumeration_mutation_handler_t _Nullable handler); /*! * @brief Constructs an instance of the specified class in the specified array * of bytes. * * @param class_ The class of which to construct an instance * @param bytes An array of bytes of at least the length of the instance size. * Must be properly aligned for the class. * @return The constructed instance */ extern id _Nullable objc_constructInstance(Class _Nullable class_, void *_Nullable bytes); /*! * @brief Destructs the specified object. * * @param object The object to destruct * @return The array of bytes that was used to back the instance */ extern void *_Nullable objc_destructInstance(id _Nullable object); /*! * @brief Creates a new autorelease pool and puts it on top of the stack of * autorelease pools. * * @return A new autorelease pool, which is now on the top of the stack of * autorelease pools */ extern void *_Null_unspecified objc_autoreleasePoolPush(void); /*! * @brief Drains the specified autorelease pool and all pools on top of it and * removes it from the stack of autorelease pools. * * @param pool The pool which should be drained together with all pools on top * of it */ extern void objc_autoreleasePoolPop(void *_Null_unspecified pool); /*! * @brief Adds the specified object to the topmost autorelease pool. * * This is only to be used to implement the `autorelease` method in a root * class. * * @param object The object to add to the topmost autorelease pool * @return The autoreleased object */ extern id _Nullable _objc_rootAutorelease(id _Nullable object); /* * Used by the compiler, but can also be called manually. * * These declarations are also required to prevent Clang's implicit * declarations which include __declspec(dllimport) on Windows. |
︙ | ︙ |
Modified src/runtime/class.m from [959b2ef399] to [25a8ac61a2].
︙ | ︙ | |||
466 467 468 469 470 471 472 | Class objc_allocateClassPair(Class superclass, const char *name, size_t extraBytes) { struct objc_class *class, *metaclass; Class iter, rootclass = Nil; if (extraBytes > LONG_MAX) | | | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | Class objc_allocateClassPair(Class superclass, const char *name, size_t extraBytes) { struct objc_class *class, *metaclass; Class iter, rootclass = Nil; if (extraBytes > LONG_MAX) OBJC_ERROR("extraBytes out of range!") if ((class = calloc(1, sizeof(*class))) == NULL || (metaclass = calloc(1, sizeof(*class))) == NULL) OBJC_ERROR("Not enough memory to allocate class pair for class " "%s!", name) class->isa = metaclass; |
︙ | ︙ |