Lots of little fixes to make -base compile with -Werror (now builds without warnings).

Richard: I'm unsure about three of these, which were fixes in memset() calls in:
- NSConcreteMapTable.m
- NSConcreteHashTable.m
- Additions/NSData+GNUstepBase.m

Please can you check them?  I think they are intended to zero the entire object
(rather than the first word), but the lack of comments makes me unsure.

Most changes were just tweaks to variable types.  I've also removed some dead code from NSInvocation.  This was small group of things that were marked for internal use only, but not actually referenced in the code anywhere.

Other improvements:

- NSArray / NSDictionary fixed up to use the 10.7 (ARC-friendly) prototypes.
- getObjects:andKeys: implemented for NSDictionary (10.5 method)
- NSPointerArray and NSHashTable now properly support weak objects.
- Tests for weak objects in collections.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33621 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
theraven 2011-07-24 13:09:22 +00:00
parent ee75164747
commit ceba92a265
39 changed files with 196 additions and 155 deletions

View file

@ -55,8 +55,8 @@ extern "C" {
- (NSArray*) arrayByAddingObjectsFromArray: (NSArray*)anotherArray;
- (BOOL) containsObject: anObject;
- (NSUInteger) count; // Primitive
- (void) getObjects: (id[])aBuffer;
- (void) getObjects: (id[])aBuffer range: (NSRange)aRange;
- (void) getObjects: (__unsafe_unretained id[])aBuffer;
- (void) getObjects: (__unsafe_unretained id[])aBuffer range: (NSRange)aRange;
- (NSUInteger) indexOfObject: (id)anObject;
- (NSUInteger) indexOfObject: (id)anObject inRange: (NSRange)aRange;
- (NSUInteger) indexOfObjectIdenticalTo: (id)anObject;

View file

@ -44,8 +44,8 @@ extern "C" {
+ (id) dictionaryWithDictionary: (NSDictionary*)otherDictionary;
+ (id) dictionaryWithObject: (id)object forKey: (id)key;
+ (id) dictionaryWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
+ (id) dictionaryWithObjects: (id*)objects
forKeys: (id*)keys
+ (id) dictionaryWithObjects: (const id[])objects
forKeys: (const id[])keys
count: (NSUInteger)count;
+ (id) dictionaryWithObjectsAndKeys: (id)firstObject, ...;
@ -68,8 +68,8 @@ extern "C" {
- (id) initWithDictionary: (NSDictionary*)other copyItems: (BOOL)shouldCopy;
- (id) initWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
- (id) initWithObjectsAndKeys: (id)firstObject, ...;
- (id) initWithObjects: (id*)objects
forKeys: (id*)keys
- (id) initWithObjects: (const id[])objects
forKeys: (const id[])keys
count: (NSUInteger)count; // Primitive
- (BOOL) isEqualToDictionary: (NSDictionary*)other;
@ -78,6 +78,8 @@ extern "C" {
- (NSEnumerator*) objectEnumerator; // Primitive
- (id) objectForKey: (id)aKey; // Primitive
- (NSArray*) objectsForKeys: (NSArray*)keys notFoundMarker: (id)marker;
- (void)getObjects: (__unsafe_unretained id[])objects
andKeys: (__unsafe_unretained id[])keys;
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)

View file

@ -44,7 +44,7 @@ typedef struct
@protocol NSFastEnumeration
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState *)state
objects: (id *)stackbuf
objects: (__unsafe_unretained id[])stackbuf
count: (NSUInteger)len;
@end

View file

@ -121,14 +121,6 @@ extern "C" {
@end
#endif
/* Do NOT use these methods ... internal use only ... not public API */
@interface NSInvocation (MacroSetup)
+ (id) _newProxyForInvocation: (id)target;
+ (id) _newProxyForMessage: (id)target;
+ (NSInvocation*) _returnInvocationAndDestroyProxy: (id)proxy;
- (id) initWithMethodSignature: (NSMethodSignature*)aSignature;
@end
/**
* Creates and returns an autoreleased invocation containing a
* message to an instance of the class. The 'message' consists

View file

@ -36,6 +36,7 @@
#include <zlib.h>
#endif
struct sockaddr_in;
/**
* DO NOT USE ... this header is here only for the SSL file handle support

View file

@ -481,6 +481,33 @@ GSIMapRemoveAndFreeNode(GSIMapTable map, uintptr_t bkt, GSIMapNode node)
return next;
}
static INLINE void
GSIMapRemoveWeak(GSIMapTable map)
{
uintptr_t bucketCount = map->bucketCount;
GSIMapBucket bucket = map->buckets;
if (GSI_MAP_ZEROED(map))
{
while (bucketCount-- > 0)
{
GSIMapNode node = bucket->firstNode;
while (node != 0)
{
GSIMapNode next = node->nextInBucket;
if (GSI_MAP_NODE_IS_EMPTY(map, node))
{
GSIMapRemoveNodeFromMap(map, bucket, node);
GSIMapFreeNode(map, node);
}
node = next;
}
bucket++;
}
return;
}
}
static INLINE void
GSIMapRemangleBuckets(GSIMapTable map,
GSIMapBucket old_buckets, uintptr_t old_bucketCount,

View file

@ -49,6 +49,9 @@
#ifndef __has_feature
# define __has_feature(x) 0
#endif
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif
#if defined(__WIN32__)
#include <w32api.h>
@ -268,5 +271,10 @@
# endif
#endif
#if __has_builtin(__builtin_unreachable)
# define GS_UNREACHABLE() __builtin_unreachable()
#else
# define GS_UNREACHABLE() abort()
#endif
#endif /* __preface_h_OBJECTS_INCLUDE */

View file

@ -37,7 +37,7 @@ typedef struct {
BOOL isGCObject;
} GCInfo;
@interface _GCDictionaryKeyEnumerator : NSObject
@interface _GCDictionaryKeyEnumerator : NSEnumerator
{
@public
GCDictionary *dict;
@ -260,8 +260,8 @@ static Class gcClass = 0;
return self;
}
- (id) initWithObjects: (id*)objects
forKeys: (id*)keys
- (id) initWithObjects: (const id[])objects
forKeys: (const id[])keys
count: (NSUInteger)count
{
NSUInteger size = (count * 4) / 3;

View file

@ -69,6 +69,7 @@
_GSInsensitiveDictionary *dictionary;
GSIMapEnumerator_t enumerator;
}
- (id) initWithDictionary: (NSDictionary*)d;
@end
@interface _GSInsensitiveDictionaryObjectEnumerator : _GSInsensitiveDictionaryKeyEnumerator
@ -169,7 +170,7 @@ static SEL objSel;
}
/* Designated initialiser */
- (id) initWithObjects: (id*)objs forKeys: (id*)keys count: (NSUInteger)c
- (id) initWithObjects: (const id[])objs forKeys: (const id[])keys count: (NSUInteger)c
{
NSUInteger i;

View file

@ -93,7 +93,7 @@
if ([NSThread isMultiThreaded] == YES)
{
DESTROY(self);
self = [NSLock new];
return (GSLazyLock*)[NSLock new];
}
else if (self != nil)
{
@ -246,7 +246,7 @@
if ([NSThread isMultiThreaded] == YES)
{
DESTROY(self);
self = [NSRecursiveLock new];
return (GSLazyRecursiveLock*)[NSRecursiveLock new];
}
else
{

View file

@ -331,7 +331,7 @@ static void MD5Final (unsigned char digest[16], struct MD5Context *ctx)
MD5Transform (ctx->buf, (uint32_t *) ctx->in);
littleEndian ((unsigned char *) ctx->buf, 4);
memcpy (digest, ctx->buf, 16);
memset (ctx, 0, sizeof (ctx)); /* In case it's sensitive */
memset (ctx, 0, sizeof (*ctx)); /* In case it's sensitive */
}
/* The four core functions - F1 is optimized somewhat */

View file

@ -353,7 +353,7 @@ static Class GSInlineArrayClass;
}
}
- (void) getObjects: (id[])aBuffer
- (void) getObjects: (__unsafe_unretained id[])aBuffer
{
NSUInteger i;
@ -363,7 +363,7 @@ static Class GSInlineArrayClass;
}
}
- (void) getObjects: (id[])aBuffer range: (NSRange)aRange
- (void) getObjects: (__unsafe_unretained id[])aBuffer range: (NSRange)aRange
{
NSUInteger i, j = 0, e = aRange.location + aRange.length;
@ -376,7 +376,7 @@ static Class GSInlineArrayClass;
}
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
objects: (id*)stackbuf
objects: (__unsafe_unretained id[])stackbuf
count: (NSUInteger)len
{
/* For immutable arrays we can return the contents pointer directly. */
@ -886,7 +886,7 @@ static Class GSInlineArrayClass;
}
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
objects: (id*)stackbuf
objects: (__unsafe_unretained id[])stackbuf
count: (NSUInteger)len
{
NSInteger count;

View file

@ -74,6 +74,7 @@ static GC_descr nodeDesc; // Type descriptor for map node.
GSDictionary *dictionary;
GSIMapEnumerator_t enumerator;
}
- (id) initWithDictionary: (NSDictionary*)d;
@end
@interface GSDictionaryObjectEnumerator : GSDictionaryKeyEnumerator
@ -183,7 +184,9 @@ static SEL objSel;
}
/* Designated initialiser */
- (id) initWithObjects: (id*)objs forKeys: (id*)keys count: (NSUInteger)c
- (id) initWithObjects: (const id[])objs
forKeys: (const id[])keys
count: (NSUInteger)c
{
NSUInteger i;
@ -354,7 +357,7 @@ static SEL objSel;
}
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
objects: (id*)stackbuf
objects: (__unsafe_unretained id[])stackbuf
count: (NSUInteger)len
{
state->mutationsPtr = (unsigned long *)self;
@ -458,7 +461,7 @@ static SEL objSel;
}
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
objects: (id*)stackbuf
objects: (__unsafe_unretained id[])stackbuf
count: (NSUInteger)len
{
state->mutationsPtr = (unsigned long *)&_version;

View file

@ -39,6 +39,11 @@ typedef struct {
BOOL isReg;
} NSArgumentInfo;
@interface NSInvocation (MacroSetup)
- (id) initWithMethodSignature: (NSMethodSignature*)aSignature;
@end
@interface GSFFIInvocation : NSInvocation
{
@public

View file

@ -389,7 +389,7 @@ static SEL rlSel;
}
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
objects: (id*)stackbuf
objects: (__unsafe_unretained id[])stackbuf
count: (NSUInteger)len
{
NSUInteger size = [self count];
@ -479,7 +479,7 @@ static SEL rlSel;
* Copies the objects from the receiver to aBuffer, which must be
* an area of memory large enough to hold them.
*/
- (void) getObjects: (id[])aBuffer
- (void) getObjects: (__unsafe_unretained id[])aBuffer
{
unsigned i, c = [self count];
IMP get = [self methodForSelector: oaiSel];
@ -492,7 +492,7 @@ static SEL rlSel;
* Copies the objects from the range aRange of the receiver to aBuffer,
* which must be an area of memory large enough to hold them.
*/
- (void) getObjects: (id[])aBuffer range: (NSRange)aRange
- (void) getObjects: (__unsafe_unretained id[])aBuffer range: (NSRange)aRange
{
unsigned i, j = 0, c = [self count], e = aRange.location + aRange.length;
IMP get = [self methodForSelector: oaiSel];

View file

@ -26,6 +26,7 @@
*/
#import "common.h"
#import "GNUstepBase/preface.h"
#import "Foundation/NSException.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSThread.h"
@ -103,6 +104,7 @@ NSString *const NSAssertionHandlerKey = @"NSAssertionHandler";
[NSException raise: NSInternalInconsistencyException
format: message arguments: ap];
va_end(ap);
GS_UNREACHABLE();
/* NOT REACHED */
}
@ -133,6 +135,7 @@ NSString *const NSAssertionHandlerKey = @"NSAssertionHandler";
format: message arguments: ap];
va_end(ap);
/* NOT REACHED */
GS_UNREACHABLE();
}
@end

View file

@ -76,7 +76,7 @@
}
@end
@interface NSDataStatic : NSObject // Help the compiler
@interface NSDataStatic : NSData // Help the compiler
@end
/* Private class from NSIndexSet.m
@ -620,7 +620,7 @@ static Class concreteMutableClass = nil;
- (id) initWithBitmap: (NSData*)bitmap number: (int)number
{
if ((self = [(NSBitmapCharSet*)self initWithBitmap: bitmap]) != nil)
if ((self = (_GSStaticCharSet*)[(NSBitmapCharSet*)self initWithBitmap: bitmap]) != nil)
{
_index = number;
}

View file

@ -90,6 +90,18 @@ typedef GSIMapNode_t *GSIMapNode;
(M->legacy ? 0 \
: ((M->cb.pf.options & NSPointerFunctionsZeroingWeakMemory) ? YES : NO))
#define GSI_MAP_WRITE_KEY(M, addr, x) \
if (M->legacy) \
*(addr) = x;\
else\
pointerFunctionsAssign(&M->cb.pf, (void**)addr, (x).obj);
#define GSI_MAP_READ_KEY(M,addr) \
(M->legacy ? *(addr) :\
(typeof(*addr))pointerFunctionsRead(&M->cb.pf, (void**)addr))
#define GSI_MAP_ZEROED(M)\
(M->legacy ? 0 \
: ((M->cb.pf.options & NSPointerFunctionsZeroingWeakMemory) ? YES : NO))
#define GSI_MAP_ENUMERATOR NSHashEnumerator
#if GS_WITH_GC
@ -353,7 +365,7 @@ NSEndHashTableEnumeration(NSHashEnumerator *enumerator)
* in the 'node' field.
*/
[(id)enumerator->node release];
memset(enumerator, '\0', sizeof(GSIMapEnumerator));
memset(enumerator, '\0', sizeof(NSHashEnumerator));
}
}
@ -914,6 +926,7 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
- (NSUInteger) count
{
GSIMapRemoveWeak(self);
return (NSUInteger)nodeCount;
}

View file

@ -116,7 +116,8 @@ typedef GSIMapNode_t *GSIMapNode;
(typeof(*addr))pointerFunctionsRead(&M->cb.pf.v, (void**)addr))
#define GSI_MAP_ZEROED(M)\
(M->legacy ? 0 \
: ((M->cb.pf.k.options & NSPointerFunctionsZeroingWeakMemory) ? YES : NO))
: (((M->cb.pf.k.options | M->cb.pf.v.options) & NSPointerFunctionsZeroingWeakMemory) ?\
YES : NO))
#define GSI_MAP_ENUMERATOR NSMapEnumerator
@ -518,7 +519,7 @@ NSEndMapTableEnumeration(NSMapEnumerator *enumerator)
* 'bucket' field.
*/
[(id)enumerator->node release];
memset(enumerator, '\0', sizeof(GSIMapEnumerator));
memset(enumerator, '\0', sizeof(NSMapEnumerator));
}
}
@ -1201,10 +1202,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
- (NSUInteger) count
{
if (!legacy && (cb.pf.k.options | cb.pf.v.options) & NSPointerFunctionsZeroingWeakMemory)
{
GSIMapCleanMap(self);
}
GSIMapRemoveWeak(self);
return (NSUInteger)nodeCount;
}

View file

@ -94,17 +94,6 @@ typedef struct
/* Wrapper functions to make use of the pointer functions.
*/
/* Acquire the pointer value to store for the specified item.
*/
static inline void *
pointerFunctionsAcquire(PFInfo *PF, void **dst, void *src)
{
if (PF->acquireFunction != 0)
src = (*PF->acquireFunction)(src, PF->sizeFunction,
PF->options & NSPointerFunctionsCopyIn ? YES : NO);
return src;
}
/**
* Reads the pointer from the specified address, inserting a read barrier if
* required.
@ -115,6 +104,8 @@ static inline void *pointerFunctionsRead(PFInfo *PF, void **addr)
{
return WEAK_READ((id*)addr);
}
NSLog(@"Reading from %p", addr);
NSLog(@"Value: %p", *addr);
return *addr;
}
@ -137,6 +128,23 @@ static inline void pointerFunctionsAssign(PFInfo *PF, void **addr, void *value)
}
}
/* Acquire the pointer value to store for the specified item.
*/
static inline void *
pointerFunctionsAcquire(PFInfo *PF, void **dst, void *src)
{
if (PF->acquireFunction != 0)
src = (*PF->acquireFunction)(src, PF->sizeFunction,
PF->options & NSPointerFunctionsCopyIn ? YES : NO);
// FIXME: This shouldn't be here. Acquire and assign are separate
// operations. Acquire is for copy-in operations (i.e. retain / copy),
// assign is for move operations of already-owned pointers. Combining them
// like this is Just Plain Wrong™
pointerFunctionsAssign(PF, dst, src);
return src;
}
/**
* Moves a pointer from location to another.
*/

View file

@ -365,7 +365,7 @@ static BOOL cacheCoders = NO;
static int debug_connection = 0;
static NSHashTable *connection_table;
static NSLock *connection_table_gate = nil;
static GSLazyRecursiveLock *connection_table_gate = nil;
/*
* Locate an existing connection with the specified send and receive ports.

View file

@ -43,7 +43,7 @@
/*
* Class variables for uniquing objects;
*/
static NSRecursiveLock *uniqueLock = nil;
static GSLazyRecursiveLock *uniqueLock = nil;
static NSCountedSet *uniqueSet = nil;
static IMP uniqueImp = 0;
static IMP lockImp = 0;
@ -73,7 +73,7 @@ static Class NSCountedSet_concrete_class;
{
NSCountedSet_abstract_class = self;
NSCountedSet_concrete_class = [GSCountedSet class];
uniqueLock = [GSLazyLock new];
uniqueLock = [GSLazyRecursiveLock new];
lockImp = [uniqueLock methodForSelector: @selector(lock)];
unlockImp = [uniqueLock methodForSelector: @selector(unlock)];
}

View file

@ -2389,7 +2389,7 @@ failure:
+ (id) dataWithShmID: (int)anID length: (NSUInteger)length
{
#ifdef HAVE_SHMCTL
NSDataShared *d;
NSMutableDataShared *d;
d = [NSMutableDataShared allocWithZone: NSDefaultMallocZone()];
d = [d initWithShmID: anID length: length];
@ -2502,7 +2502,7 @@ failure:
+ (id) allocWithZone: (NSZone*)z
{
return (NSData*)NSAllocateObject(self, 0, z);
return NSAllocateObject(self, 0, z);
}
/* Creation and Destruction of objects. */
@ -2979,7 +2979,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
@implementation NSDataMappedFile
+ (id) allocWithZone: (NSZone*)z
{
return (NSData*)NSAllocateObject([NSDataMappedFile class], 0, z);
return NSAllocateObject([NSDataMappedFile class], 0, z);
}
- (void) dealloc
@ -3070,7 +3070,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
@implementation NSDataShared
+ (id) allocWithZone: (NSZone*)z
{
return (NSData*)NSAllocateObject([NSDataShared class], 0, z);
return NSAllocateObject([NSDataShared class], 0, z);
}
- (void) dealloc
@ -3184,7 +3184,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
+ (id) allocWithZone: (NSZone*)z
{
return (NSData*)NSAllocateObject(mutableDataMalloc, 0, z);
return NSAllocateObject(mutableDataMalloc, 0, z);
}
- (Class) classForCoder
@ -3797,7 +3797,7 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
@implementation NSMutableDataShared
+ (id) allocWithZone: (NSZone*)z
{
return (NSData*)NSAllocateObject([NSMutableDataShared class], 0, z);
return NSAllocateObject([NSMutableDataShared class], 0, z);
}
- (void) dealloc

View file

@ -78,8 +78,8 @@ static Class calendarClass = nil;
@interface GSDateFuture : GSDateSingle
@end
static NSDate *_distantPast = nil;
static NSDate *_distantFuture = nil;
static id _distantPast = nil;
static id _distantFuture = nil;
static NSString*

View file

@ -66,7 +66,7 @@ static table_entry* the_table = 0;
static BOOL debug_allocation = NO;
static NSLock *uniqueLock = nil;
static GSLazyRecursiveLock *uniqueLock = nil;
static const char* _GSDebugAllocationList(BOOL difference);
static const char* _GSDebugAllocationListAll(void);

View file

@ -41,6 +41,7 @@
#import "Foundation/NSKeyedArchiver.h"
#import "GNUstepBase/NSObject+GNUstepBase.h"
#import "GSPrivate.h"
#import "GSFastEnumeration.h"
static BOOL GSMacOSXCompatiblePropertyLists(void)
{
@ -165,8 +166,8 @@ static SEL appSel;
* and needs to be re-implemented in subclasses in order to have all
* other initialisers work.
*/
- (id) initWithObjects: (id*)objects
forKeys: (id*)keys
- (id) initWithObjects: (const id[])objects
forKeys: (const id[])keys
count: (NSUInteger)count
{
self = [self init];
@ -396,8 +397,8 @@ static SEL appSel;
* The n th element of the objects array is associated with the n th
* element of the keys array.
*/
+ (id) dictionaryWithObjects: (id*)objects
forKeys: (id*)keys
+ (id) dictionaryWithObjects: (const id[])objects
forKeys: (const id[])keys
count: (NSUInteger)count
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
@ -814,6 +815,15 @@ static SEL appSel;
return AUTORELEASE(result);
}
}
- (void)getObjects: (__unsafe_unretained id[])objects
andKeys: (__unsafe_unretained id[])keys
{
int i=0;
FOR_IN(id, key, self)
keys[i] = key;
objects[i] = [self objectForKey: key];
END_FOR_IN(self)
}
/**
* Returns an array containing all the dictionary's keys that are
@ -1103,7 +1113,7 @@ compareIt(id o1, id o2, void* context)
return o;
}
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
objects: (id*)stackbuf
objects: (__unsafe_unretained id[])stackbuf
count: (NSUInteger)len
{
[self subclassResponsibility: _cmd];
@ -1231,8 +1241,8 @@ compareIt(id o1, id o2, void* context)
* The n th element of the objects array is associated with the n th
* element of the keys array.
*/
- (id) initWithObjects: (id*)objects
forKeys: (id*)keys
- (id) initWithObjects: (const id[])objects
forKeys: (const id[])keys
count: (NSUInteger)count
{
self = [self initWithCapacity: count];

View file

@ -407,7 +407,7 @@ enum proxyLocation
+ (id) allocWithZone: (NSZone*)z
{
return placeHolder;
return (NSDistantObject*)placeHolder;
}
/**

View file

@ -56,7 +56,7 @@
static NSString *localHostName = @"GNUstep local host";
static Class hostClass;
static NSLock *_hostCacheLock = nil;
static NSRecursiveLock *_hostCacheLock = nil;
static BOOL _hostCacheEnabled = YES;
static NSMutableDictionary *_hostCache = nil;

View file

@ -34,7 +34,7 @@
#import "Foundation/NSLock.h"
#import "GNUstepBase/GSLock.h"
static NSLock *lock = nil;
static GSLazyRecursiveLock *lock = nil;
static NSHashTable *shared = 0;
static Class myClass = 0;
static NSIndexPath *empty = nil;

View file

@ -153,20 +153,6 @@
static Class NSInvocation_abstract_class;
static Class NSInvocation_concrete_class;
@interface GSInvocationProxy
{
@public
Class isa;
id target;
NSInvocation *invocation;
}
+ (id) _newWithTarget: (id)t;
- (NSInvocation*) _invocation;
- (void) forwardInvocation: (NSInvocation*)anInvocation;
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector;
@end
@interface GSMessageProxy : GSInvocationProxy
@end
@ -788,26 +774,6 @@ _arg_addr(NSInvocation *inv, int index)
return nil;
}
/**
* Internal use.<br />
* Provides a return frame that the ObjectiveC runtime can use to
* return the result of an invocation to a calling function.
*/
+ (id) _newProxyForInvocation: (id)target
{
return [GSInvocationProxy _newWithTarget: target];
}
+ (id) _newProxyForMessage: (id)target
{
return [GSMessageProxy _newWithTarget: target];
}
+ (NSInvocation*) _returnInvocationAndDestroyProxy: (id)proxy
{
NSInvocation *inv = [proxy _invocation];
NSDeallocateObject(proxy);
return inv;
}
@end
@implementation NSInvocation (BackwardCompatibility)
@ -849,34 +815,3 @@ _arg_addr(NSInvocation *inv, int index)
@end
#endif
@implementation GSInvocationProxy
+ (id) _newWithTarget: (id)t
{
GSInvocationProxy *o;
o = (GSInvocationProxy*) NSAllocateObject(self, 0, NSDefaultMallocZone());
o->target = RETAIN(t);
return o;
}
- (NSInvocation*) _invocation
{
return invocation;
}
- (void) forwardInvocation: (NSInvocation*)anInvocation
{
invocation = anInvocation;
}
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector
{
return [target methodSignatureForSelector: aSelector];
}
@end
@implementation GSMessageProxy
- (NSInvocation*) _invocation
{
[invocation setTarget: target];
return invocation;
}
@end

View file

@ -174,7 +174,7 @@ setup()
@interface GSKVOInfo : NSObject
{
NSObject *instance; // Not retained.
NSLock *iLock;
GSLazyRecursiveLock *iLock;
NSMapTable *paths;
}
- (GSKVOPathInfo *) lockReturningPathInfoForKey: (NSString *)key;

View file

@ -240,7 +240,7 @@ static Class concreteClass = Nil;
for (i = 0; i < _count; i++)
{
if (pointerFunctionsRead(&_pf, _contents[i]) != 0)
if (pointerFunctionsRead(&_pf, &_contents[i]) != 0)
{
c++;
}
@ -256,7 +256,7 @@ static Class concreteClass = Nil;
for (i = 0; i < _count; i++)
{
id obj = pointerFunctionsRead(&_pf, _contents[i]);
id obj = pointerFunctionsRead(&_pf, &_contents[i]);
if (obj != 0)
{
[a addObject: obj];
@ -309,8 +309,9 @@ static Class concreteClass = Nil;
#endif
for (i = 0; i < _count; i++)
{
NSLog(@"Copying %d, %p", i, _contents[i]);
pointerFunctionsAcquire(&_pf, &c->_contents[i],
pointerFunctionsRead(&_pf, _contents[i]));
pointerFunctionsRead(&_pf, &_contents[i]));
}
return c;
}
@ -432,6 +433,7 @@ static Class concreteClass = Nil;
- (void) insertPointer: (void*)pointer atIndex: (NSUInteger)index
{
NSUInteger i;
if (index > _count)
{
@ -467,7 +469,7 @@ static Class concreteClass = Nil;
while (count-- > 0)
{
if (pointerFunctionsEqual(&_pf,
pointerFunctionsRead(&_pf, _contents[count]),
pointerFunctionsRead(&_pf, &_contents[count]),
[other pointerAtIndex: count]) == NO)
return NO;
}

View file

@ -211,7 +211,7 @@ static NSString *_gnu_processName = nil;
static NSArray *_gnu_arguments = nil;
// Dictionary of environment vars and their values
static NSMutableDictionary *_gnu_environment = nil;
static NSDictionary *_gnu_environment = nil;
// The operating system we are using.
static unsigned int _operatingSystem = 0;

View file

@ -86,7 +86,7 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
NSXMLParser *theParser;
NSMutableString *value;
NSMutableArray *stack;
NSString *key;
id key;
BOOL inArray;
BOOL inDictionary;
BOOL inString;

View file

@ -408,7 +408,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type)
{
zone = RETAIN(localTimeZone);
DESTROY(self);
return zone;
return (GSPlaceholderTimeZone*)zone;
}
/*
@ -557,7 +557,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type)
}
}
DESTROY(self);
return zone;
return (GSPlaceholderTimeZone*)zone;
}
- (void) release

View file

@ -62,7 +62,7 @@
@interface GSSizeValue : NSObject // Help the compiler
@end
@class NSDataStatic; // Needed for decoding.
@interface NSDataStatic : NSObject // Help the compiler
@interface NSDataStatic : NSData // Help the compiler
@end

View file

@ -354,8 +354,8 @@
outputStream: (NSOutputStream **)outputStream
{
NSString *address = host ? (id)[host address] : (id)@"127.0.0.1";
GSSocketStream *ins = nil;
GSSocketStream *outs = nil;
id ins = nil;
id outs = nil;
// try ipv4 first
ins = AUTORELEASE([[GSInetInputStream alloc]
@ -388,8 +388,8 @@
inputStream: (NSInputStream **)inputStream
outputStream: (NSOutputStream **)outputStream
{
GSSocketStream *ins = nil;
GSSocketStream *outs = nil;
id ins = nil;
id outs = nil;
ins = AUTORELEASE([[GSLocalInputStream alloc] initToAddr: path]);
outs = AUTORELEASE([[GSLocalOutputStream alloc] initToAddr: path]);
@ -409,8 +409,8 @@
+ (void) pipeWithInputStream: (NSInputStream **)inputStream
outputStream: (NSOutputStream **)outputStream
{
GSSocketStream *ins = nil;
GSSocketStream *outs = nil;
id ins = nil;
id outs = nil;
int fds[2];
int pipeReturn;

View file

@ -0,0 +1,18 @@
#import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSHashTable.h>
int main()
{
[NSAutoreleasePool new];
NSHashTable *ht = [NSHashTable hashTableWithWeakObjects];
id obj = [NSObject new];
[ht addObject: obj];
PASS([ht containsObject: obj], "Added object to weak hash table");
PASS(1 == [ht count], "Weak hash table contains one object");
PASS([ht containsObject: obj], "Added object to weak hash table");
[obj release];
PASS(0 == [ht count], "Weak hash table contains no objects");
PASS(0 == [[ht allObjects] count], "Weak hash table contains no objects");
return 0;
}

View file

@ -0,0 +1,15 @@
#import "ObjectTesting.h"
#import <Foundation/NSPointerArray.h>
int main(void)
{
[NSAutoreleasePool new];
NSPointerArray *pa = [NSPointerArray pointerArrayWithWeakObjects];
id obj = [NSObject new];
[pa addPointer: obj];
PASS([pa count] == 1, "Added object to weak array");
[obj release];
[pa compact];
PASS([pa count] == 0, "Removed object to weak array");
return 0;
}