--- gcc/objc/Object.m 2018/04/24 18:13:41 1.1.1.2 +++ gcc/objc/Object.m 2018/04/24 18:20:17 1.1.1.3 @@ -1,5 +1,5 @@ /* The implementation of class Object for Objective-C. - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. This file is part of GNU CC. @@ -23,11 +23,11 @@ the Free Software Foundation, 675 Mass A exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ +#include #include "objc/Object.h" #include "objc/Protocol.h" #include "objc/objc-api.h" -#include "gstdarg.h" extern void (*_objc_error)(id object, const char *format, va_list); extern int errno; @@ -194,12 +194,17 @@ extern int errno; // Indicates if the receiving class or instance conforms to the given protocol // not usually overridden by subclasses -- (BOOL) conformsTo: (Protocol*)aProtocol +// +// Modified 9/5/94 to always search the class object's protocol list, rather +// than the meta class. + ++ (BOOL) conformsTo: (Protocol*)aProtocol { int i; struct objc_protocol_list* proto_list; + id parent; - for (proto_list = isa->protocols; + for (proto_list = ((Class*)self)->protocols; proto_list; proto_list = proto_list->next) { for (i=0; i < proto_list->count; i++) @@ -209,12 +214,17 @@ extern int errno; } } - if ([self superClass]) - return [[self superClass] conformsTo: aProtocol]; + if (parent = [self superClass]) + return [parent conformsTo: aProtocol]; else return NO; } +- (BOOL) conformsTo: (Protocol*)aProtocol +{ + return [[self class] conformsTo:aProtocol]; +} + - (IMP)methodFor:(SEL)aSel { return (method_get_imp(object_is_instance(self) @@ -260,12 +270,12 @@ extern int errno; return (*msg)(self, aSel, anObject1, anObject2); } -- forward:(SEL)aSel :(arglist_t)argFrame +- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame { - return [self doesNotRecognize: aSel]; + return (retval_t)[self doesNotRecognize: aSel]; } -- performv:(SEL)aSel :(arglist_t)argFrame +- (retval_t)performv:(SEL)aSel :(arglist_t)argFrame { return objc_msg_sendv(self, aSel, argFrame); } @@ -311,6 +321,10 @@ extern int errno; object_get_class_name(self), sel_get_name(aSel)]; } +#ifdef __alpha__ +extern size_t strlen(const char*); +#endif + - error:(const char *)aString, ... { #define FMT "error: %s (%s)\n%s\n" @@ -341,11 +355,9 @@ extern int errno; + (int)streamVersion: (TypedStream*)aStream { -#ifndef __alpha__ if (aStream->mode == OBJC_READONLY) return objc_get_stream_class_version (aStream, self); else -#endif return class_get_version (self); }