2009-01-22 18:43:47 +00:00
|
|
|
/**Implementation for NSPointerFunctions for GNUStep
|
|
|
|
Copyright (C) 2009 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
|
|
|
Date: 2009
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2009-02-10 19:47:01 +00:00
|
|
|
#import "NSConcretePointerFunctions.h"
|
2010-02-10 17:15:09 +00:00
|
|
|
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
2009-01-22 18:43:47 +00:00
|
|
|
|
2009-02-10 19:47:01 +00:00
|
|
|
static Class abstractClass = Nil;
|
|
|
|
static Class concreteClass = Nil;
|
2009-01-22 18:43:47 +00:00
|
|
|
|
|
|
|
@implementation NSPointerFunctions
|
|
|
|
|
|
|
|
+ (id) allocWithZone: (NSZone*)zone
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
if (self == abstractClass)
|
|
|
|
{
|
|
|
|
return (id) NSAllocateObject(concreteClass, 0, zone);
|
|
|
|
}
|
|
|
|
return [super allocWithZone: zone];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (abstractClass == nil)
|
|
|
|
{
|
|
|
|
abstractClass = [NSPointerFunctions class];
|
|
|
|
concreteClass = [NSConcretePointerFunctions class];
|
|
|
|
}
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (id) pointerFunctionsWithOptions: (NSPointerFunctionsOptions)options
|
|
|
|
{
|
|
|
|
return AUTORELEASE([[self alloc] initWithOptions: options]);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) copyWithZone: (NSZone*)zone
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
return NSCopyObject(self, 0, zone);
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithOptions: (NSPointerFunctionsOptions)options
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
return [self subclassResponsibility: _cmd];
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void* (*)(const void *item,
|
|
|
|
NSUInteger (*size)(const void *item), BOOL shouldCopy)) acquireFunction
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
return 0;
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 22:32:47 +00:00
|
|
|
- (NSString *(*)(const void *item)) descriptionFunction
|
2009-01-22 18:43:47 +00:00
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
return 0;
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSUInteger (*)(const void *item,
|
|
|
|
NSUInteger (*size)(const void *item))) hashFunction
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
return 0;
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL (*)(const void *item1, const void *item2,
|
|
|
|
NSUInteger (*size)(const void *item))) isEqualFunction
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
return 0;
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void (*)(const void *item,
|
|
|
|
NSUInteger (*size)(const void *item))) relinquishFunction
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
return 0;
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setAcquireFunction: (void* (*)(const void *item,
|
|
|
|
NSUInteger (*size)(const void *item), BOOL shouldCopy))func
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 22:32:47 +00:00
|
|
|
- (void) setDescriptionFunction: (NSString *(*)(const void *item))func
|
2009-01-22 18:43:47 +00:00
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setHashFunction: (NSUInteger (*)(const void *item,
|
|
|
|
NSUInteger (*size)(const void *item)))func
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setIsEqualFunction: (BOOL (*)(const void *item1, const void *item2,
|
|
|
|
NSUInteger (*size)(const void *item)))func
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setRelinquishFunction: (void (*)(const void *item,
|
|
|
|
NSUInteger (*size)(const void *item))) func
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSizeFunction: (NSUInteger (*)(const void *item))func
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUsesStrongWriteBarrier: (BOOL)flag
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUsesWeakReadAndWriteBarriers: (BOOL)flag
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSUInteger (*)(const void *item)) sizeFunction
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
return 0;
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) usesStrongWriteBarrier
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
return 0;
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) usesWeakReadAndWriteBarriers
|
|
|
|
{
|
2009-02-10 19:47:01 +00:00
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
return 0;
|
2009-01-22 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|