Some cleanup of NSObject. Call runtime functions, rather than duplicate their implementation, and only conditionally call some non-portable functions.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30597 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
theraven 2010-06-07 02:50:40 +00:00
parent d6b7b103ab
commit ca19318055

View file

@ -1390,35 +1390,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
*/ */
+ (BOOL) conformsToProtocol: (Protocol*)aProtocol + (BOOL) conformsToProtocol: (Protocol*)aProtocol
{ {
struct objc_protocol_list* proto_list; return class_conformsToProtocol(self, aProtocol);
if (aProtocol == 0)
{
return NO;
}
for (proto_list = ((struct objc_class*)self)->protocols;
proto_list; proto_list = proto_list->next)
{
NSUInteger i;
for (i = 0; i < proto_list->count; i++)
{
/* xxx We should add conformsToProtocol to Protocol class. */
if ([proto_list->list[i] conformsTo: aProtocol])
{
return YES;
}
}
}
if ([self superclass])
{
return [[self superclass] conformsToProtocol: aProtocol];
}
else
{
return NO;
}
} }
/** /**
@ -1427,7 +1399,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
*/ */
- (BOOL) conformsToProtocol: (Protocol*)aProtocol - (BOOL) conformsToProtocol: (Protocol*)aProtocol
{ {
return [[self class] conformsToProtocol: aProtocol]; return class_conformsToProtocol([self class], aProtocol);
} }
/** /**
@ -2115,6 +2087,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
*/ */
- (id) error: (const char *)aString, ... - (id) error: (const char *)aString, ...
{ {
#if !defined(NeXT_RUNTIME) && !defined(__GNUSTEP_RUNTIME__)
#define FMT "error: %s (%s)\n%s\n" #define FMT "error: %s (%s)\n%s\n"
char fmt[(strlen((char*)FMT)+strlen((char*)GSClassNameFromObject(self)) char fmt[(strlen((char*)FMT)+strlen((char*)GSClassNameFromObject(self))
+((aString!=NULL)?strlen((char*)aString):0)+8)]; +((aString!=NULL)?strlen((char*)aString):0)+8)];
@ -2127,8 +2100,9 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
/* xxx What should `code' argument be? Current 0. */ /* xxx What should `code' argument be? Current 0. */
objc_verror (self, 0, fmt, ap); objc_verror (self, 0, fmt, ap);
va_end(ap); va_end(ap);
return nil;
#undef FMT #undef FMT
#endif
return nil;
} }
/* /*
@ -2340,7 +2314,7 @@ objc_create_block_classes_as_subclasses_of(Class super) __attribute__((weak));
+ (NSInteger) streamVersion: (TypedStream*)aStream + (NSInteger) streamVersion: (TypedStream*)aStream
{ {
#ifndef NeXT_RUNTIME #if !defined(NeXT_RUNTIME) && !defined(__GNUSTEP_RUNTIME__)
if (aStream->mode == OBJC_READONLY) if (aStream->mode == OBJC_READONLY)
return objc_get_stream_class_version (aStream, self); return objc_get_stream_class_version (aStream, self);
else else