[Patch][ObjC][Proposal] NSValue literals

AlexDenisov 1101.debian at gmail.com
Fri Nov 21 04:45:47 PST 2014


- It is important to have a complete IRGen tests for all the supported boxed items.
Could you, please, point me to the right direction? I’ve found only few tests for literals under CodeGenObjC: boxing.m and objc-literal-tests.m. Should I put new one there as well or just create another file?

- CGPoint, CGSize, CGRect are iOS APIs only. But I haven’t been able to find their APIs in
  the later version of iPhone SDKs. If they have been removed recently, then we should make sure to check
  the deployment target and issue proper diagnostics if need be. This is generally the case for all the APIs.
  If we are going to use auto boxing, then we need to make sure the APIs available in earlier (or later) versions
  of the SDKs.
CG-structs are part of the CoreGraphics.framework. On OS X NSValue' factory methods is a part of Foundation.framework (NSGeometry.h, NSValueGeometryExtensions), while on iOS they’re part of UIKit (UIGeometry.h, NSValueUIGeometryExtensions). I guess they’re not going to disappear. Bu, I totally agree - deployment target should be checked for methods/structs, which is unavailable at some target version (e.g. NSEdgeInsets, UIOffset).

- Have you though of supporting other item types? 
  NSEdgeInsets (CGEdgeInsets for iOS?) macosx 10.10,  iPhone 8.0 
  non-retaining Objective-C objects.
  Any C pointers

I wasn’t sure if this feature will be accepted (and still don't), so decided to sent patch only for these structs. But, yes, in my opinion support for the whole ‘NSValueBoxable’ data types should be implemented.


Also, I've realized later, there should be support for modernizer to convert ‘old’ syntax to the new one.
I will add more tests, and, probably add other data types support, if there are no objections.

Thank you for feedback.
-- 
AlexDenisov
Software Engineer, https://github.com/AlexDenisov

On 20 Nov 2014 at 20:14:39, jahanian (fjahanian at apple.com) wrote:

While, the review process is ongoing, I looked at the patch. It is generally very good and closely follows the convention for
doing auto boxing of other types. I have few general comments to make.

- It is important to have a complete IRGen tests for all the supported boxed items.

- CGPoint, CGSize, CGRect are iOS APIs only. But I haven’t been able to find their APIs in
  the later version of iPhone SDKs. If they have been removed recently, then we should make sure to check
  the deployment target and issue proper diagnostics if need be. This is generally the case for all the APIs.
  If we are going to use auto boxing, then we need to make sure the APIs available in earlier (or later) versions
  of the SDKs.

- Have you though of supporting other item types? 
  NSEdgeInsets (CGEdgeInsets for iOS?) macosx 10.10,  iPhone 8.0 
  non-retaining Objective-C objects.
  Any C pointers

 One code comment: getNSValueFactoryMethod has two default arguments but do not have non-default value.
 
- Fariborz

On Nov 16, 2014, at 10:15 AM, AlexDenisov <1101.debian at gmail.com> wrote:

Patch extends boxing expressions to support NSValue.

Some C structures might be boxed into a NSValue, e.g.: NSPoint, CGPoint, NSRect, etc.
This patch extends boxing expressions to accept the structures, that could be used to construct NSValue object:

NSPoint p;
NSValue *point = @(p);
CGRect r;
NSValue rect = @(r);

Full list of supported structures:
NSPoint, NSSize, NSRect, CGPoint, CGSize, CGRect, NSRange.

-- 
AlexDenisov
Software Engineer, https://github.com/AlexDenisov
<nsvalue_literals.diff>_______________________________________________
cfe-commits mailing list
cfe-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141121/2ea6cba0/attachment.html>


More information about the cfe-commits mailing list