Commits

Dave Dribin  committed 507f988

Remove NSObject+SupersequentImplementation

  • Participants
  • Parent commits 83bdeec

Comments (0)

Files changed (3)

File WhereIsMyMac-WithUnitTests/Classes/NSObject+SupersequentImplementation.h

-//
-//  NSObjectSupersequentImplementation.h
-//  SupersequentImplementation
-//
-//  Created by Matt Gallagher on 9/11/07.
-//  Copyright 2007 OnceBuilt. All rights reserved.
-//
-//  Permission is given to use this source code file, free of charge, in any
-//  project, commercial or otherwise, entirely at your risk, with the condition
-//  that any redistribution (in part or whole) of source code must retain
-//  this copyright and permission notice. Attribution in compiled projects is
-//  appreciated but not required.
-//
-
-@interface NSObject (SupersequentImplementation)
-
-- (IMP)getImplementationOf:(SEL)lookup after:(IMP)imp;
-
-@end
-
-IMP impOfCallingMethod(id lookupObject, SEL selector);
-
-#define invokeSupersequent(args...) \
-	([self getImplementationOf:_cmd \
-		after:impOfCallingMethod(self, _cmd)]) \
-			(self, _cmd, ##args)
-
-#define invokeSupersequentNoArgs() \
-	([self getImplementationOf:_cmd \
-		after:impOfCallingMethod(self, _cmd)]) \
-			(self, _cmd)

File WhereIsMyMac-WithUnitTests/Classes/NSObject+SupersequentImplementation.m

-//
-//  NSObjectSupersequentImplementation.m
-//  SupersequentImplementation
-//
-//  Created by Matt Gallagher on 9/11/07.
-//  Copyright 2007 OnceBuilt. All rights reserved.
-//
-//  Permission is given to use this source code file, free of charge, in any
-//  project, commercial or otherwise, entirely at your risk, with the condition
-//  that any redistribution (in part or whole) of source code must retain
-//  this copyright and permission notice. Attribution in compiled projects is
-//  appreciated but not required.
-//
-
-#import "NSObject+SupersequentImplementation.h"
-#import <objc/runtime.h>
-
-IMP impOfCallingMethod(id lookupObject, SEL selector)
-{
-	NSUInteger returnAddress = (NSUInteger)__builtin_return_address(0);
-	NSUInteger closest = 0;
-	
-	//
-	// Iterate over the class and all superclasses
-	//
-	Class currentClass = object_getClass(lookupObject);
-	while (currentClass)
-	{
-		//
-		// Iterate over all instance methods for this class
-		//
-		unsigned int methodCount;
-		Method *methodList = class_copyMethodList(currentClass, &methodCount);
-		unsigned int i;
-		for (i = 0; i < methodCount; i++)
-		{
-			//
-			// Ignore methods with different selectors
-			//
-			if (method_getName(methodList[i]) != selector)
-			{
-				continue;
-			}
-			
-			//
-			// If this address is closer, use it instead
-			//
-			NSUInteger address = (NSUInteger)method_getImplementation(methodList[i]);
-			if (address < returnAddress && address > closest)
-			{
-				closest = address;
-			}
-		}
-	
-		free(methodList);
-		currentClass = class_getSuperclass(currentClass);
-	}
-	
-	return (IMP)closest;
-}
-
-@implementation NSObject (SupersequentImplementation)
-
-//
-// getInstanceImplementationOf:after:
-//
-// Looks up the next implementation of the given selector after the
-// default one.
-//
-// Returns nil if no alternate implementation is found.
-//
-- (IMP)getImplementationOf:(SEL)lookup after:(IMP)skip
-{
-	BOOL found = NO;
-	
-	Class currentClass = object_getClass(self);
-	while (currentClass)
-	{
-		//
-		// Get the complete list of methods. Fortunately, this list is in priority
-		// order (the IMP to avoid should be the first IMP matching the SEL and
-		// the next one in the priority list will be next).
-		//
-		unsigned int methodCount;
-		Method *methodList = class_copyMethodList(currentClass, &methodCount);
-		
-		//
-		// Iterate over all methods
-		//
-		unsigned int i;
-		for (i = 0; i < methodCount; i++)
-		{
-			//
-			// Look for the selector
-			//
-			if (method_getName(methodList[i]) != lookup)
-			{
-				continue;
-			}
-			
-			IMP implementation = method_getImplementation(methodList[i]);
-			
-			//
-			// Check if this is the "skip" implementation
-			//
-			if (implementation == skip)
-			{
-				found = YES;
-			}
-			else if (found)
-			{
-				//
-				// Return the match.
-				//
-				free(methodList);
-				return implementation;
-			}
-		}
-	
-		//
-		// No match found. Traverse up through super class' methods.
-		//
-		free(methodList);
-
-		currentClass = class_getSuperclass(currentClass);
-	}
-	return nil;
-}
-
-@end

File WhereIsMyMac-WithUnitTests/WhereIsMyMac.xcodeproj/project.pbxproj

 		C968AC8110DC9AB600F35B40 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C968AC8010DC9AB600F35B40 /* WebKit.framework */; };
 		C968AC9410DC9B8100F35B40 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C968AC6D10DC9A0D00F35B40 /* CoreLocation.framework */; };
 		C9849B3410DEF24400411F31 /* HTMLFormatString.html in Resources */ = {isa = PBXBuildFile; fileRef = C9849B3310DEF24400411F31 /* HTMLFormatString.html */; };
-		C9849B5710DEF7FE00411F31 /* NSObject+SupersequentImplementation.m in Sources */ = {isa = PBXBuildFile; fileRef = C9849B5510DEF7E700411F31 /* NSObject+SupersequentImplementation.m */; };
 		C9849CDB10DF0C2F00411F31 /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9F305E610DC736D004F4B59 /* OCMock.framework */; };
 		C9849D4310DF172300411F31 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C968AC8010DC9AB600F35B40 /* WebKit.framework */; };
 		C9849D4410DF173300411F31 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
 		C968AC6D10DC9A0D00F35B40 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
 		C968AC8010DC9AB600F35B40 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
 		C9849B3310DEF24400411F31 /* HTMLFormatString.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLFormatString.html; sourceTree = "<group>"; };
-		C9849B5410DEF7E700411F31 /* NSObject+SupersequentImplementation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+SupersequentImplementation.h"; sourceTree = "<group>"; };
-		C9849B5510DEF7E700411F31 /* NSObject+SupersequentImplementation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+SupersequentImplementation.m"; sourceTree = "<group>"; };
 		C9849D5E10DF17C200411F31 /* WebPageTestContent.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WebPageTestContent.html; sourceTree = "<group>"; };
 		C9F305D810DC6EFE004F4B59 /* UnitTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
 		C9F305D910DC6EFE004F4B59 /* UnitTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UnitTests-Info.plist"; sourceTree = "<group>"; };
 				C90E7AF210DC747F00CCE376 /* WhereIsMyMacAppDelegateTests.m */,
 				C968AC6210DC984B00F35B40 /* WhereIsMyMacWindowControllerTests.m */,
 				55A19EF010F6EA6B0020688E /* CoreLocationFormatterTest.m */,
-				C9849B5410DEF7E700411F31 /* NSObject+SupersequentImplementation.h */,
-				C9849B5510DEF7E700411F31 /* NSObject+SupersequentImplementation.m */,
 			);
 			name = Tests;
 			path = Classes;
 			files = (
 				C90E7AFF10DC74D100CCE376 /* WhereIsMyMacAppDelegateTests.m in Sources */,
 				C968AC7710DC9A4F00F35B40 /* WhereIsMyMacWindowControllerTests.m in Sources */,
-				C9849B5710DEF7FE00411F31 /* NSObject+SupersequentImplementation.m in Sources */,
 				55A19EF110F6EA6B0020688E /* CoreLocationFormatterTest.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;