Re: ARC + CF types

2011-08-31 Thread Clark Cox
On Mon, Aug 29, 2011 at 7:20 AM, Thomas Davie tom.da...@gmail.com wrote:
 I'm not really very clear on how ARC and CF types are meant to interact yet, 
 because of that I've managed to create some buggy code, could someone have a 
 quick stare at this and tell me what I've misunderstood that's causing a 
 segfault when adding to the mutable set:

 https://gist.github.com/1178475

Does the implementation of those objects' -hash method agree with your
definition of equality? (i.e. it is almost always wrong to change the
concept of equality without also changing the hash implementation).

-- 
Clark S. Cox III
clarkc...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: ARC + CF types

2011-08-31 Thread Thomas Davie

On 31 Aug 2011, at 21:55, Clark Cox wrote:

 On Mon, Aug 29, 2011 at 7:20 AM, Thomas Davie tom.da...@gmail.com wrote:
 I'm not really very clear on how ARC and CF types are meant to interact yet, 
 because of that I've managed to create some buggy code, could someone have a 
 quick stare at this and tell me what I've misunderstood that's causing a 
 segfault when adding to the mutable set:
 
 https://gist.github.com/1178475
 
 Does the implementation of those objects' -hash method agree with your
 definition of equality? (i.e. it is almost always wrong to change the
 concept of equality without also changing the hash implementation).

The only change in the equality concept is that isEqualToAPIObject: assumes 
that it's been given an APIObject and doesn't check that the other object is 
the right class.  Otherwise the equality semantics are identical.
if (*ra4 != 0xffc78948) { return false; }

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


ARC + CF types

2011-08-29 Thread Thomas Davie
I'm not really very clear on how ARC and CF types are meant to interact yet, 
because of that I've managed to create some buggy code, could someone have a 
quick stare at this and tell me what I've misunderstood that's causing a 
segfault when adding to the mutable set:

https://gist.github.com/1178475

Thanks

Tom Davie
if (*ra4 != 0xffc78948) { return false; }

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: ARC + CF types

2011-08-29 Thread David Duncan

On Aug 29, 2011, at 7:20 AM, Thomas Davie wrote:

 I'm not really very clear on how ARC and CF types are meant to interact yet, 
 because of that I've managed to create some buggy code, could someone have a 
 quick stare at this and tell me what I've misunderstood that's causing a 
 segfault when adding to the mutable set:


Given id foo and CFTypeRef bar:

// assign bar to foo without making any implicit change to bar – traditional 
toll free bridging
foo = (__bridge id)bar; 

// consume bar to create an ARC managed reference in foo – replaces foo = 
(id)bar; [foo release];
foo = (__bridge_transfer id)bar; 

// retain foo and manage it as a non-ARC reference – replaces bar = 
(CFTypeRef)[foo retain];
bar = (__bridge_retain CFTypeRef)foo;
--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: ARC + CF types

2011-08-29 Thread Dave Zarzycki
Thomas,

Why not use a NSMutableSet and avoid the bridging casts entirely?

davez



On Aug 29, 2011, at 7:20 AM, Thomas Davie wrote:

 I'm not really very clear on how ARC and CF types are meant to interact yet, 
 because of that I've managed to create some buggy code, could someone have a 
 quick stare at this and tell me what I've misunderstood that's causing a 
 segfault when adding to the mutable set:
 
 https://gist.github.com/1178475
 
 Thanks
 
 Tom Davie
 if (*ra4 != 0xffc78948) { return false; }
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 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:
 http://lists.apple.com/mailman/options/cocoa-dev/zarzycki%40apple.com
 
 This email sent to zarzy...@apple.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: ARC + CF types

2011-08-29 Thread Thomas Davie
Because NSMutableSet does not have the ability to specify a different version 
of equality – though as Mike Ash pointed out in #macdev, NSHashTable may well 
be appropriate.

Thanks

Thomas
if (*ra4 != 0xffc78948) { return false; }

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: ARC + CF types

2011-08-29 Thread Dave Zarzycki
Or, your code could subclass NSMutableSet and interpose the methods that add to 
the set. In other words, mentally separate objects that are equal from 
objects that should be in the set. The former is an equality check, the 
latter is a policy decision.

davez


On Aug 29, 2011, at 7:37 AM, Thomas Davie wrote:

 Because NSMutableSet does not have the ability to specify a different version 
 of equality – though as Mike Ash pointed out in #macdev, NSHashTable may well 
 be appropriate.
 
 Thanks
 
 Thomas
 if (*ra4 != 0xffc78948) { return false; }
 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: ARC + CF types

2011-08-29 Thread Thomas Davie
Doing that wouldn't magically use the more efficient equality check though 
without recoding NSMutableSet almost entirely, or… you know, using 
CFMutableSetRef and providing your own equality function.

Thanks

Tom Davie
if (*ra4 != 0xffc78948) { return false; }

On 29 Aug 2011, at 17:43, Dave Zarzycki wrote:

 Or, your code could subclass NSMutableSet and interpose the methods that add 
 to the set. In other words, mentally separate objects that are equal from 
 objects that should be in the set. The former is an equality check, the 
 latter is a policy decision.
 
 davez
 
 
 On Aug 29, 2011, at 7:37 AM, Thomas Davie wrote:
 
 Because NSMutableSet does not have the ability to specify a different 
 version of equality – though as Mike Ash pointed out in #macdev, NSHashTable 
 may well be appropriate.
 
 Thanks
 
 Thomas
 if (*ra4 != 0xffc78948) { return false; }
 
 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: ARC + CF types

2011-08-29 Thread Greg Parker
On Aug 29, 2011, at 9:43 AM, Dave Zarzycki wrote:
 Or, your code could subclass NSMutableSet and interpose the methods that add 
 to the set. In other words, mentally separate objects that are equal from 
 objects that should be in the set. The former is an equality check, the 
 latter is a policy decision.

Note that NSMutableSet is a class cluster. Class NSMutableSet itself does not 
implement any storage. If you want to subclass NSMutableSet, you'll need to 
implement the storage and all of the core methods from NSSet and NSMutableSet 
yourself.

Note that NSSet and NSMutableSet define set member equality as -isEqual:. 
Violating that in a subclass may break other code.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com