2010-02-14 10:48:10 +00:00
|
|
|
/* Implementation of extension methods to base additions
|
|
|
|
|
|
|
|
Copyright (C) 2010 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library 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
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
|
|
|
|
|
|
|
*/
|
2010-02-19 08:12:46 +00:00
|
|
|
#import "common.h"
|
2010-02-14 10:48:10 +00:00
|
|
|
#import "Foundation/NSException.h"
|
|
|
|
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
2010-02-26 08:39:47 +00:00
|
|
|
#import "GNUstepBase/NSDebug+GNUstepBase.h"
|
2010-02-14 10:48:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extension methods for the NSObject class
|
|
|
|
*/
|
|
|
|
@implementation NSObject (GNUstepBase)
|
|
|
|
|
|
|
|
+ (id) notImplemented: (SEL)selector
|
|
|
|
{
|
|
|
|
[NSException raise: NSGenericException
|
|
|
|
format: @"method %@ not implemented in %s(class)",
|
|
|
|
selector ? (id)NSStringFromSelector(selector) : (id)@"(null)",
|
|
|
|
NSStringFromClass(self)];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2010-02-25 08:19:52 +00:00
|
|
|
- (NSComparisonResult) compare: (id)anObject
|
|
|
|
{
|
|
|
|
NSLog(@"WARNING: The -compare: method for NSObject is deprecated.");
|
|
|
|
|
|
|
|
if (anObject == self)
|
|
|
|
{
|
|
|
|
return NSOrderedSame;
|
|
|
|
}
|
|
|
|
if (anObject == nil)
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"nil argument for compare:"];
|
|
|
|
}
|
|
|
|
if ([self isEqual: anObject])
|
|
|
|
{
|
|
|
|
return NSOrderedSame;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Ordering objects by their address is pretty useless,
|
|
|
|
* so subclasses should override this is some useful way.
|
|
|
|
*/
|
|
|
|
if ((id)self > anObject)
|
|
|
|
{
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NSOrderedAscending;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-14 10:48:10 +00:00
|
|
|
- (BOOL) isInstance
|
|
|
|
{
|
2010-02-25 08:19:52 +00:00
|
|
|
GSOnceMLog(@"Warning, the -isInstance method is deprecated. "
|
|
|
|
@"Use 'class_isMetaClass([self class]) ? NO : YES' instead");
|
|
|
|
return class_isMetaClass([self class]) ? NO : YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) makeImmutableCopyOnFail: (BOOL)force
|
|
|
|
{
|
|
|
|
if (force == YES)
|
|
|
|
{
|
|
|
|
return AUTORELEASE([self copy]);
|
|
|
|
}
|
|
|
|
return self;
|
2010-02-14 10:48:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) notImplemented: (SEL)aSel
|
|
|
|
{
|
|
|
|
[NSException
|
|
|
|
raise: NSGenericException
|
|
|
|
format: @"method %@ not implemented in %@(%s)",
|
|
|
|
aSel ? (id)NSStringFromSelector(aSel) : (id)@"(null)",
|
|
|
|
NSStringFromClass([self class]),
|
|
|
|
GSObjCIsInstance(self) ? "instance" : "class"];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) shouldNotImplement: (SEL)aSel
|
|
|
|
{
|
|
|
|
[NSException
|
|
|
|
raise: NSGenericException
|
|
|
|
format: @"%@(%s) should not implement %@",
|
|
|
|
NSStringFromClass([self class]),
|
|
|
|
GSObjCIsInstance(self) ? "instance" : "class",
|
|
|
|
aSel ? (id)NSStringFromSelector(aSel) : (id)@"(null)"];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) subclassResponsibility: (SEL)aSel
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"subclass %@(%s) should override %@",
|
|
|
|
NSStringFromClass([self class]),
|
|
|
|
GSObjCIsInstance(self) ? "instance" : "class",
|
|
|
|
aSel ? (id)NSStringFromSelector(aSel) : (id)@"(null)"];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2011-02-10 10:52:54 +00:00
|
|
|
|
|
|
|
/* See ../GSPrivate.h for details.
|
|
|
|
*/
|
|
|
|
#import "GSPrivate.h"
|
|
|
|
BaseCacheStruct GSBaseCache = { };
|
|
|
|
|