Differences From Artifact [1907dcf7b8]:
- File
src/OFObject.h
— part of check-in
[ffb39d1df6]
at
2015-03-30 21:33:29
on branch trunk
— Add OF_NO_RETURN_FUNC
OF_NO_RETURN_FUNC is defined when __attribute__((__noreturn__)) is
supported for functions, whereas OF_NO_RETURN is only defined when it is
supported for both functions and methods. (user: js, size: 26640) [annotate] [blame] [check-ins using]
To Artifact [c9ef03c38f]:
- File src/OFObject.h — part of check-in [9e76144ef8] at 2015-06-13 22:26:05 on branch trunk — Add support for and use the new nullability (user: js, size: 27023) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <stdint.h> #include <stdbool.h> #include <limits.h> #import "macros.h" #import "autorelease.h" /*! @file */ /*! * @brief A result of a comparison. */ typedef enum { /*! The left object is smaller than the right */ | > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <stdint.h> #include <stdbool.h> #include <limits.h> #import "macros.h" #import "autorelease.h" OF_ASSUME_NONNULL_BEGIN /*! @file */ /*! * @brief A result of a comparison. */ typedef enum { /*! The left object is smaller than the right */ |
︙ | ︙ | |||
232 233 234 235 236 237 238 | /*! * @brief Returns the implementation for the specified selector. * * @param selector The selector for which the method should be returned * @return The implementation for the specified selector */ | | | | | | | | | | | 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 | /*! * @brief Returns the implementation for the specified selector. * * @param selector The selector for which the method should be returned * @return The implementation for the specified selector */ - (nullable IMP)methodForSelector: (SEL)selector; /*! * @brief Returns the type encoding for the specified selector. * * @param selector The selector for which the type encoding should be returned * @return The type encoding for the specified selector */ - (nullable const char*)typeEncodingForSelector: (SEL)selector; /*! * @brief Performs the specified selector. * * @param selector The selector to perform * @return The object returned by the method specified by the selector */ - (nullable id)performSelector: (SEL)selector; /*! * @brief Performs the specified selector with the specified object. * * @param selector The selector to perform * @param object The object that is passed to the method specified by the * selector * @return The object returned by the method specified by the selector */ - (nullable id)performSelector: (SEL)selector withObject: (nullable id)object; /*! * @brief Performs the specified selector with the specified objects. * * @param selector The selector to perform * @param object1 The first object that is passed to the method specified by the * selector * @param object2 The second object that is passed to the method specified by * the selector * @return The object returned by the method specified by the selector */ - (nullable id)performSelector: (SEL)selector withObject: (nullable id)object1 withObject: (nullable id)object2; /*! * @brief Checks two objects for equality. * * Classes containing data (like strings, arrays, lists etc.) should reimplement * this! * * @warning If you reimplement this, you also need to reimplement @ref hash to * return the same hash for objects which are equal! * * @param object The object which should be tested for equality * @return A boolean whether the object is equal to the specified object */ - (bool)isEqual: (nullable id)object; /*! * @brief Calculates a hash for the object. * * Classes containing data (like strings, arrays, lists etc.) should reimplement * this! * |
︙ | ︙ | |||
467 468 469 470 471 472 473 | * @brief Returns the implementation of the instance method for the specified * selector. * * @param selector The selector for which the method should be returned * @return The implementation of the instance method for the specified selector * or nil if it isn't implemented */ | | | | | | | | | | | | | | 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 | * @brief Returns the implementation of the instance method for the specified * selector. * * @param selector The selector for which the method should be returned * @return The implementation of the instance method for the specified selector * or nil if it isn't implemented */ + (nullable IMP)instanceMethodForSelector: (SEL)selector; /*! * @brief Returns the type encoding of the instance method for the specified * selector. * * @param selector The selector for which the type encoding should be returned * @return The type encoding of the instance method for the specified selector */ + (nullable const char*)typeEncodingForInstanceSelector: (SEL)selector; /*! * @brief Returns a description for the class, which is usually the class name. * * This is mostly for debugging purposes. * * @return A description for the class, which is usually the class name */ + (OFString*)description; /*! * @brief Replaces a class method with a class method from another class. * * @param selector The selector of the class method to replace * @param class_ The class from which the new class method should be taken * @return The old implementation */ + (nullable IMP)replaceClassMethod: (SEL)selector withMethodFromClass: (Class)class_; /*! * @brief Replaces an instance method with an instance method from another * class. * * @param selector The selector of the instance method to replace * @param class_ The class from which the new instance method should be taken * @return The old implementation */ + (nullable IMP)replaceInstanceMethod: (SEL)selector withMethodFromClass: (Class)class_; /*! * @brief Replaces or adds a class method. * * If the method already exists, it is replaced and the old implementation * returned. If the method does not exist, it is added with the specified type * encoding. * * @param selector The selector for the new method * @param implementation The implementation for the new method * @param typeEncoding The type encoding for the new method * @return The old implementation or nil if the method was added */ + (nullable IMP)replaceClassMethod: (SEL)selector withImplementation: (IMP)implementation typeEncoding: (const char*)typeEncoding; /*! * @brief Replaces or adds an instance method. * * If the method already exists, it is replaced and the old implementation * returned. If the method does not exist, it is added with the specified type * encoding. * * @param selector The selector for the new method * @param implementation The implementation for the new method * @param typeEncoding The type encoding for the new method * @return The old implementation or nil if the method was added */ + (nullable IMP)replaceInstanceMethod: (SEL)selector withImplementation: (IMP)implementation typeEncoding: (const char*)typeEncoding; /*! * @brief Adds all methods from the specified class to the class that is the * receiver. * * Methods implemented by the receiving class itself will not be overridden, * however methods implemented by its superclass will. Therefore it behaves |
︙ | ︙ | |||
654 655 656 657 658 659 660 | * If the pointer is NULL, this is equivalent to allocating memory. * If the size is 0, this is equivalent to freeing memory. * * @param pointer A pointer to the already allocated memory * @param size The new size for the memory chunk * @return A pointer to the resized memory chunk */ | | | | | | | | 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | * If the pointer is NULL, this is equivalent to allocating memory. * If the size is 0, this is equivalent to freeing memory. * * @param pointer A pointer to the already allocated memory * @param size The new size for the memory chunk * @return A pointer to the resized memory chunk */ - (nullable void*)resizeMemory: (nullable void*)pointer size: (size_t)size; /*! * @brief Resizes memory in the object's memory pool to the specific number of * items of the specified size. * * If the pointer is NULL, this is equivalent to allocating memory. * If the size or number of items is 0, this is equivalent to freeing memory. * * @param pointer A pointer to the already allocated memory * @param size The size of each item to resize to * @param count The number of items to resize to * @return A pointer to the resized memory chunk */ - (nullable void*)resizeMemory: (nullable void*)pointer size: (size_t)size count: (size_t)count; /*! * @brief Frees allocated memory and removes it from the object's memory pool. * * Does nothing if the pointer is NULL. * * @param pointer A pointer to the allocated memory */ - (void)freeMemory: (nullable void*)pointer; /*! * @brief Deallocates the object. * * It is automatically called when the retain count reaches zero. * * This also frees all memory in its memory pool. |
︙ | ︙ | |||
710 711 712 713 714 715 716 | * * @param selector The selector to perform * @param object The object that is passed to the method specified by the * selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector | | | | | 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | * * @param selector The selector to perform * @param object The object that is passed to the method specified by the * selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector withObject: (nullable id)object afterDelay: (of_time_interval_t)delay; /*! * @brief Performs the specified selector with the specified objects after the * specified delay. * * @param selector The selector to perform * @param object1 The first object that is passed to the method specified by the * selector * @param object2 The second object that is passed to the method specified by * the selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector withObject: (nullable id)object1 withObject: (nullable id)object2 afterDelay: (of_time_interval_t)delay; #ifdef OF_HAVE_THREADS /*! * @brief Performs the specified selector on the specified thread. * * @param selector The selector to perform |
︙ | ︙ | |||
753 754 755 756 757 758 759 | * @param thread The thread on which to perform the selector * @param object The object that is passed to the method specified by the * selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread | | | | | 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | * @param thread The thread on which to perform the selector * @param object The object that is passed to the method specified by the * selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread withObject: (nullable id)object waitUntilDone: (bool)waitUntilDone; /*! * @brief Performs the specified selector on the specified thread with the * specified objects. * * @param selector The selector to perform * @param thread The thread on which to perform the selector * @param object1 The first object that is passed to the method specified by the * selector * @param object2 The second object that is passed to the method specified by * the selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread withObject: (nullable id)object1 withObject: (nullable id)object2 waitUntilDone: (bool)waitUntilDone; /*! * @brief Performs the specified selector on the main thread. * * @param selector The selector to perform * @param waitUntilDone Whether to wait until the perform finished |
︙ | ︙ | |||
793 794 795 796 797 798 799 | * * @param selector The selector to perform * @param object The object that is passed to the method specified by the * selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelectorOnMainThread: (SEL)selector | | | | | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 | * * @param selector The selector to perform * @param object The object that is passed to the method specified by the * selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelectorOnMainThread: (SEL)selector withObject: (nullable id)object waitUntilDone: (bool)waitUntilDone; /*! * @brief Performs the specified selector on the main thread with the specified * objects. * * @param selector The selector to perform * @param object1 The first object that is passed to the method specified by the * selector * @param object2 The second object that is passed to the method specified by * the selector * @param waitUntilDone Whether to wait until the perform finished */ - (void)performSelectorOnMainThread: (SEL)selector withObject: (nullable id)object1 withObject: (nullable id)object2 waitUntilDone: (bool)waitUntilDone; /*! * @brief Performs the specified selector on the specified thread after the * specified delay. * * @param selector The selector to perform |
︙ | ︙ | |||
836 837 838 839 840 841 842 | * @param thread The thread on which to perform the selector * @param object The object that is passed to the method specified by the * selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread | | | | | | 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | * @param thread The thread on which to perform the selector * @param object The object that is passed to the method specified by the * selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread withObject: (nullable id)object afterDelay: (of_time_interval_t)delay; /*! * @brief Performs the specified selector on the specified thread with the * specified objects after the specified delay. * * @param selector The selector to perform * @param thread The thread on which to perform the selector * @param object1 The first object that is passed to the method specified by the * selector * @param object2 The second object that is passed to the method specified by * the selector * @param delay The delay after which the selector will be performed */ - (void)performSelector: (SEL)selector onThread: (OFThread*)thread withObject: (nullable id)object1 withObject: (nullable id)object2 afterDelay: (of_time_interval_t)delay; #endif /*! * @brief This method is called when @ref resolveClassMethod: or * @ref resolveInstanceMethod: returned false. It should return a target * to which the message should be forwarded. * * @note When the message should not be forwarded, you should not return nil, * but instead return the result of the superclass! * * @return The target to forward the message to */ - (nullable id)forwardingTargetForSelector: (SEL)selector; /*! * @brief Handles messages which are not understood by the receiver. * * @warning If you override this method, you must make sure that it never * returns. * |
︙ | ︙ | |||
933 934 935 936 937 938 939 | * * @param object An object to compare the object to * @return The result of the comparison */ - (of_comparison_result_t)compare: (id <OFComparing>)object; @end | < < | | > > > > | 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 | * * @param object An object to compare the object to * @return The result of the comparison */ - (of_comparison_result_t)compare: (id <OFComparing>)object; @end #ifdef __cplusplus extern "C" { #endif extern id of_alloc_object(Class class_, size_t extraSize, size_t extraAlignment, __nonnull void **__nullable extra); extern void OF_NO_RETURN_FUNC of_method_not_found(id self, SEL _cmd); extern uint32_t of_hash_seed; #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END #import "OFObject+Serialization.h" |