RQEXTRuntimeExtensions.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // RQEXTRuntimeExtensions.h
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/16.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import <objc/runtime.h>
  9. /**
  10. * Describes the memory management policy of a property.
  11. */
  12. typedef enum {
  13. /**
  14. * The value is assigned.
  15. */
  16. rq_propertyMemoryManagementPolicyAssign = 0,
  17. /**
  18. * The value is retained.
  19. */
  20. rq_propertyMemoryManagementPolicyRetain,
  21. /**
  22. * The value is copied.
  23. */
  24. rq_propertyMemoryManagementPolicyCopy
  25. } rq_propertyMemoryManagementPolicy;
  26. /**
  27. * Describes the attributes and type information of a property.
  28. */
  29. typedef struct {
  30. /**
  31. * Whether this property was declared with the \c readonly attribute.
  32. */
  33. BOOL readonly;
  34. /**
  35. * Whether this property was declared with the \c nonatomic attribute.
  36. */
  37. BOOL nonatomic;
  38. /**
  39. * Whether the property is a weak reference.
  40. */
  41. BOOL weak;
  42. /**
  43. * Whether the property is eligible for garbage collection.
  44. */
  45. BOOL canBeCollected;
  46. /**
  47. * Whether this property is defined with \c \@dynamic.
  48. */
  49. BOOL dynamic;
  50. /**
  51. * The memory management policy for this property. This will always be
  52. * #rq_propertyMemoryManagementPolicyAssign if #readonly is \c YES.
  53. */
  54. rq_propertyMemoryManagementPolicy memoryManagementPolicy;
  55. /**
  56. * The selector for the getter of this property. This will reflect any
  57. * custom \c getter= attribute provided in the property declaration, or the
  58. * inferred getter name otherwise.
  59. */
  60. SEL getter;
  61. /**
  62. * The selector for the setter of this property. This will reflect any
  63. * custom \c setter= attribute provided in the property declaration, or the
  64. * inferred setter name otherwise.
  65. *
  66. * @note If #readonly is \c YES, this value will represent what the setter
  67. * \e would be, if the property were writable.
  68. */
  69. SEL setter;
  70. /**
  71. * The backing instance variable for this property, or \c NULL if \c
  72. * \c @synthesize was not used, and therefore no instance variable exists. This
  73. * would also be the case if the property is implemented dynamically.
  74. */
  75. const char *ivar;
  76. /**
  77. * If this property is defined as being an instance of a specific class,
  78. * this will be the class object representing it.
  79. *
  80. * This will be \c nil if the property was defined as type \c id, if the
  81. * property is not of an object type, or if the class could not be found at
  82. * runtime.
  83. */
  84. Class objectClass;
  85. /**
  86. * The type encoding for the value of this property. This is the type as it
  87. * would be returned by the \c \@encode() directive.
  88. */
  89. char type[];
  90. } rq_propertyAttributes;
  91. /**
  92. * Returns a pointer to a structure containing information about \a property.
  93. * You must \c free() the returned pointer. Returns \c NULL if there is an error
  94. * obtaining information from \a property.
  95. */
  96. rq_propertyAttributes *rq_copyPropertyAttributes (objc_property_t property);