[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Patch/gdl2] -compare:
From: |
David Ayers |
Subject: |
[Patch/gdl2] -compare: |
Date: |
Wed, 10 Sep 2003 15:33:17 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030507 |
Hello everyone,
Wow! I didn't realize how messy "ObjC hygiene" can be :-). This patch
prepares GDL2 for the removal of the -compare:
declaration/implementation of -base.
Committed:
* EOControl/EOFault.m
(+[EOFault respondsToSelector:]): Use GSObjCRuntime functions and
correct casts.
(-[EOFault respondsToSelector:]): Correct casts.
* EOControl/EOKeyComparisonQualifier.m
* EOControl/EOKeyValueCoding.m
* EOControl/EOKeyValueQualifier.m
* EOControl/EOQualifier.m
* EOControl/EOSortOrdering.m
(-[NSObject compare:]): Add declaration to prepare for removal
of declaration from -base.
(-[EOKeyComparisonQualifier evaluateWithObject:]): Adapt vraiables
and casts to use correct prototype.
(-[EOKeyValueQualifier evaluateWithObject:]): Ditto
(-[NSArray computeMaxForKey:]): Ditto.
(-[NSArray computeMinForKey:]): Ditto.
Cheers,
David
Index: EOControl/EOFault.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOControl/EOFault.m,v
retrieving revision 1.16
diff -u -r1.16 EOFault.m
--- EOControl/EOFault.m 25 Aug 2003 20:01:58 -0000 1.16
+++ EOControl/EOFault.m 10 Sep 2003 13:14:52 -0000
@@ -137,7 +137,7 @@
+ (BOOL)respondsToSelector: (SEL)sel
{
- return (IMP)class_get_instance_method(self, sel) != (IMP)0;
+ return (GSGetInstanceMethod(self, sel) != (GSMethod)0);
}
@@ -323,7 +323,7 @@
NSDebugFLLog(@"gsdb", @"class=%@ aSelector=%@", class,
NSStringFromSelector(aSelector));
- respondsToSelector = (GSGetInstanceMethod(class, aSelector) != (IMP)0);
+ respondsToSelector = (GSGetInstanceMethod(class, aSelector) != (GSMethod)0);
NSDebugFLLog(@"gsdb", @"STOP self=%p", self);
return respondsToSelector;
Index: EOControl/EOKeyComparisonQualifier.m
===================================================================
RCS file:
/cvsroot/gnustep/gnustep/dev-libs/gdl2/EOControl/EOKeyComparisonQualifier.m,v
retrieving revision 1.11
diff -u -r1.11 EOKeyComparisonQualifier.m
--- EOControl/EOKeyComparisonQualifier.m 25 Aug 2003 20:01:58 -0000
1.11
+++ EOControl/EOKeyComparisonQualifier.m 10 Sep 2003 13:14:52 -0000
@@ -52,6 +52,17 @@
#include <EOControl/EOKeyValueCoding.h>
#include <EOControl/EODebug.h>
+/*
+ This declaration is needed by the compiler to state that
+ eventhough we know not all objects respond to -compare:,
+ we want the compiler to generate code for the given
+ prototype when calling -compare: in the following methods.
+ We do not put this declaration in a header file to avoid
+ the compiler seeing conflicting prototypes in user code.
+*/
+@interface NSObject (Comparison)
+- (NSComparisonResult)compare: (id)other;
+@end
@implementation EOKeyComparisonQualifier
@@ -164,7 +175,8 @@
*/
- (BOOL) evaluateWithObject: (id)object
{
- id leftVal, rightVal;
+ NSObject *leftVal;
+ NSObject *rightVal;
BOOL (*imp)(id, SEL, id);
leftVal = [object valueForKey: _leftKey];
@@ -201,7 +213,7 @@
}
else if (sel_eq(_selector, EOQualifierOperatorContains) == YES)
{
- return [leftVal rangeOfString: rightVal].location != NSNotFound;
+ return [(id)leftVal rangeOfString: (id)rightVal].location != NSNotFound;
}
else if (sel_eq(_selector, EOQualifierOperatorLike) == YES)
{
@@ -212,7 +224,7 @@
else if (sel_eq(_selector, EOQualifierOperatorCaseInsensitiveLike) == YES)
{
NSEmitTODO(); //TODO
- return [[leftVal uppercaseString] isEqual: [rightVal uppercaseString]]
+ return [[(id)leftVal uppercaseString] isEqual: [(id)rightVal
uppercaseString]]
== NSOrderedSame;
}
/*Ayers (09-02-2002): Maybe we should raise instead of returning NO.*/
Index: EOControl/EOKeyValueCoding.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOControl/EOKeyValueCoding.m,v
retrieving revision 1.15
diff -u -r1.15 EOKeyValueCoding.m
--- EOControl/EOKeyValueCoding.m 25 Aug 2003 20:01:58 -0000 1.15
+++ EOControl/EOKeyValueCoding.m 10 Sep 2003 13:14:52 -0000
@@ -168,6 +168,20 @@
}
@end
+
+/*
+ This declaration is needed by the compiler to state that
+ eventhough we know not all objects respond to -compare:,
+ we want the compiler to generate code for the given
+ prototype when calling -compare: in the following methods.
+ We do not put this declaration in a header file to avoid
+ the compiler seeing conflicting prototypes in user code.
+*/
+@interface NSObject (Comparison)
+- (NSComparisonResult)compare: (id)other;
+@end
+
+
@implementation NSArray (EOKeyValueCoding)
/**
@@ -413,7 +427,7 @@
if (currentVal == nil || currentVal == null) continue;
- if ([resultVal compare: currentVal] == NSOrderedAscending)
+ if ([(NSObject *)resultVal compare: currentVal] == NSOrderedAscending)
{
result = current;
resultVal = currentVal;
@@ -455,7 +469,7 @@
if (currentVal == nil || currentVal == null) continue;
- if ([resultVal compare: currentVal] == NSOrderedDescending)
+ if ([(NSObject *)resultVal compare: currentVal] ==
NSOrderedDescending)
{
result = current;
resultVal = currentVal;
Index: EOControl/EOKeyValueQualifier.m
===================================================================
RCS file:
/cvsroot/gnustep/gnustep/dev-libs/gdl2/EOControl/EOKeyValueQualifier.m,v
retrieving revision 1.10
diff -u -r1.10 EOKeyValueQualifier.m
--- EOControl/EOKeyValueQualifier.m 25 Aug 2003 20:01:58 -0000 1.10
+++ EOControl/EOKeyValueQualifier.m 10 Sep 2003 13:14:52 -0000
@@ -57,6 +57,17 @@
#include <EOControl/EOEditingContext.h>
#include <EOControl/EODebug.h>
+/*
+ This declaration is needed by the compiler to state that
+ eventhough we know not all objects respond to -compare:,
+ we want the compiler to generate code for the given
+ prototype when calling -compare: in the following methods.
+ We do not put this declaration in a header file to avoid
+ the compiler seeing conflicting prototypes in user code.
+*/
+@interface NSObject (Comparison)
+- (NSComparisonResult)compare: (id)other;
+@end
@implementation EOKeyValueQualifier
@@ -169,7 +180,7 @@
*/
- (BOOL) evaluateWithObject: (id)object
{
- id val;
+ NSObject *val;
BOOL (*imp)(id, SEL, id);
val = [object valueForKey: _key];
@@ -205,7 +216,7 @@
}
else if (sel_eq(_selector, EOQualifierOperatorContains) == YES)
{
- return [val rangeOfString: _value].location != NSNotFound;
+ return [(id)val rangeOfString: _value].location != NSNotFound;
}
else if (sel_eq(_selector, EOQualifierOperatorLike) == YES)
{
@@ -215,7 +226,7 @@
else if (sel_eq(_selector, EOQualifierOperatorCaseInsensitiveLike) == YES)
{
NSEmitTODO(); //TODO
- return [[val uppercaseString] isEqual: [_value uppercaseString]]
+ return [[(id)val uppercaseString] isEqual: [_value uppercaseString]]
== NSOrderedSame;
}
/*Ayers (09-02-2002): Maybe we should raise instead of returning NO.*/
Index: EOControl/EOQualifier.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOControl/EOQualifier.m,v
retrieving revision 1.15
diff -u -r1.15 EOQualifier.m
--- EOControl/EOQualifier.m 25 Aug 2003 20:01:59 -0000 1.15
+++ EOControl/EOQualifier.m 10 Sep 2003 13:14:52 -0000
@@ -883,6 +883,18 @@
@end
+/*
+ This declaration is needed by the compiler to state that
+ eventhough we know not all objects respond to -compare:,
+ we want the compiler to generate code for the given
+ prototype when calling -compare: in the following methods.
+ We do not put this declaration in a header file to avoid
+ the compiler seeing conflicting prototypes in user code.
+*/
+@interface NSObject (Comparison)
+- (NSComparisonResult)compare: (id)other;
+@end
+
@implementation NSObject (EORelationalSelectors)
Index: EOControl/EOSortOrdering.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOControl/EOSortOrdering.m,v
retrieving revision 1.10
diff -u -r1.10 EOSortOrdering.m
--- EOControl/EOSortOrdering.m 25 Aug 2003 20:01:59 -0000 1.10
+++ EOControl/EOSortOrdering.m 10 Sep 2003 13:14:52 -0000
@@ -269,6 +269,18 @@
@end
+/*
+ This declaration is needed by the compiler to state that
+ eventhough we know not all objects respond to -compare:,
+ we want the compiler to generate code for the given
+ prototype when calling -compare: in the following methods.
+ We do not put this declaration in a header file to avoid
+ the compiler seeing conflicting prototypes in user code.
+ */
+@interface NSObject (Comparison)
+- (NSComparisonResult)compare: (id)other;
+@end
+
@implementation NSObject (EOSortOrderingComparison)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Patch/gdl2] -compare:,
David Ayers <=