mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
NSPointerFunctions added
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27655 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4326b17dc6
commit
69e6876332
5 changed files with 188 additions and 6 deletions
|
@ -8,6 +8,10 @@
|
||||||
* Headers/Foundation/NSGarbageCollector.h: Improve documentation.
|
* Headers/Foundation/NSGarbageCollector.h: Improve documentation.
|
||||||
* Source/NSAutoreleasePool.m: ([-drain[) Implemented.
|
* Source/NSAutoreleasePool.m: ([-drain[) Implemented.
|
||||||
* Headers/Foundation/NSAutoreleasePool.m: ([-drain]) fix comment.
|
* Headers/Foundation/NSAutoreleasePool.m: ([-drain]) fix comment.
|
||||||
|
* Source/NSPointerFunctions.m: New class implementation
|
||||||
|
* Headers/Foundation/NSPointerFunctions.h: Fix some declarations
|
||||||
|
* Headers/Foundation/Foundation.h: Include NSPointerFunctions.h
|
||||||
|
* Source/GNUmakefile: Build and install NSPointerFunctions
|
||||||
|
|
||||||
2009-01-21 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-01-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@
|
||||||
#import <Foundation/NSNull.h>
|
#import <Foundation/NSNull.h>
|
||||||
#import <Foundation/NSNumberFormatter.h>
|
#import <Foundation/NSNumberFormatter.h>
|
||||||
#import <Foundation/NSPathUtilities.h>
|
#import <Foundation/NSPathUtilities.h>
|
||||||
|
#import <Foundation/NSPointerFunctions.h>
|
||||||
#import <Foundation/NSPortCoder.h>
|
#import <Foundation/NSPortCoder.h>
|
||||||
#import <Foundation/NSPortMessage.h>
|
#import <Foundation/NSPortMessage.h>
|
||||||
#import <Foundation/NSPortNameServer.h>
|
#import <Foundation/NSPortNameServer.h>
|
||||||
|
|
|
@ -45,7 +45,7 @@ enum {
|
||||||
NSPointerFunctionsStrongMemory = (0<<0),
|
NSPointerFunctionsStrongMemory = (0<<0),
|
||||||
|
|
||||||
/** Garbage collected weak references */
|
/** Garbage collected weak references */
|
||||||
NSPointerFunctionsZeroingWeakgMemory = (1<<0),
|
NSPointerFunctionsZeroingWeakMemory = (1<<0),
|
||||||
|
|
||||||
/** Non-GC memory */
|
/** Non-GC memory */
|
||||||
NSPointerFunctionsOpaqueMemory = (2<<0),
|
NSPointerFunctionsOpaqueMemory = (2<<0),
|
||||||
|
@ -86,7 +86,7 @@ enum {
|
||||||
NSPointerFunctionsIntegerPersonality = (5<<8),
|
NSPointerFunctionsIntegerPersonality = (5<<8),
|
||||||
|
|
||||||
|
|
||||||
/** Request the memory aquire function to allocate/copy items.
|
/** Request the memory acquire function to allocate/copy items.
|
||||||
*/
|
*/
|
||||||
NSPointerFunctionsCopyIn = (1<<16)
|
NSPointerFunctionsCopyIn = (1<<16)
|
||||||
};
|
};
|
||||||
|
@ -103,7 +103,7 @@ typedef NSUInteger NSPointerFunctionsOptions;
|
||||||
- (id) initWithOptions: (NSPointerFunctionsOptions)options;
|
- (id) initWithOptions: (NSPointerFunctionsOptions)options;
|
||||||
|
|
||||||
- (void* (*)(const void *item,
|
- (void* (*)(const void *item,
|
||||||
NSUInteger (*size)(const void *item), BOOL shouldCopy)) aquireFunction;
|
NSUInteger (*size)(const void *item), BOOL shouldCopy)) acquireFunction;
|
||||||
|
|
||||||
- (NSString (*)(const void *item)) descriptionFunction;
|
- (NSString (*)(const void *item)) descriptionFunction;
|
||||||
|
|
||||||
|
@ -127,8 +127,8 @@ typedef NSUInteger NSPointerFunctionsOptions;
|
||||||
- (void) setIsEqualFunction: (BOOL (*)(const void *item1, const void *item2,
|
- (void) setIsEqualFunction: (BOOL (*)(const void *item1, const void *item2,
|
||||||
NSUInteger (*size)(const void *item)))func;
|
NSUInteger (*size)(const void *item)))func;
|
||||||
|
|
||||||
- (void) setRelinquishFunction: (NSUInteger (*)(const void *item,
|
- (void) setRelinquishFunction: (void (*)(const void *item,
|
||||||
NSUInteger (*size)(const void *item)))func;
|
NSUInteger (*size)(const void *item))) func;
|
||||||
|
|
||||||
- (void) setSizeFunction: (NSUInteger (*)(const void *item))func;
|
- (void) setSizeFunction: (NSUInteger (*)(const void *item))func;
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ typedef NSUInteger NSPointerFunctionsOptions;
|
||||||
|
|
||||||
- (BOOL) usesStrongWriteBarrier;
|
- (BOOL) usesStrongWriteBarrier;
|
||||||
|
|
||||||
- (BOOL) usesWeak ReadAndWriteBarriers;
|
- (BOOL) usesWeakReadAndWriteBarriers;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ NSObject+NSComparisonMethods.m \
|
||||||
NSPage.m \
|
NSPage.m \
|
||||||
NSPathUtilities.m \
|
NSPathUtilities.m \
|
||||||
NSPipe.m \
|
NSPipe.m \
|
||||||
|
NSPointerFunctions.m \
|
||||||
NSPort.m \
|
NSPort.m \
|
||||||
NSPortCoder.m \
|
NSPortCoder.m \
|
||||||
NSPortMessage.m \
|
NSPortMessage.m \
|
||||||
|
@ -360,6 +361,7 @@ NSNumberFormatter.h \
|
||||||
NSObjCRuntime.h \
|
NSObjCRuntime.h \
|
||||||
NSObject.h \
|
NSObject.h \
|
||||||
NSPathUtilities.h \
|
NSPathUtilities.h \
|
||||||
|
NSPointerFunctions.h \
|
||||||
NSPortCoder.h \
|
NSPortCoder.h \
|
||||||
NSPort.h \
|
NSPort.h \
|
||||||
NSPortMessage.h \
|
NSPortMessage.h \
|
||||||
|
|
175
Source/NSPointerFunctions.m
Normal file
175
Source/NSPointerFunctions.m
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
/**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.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "Foundation/NSPointerFunctions.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
NSUInteger options;
|
||||||
|
|
||||||
|
void* (*acquireFunction)(const void *item,
|
||||||
|
NSUInteger (*size)(const void *item), BOOL shouldCopy);
|
||||||
|
|
||||||
|
NSString (*descriptionFunction)(const void *item);
|
||||||
|
|
||||||
|
NSUInteger (*hashFunction)(const void *item,
|
||||||
|
NSUInteger (*size)(const void *item));
|
||||||
|
|
||||||
|
BOOL (*isEqualFunction)(const void *item1, const void *item2,
|
||||||
|
NSUInteger (*size)(const void *item));
|
||||||
|
|
||||||
|
void (*relinquishFunction)(const void *item,
|
||||||
|
NSUInteger (*size)(const void *item));
|
||||||
|
|
||||||
|
NSUInteger (*sizeFunction)(const void *item);
|
||||||
|
|
||||||
|
BOOL usesStrongWriteBarrier;
|
||||||
|
|
||||||
|
BOOL usesWeakReadAndWriteBarriers;
|
||||||
|
} _internal;
|
||||||
|
|
||||||
|
#define _options ((_internal*)(self+1))->options
|
||||||
|
#define _acquireFunction ((_internal*)(self+1))->acquireFunction
|
||||||
|
#define _descriptionFunction ((_internal*)(self+1))->descriptionFunction
|
||||||
|
#define _hashFunction ((_internal*)(self+1))->hashFunction
|
||||||
|
#define _isEqualFunction ((_internal*)(self+1))->isEqualFunction
|
||||||
|
#define _relinquishFunction ((_internal*)(self+1))->relinquishFunction
|
||||||
|
#define _sizeFunction ((_internal*)(self+1))->sizeFunction
|
||||||
|
#define _usesStrongWriteBarrier ((_internal*)(self+1))->usesStrongWriteBarrier
|
||||||
|
#define _usesWeakReadAndWriteBarriers ((_internal*)(self+1))->usesWeakReadAndWriteBarriers
|
||||||
|
|
||||||
|
|
||||||
|
@implementation NSPointerFunctions
|
||||||
|
|
||||||
|
+ (id) allocWithZone: (NSZone*)zone
|
||||||
|
{
|
||||||
|
return (id) NSAllocateObject(self, sizeof(_internal), zone);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) pointerFunctionsWithOptions: (NSPointerFunctionsOptions)options
|
||||||
|
{
|
||||||
|
return AUTORELEASE([[self alloc] initWithOptions: options]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) copyWithZone: (NSZone*)zone
|
||||||
|
{
|
||||||
|
return NSCopyObject(self, sizeof(_internal), zone);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithOptions: (NSPointerFunctionsOptions)options
|
||||||
|
{
|
||||||
|
_options = options;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void* (*)(const void *item,
|
||||||
|
NSUInteger (*size)(const void *item), BOOL shouldCopy)) acquireFunction
|
||||||
|
{
|
||||||
|
return _acquireFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString (*)(const void *item)) descriptionFunction
|
||||||
|
{
|
||||||
|
return _descriptionFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSUInteger (*)(const void *item,
|
||||||
|
NSUInteger (*size)(const void *item))) hashFunction
|
||||||
|
{
|
||||||
|
return _hashFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL (*)(const void *item1, const void *item2,
|
||||||
|
NSUInteger (*size)(const void *item))) isEqualFunction
|
||||||
|
{
|
||||||
|
return _isEqualFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void (*)(const void *item,
|
||||||
|
NSUInteger (*size)(const void *item))) relinquishFunction
|
||||||
|
{
|
||||||
|
return _relinquishFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setAcquireFunction: (void* (*)(const void *item,
|
||||||
|
NSUInteger (*size)(const void *item), BOOL shouldCopy))func
|
||||||
|
{
|
||||||
|
_acquireFunction = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setDescriptionFunction: (NSString (*)(const void *item))func
|
||||||
|
{
|
||||||
|
_descriptionFunction = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setHashFunction: (NSUInteger (*)(const void *item,
|
||||||
|
NSUInteger (*size)(const void *item)))func
|
||||||
|
{
|
||||||
|
_hashFunction = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setIsEqualFunction: (BOOL (*)(const void *item1, const void *item2,
|
||||||
|
NSUInteger (*size)(const void *item)))func
|
||||||
|
{
|
||||||
|
_isEqualFunction = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setRelinquishFunction: (void (*)(const void *item,
|
||||||
|
NSUInteger (*size)(const void *item))) func
|
||||||
|
{
|
||||||
|
_relinquishFunction = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setSizeFunction: (NSUInteger (*)(const void *item))func
|
||||||
|
{
|
||||||
|
_sizeFunction = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setUsesStrongWriteBarrier: (BOOL)flag
|
||||||
|
{
|
||||||
|
_usesStrongWriteBarrier = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setUsesWeakReadAndWriteBarriers: (BOOL)flag
|
||||||
|
{
|
||||||
|
_usesWeakReadAndWriteBarriers = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSUInteger (*)(const void *item)) sizeFunction
|
||||||
|
{
|
||||||
|
return _sizeFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) usesStrongWriteBarrier
|
||||||
|
{
|
||||||
|
return _usesStrongWriteBarrier;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) usesWeakReadAndWriteBarriers
|
||||||
|
{
|
||||||
|
return _usesStrongWriteBarrier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue