From 2e0037d9c002db5073a484f9f9fb6dd4432a47c0 Mon Sep 17 00:00:00 2001 From: Wincent Colaiuta Date: Thu, 27 Sep 2007 21:07:13 +0200 Subject: [PATCH] Remove private API support code The signatureWithObjCTypes: method in NSMethodSignature is at last exposed in Leopard, so remove the all the support code that was previously used to (carefully) work with (or around) it and just use the now-official API. Signed-off-by: Wincent Colaiuta --- NSMethodSignature+WOTest.h | 28 ------- NSMethodSignature+WOTest.m | 137 ------------------------------- WOMock.m | 3 +- WOProtocolMock.m | 3 +- WOStub.m | 1 - WOTest.h | 1 - WOTest.xcodeproj/project.pbxproj | 10 +-- 7 files changed, 3 insertions(+), 180 deletions(-) delete mode 100644 NSMethodSignature+WOTest.h delete mode 100644 NSMethodSignature+WOTest.m diff --git a/NSMethodSignature+WOTest.h b/NSMethodSignature+WOTest.h deleted file mode 100644 index 780ed54..0000000 --- a/NSMethodSignature+WOTest.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// NSMethodSignature+WOTest.h -// WOTest -// -// Created by Wincent Colaiuta on 30 January 2006. -// -// Copyright 2006-2007 Wincent Colaiuta. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#import - -@interface NSMethodSignature (WOTest) - -+ (id)WOTest_signatureBasedOnObjCTypes:(const char *)types; - -@end diff --git a/NSMethodSignature+WOTest.m b/NSMethodSignature+WOTest.m deleted file mode 100644 index c136779..0000000 --- a/NSMethodSignature+WOTest.m +++ /dev/null @@ -1,137 +0,0 @@ -// -// NSMethodSignature+WOTest.m -// WOTest -// -// Created by Wincent Colaiuta on 30 January 2006. -// -// Copyright 2006-2007 Wincent Colaiuta. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#import "NSMethodSignature+WOTest.h" -#import - -/* - - The real 10.4 NSMethodSignature API (obtained using class-dump; TODO: run class-dump to get 10.5 API): - -@interface NSMethodSignature : NSObject -{ - char *_types; - int _nargs; - unsigned int _sizeofParams; - unsigned int _returnValueLength; - void *_parmInfoP; - int *_fixup; - void *_reserved; -} - -+ (id)signatureWithObjCTypes:(const char *)fp8; -- (BOOL)_isReturnStructInRegisters; -- (id)retain; -- (void)release; -- (unsigned int)retainCount; -- (const char *)methodReturnType; // PUBLIC -- (unsigned int)methodReturnLength; // PUBLIC -- (BOOL)isOneway; // PUBLIC -- (const char *)getArgumentTypeAtIndex:(unsigned int)fp8; // PUBLIC -- (struct _arginfo)_argumentInfoAtIndex:(unsigned int)fp8; -- (unsigned int)frameLength; // PUBLIC -- (unsigned int)numberOfArguments; // PUBLIC -- (id)description; -- (id)debugDescription; - -@end - -The public API: - -@interface NSMethodSignature : NSObject { - @private - const char *_types; - int _nargs; - unsigned _sizeofParams; - unsigned _returnValueLength; - void *_parmInfoP; - int *_fixup; - void *_reserved; -} - -- (unsigned)numberOfArguments; -- (const char *)getArgumentTypeAtIndex:(unsigned)index; -- (unsigned)frameLength; -- (BOOL)isOneway; -- (const char *)methodReturnType; -- (unsigned)methodReturnLength; - -@end - -Many public implementations of that use NSProxy subclasses to implement trampolines make use of the signatureWithObjCTypes: private API. - -Examples: OCMock -http://www.cocoadev.com/index.pl?LSTrampoline -http://www.cocoadev.com/index.pl?BSTrampoline - -See also http://www.stuffonfire.com/2005/12/signaturewithobjctypes_is_stil.html - - */ - -@interface NSMethodSignature (WOApplePrivate) - -/*! Private Apple API. */ -+ (id)signatureWithObjCTypes:(const char *)fp8; - -@end - -@interface NSMethodSignature () - -- (id)initWithObjCTypes:(const char *)types; - -@end - -@implementation NSMethodSignature (WOTest) - -+ (id)WOTest_signatureBasedOnObjCTypes:(const char *)types -{ - NSParameterAssert(types != NULL); - -#ifdef WO_USE_OWN_METHOD_SIGNATURE_IMPLEMENTATION - - return [[self alloc] initWithObjCTypes:types]; - -#else /* use private Apple API */ - - NSAssert([self respondsToSelector:@selector(signatureWithObjCTypes:)], @"signatureWithObjCTypes: selector not recognized"); - return [self signatureWithObjCTypes:types]; - -#endif - -} - -- (id)initWithObjCTypes:(const char *)types -{ - NSParameterAssert(types != NULL); - if ((self = [super init])) - { - // TODO: finish implementation - // loop through args -/* unsigned method_getNumberOfArguments(Method); - unsigned method_getSizeOfArguments(Method); */ - - // I hate using private Apple APIs, even ones that appear stable, but - // not sure that meddling with these instance variables is a good idea - } - return self; -} - -@end diff --git a/WOMock.m b/WOMock.m index 2d7dbff..9129270 100644 --- a/WOMock.m +++ b/WOMock.m @@ -27,7 +27,6 @@ // framework headers #import "NSInvocation+WOTest.h" -#import "NSMethodSignature+WOTest.h" #import "NSObject+WOTest.h" #import "NSProxy+WOTest.h" #import "NSValue+WOTest.h" @@ -192,7 +191,7 @@ - (void)setObjCTypes:(NSString *)types forSelector:(SEL)aSelector { - [methodSignatures setObject:[NSMethodSignature WOTest_signatureBasedOnObjCTypes:[types UTF8String]] + [methodSignatures setObject:[NSMethodSignature signatureWithObjCTypes:[types UTF8String]] forKey:NSStringFromSelector(aSelector)]; } diff --git a/WOProtocolMock.m b/WOProtocolMock.m index c742925..78ca991 100644 --- a/WOProtocolMock.m +++ b/WOProtocolMock.m @@ -28,7 +28,6 @@ // framework headers #import "NSInvocation+WOTest.h" -#import "NSMethodSignature+WOTest.h" #import "WOProtocolStub.h" #pragma mark - @@ -200,7 +199,7 @@ NSString *WOStringFromProtocol(Protocol *aProtocol) BOOL isRequiredMethod = YES; // no idea what to pass here struct objc_method_description description = protocol_getMethodDescription([self mockedProtocol], aSelector, isRequiredMethod, YES); - return [NSMethodSignature WOTest_signatureBasedOnObjCTypes:description.types]; + return [NSMethodSignature signatureWithObjCTypes:description.types]; } #pragma mark - diff --git a/WOStub.m b/WOStub.m index 197342d..0cc4703 100644 --- a/WOStub.m +++ b/WOStub.m @@ -27,7 +27,6 @@ // framework headers #import "NSInvocation+WOTest.h" -#import "NSMethodSignature+WOTest.h" #import "NSObject+WOTest.h" #import "NSProxy+WOTest.h" #import "NSValue+WOTest.h" diff --git a/WOTest.h b/WOTest.h index 2353aad..fd84741 100644 --- a/WOTest.h +++ b/WOTest.h @@ -53,7 +53,6 @@ #import "NSException+WOTest.h" #import "NSInvocation+WOTest.h" -#import "NSMethodSignature+WOTest.h" #import "NSObject+WOTest.h" #import "NSProxy+WOTest.h" #import "NSScanner+WOTest.h" diff --git a/WOTest.xcodeproj/project.pbxproj b/WOTest.xcodeproj/project.pbxproj index 905a643..0007577 100644 --- a/WOTest.xcodeproj/project.pbxproj +++ b/WOTest.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 43; + objectVersion = 44; objects = { /* Begin PBXAggregateTarget section */ @@ -126,7 +126,6 @@ BCD155AF0A961949005B1950 /* WOProtocolMock.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = BCFA3172098BFD9300EEEE22 /* WOProtocolMock.h */; }; BCD155B00A961949005B1950 /* WOEnumerate.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = BCFA31DB098C030300EEEE22 /* WOEnumerate.h */; }; BCD155B10A961949005B1950 /* NSInvocation+WOTest.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = BCFA342A098DB87300EEEE22 /* NSInvocation+WOTest.h */; }; - BCD155B20A961949005B1950 /* NSMethodSignature+WOTest.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = BCFA35CA098E6A0D00EEEE22 /* NSMethodSignature+WOTest.h */; }; BCD155B30A961949005B1950 /* WOLightweightRoot.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = BCFA3CE0098F9B4800EEEE22 /* WOLightweightRoot.h */; }; BCD155B40A961949005B1950 /* WOObjectMock.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = BCBB58EC099D311B0065D0C5 /* WOObjectMock.h */; }; BCD155B50A961949005B1950 /* WOProtocolStub.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = BCBB59A0099D38BE0065D0C5 /* WOProtocolStub.h */; }; @@ -145,7 +144,6 @@ BCFA326D098C71D300EEEE22 /* WOObjectMockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFA326C098C71D300EEEE22 /* WOObjectMockTests.m */; }; BCFA342D098DB87300EEEE22 /* NSInvocation+WOTest.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFA342B098DB87300EEEE22 /* NSInvocation+WOTest.m */; }; BCFA3446098E25FA00EEEE22 /* NSInvocationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFA3445098E25FA00EEEE22 /* NSInvocationTests.m */; }; - BCFA35CF098E6A0D00EEEE22 /* NSMethodSignature+WOTest.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFA35CB098E6A0D00EEEE22 /* NSMethodSignature+WOTest.m */; }; BCFA3CE3098F9B4800EEEE22 /* WOLightweightRoot.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFA3CE1098F9B4800EEEE22 /* WOLightweightRoot.m */; }; BCFA3EA8098FCF9800EEEE22 /* NSValueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BCFA3EA7098FCF9700EEEE22 /* NSValueTests.m */; }; /* End PBXBuildFile section */ @@ -245,7 +243,6 @@ BCD155AF0A961949005B1950 /* WOProtocolMock.h in CopyFiles */, BCD155B00A961949005B1950 /* WOEnumerate.h in CopyFiles */, BCD155B10A961949005B1950 /* NSInvocation+WOTest.h in CopyFiles */, - BCD155B20A961949005B1950 /* NSMethodSignature+WOTest.h in CopyFiles */, BCD155B30A961949005B1950 /* WOLightweightRoot.h in CopyFiles */, BCD155B40A961949005B1950 /* WOObjectMock.h in CopyFiles */, BCD155B50A961949005B1950 /* WOProtocolStub.h in CopyFiles */, @@ -363,8 +360,6 @@ BCFA342B098DB87300EEEE22 /* NSInvocation+WOTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSInvocation+WOTest.m"; sourceTree = ""; }; BCFA3444098E25FA00EEEE22 /* NSInvocationTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSInvocationTests.h; path = Tests/NSInvocationTests.h; sourceTree = ""; }; BCFA3445098E25FA00EEEE22 /* NSInvocationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NSInvocationTests.m; path = Tests/NSInvocationTests.m; sourceTree = ""; }; - BCFA35CA098E6A0D00EEEE22 /* NSMethodSignature+WOTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMethodSignature+WOTest.h"; sourceTree = ""; }; - BCFA35CB098E6A0D00EEEE22 /* NSMethodSignature+WOTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMethodSignature+WOTest.m"; sourceTree = ""; }; BCFA3CE0098F9B4800EEEE22 /* WOLightweightRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOLightweightRoot.h; sourceTree = ""; }; BCFA3CE1098F9B4800EEEE22 /* WOLightweightRoot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOLightweightRoot.m; sourceTree = ""; }; BCFA3EA6098FCF9700EEEE22 /* NSValueTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSValueTests.h; path = Tests/NSValueTests.h; sourceTree = ""; }; @@ -580,8 +575,6 @@ BC5B1161072483FC000A7198 /* NSException+WOTest.m */, BCFA342A098DB87300EEEE22 /* NSInvocation+WOTest.h */, BCFA342B098DB87300EEEE22 /* NSInvocation+WOTest.m */, - BCFA35CA098E6A0D00EEEE22 /* NSMethodSignature+WOTest.h */, - BCFA35CB098E6A0D00EEEE22 /* NSMethodSignature+WOTest.m */, BC1A6961085C5002004E0E61 /* NSObject+WOTest.h */, BC1A6962085C5002004E0E61 /* NSObject+WOTest.m */, BC7CC40D0A8E0A5D00B83673 /* NSProxy+WOTest.h */, @@ -965,7 +958,6 @@ BCFA316D098BFD8900EEEE22 /* WOClassMock.m in Sources */, BCFA3175098BFD9300EEEE22 /* WOProtocolMock.m in Sources */, BCFA342D098DB87300EEEE22 /* NSInvocation+WOTest.m in Sources */, - BCFA35CF098E6A0D00EEEE22 /* NSMethodSignature+WOTest.m in Sources */, BCFA3CE3098F9B4800EEEE22 /* WOLightweightRoot.m in Sources */, BCBB58EF099D31280065D0C5 /* WOObjectMock.m in Sources */, BCBB59A5099D38BE0065D0C5 /* WOProtocolStub.m in Sources */, -- 2.37.1