From 66a61fbc1c930c8e5c2655ba03d31197e04fe400 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Wed, 4 Apr 2012 00:02:43 +0000 Subject: [Author: aharper] Implement sel_isEqual R=dmaclach APPROVED=dmaclach --- Foundation/GTMObjC2Runtime.m | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Foundation/GTMObjC2Runtime.m') diff --git a/Foundation/GTMObjC2Runtime.m b/Foundation/GTMObjC2Runtime.m index 2eb5dc3..0b4614c 100644 --- a/Foundation/GTMObjC2Runtime.m +++ b/Foundation/GTMObjC2Runtime.m @@ -6,9 +6,9 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -73,7 +73,7 @@ Method *class_copyMethodList(Class cls, unsigned int *outCount) { while ( (mlist = class_nextMethodList(cls, &iterator)) ) { if (mlist->method_count == 0) continue; - methods = (Method *)realloc(methods, + methods = (Method *)realloc(methods, sizeof(Method) * (count + mlist->method_count + 1)); if (!methods) { //Memory alloc failed, so what can we do? @@ -107,7 +107,7 @@ IMP method_setImplementation(Method method, IMP imp) { // We intentionally don't test method for nil. // Leopard fails here, so should we. // I logged this as Radar: - // 5572981 method_setImplementation crashes if you pass nil for the + // 5572981 method_setImplementation crashes if you pass nil for the // method arg (arg 1) // because it seems odd that this API won't accept nil for method considering // all the other apis will accept nil args. @@ -121,7 +121,7 @@ IMP method_setImplementation(Method method, IMP imp) { if (imp) { oldImp = method->method_imp; method->method_imp = imp; - } + } return oldImp; } @@ -154,6 +154,11 @@ struct objc_method_description protocol_getMethodDescription(Protocol *p, return desc; } +BOOL sel_isEqual(SEL lhs, SEL rhs) { + // Apple (informally) promises this will work in the future: + // http://twitter.com/#!/gparker/status/2400099786 + return (lhs == rhs) ? YES : NO; +} #endif -- cgit v1.2.3