Fix NSDictionary and NSMutableDictionary implementation.

NSCharacterSet searches in appropriate places for resources.
NSBundle no longer supports GNUSTEP_LIBRARY_PATH variable.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2519 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Scott Christley 1997-10-16 23:56:27 +00:00
parent 93f5864843
commit 7a235b4935
19 changed files with 383 additions and 152 deletions

View file

@ -1,3 +1,51 @@
Thu Oct 16 16:14:31 1997 Scott Christley <scottc@net-community.com>
* checks/Makefile: Add variables to create bundle example.
* checks/NXStringTable.example: Move to English.lproj subdir.
* checks/nsarray.m: Turn off behaviour debugging.
* checks/nsdictionary.m: Add isEqual check.
* checks/values.m: Add isEqual check.
* src/Collection.m (isEqual:): Don't require that the classes
be the same.
* src/NSDictionary.m: Fix implementation by creating
NSDictionaryNonCore and NSMutableDictionaryNonCore classes; move
implemented methods to non-core classes.
* src/include/NSDictionary.h: Likewise.
* src/NSGDictionary.m: Add behaviour from non-core classes.
* src/ObjCRuntime.m (NSClassFromString): Use objc_lookup_class
instead of objc_get_class so that the program will not abort
if the class is not found.
* src/NSTimeZone.M (TIME_ZONE_DIR): Eliminate reference to
obsolete GNUSTEP_INSTALL_DIR macro.
* src/NSZone.m: Use default zone if zone is NULL.
* src/include/NSZone.h: Likewise.
* src/behavior.m (behavior_class_add_class): Add debug message.
* src/Makefile: Define macros for the target directory and
library combo that the library is compiled for.
* src/NSBundle.m (gnustep_target_dir, library_combo): New variables.
(bundle_object_name): Use the target directory and library
combo when determine where the executable file is located.
(+_bundleResourcePathsWithRootPath:subPath:): Don't search
directory specified by GNUSTEP_LIBRARY_PATH environment variable.
* src/NSCharacterSet.m (+_bitmapForSet:number:): Rewrite to search
the user, local, and system directories based upon environment
variable values.
* src/NSData.m (getBytes:range:): Fix range check.
(subdataWithRange:, replaceBytesInRange:withBytes:): Likewise.
(resetBytesInRange:): Likewise.
Wed Oct 1 14:44:17 1997 Adam Fedor <fedor@doc.com>
* src/NSConnection.m ([-registerName:]): Remove
@ -145,6 +193,7 @@ Sat Sep 23 10:18:41 2017 Scott Christley <scottc@net-community.com>
* checks/Makefile: New file.
* checks/Makefile.preamble: New file.
* checks/Makefile.in: Delete.
* checks/Makefile.sed.nt: Delete.
* examples/Makefile: New file.
* examples/Makefile.preamble: New file.
* examples/Makefile.in: Delete.

View file

@ -28,7 +28,17 @@
@class NSArray, NSString, NSEnumerator;
@interface NSDictionary : NSObject <NSCopying>
@interface NSDictionary : NSObject
- initWithObjects: (id*)objects
forKeys: (NSObject**)keys
count: (unsigned)count;
- (unsigned) count;
- objectForKey: (NSObject*)aKey;
- (NSEnumerator*) keyEnumerator;
- (NSEnumerator*) objectEnumerator;
@end
@interface NSDictionary (NonCore) <NSCopying>
+ allocWithZone: (NSZone*)zone;
+ dictionary;
@ -38,14 +48,9 @@
+ dictionaryWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
+ dictionaryWithObjectsAndKeys: (id)object, ...;
- initWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
- initWithObjects: (id*)objects forKeys: (id*)keys
count: (unsigned)count;
- initWithDictionary: (NSDictionary*)otherDictionary;
- initWithContentsOfFile: (NSString*)path;
- (unsigned) count;
- objectForKey: aKey;
- (NSEnumerator*) keyEnumerator;
- (BOOL) isEqualToDictionary: (NSDictionary*)other;
- (NSString*) description;
- (NSString*) descriptionWithIndent: (unsigned)level;
@ -53,18 +58,20 @@
- (NSArray*) allValues;
- (NSArray*) allKeysForObject: anObject;
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
- (NSEnumerator*) objectEnumerator;
@end
@interface NSMutableDictionary: NSDictionary
- initWithCapacity: (unsigned)numItems;
- (void) setObject:anObject forKey:(NSObject *)aKey;
- (void) removeObjectForKey:(NSObject *)aKey;
@end
@interface NSMutableDictionary (NonCore)
+ allocWithZone: (NSZone*)zone;
+ dictionaryWithCapacity: (unsigned)numItems;
- initWithCapacity: (unsigned)numItems;
- (void) setObject: anObject forKey: aKey;
- (void) removeObjectForKey: aKey;
- (void) removeAllObjects;
- (void) removeObjectsForKeys: (NSArray*)keyArray;
- (void) addEntriesFromDictionary: (NSDictionary*)otherDictionary;

View file

@ -74,23 +74,28 @@ extern void NSSetDefaultMallocZone (NSZone *zone); // Not in OpenStep
extern NSZone* NSZoneFromPointer (void *ptr);
extern inline void* NSZoneMalloc (NSZone *zone, size_t size)
{ return (zone->malloc)(zone, size); }
{ if (!zone) zone = NSDefaultMallocZone();
return (zone->malloc)(zone, size); }
extern void* NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes);
extern inline void* NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
{ return (zone->realloc)(zone, ptr, size); }
{ if (!zone) zone = NSDefaultMallocZone();
return (zone->realloc)(zone, ptr, size); }
extern inline void NSRecycleZone (NSZone *zone)
{ (zone->recycle)(zone); }
{ if (!zone) zone = NSDefaultMallocZone();
(zone->recycle)(zone); }
extern inline void NSZoneFree (NSZone *zone, void *ptr)
{ (zone->free)(zone, ptr); }
{ if (!zone) zone = NSDefaultMallocZone();
(zone->free)(zone, ptr); }
extern void NSSetZoneName (NSZone *zone, NSString *name);
extern inline NSString* NSZoneName (NSZone *zone)
{ return zone->name; }
{ if (!zone) zone = NSDefaultMallocZone();
return zone->name; }
/* Not in OpenStep */
extern void NSZoneRegisterRegion (NSZone *zone, void *low, void *high);
@ -103,10 +108,12 @@ extern void* NSZoneRegisterChunk (NSZone *zone, void *chunk);
extern size_t NSZoneChunkOverhead (void); // Not in OpenStep
extern inline BOOL NSZoneCheck (NSZone *zone) // Not in OpenStep
{ return (zone->check)(zone); }
{ if (!zone) zone = NSDefaultMallocZone();
return (zone->check)(zone); }
/* Not in OpenStep */
extern inline struct NSZoneStats NSZoneStats (NSZone *zone)
{ return (zone->stats)(zone); }
{ if (!zone) zone = NSDefaultMallocZone();
return (zone->stats)(zone); }
#endif /* not __NSZone_h_GNUSTEP_BASE_INCLUDE */

View file

@ -221,8 +221,7 @@
{
if (self == anObject)
return YES;
if ([anObject class] == [self class]
&& [self contentsEqual: anObject] )
if ( [self contentsEqual: anObject] )
return YES;
else
return NO;

View file

@ -38,7 +38,8 @@ LIBRARY_NAME=libgnustep-base
# the installing person may set it on the `make' command line.
DEFS= -DGNUSTEP_INSTALL_PREFIX=$(GNUSTEP_SYSTEM_ROOT) \
-DPLATFORM_OS=\"@PLATFORM_OS@\" \
-DGNUSTEP_INSTALL_LIBDIR=\"$(gnustep_libdir)\"
-DGNUSTEP_TARGET_DIR=\"$(GNUSTEP_TARGET_DIR)\" \
-DLIBRARY_COMBO=\"$(LIBRARY_COMBO)\"
# Grep for these names to build the legally-required "AUTHORS" file.
FILE_AUTHORS = \

View file

@ -109,6 +109,18 @@ static NSString* platform =
#else
nil;
#endif
static NSString* gnustep_target_dir =
#ifdef GNUSTEP_TARGET_DIR
@GNUSTEP_TARGET_DIR;
#else
nil;
#endif
static NSString* library_combo =
#ifdef LIBRARY_COMBO
@LIBRARY_COMBO;
#else
nil;
#endif
/* Declaration from find_exec.c */
extern char *objc_find_executable(const char *name);
@ -125,14 +137,20 @@ objc_executable_location( void )
static NSString *
bundle_object_name(NSString *path, NSString* executable)
{
NSString *name;
NSString *name, *subpath;
if (executable)
name = [path stringByAppendingPathComponent: executable];
{
subpath = [path stringByAppendingPathComponent: gnustep_target_dir];
subpath = [subpath stringByAppendingPathComponent: library_combo];
name = [subpath stringByAppendingPathComponent: executable];
}
else
{
name = [[path lastPathComponent] stringByDeletingPathExtension];
name = [path stringByAppendingPathComponent:name];
subpath = [path stringByAppendingPathComponent: gnustep_target_dir];
subpath = [subpath stringByAppendingPathComponent: library_combo];
name = [subpath stringByAppendingPathComponent:name];
}
return name;
}
@ -482,8 +500,6 @@ _bundle_load_callback(Class theClass, Category *theCategory)
<main bundle>/Resources/<bundlePath>/<language.lproj>
<main bundle>/<bundlePath>
<main bundle>/<bundlePath>/<language.lproj>
<$GNUSTEP_LIBRARY_PATH>/<bundlePath>
<$GNUSTEP_LIBRARY_PATH>/<bundlePath>/<language.lproj>
*/
+ (NSArray *) _bundleResourcePathsWithRootPath: (NSString *)rootPath
subPath: (NSString *)bundlePath
@ -511,18 +527,6 @@ _bundle_load_callback(Class theClass, Category *theCategory)
while ((language = [enumerate nextObject]))
[array addObject: _bundle_resource_path(primary, bundlePath, language)];
/* Allow the GNUSTEP_LIBRARY_PATH environment variable be used
to find resources. */
gnustep_env = [envd objectForKey: @"GNUSTEP_LIBRARY_PATH"];
if (gnustep_env)
{
[array addObject: _bundle_resource_path(gnustep_env, bundlePath, nil)];
enumerate = [languages objectEnumerator];
while ((language = [enumerate nextObject]))
[array addObject: _bundle_resource_path(gnustep_env,
bundlePath, language)];
}
return array;
}

View file

@ -26,15 +26,10 @@
#include <Foundation/NSBundle.h>
#include <Foundation/NSData.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSDictionary.h>
static NSString* NSCharacterSet_PATH = @"NSCharacterSets";
static NSString* gnustep_libdir =
#ifdef GNUSTEP_INSTALL_LIBDIR
@GNUSTEP_INSTALL_LIBDIR;
#else
nil;
#endif
static NSString* NSCharacterSet_PATH = @"gnustep/NSCharacterSets";
/* A simple array for caching standard bitmap sets */
#define MAX_STANDARD_SETS 12
@ -67,8 +62,37 @@ static NSLock* cache_lock = nil;
+ (NSCharacterSet *) _bitmapForSet: (NSString *)setname number: (int)number
{
NSCharacterSet* set;
NSString *path;
NSBundle *gstep_base_bundle = [NSBundle bundleWithPath: gnustep_libdir];
NSString *user_path, *local_path, *system_path;
NSBundle *user_bundle = nil, *local_bundle = nil, *system_bundle = nil;
NSProcessInfo *pInfo;
NSDictionary *env;
NSMutableString *user, *local, *system;
/*
The path of where to search for the resource files
is based upon environment variables.
GNUSTEP_USER_ROOT
GNUSTEP_LOCAL_ROOT
GNUSTEP_SYSTEM_ROOT
*/
pInfo = [NSProcessInfo processInfo];
env = [pInfo environment];
user = [[[env objectForKey: @"GNUSTEP_USER_ROOT"]
mutableCopy] autorelease];
[user appendString: @"/Libraries"];
local = [[[env objectForKey: @"GNUSTEP_LOCAL_ROOT"]
mutableCopy] autorelease];
[local appendString: @"/Libraries"];
system = [[[env objectForKey: @"GNUSTEP_SYSTEM_ROOT"]
mutableCopy] autorelease];
[system appendString: @"/Libraries"];
if (user)
user_bundle = [NSBundle bundleWithPath: user];
if (local)
local_bundle = [NSBundle bundleWithPath: local];
if (system)
system_bundle = [NSBundle bundleWithPath: system];
if (!cache_lock)
cache_lock = [NSLock new];
@ -78,27 +102,76 @@ static NSLock* cache_lock = nil;
if (cache_set[number] == nil)
{
NS_DURING
path = [gstep_base_bundle pathForResource:setname
ofType:@"dat"
inDirectory:NSCharacterSet_PATH];
/* This is for testing purposes only! Look in uninstalled dir */
if (path == nil || [path length] == 0)
/* Gather up the paths */
/* Search user first */
user_path = [user_bundle pathForResource:setname
ofType:@"dat"
inDirectory:NSCharacterSet_PATH];
/* Search local second */
local_path = [local_bundle pathForResource:setname
ofType:@"dat"
inDirectory:NSCharacterSet_PATH];
/* Search system last */
system_path = [system_bundle pathForResource:setname
ofType:@"dat"
inDirectory:NSCharacterSet_PATH];
/* Try to load the set from the user path */
set = nil;
if (user_path != nil && [user_path length] != 0)
{
path = [@"../NSCharacterSets" stringByAppendingPathComponent:
setname];
path = [path stringByAppendingPathExtension: @"dat"];
NS_DURING
/* Load the character set file */
set = [self characterSetWithBitmapRepresentation:
[NSData dataWithContentsOfFile: user_path]];
NS_HANDLER
NSLog(@"Unable to read NSCharacterSet file %s",
[user_path cString]);
set = nil;
NS_ENDHANDLER
}
if (path == nil || [path length] == 0)
/* If we don't have a set yet then check local path */
if (set == nil && local_path != nil && [local_path length] != 0)
{
NS_DURING
/* Load the character set file */
set = [self characterSetWithBitmapRepresentation:
[NSData dataWithContentsOfFile: local_path]];
NS_HANDLER
NSLog(@"Unable to read NSCharacterSet file %s",
[local_path cString]);
set = nil;
NS_ENDHANDLER
}
/* Lastly if we don't have a set yet then check system path */
if (set == nil && system_path != nil && [system_path length] != 0)
{
NS_DURING
/* Load the character set file */
set = [self characterSetWithBitmapRepresentation:
[NSData dataWithContentsOfFile: system_path]];
NS_HANDLER
NSLog(@"Unable to read NSCharacterSet file %s",
[system_path cString]);
set = nil;
NS_ENDHANDLER
}
/* If we didn't load a set then raise an exception */
if (!set)
{
[NSException raise:NSGenericException
format:@"Could not find bitmap file %s", [setname cString]];
format:@"Could not find bitmap file %s",
[setname cString]];
/* NOT REACHED */
}
else
/* Else cache the set */
cache_set[number] = [set retain];
set = [self characterSetWithBitmapRepresentation:
[NSData dataWithContentsOfFile: path]];
cache_set[number] = [set retain];
NS_HANDLER
[cache_lock unlock];
[localException raise];

View file

@ -347,8 +347,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
// NSRange location and length types will remain unsigned (hence
// the lack of a less-than-zero check).
size = [self length];
if (aRange.location >= size ||
aRange.length >= size ||
if (aRange.location > size ||
aRange.length > size ||
NSMaxRange( aRange ) > size)
{
[NSException raise: NSRangeException
@ -369,7 +369,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
// so that we can be sure that we don't get a range exception raised
// after we have allocated memory.
l = [self length];
if (aRange.location >= l || aRange.length >= l || NSMaxRange(aRange) > l)
if (aRange.location > l || aRange.length > l || NSMaxRange(aRange) > l)
[NSException raise: NSRangeException
format: @"Range: (%u, %u) Size: %d",
aRange.location, aRange.length, l];
@ -880,8 +880,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
// NSRange location and length types will remain unsigned (hence
// the lack of a less-than-zero check).
size = [self length];
if (aRange.location >= size ||
aRange.length >= size ||
if (aRange.location > size ||
aRange.length > size ||
NSMaxRange( aRange ) > size)
{
// Raise an exception.
@ -902,8 +902,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
// NSRange location and length types will remain unsigned (hence
// the lack of a less-than-zero check).
size = [self length];
if (aRange.location >= size ||
aRange.length >= size ||
if (aRange.location > size ||
aRange.length > size ||
NSMaxRange( aRange ) > size)
{
// Raise an exception.
@ -1434,22 +1434,10 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
[super dealloc];
}
- (id) init
{
return [self initWithBytesNoCopy: 0 length: 0];
}
- (id) initWithBytesNoCopy: (void*)aBuffer
length: (unsigned int)bufferSize
{
self = [super init];
if (self)
{
bytes = aBuffer;
if (bytes)
length = bufferSize;
}
return self;
return [super initWithBytesNoCopy: aBuffer length: bufferSize];
}
@end

View file

@ -30,6 +30,11 @@
#include <gnustep/base/NSException.h>
#include <assert.h>
@interface NSDictionaryNonCore : NSDictionary
@end
@interface NSMutableDictionaryNonCore: NSMutableDictionary
@end
@implementation NSDictionary
static Class NSDictionary_concrete_class;
@ -57,8 +62,12 @@ static Class NSMutableDictionary_concrete_class;
+ (void) initialize
{
NSDictionary_concrete_class = [NSGDictionary class];
NSMutableDictionary_concrete_class = [NSGMutableDictionary class];
if (self == [NSDictionary class])
{
NSDictionary_concrete_class = [NSGDictionary class];
NSMutableDictionary_concrete_class = [NSGMutableDictionary class];
behavior_class_add_class (self, [NSDictionaryNonCore class]);
}
}
+ allocWithZone: (NSZone*)z
@ -66,6 +75,43 @@ static Class NSMutableDictionary_concrete_class;
return NSAllocateObject([self _concreteClass], 0, z);
}
/* This is the designated initializer */
- initWithObjects: (id*)objects
forKeys: (NSObject**)keys
count: (unsigned)count
{
[self subclassResponsibility:_cmd];
return 0;
}
- (unsigned) count
{
[self subclassResponsibility:_cmd];
return 0;
}
- objectForKey: (NSObject*)aKey
{
[self subclassResponsibility:_cmd];
return 0;
}
- (NSEnumerator*) keyEnumerator
{
[self subclassResponsibility:_cmd];
return nil;
}
- (NSEnumerator*) objectEnumerator
{
[self subclassResponsibility:_cmd];
return nil;
}
@end
@implementation NSDictionaryNonCore
+ dictionary
{
return [[[self alloc] init]
@ -149,15 +195,6 @@ static Class NSMutableDictionary_concrete_class;
autorelease];
}
/* This is the designated initializer */
- initWithObjects: (id*)objects
forKeys: (NSObject**)keys
count: (unsigned)count
{
[self subclassResponsibility:_cmd];
return 0;
}
/* Override superclass's designated initializer */
- init
{
@ -203,24 +240,6 @@ static Class NSMutableDictionary_concrete_class;
autorelease];
}
- (unsigned) count
{
[self subclassResponsibility:_cmd];
return 0;
}
- objectForKey: (NSObject*)aKey
{
[self subclassResponsibility:_cmd];
return 0;
}
- (NSEnumerator*) keyEnumerator
{
[self subclassResponsibility:_cmd];
return nil;
}
- (BOOL) isEqual: other
{
if ([other isKindOfClass:[NSDictionary class]])
@ -235,25 +254,20 @@ static Class NSMutableDictionary_concrete_class;
{
id k, e = [self keyEnumerator];
while ((k = [e nextObject]))
{
id o1 = [self objectForKey: k];
id o2 = [other objectForKey: k];
if (![o1 isEqual: o2])
return NO;
/*
if (![[self objectForKey:k] isEqual:[other objectForKey:k]])
return NO;
return NO; */
}
}
/* xxx Recheck this. */
return YES;
}
- (NSString*) description
{
/* This method is overridden by [Dictionary -description] */
return nil;
}
- (NSString*) descriptionWithIndent: (unsigned)level
{
/* This method is overridden by [Dictionary -descriptionWithIndent:] */
return nil;
}
- (NSArray*) allKeys
{
id e = [self keyEnumerator];
@ -305,12 +319,6 @@ static Class NSMutableDictionary_concrete_class;
return 0;
}
- (NSEnumerator*) objectEnumerator
{
[self subclassResponsibility:_cmd];
return nil;
}
- copyWithZone: (NSZone*)z
{
/* a deep copy */
@ -343,17 +351,20 @@ static Class NSMutableDictionary_concrete_class;
@implementation NSMutableDictionary
+ (void)initialize
{
if (self == [NSMutableDictionary class])
{
behavior_class_add_class (self, [NSMutableDictionaryNonCore class]);
behavior_class_add_class (self, [NSDictionaryNonCore class]);
}
}
+ allocWithZone: (NSZone*)z
{
return NSAllocateObject([self _mutableConcreteClass], 0, z);
}
+ dictionaryWithCapacity: (unsigned)numItems
{
return [[[self alloc] initWithCapacity:numItems]
autorelease];
}
/* This is the designated initializer */
- initWithCapacity: (unsigned)numItems
{
@ -361,6 +372,26 @@ static Class NSMutableDictionary_concrete_class;
return 0;
}
- (void) setObject:anObject forKey:(NSObject *)aKey
{
[self subclassResponsibility:_cmd];
}
- (void) removeObjectForKey:(NSObject *)aKey
{
[self subclassResponsibility:_cmd];
}
@end
@implementation NSMutableDictionaryNonCore
+ dictionaryWithCapacity: (unsigned)numItems
{
return [[[self alloc] initWithCapacity:numItems]
autorelease];
}
/* Override superclass's designated initializer */
- initWithObjects: (id*)objects
forKeys: (NSObject**)keys
@ -372,16 +403,6 @@ static Class NSMutableDictionary_concrete_class;
return self;
}
- (void) setObject:anObject forKey:(NSObject *)aKey
{
[self subclassResponsibility:_cmd];
}
- (void) removeObjectForKey:(NSObject *)aKey
{
[self subclassResponsibility:_cmd];
}
- (void) removeAllObjects
{
id k, e = [self keyEnumerator];

View file

@ -28,6 +28,9 @@
#include <Foundation/NSUtilities.h>
#include <Foundation/NSString.h>
@class NSDictionaryNonCore;
@class NSMutableDictionaryNonCore;
@interface NSGDictionaryKeyEnumerator : NSEnumerator
{
NSDictionary *dictionary;
@ -81,7 +84,10 @@
+ (void) initialize
{
if (self == [NSGDictionary class])
behavior_class_add_class (self, [Dictionary class]);
{
behavior_class_add_class (self, [NSDictionaryNonCore class]);
behavior_class_add_class (self, [Dictionary class]);
}
}
- objectForKey: aKey
@ -108,9 +114,14 @@
+ (void) initialize
{
if (self == [NSGMutableDictionary class])
behavior_class_add_class (self, [NSGDictionary class]);
{
behavior_class_add_class (self, [NSMutableDictionaryNonCore class]);
behavior_class_add_class (self, [NSGDictionary class]);
behavior_class_add_class (self, [Dictionary class]);
}
}
/* This is the designated initializer */
/* Comes from Dictionary.m
- initWithCapacity: (unsigned)numItems

View file

@ -40,7 +40,7 @@ NSSelectorFromString(NSString *aSelectorName)
Class
NSClassFromString(NSString *aClassName)
{
return objc_get_class ([aClassName cString]);
return objc_lookup_class ([aClassName cString]);
}
NSString *NSStringFromClass(Class aClass)

View file

@ -71,7 +71,7 @@
#endif
/* Directory that contains the time zone data. */
#define TIME_ZONE_DIR GNUSTEP_INSTALL_LIBDIR "/NSTimeZones/"
#define TIME_ZONE_DIR "NSTimeZones/"
/* Location of time zone abbreviation dictionary. It is a text file
with each line comprised of the abbreviation, a whitespace, and the

View file

@ -1228,6 +1228,8 @@ NSZoneFromPointer (void *ptr)
inline void*
NSZoneMalloc (NSZone *zone, size_t size)
{
if (!zone)
zone = NSDefaultMallocZone();
return (zone->malloc)(zone, size);
}
@ -1240,18 +1242,24 @@ NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes)
inline void*
NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
{
if (!zone)
zone = NSDefaultMallocZone();
return (zone->realloc)(zone, ptr, size);
}
inline void
NSRecycleZone (NSZone *zone)
{
if (!zone)
zone = NSDefaultMallocZone();
(zone->recycle)(zone);
}
inline void
NSZoneFree (NSZone *zone, void *ptr)
{
if (!zone)
zone = NSDefaultMallocZone();
(zone->free)(zone, ptr);
}
@ -1259,6 +1267,8 @@ void
NSSetZoneName (NSZone *zone, NSString *name)
{
/* FIXME: Not thread safe. But will it matter? */
if (!zone)
zone = NSDefaultMallocZone();
if (zone->name != nil)
[zone->name release];
if (name == nil)
@ -1270,6 +1280,8 @@ NSSetZoneName (NSZone *zone, NSString *name)
inline NSString*
NSZoneName (NSZone *zone)
{
if (!zone)
zone = NSDefaultMallocZone();
return zone->name;
}
@ -1293,6 +1305,8 @@ NSZoneRegisterChunk (NSZone *zone, void *chunk)
{
NSZone **zoneptr = chunk;
if (!zone)
zone = NSDefaultMallocZone();
*zoneptr = zone;
return zoneptr+1;
}
@ -1308,6 +1322,8 @@ NSZoneChunkOverhead (void)
inline BOOL
NSZoneCheck (NSZone *zone)
{
if (!zone)
zone = NSDefaultMallocZone();
return (zone->check)(zone);
}
@ -1315,5 +1331,7 @@ NSZoneCheck (NSZone *zone)
inline struct NSZoneStats
NSZoneStats (NSZone *zone)
{
if (!zone)
zone = NSDefaultMallocZone();
return (zone->stats)(zone);
}

View file

@ -109,6 +109,12 @@ behavior_class_add_class (Class class, Class behavior)
}
#endif
if (behavior_debug)
{
fprintf(stderr, "Adding behavior to class %s\n",
class->name);
}
/* Add instance methods */
if (behavior_debug)
{

View file

@ -73,7 +73,7 @@ thread-except \
nscharacterset \
NSData-test
# The Objective-C source files to be compiled
# The tool Objective-C source files to be compiled
test01_OBJC_FILES = test01.m
test02_OBJC_FILES = test02.m
heap_OBJC_FILES = heap.m
@ -117,12 +117,21 @@ thread-except_OBJC_FILES = thread-except.m
nscharacterset_OBJC_FILES = nscharacterset.m
NSData-test_OBJC_FILES = NSData-test.m
# The bundles to be compiled
BUNDLE_NAME=LoadMe
# The bundle Objective-C source files to be compiled
LoadMe_OBJC_FILES = LoadMe.m MyCategory.m SecondClass.m
# The bundle resource files and directories
LoadMe_RESOURCES = English.lproj/NXStringTable.example
LoadMe_RESOURCE_DIRS = English.lproj
SRCS = $(TOOL_NAME:=.m)
HDRS = \
server.h
BUNDLE_NAME=LoadMe
DYNAMIC_MFILES = \
LoadMe.m \
MyCategory.m \
@ -139,5 +148,6 @@ DIST_FILES = $(SRCS) $(HDRS) $(DYNAMIC_MFILES) $(DYNAMIC_HFILES) \
-include Makefile.preamble
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/tool.make
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/bundle.make
-include Makefile.postamble

View file

@ -14,7 +14,7 @@ main()
id o1, o2, o3;
unsigned int p;
behavior_set_debug(1);
behavior_set_debug(0);
[NSAutoreleasePool enableDoubleReleaseCheck:YES];
pool = [[NSAutoreleasePool alloc] init];

View file

@ -9,6 +9,7 @@ main()
id enumerator;
id objects, keys;
id key;
BOOL ok;
behavior_set_debug(0);
@ -38,6 +39,10 @@ main()
b = [a mutableCopy];
assert([b count]);
ok = [b isEqual: a];
assert(ok);
[b setObject:@"formi" forKey:@"ant"];
[b removeObjectForKey:@"horse"];

View file

@ -7,6 +7,7 @@
#include <Foundation/NSException.h>
#include <Foundation/NSString.h>
#include <Foundation/NSGeometry.h>
#include <Foundation/NSArray.h>
int main()
@ -14,11 +15,15 @@ int main()
NSPoint p;
NSRect rect;
NSValue *v1, *v2;
NSNumber *n1, *n2;
NSNumber *n1, *n2, *n3, *n4, *n5;
NSArray *a1, *a2;
// Numbers
n1 = [NSNumber numberWithUnsignedShort:30];
n2 = [NSNumber numberWithDouble:2.7];
n3 = [NSNumber numberWithDouble:30];
n4 = [NSNumber numberWithChar:111];
n5 = [NSNumber numberWithChar:111];
printf("Number(n1) as int %d, as float %f\n",
[n1 intValue], [n1 floatValue]);
printf("n1 times n2=%f as int to get %d\n",
@ -26,7 +31,34 @@ int main()
printf("n2 as string: %s\n", [[n2 stringValue] cString]);
printf("n2 compare:n1 is %d\n", [n2 compare:n1]);
printf("n1 compare:n2 is %d\n", [n1 compare:n2]);
printf("n1 isEqual:n3 is %d\n", [n1 isEqual:n3]);
printf("n4 isEqual:n5 is %d\n", [n4 isEqual:n5]);
a1 = [NSArray arrayWithObjects:
[NSNumber numberWithChar: 111],
[NSNumber numberWithUnsignedChar: 112],
[NSNumber numberWithShort: 121],
[NSNumber numberWithUnsignedShort: 122],
[NSNumber numberWithInt: 131],
[NSNumber numberWithUnsignedInt: 132],
[NSNumber numberWithInt: 141],
[NSNumber numberWithUnsignedInt: 142],
[NSNumber numberWithFloat: 151],
[NSNumber numberWithDouble: 152], nil];
a2 = [NSArray arrayWithObjects:
[NSNumber numberWithChar: 111],
[NSNumber numberWithUnsignedChar: 112],
[NSNumber numberWithShort: 121],
[NSNumber numberWithUnsignedShort: 122],
[NSNumber numberWithInt: 131],
[NSNumber numberWithUnsignedInt: 132],
[NSNumber numberWithInt: 141],
[NSNumber numberWithUnsignedInt: 142],
[NSNumber numberWithFloat: 151],
[NSNumber numberWithDouble: 152], nil];
printf("a1 isEqual:a2 is %d\n", [a1 isEqual:a2]);
// Test values, Geometry
rect = NSMakeRect(1.0, 103.3, 40.0, 843.);