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