Author: ericwa
Date: Thu Mar 20 21:40:41 2014
New Revision: 10599

URL: http://svn.gna.org/viewcvs/etoile?rev=10599&view=rev
Log:
COObject: switch to pointer equality. The CoreObject and EtoileUI test suite 
passes (minus the NSCell test that always failed on 10.9)

Modified:
    trunk/Etoile/Frameworks/CoreObject/Core/COObject.h
    trunk/Etoile/Frameworks/CoreObject/Core/COObject.m
    trunk/Etoile/Frameworks/CoreObject/Tests/Core/TestObject.m
    trunk/Etoile/Frameworks/EtoileUI/Tests/TestPersistency.m

Modified: trunk/Etoile/Frameworks/CoreObject/Core/COObject.h
URL: 
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Core/COObject.h?rev=10599&r1=10598&r2=10599&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Core/COObject.h  (original)
+++ trunk/Etoile/Frameworks/CoreObject/Core/COObject.h  Thu Mar 20 21:40:41 2014
@@ -40,6 +40,18 @@
  * but you can also make subclasses of COObject for a particular entity to get 
  * static type checking.
  * 
+ * @section Object Equality
+ *
+ * COObject inherits NSObject's -hash and -isEqual: methods, so equality is
+ * based on pointer comparison.
+ *
+ * You must never override -hash or -isEqual:. This is a consequence of the 
fact that
+ * we promise it is safe to put a COObject instance in an NSSet and then mutate
+ * the COObject.
+ *
+ * Use -isTemporallyEqual: to check both UUID and revision match. For example,
+ * when the same object is in use in multiple editing contexts simultaneously.
+ *
  * @section Common Use Cases
  *
  * For an existing persistent root or transient object graph context, 
@@ -829,27 +841,6 @@
 
 /** @taskunit Object Equality */
 
-
-/** 
- * Returns a hash based on the UUID. 
- *
- * You must never override -hash.
- */
-- (NSUInteger)hash;
-/**
- * Returns whether anObject is equal to the receiver.
- *
- * Two persistent objects are equal if they share the same UUID (even when the 
- * two object revisions don't match).
- *
- * Use -isTemporallyEqual: to check both UUID and revision match. For example, 
- * when the same object is in use in multiple editing contexts simultaneously.
- *
- * You must never override -isEqual:. This is a consequence of the fact that
- * we promise it is safe to put a COObject instance in an NSSet and then mutate
- * the COObject.
- */
-- (BOOL)isEqual: (id)anObject;
 /** 
  * Returns whether anObject saved state is equal the receiver saved state. 
  *

Modified: trunk/Etoile/Frameworks/CoreObject/Core/COObject.m
URL: 
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Core/COObject.m?rev=10599&r1=10598&r2=10599&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Core/COObject.m  (original)
+++ trunk/Etoile/Frameworks/CoreObject/Core/COObject.m  Thu Mar 20 21:40:41 2014
@@ -1336,30 +1336,7 @@
        
 }
 
-#pragma mark - Hash and Equality
-
-// FIXME: Remove, to revert to pointer hash/equality. See failing test 
-[TestObject testHashStabilityAcrossSetCurrentBranch] and Jan 25th email
-- (NSUInteger)hash
-{
-       return [_UUID hash] ^ [[_objectGraphContext branchUUID] hash] ^ 
[_objectGraphContext isTrackingSpecificBranch] ^ 0x39ab6f39b15233de;
-}
-
-// FIXME: Remove, to revert to pointer hash/equality. See failing test 
-[TestObject testHashStabilityAcrossSetCurrentBranch] and Jan 25th email
-- (BOOL)isEqual: (id)anObject
-{
-       if (anObject == self)
-       {
-               return YES;
-       }
-       if (![anObject isKindOfClass: [COObject class]])
-       {
-               return NO;
-       }
-
-       return ([[anObject UUID] isEqual: _UUID]
-               && [[[anObject objectGraphContext] branchUUID] isEqual: 
[_objectGraphContext branchUUID]]
-               && ([_objectGraphContext isTrackingSpecificBranch] == 
[[anObject objectGraphContext] isTrackingSpecificBranch]));
-}
+#pragma mark - Equality
 
 - (BOOL)isTemporallyEqual: (id)anObject
 {

Modified: trunk/Etoile/Frameworks/CoreObject/Tests/Core/TestObject.m
URL: 
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Tests/Core/TestObject.m?rev=10599&r1=10598&r2=10599&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Tests/Core/TestObject.m  (original)
+++ trunk/Etoile/Frameworks/CoreObject/Tests/Core/TestObject.m  Thu Mar 20 
21:40:41 2014
@@ -138,13 +138,30 @@
        [proot setCurrentBranch: secondaryBranch];
        [ctx commit];
        
-       // This breaks currently, because object belongs to the "current branch 
object graph"
-       // [proot objectGraphContext]. The branch of [proot objectGraphContext] 
changes
-       // when -setCurrentBranch: is called, but the branch UUID is 
incorporated
-       // into -[COObject hash] right now, so this fails
-#if 0
        UKIntsEqual(hash, [object hash]);
-#endif
+}
+
+- (void) testIsEqualUsesPointerEquality
+{
+       COPersistentRoot *proot = [ctx insertNewPersistentRootWithEntityName: 
@"OutlineItem"];
+       [ctx commit];
+       
+       COObject *object = [proot rootObject];
+       
+       [self checkPersistentRootWithExistingAndNewContext: proot
+                                                                               
           inBlock: ^(COEditingContext *testCtx, COPersistentRoot *testProot, 
COBranch *testBranch, BOOL isNewContext)
+        {
+                if (isNewContext)
+                {
+                        UKObjectsNotEqual(object, [testProot rootObject]);
+                        UKObjectsNotSame(object, [testProot rootObject]);
+                }
+                else
+                {
+                        UKObjectsEqual(object, [testProot rootObject]);
+                        UKObjectsSame(object, [testProot rootObject]);
+                }
+        }];
 }
 
 - (void) testDetailedDescription

Modified: trunk/Etoile/Frameworks/EtoileUI/Tests/TestPersistency.m
URL: 
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/EtoileUI/Tests/TestPersistency.m?rev=10599&r1=10598&r2=10599&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/EtoileUI/Tests/TestPersistency.m    (original)
+++ trunk/Etoile/Frameworks/EtoileUI/Tests/TestPersistency.m    Thu Mar 20 
21:40:41 2014
@@ -539,8 +539,8 @@
 
        UKObjectsEqual(URLType, [newController currentObjectType]);
        UKObjectsEqual([controller currentGroupType], [newController 
currentGroupType]);
-       UKObjectsEqual(objectTemplate, newObjectTemplate);
-       UKObjectsEqual(groupTemplate, newGroupTemplate);
+       UKObjectsEqual([objectTemplate UUID], [newObjectTemplate UUID]);
+       UKObjectsEqual([groupTemplate UUID], [newGroupTemplate UUID]);
 
        UKObjectKindOf([[newObjectTemplate item] view], NSTextField);
        UKNil([newObjectTemplate objectClass]);


_______________________________________________
Etoile-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-cvs

Reply via email to