}
}
+static const char *PropertyMemoryAttribute(ASTContext &Context, QualType ArgType) {
+ Qualifiers::ObjCLifetime propertyLifetime = ArgType.getObjCLifetime();
+ bool RetainableObject = ArgType->isObjCRetainableType();
+ if (RetainableObject && propertyLifetime == Qualifiers::OCL_Strong) {
+ if (const ObjCObjectPointerType *ObjPtrTy =
+ ArgType->getAs<ObjCObjectPointerType>()) {
+ ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface();
+ if (IDecl &&
+ IDecl->lookupNestedProtocol(&Context.Idents.get("NSCopying")))
+ return "copy";
+ else
+ return "retain";
+ }
+ else if (ArgType->isBlockPointerType())
+ return "copy";
+ } else if (propertyLifetime == Qualifiers::OCL_Weak)
+ // TODO. More precise determination of 'weak' attribute requires
+ // looking into setter's implementation for backing weak ivar.
+ return "weak";
+ else if (RetainableObject)
+ return ArgType->isBlockPointerType() ? "copy" : "retain";
+ return 0;
+}
static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
const ObjCMethodDecl *Setter,
}
// Property with no setter may be suggested as a 'readonly' property.
if (!Setter) {
- if (!LParenAdded) {
- PropertyString += "(readonly";
- LParenAdded = true;
- }
- else
- append_attr(PropertyString, "readonly", LParenAdded);
+ append_attr(PropertyString, "readonly", LParenAdded);
+ QualType ResType = Context.getCanonicalType(Getter->getResultType());
+ if (const char *MemoryManagementAttr = PropertyMemoryAttribute(Context, ResType))
+ append_attr(PropertyString, MemoryManagementAttr, LParenAdded);
}
// Short circuit 'delegate' properties that contain the name "delegate" or
else if (Setter) {
const ParmVarDecl *argDecl = *Setter->param_begin();
QualType ArgType = Context.getCanonicalType(argDecl->getType());
- Qualifiers::ObjCLifetime propertyLifetime = ArgType.getObjCLifetime();
- bool RetainableObject = ArgType->isObjCRetainableType();
- if (RetainableObject && propertyLifetime == Qualifiers::OCL_Strong) {
- if (const ObjCObjectPointerType *ObjPtrTy =
- ArgType->getAs<ObjCObjectPointerType>()) {
- ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface();
- if (IDecl &&
- IDecl->lookupNestedProtocol(&Context.Idents.get("NSCopying")))
- append_attr(PropertyString, "copy", LParenAdded);
- else
- append_attr(PropertyString, "retain", LParenAdded);
- }
- else if (ArgType->isBlockPointerType())
- append_attr(PropertyString, "copy", LParenAdded);
- } else if (propertyLifetime == Qualifiers::OCL_Weak)
- // TODO. More precise determination of 'weak' attribute requires
- // looking into setter's implementation for backing weak ivar.
- append_attr(PropertyString, "weak", LParenAdded);
- else if (RetainableObject)
- append_attr(PropertyString,
- ArgType->isBlockPointerType() ? "copy" : "retain", LParenAdded);
+ if (const char *MemoryManagementAttr = PropertyMemoryAttribute(Context, ArgType))
+ append_attr(PropertyString, MemoryManagementAttr, LParenAdded);
}
if (LParenAdded)
PropertyString += ')';
- (void) Nothing;
@property (readonly) int Length;
-@property (readonly) id object;
+@property (readonly, retain) id object;
+ (double) D;
@property (readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
@property (getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents;
@property (getter=getStringValue, retain) NSString *stringValue;
@property (getter=getCounterValue, readonly) BOOL counterValue;
-@property (getter=getns_dixtionary, readonly) NSDictionary *ns_dixtionary;
+@property (getter=getns_dixtionary, readonly, retain) NSDictionary *ns_dixtionary;
- (BOOL)is3bar; // watch out
- (NSString *)get3foo; // watch out
- (void) Nothing;
@property (readonly) int Length;
-@property (readonly) id object;
+@property (readonly, retain) id object;
+ (double) D;
- (BOOL)is3bar; // watch out
@property (retain) NSURL *appStoreReceiptURLY ;
- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
-@property (readonly) id OkToInfer NS_AVAILABLE;
+@property (readonly, retain) id OkToInfer NS_AVAILABLE;
// Do not infer a property.
@property (retain) NSURL *appStoreReceiptURLZ ;
@class NSMutableDictionary;
@interface NSArray
-@property (readonly) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
+@property (readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
@property (copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *);
@property (readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *);
@property id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *);
- (void) Nothing;
@property (NS_NONATOMIC_IOSONLY, readonly) int Length;
-@property (NS_NONATOMIC_IOSONLY, readonly) id object;
+@property (NS_NONATOMIC_IOSONLY, readonly, retain) id object;
+ (double) D;
@property (NS_NONATOMIC_IOSONLY, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
@property (NS_NONATOMIC_IOSONLY, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents;
@property (NS_NONATOMIC_IOSONLY, getter=getStringValue, retain) NSString *stringValue;
@property (NS_NONATOMIC_IOSONLY, getter=getCounterValue, readonly) BOOL counterValue;
-@property (NS_NONATOMIC_IOSONLY, getter=getns_dixtionary, readonly) NSDictionary *ns_dixtionary;
+@property (NS_NONATOMIC_IOSONLY, getter=getns_dixtionary, readonly, retain) NSDictionary *ns_dixtionary;
- (BOOL)is3bar; // watch out
- (NSString *)get3foo; // watch out
- (void) Nothing;
@property (NS_NONATOMIC_IOSONLY, readonly) int Length;
-@property (NS_NONATOMIC_IOSONLY, readonly) id object;
+@property (NS_NONATOMIC_IOSONLY, readonly, retain) id object;
+ (double) D;
- (BOOL)is3bar; // watch out
@property (NS_NONATOMIC_IOSONLY, retain) NSURL *appStoreReceiptURLY ;
- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
-@property (NS_NONATOMIC_IOSONLY, readonly) id OkToInfer NS_AVAILABLE;
+@property (NS_NONATOMIC_IOSONLY, readonly, retain) id OkToInfer NS_AVAILABLE;
// Do not infer a property.
@property (NS_NONATOMIC_IOSONLY, retain) NSURL *appStoreReceiptURLZ ;
@class NSMutableDictionary;
@interface NSArray
-@property (NS_NONATOMIC_IOSONLY, readonly) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
+@property (NS_NONATOMIC_IOSONLY, readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
@property (NS_NONATOMIC_IOSONLY, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *);
@property (NS_NONATOMIC_IOSONLY, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *);
@property (NS_NONATOMIC_IOSONLY) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *);
- (void) Nothing;
@property (nonatomic, readonly) int Length;
-@property (nonatomic, readonly) id object;
+@property (nonatomic, readonly, retain) id object;
+ (double) D;
@property (nonatomic, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER);
@property (nonatomic, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents;
@property (nonatomic, getter=getStringValue, retain) NSString *stringValue;
@property (nonatomic, getter=getCounterValue, readonly) BOOL counterValue;
-@property (nonatomic, getter=getns_dixtionary, readonly) NSDictionary *ns_dixtionary;
+@property (nonatomic, getter=getns_dixtionary, readonly, retain) NSDictionary *ns_dixtionary;
- (BOOL)is3bar; // watch out
- (NSString *)get3foo; // watch out
- (void) Nothing;
@property (nonatomic, readonly) int Length;
-@property (nonatomic, readonly) id object;
+@property (nonatomic, readonly, retain) id object;
+ (double) D;
- (BOOL)is3bar; // watch out
@property (nonatomic, retain) NSURL *appStoreReceiptURLY ;
- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE;
-@property (nonatomic, readonly) id OkToInfer NS_AVAILABLE;
+@property (nonatomic, readonly, retain) id OkToInfer NS_AVAILABLE;
// Do not infer a property.
@property (nonatomic, retain) NSURL *appStoreReceiptURLZ ;
@class NSMutableDictionary;
@interface NSArray
-@property (nonatomic, readonly) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
+@property (nonatomic, readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *);
@property (nonatomic, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *);
@property (nonatomic, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *);
@property (nonatomic) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *);