diff --git a/ChangeLog b/ChangeLog index 4f9f7f18d..20e512684 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2012-07-11 Richard Frith-Macdonald + + * Source/GSFFCallInvocation.m: + * Source/NSKeyValueObserving.m: + * Source/Additions/GSObjCRuntime.m: + * Source/NSProtocolChecker.m: + * Source/GSValue.m: + * Source/NSValue.m: + Use GSSelectorTypesMatch() for type comparisons. + 2012-07-12 19:26-EDT Gregory John Casamento * Source/NSFileManager.m: Correct misspelled ASSIGN which was diff --git a/Source/Additions/GSObjCRuntime.m b/Source/Additions/GSObjCRuntime.m index 76a1665af..ae04ce88a 100644 --- a/Source/Additions/GSObjCRuntime.m +++ b/Source/Additions/GSObjCRuntime.m @@ -1293,7 +1293,7 @@ GSObjCGetVal(NSObject *self, const char *key, SEL sel, break; case _C_STRUCT_B: - if (strcmp(@encode(NSPoint), type) == 0) + if (GSSelectorTypesMatch(@encode(NSPoint), type)) { NSPoint v; @@ -1310,7 +1310,7 @@ GSObjCGetVal(NSObject *self, const char *key, SEL sel, } val = [NSValue valueWithPoint: v]; } - else if (strcmp(@encode(NSRange), type) == 0) + else if (GSSelectorTypesMatch(@encode(NSRange), type)) { NSRange v; @@ -1327,7 +1327,7 @@ GSObjCGetVal(NSObject *self, const char *key, SEL sel, } val = [NSValue valueWithRange: v]; } - else if (strcmp(@encode(NSRect), type) == 0) + else if (GSSelectorTypesMatch(@encode(NSRect), type)) { NSRect v; @@ -1344,7 +1344,7 @@ GSObjCGetVal(NSObject *self, const char *key, SEL sel, } val = [NSValue valueWithRect: v]; } - else if (strcmp(@encode(NSSize), type) == 0) + else if (GSSelectorTypesMatch(@encode(NSSize), type)) { NSSize v; @@ -1740,7 +1740,7 @@ GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel, break; case _C_STRUCT_B: - if (strcmp(@encode(NSPoint), type) == 0) + if (GSSelectorTypesMatch(@encode(NSPoint), type)) { NSPoint v = [val pointValue]; @@ -1758,7 +1758,7 @@ GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel, (*imp)(self, sel, v); } } - else if (strcmp(@encode(NSRange), type) == 0) + else if (GSSelectorTypesMatch(@encode(NSRange), type)) { NSRange v = [val rangeValue]; @@ -1776,7 +1776,7 @@ GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel, (*imp)(self, sel, v); } } - else if (strcmp(@encode(NSRect), type) == 0) + else if (GSSelectorTypesMatch(@encode(NSRect), type)) { NSRect v = [val rectValue]; @@ -1794,7 +1794,7 @@ GSObjCSetVal(NSObject *self, const char *key, id val, SEL sel, (*imp)(self, sel, v); } } - else if (strcmp(@encode(NSSize), type) == 0) + else if (GSSelectorTypesMatch(@encode(NSSize), type)) { NSSize v = [val sizeValue]; diff --git a/Source/GSFFCallInvocation.m b/Source/GSFFCallInvocation.m index 7843d71be..1b1d14342 100644 --- a/Source/GSFFCallInvocation.m +++ b/Source/GSFFCallInvocation.m @@ -918,7 +918,8 @@ GSInvocationCallback (void *callback_data, va_alist args) const char *receiverTypes = [sig methodType]; const char *runtimeTypes = sel_get_type (selector); - if (runtimeTypes == 0 || strcmp(receiverTypes, runtimeTypes) != 0) + if (runtimeTypes == 0 + || NO == GSSelectorTypesMatch(receiverTypes, runtimeTypes)) { const char *runtimeName = sel_getName(selector); diff --git a/Source/GSValue.m b/Source/GSValue.m index 33761ad65..b575b4fdc 100644 --- a/Source/GSValue.m +++ b/Source/GSValue.m @@ -159,7 +159,7 @@ typeSize(const char* type) return NO; if (object_getClass(aValue) != object_getClass(self)) return NO; - if (strcmp(objctype, ((GSValue*)aValue)->objctype) != 0) + if (GSSelectorTypesMatch(objctype, ((GSValue*)aValue)->objctype)) return NO; else { diff --git a/Source/NSKeyValueObserving.m b/Source/NSKeyValueObserving.m index fbed5e654..596c55a9b 100644 --- a/Source/NSKeyValueObserving.m +++ b/Source/NSKeyValueObserving.m @@ -535,22 +535,22 @@ replacementForClass(Class c) instanceMethodForSelector: @selector(setter:)]; break; case _C_STRUCT_B: - if (strcmp(@encode(NSRange), type) == 0) + if (GSSelectorTypesMatch(@encode(NSRange), type)) { imp = [[GSKVOSetter class] instanceMethodForSelector: @selector(setterRange:)]; } - else if (strcmp(@encode(NSPoint), type) == 0) + else if (GSSelectorTypesMatch(@encode(NSPoint), type)) { imp = [[GSKVOSetter class] instanceMethodForSelector: @selector(setterPoint:)]; } - else if (strcmp(@encode(NSSize), type) == 0) + else if (GSSelectorTypesMatch(@encode(NSSize), type)) { imp = [[GSKVOSetter class] instanceMethodForSelector: @selector(setterSize:)]; } - else if (strcmp(@encode(NSRect), type) == 0) + else if (GSSelectorTypesMatch(@encode(NSRect), type)) { imp = [[GSKVOSetter class] instanceMethodForSelector: @selector(setterRect:)]; diff --git a/Source/NSProtocolChecker.m b/Source/NSProtocolChecker.m index 9aba5ed5f..8660f0f3c 100644 --- a/Source/NSProtocolChecker.m +++ b/Source/NSProtocolChecker.m @@ -98,13 +98,15 @@ { [NSException raise: NSInvalidArgumentException format: @"<%s -%@> not declared", - protocol_getName(_myProtocol), NSStringFromSelector([anInvocation selector])]; + protocol_getName(_myProtocol), + NSStringFromSelector([anInvocation selector])]; } else { [NSException raise: NSInvalidArgumentException format: @"<%s +%@> not declared", - protocol_getName(_myProtocol), NSStringFromSelector([anInvocation selector])]; + protocol_getName(_myProtocol), + NSStringFromSelector([anInvocation selector])]; } } [anInvocation invokeWithTarget: _myTarget]; @@ -114,7 +116,7 @@ * returned value with the protocol checker. */ type = [[anInvocation methodSignature] methodReturnType]; - if (strcmp(type, @encode(id)) == 0) + if (GSSelectorTypesMatch(type, @encode(id))) { id buf; diff --git a/Source/NSValue.m b/Source/NSValue.m index e1b90d750..5c5eabc9d 100644 --- a/Source/NSValue.m +++ b/Source/NSValue.m @@ -175,6 +175,8 @@ static NSLock *placeholderLock; if (!type) return theClass; + /* Try for an exact type match. + */ if (strcmp(@encode(id), type) == 0) theClass = nonretainedObjectValueClass; else if (strcmp(@encode(NSPoint), type) == 0) @@ -188,6 +190,21 @@ static NSLock *placeholderLock; else if (strcmp(@encode(NSSize), type) == 0) theClass = sizeValueClass; + /* Try for equivalent types match. + */ + else if (GSSelectorTypesMatch(@encode(id), type)) + theClass = nonretainedObjectValueClass; + else if (GSSelectorTypesMatch(@encode(NSPoint), type)) + theClass = pointValueClass; + else if (GSSelectorTypesMatch(@encode(void *), type)) + theClass = pointerValueClass; + else if (GSSelectorTypesMatch(@encode(NSRange), type)) + theClass = rangeValueClass; + else if (GSSelectorTypesMatch(@encode(NSRect), type)) + theClass = rectValueClass; + else if (GSSelectorTypesMatch(@encode(NSSize), type)) + theClass = sizeValueClass; + return theClass; }