Re: How do I get NSRect to be the same as CGRect?
Re: How do I get NSRect to be the same as CGRect?
- Subject: Re: How do I get NSRect to be the same as CGRect?
- From: "Ken Ferry" <email@hidden>
- Date: Mon, 17 Dec 2007 13:31:39 -0800
The implementation should be okay with or without with -fstrict-aliasing.
Pointer casting still works too, it's just ugly and screws up type
checking (and violates strict aliasing). NSRectToCGRect and friends
were added as convenience.
Struct tags also show up in objective-c method signatures, which are
introspectable and in @encode directives, which are evaluated to c
strings at compile time. Code that wants to treat NSRect, NSPoint
and NSSize specially (e.g. KVC's object wrapping of those return
types) tends to require a recompile when struct tags in the method
signatures change. Obviously KVC itself isn't a problem, since it
ships in sync with the NSGeometry header, but external clients can
(and do) have similar dependencies.
The difference between long and int is also introspectable in method signatures.
Ken Ferry
Cocoa Frameworks
On Dec 17, 2007 1:11 PM, Rick Mann <email@hidden> wrote:
>
> On Dec 17, 2007, at 1:04 PM, Sean McBride wrote:
>
> > I agree it's unlikely, but the possibility is no doubt the reason for
> > NSRectToCGRect() existing (it uses the union trick).
>
> I think that means that NSRectToCGRect() must take care to be compiled
> with the correct setting of -fstrict-aliasing.
>
> > Could you not make your Graphics::Rect class Objective-C++? Just
> > changing its extension should do the trick.
>
> Perhaps, but it would limit its usefulness. All files that included
> the header file would need to use .mm as an extension.
>
> --
> Rick
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden