EXTRuntimeExtensions.h 3.0 KB

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