Bug 140215

Summary: Annotate properties that start with "new" so they'll work under ARC
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: New BugsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal CC: ggaren
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch ggaren: review+

Description Anders Carlsson 2015-01-07 14:46:08 PST
Annotate properties that start with "new" so they'll work under ARC
Comment 1 Anders Carlsson 2015-01-07 14:47:53 PST
Created attachment 244206 [details]
Patch
Comment 2 Geoffrey Garen 2015-01-07 14:58:17 PST
Comment on attachment 244206 [details]
Patch

r=me
Comment 3 Geoffrey Garen 2015-01-07 14:58:35 PST
Does this require an update to some bindings test expectations or a new bindings test?
Comment 4 Anders Carlsson 2015-01-07 14:59:42 PST
Committed r178057: <http://trac.webkit.org/changeset/178057>
Comment 5 Darin Adler 2015-01-07 20:45:56 PST
Comment on attachment 244206 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=244206&action=review

> Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm:899
> +                my $needsReturnsRetainedAnnotation = $attributeName =~ /new([A-Z].*)?/;

http://clang.llvm.org/docs/AutomaticReferenceCounting.html#method-families says that we also need to check for alloc, copy, mutableCopy, and new. And maybe even init. I also was considering whether __attribute__((objc_method_family(none))) might not be better than NS_RETURNS_NOT_RETAINED, but I guess not.

Given that documentation, I’m thinking this regular expression should be:

    /_*(alloc|copy|mutableCopy|new)([^a-z].*)?/

That wouldn’t address the init family, but it would cover the copy cases, which I think could easily happen in practice.