mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
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:
parent
04e12e7ff5
commit
a02a4e9e88
19 changed files with 383 additions and 152 deletions
49
ChangeLog
49
ChangeLog
|
@ -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>
|
Wed Oct 1 14:44:17 1997 Adam Fedor <fedor@doc.com>
|
||||||
|
|
||||||
* src/NSConnection.m ([-registerName:]): Remove
|
* 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: New file.
|
||||||
* checks/Makefile.preamble: New file.
|
* checks/Makefile.preamble: New file.
|
||||||
* checks/Makefile.in: Delete.
|
* checks/Makefile.in: Delete.
|
||||||
|
* checks/Makefile.sed.nt: Delete.
|
||||||
* examples/Makefile: New file.
|
* examples/Makefile: New file.
|
||||||
* examples/Makefile.preamble: New file.
|
* examples/Makefile.preamble: New file.
|
||||||
* examples/Makefile.in: Delete.
|
* examples/Makefile.in: Delete.
|
||||||
|
|
|
@ -28,7 +28,17 @@
|
||||||
|
|
||||||
@class NSArray, NSString, NSEnumerator;
|
@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;
|
+ allocWithZone: (NSZone*)zone;
|
||||||
+ dictionary;
|
+ dictionary;
|
||||||
|
@ -38,14 +48,9 @@
|
||||||
+ dictionaryWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
|
+ dictionaryWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
|
||||||
+ dictionaryWithObjectsAndKeys: (id)object, ...;
|
+ dictionaryWithObjectsAndKeys: (id)object, ...;
|
||||||
- initWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
|
- initWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
|
||||||
- initWithObjects: (id*)objects forKeys: (id*)keys
|
|
||||||
count: (unsigned)count;
|
|
||||||
- initWithDictionary: (NSDictionary*)otherDictionary;
|
- initWithDictionary: (NSDictionary*)otherDictionary;
|
||||||
- initWithContentsOfFile: (NSString*)path;
|
- initWithContentsOfFile: (NSString*)path;
|
||||||
|
|
||||||
- (unsigned) count;
|
|
||||||
- objectForKey: aKey;
|
|
||||||
- (NSEnumerator*) keyEnumerator;
|
|
||||||
- (BOOL) isEqualToDictionary: (NSDictionary*)other;
|
- (BOOL) isEqualToDictionary: (NSDictionary*)other;
|
||||||
- (NSString*) description;
|
- (NSString*) description;
|
||||||
- (NSString*) descriptionWithIndent: (unsigned)level;
|
- (NSString*) descriptionWithIndent: (unsigned)level;
|
||||||
|
@ -53,18 +58,20 @@
|
||||||
- (NSArray*) allValues;
|
- (NSArray*) allValues;
|
||||||
- (NSArray*) allKeysForObject: anObject;
|
- (NSArray*) allKeysForObject: anObject;
|
||||||
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
|
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
|
||||||
- (NSEnumerator*) objectEnumerator;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSMutableDictionary: NSDictionary
|
@interface NSMutableDictionary: NSDictionary
|
||||||
|
- initWithCapacity: (unsigned)numItems;
|
||||||
|
- (void) setObject:anObject forKey:(NSObject *)aKey;
|
||||||
|
- (void) removeObjectForKey:(NSObject *)aKey;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSMutableDictionary (NonCore)
|
||||||
|
|
||||||
+ allocWithZone: (NSZone*)zone;
|
+ allocWithZone: (NSZone*)zone;
|
||||||
+ dictionaryWithCapacity: (unsigned)numItems;
|
+ dictionaryWithCapacity: (unsigned)numItems;
|
||||||
- initWithCapacity: (unsigned)numItems;
|
|
||||||
|
|
||||||
- (void) setObject: anObject forKey: aKey;
|
|
||||||
- (void) removeObjectForKey: aKey;
|
|
||||||
- (void) removeAllObjects;
|
- (void) removeAllObjects;
|
||||||
- (void) removeObjectsForKeys: (NSArray*)keyArray;
|
- (void) removeObjectsForKeys: (NSArray*)keyArray;
|
||||||
- (void) addEntriesFromDictionary: (NSDictionary*)otherDictionary;
|
- (void) addEntriesFromDictionary: (NSDictionary*)otherDictionary;
|
||||||
|
|
|
@ -74,23 +74,28 @@ extern void NSSetDefaultMallocZone (NSZone *zone); // Not in OpenStep
|
||||||
extern NSZone* NSZoneFromPointer (void *ptr);
|
extern NSZone* NSZoneFromPointer (void *ptr);
|
||||||
|
|
||||||
extern inline void* NSZoneMalloc (NSZone *zone, size_t size)
|
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 void* NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes);
|
||||||
|
|
||||||
extern inline void* NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
|
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)
|
extern inline void NSRecycleZone (NSZone *zone)
|
||||||
{ (zone->recycle)(zone); }
|
{ if (!zone) zone = NSDefaultMallocZone();
|
||||||
|
(zone->recycle)(zone); }
|
||||||
|
|
||||||
extern inline void NSZoneFree (NSZone *zone, void *ptr)
|
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 void NSSetZoneName (NSZone *zone, NSString *name);
|
||||||
|
|
||||||
extern inline NSString* NSZoneName (NSZone *zone)
|
extern inline NSString* NSZoneName (NSZone *zone)
|
||||||
{ return zone->name; }
|
{ if (!zone) zone = NSDefaultMallocZone();
|
||||||
|
return zone->name; }
|
||||||
|
|
||||||
/* Not in OpenStep */
|
/* Not in OpenStep */
|
||||||
extern void NSZoneRegisterRegion (NSZone *zone, void *low, void *high);
|
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 size_t NSZoneChunkOverhead (void); // Not in OpenStep
|
||||||
|
|
||||||
extern inline BOOL NSZoneCheck (NSZone *zone) // 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 */
|
/* Not in OpenStep */
|
||||||
extern inline struct NSZoneStats NSZoneStats (NSZone *zone)
|
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 */
|
#endif /* not __NSZone_h_GNUSTEP_BASE_INCLUDE */
|
||||||
|
|
|
@ -221,8 +221,7 @@
|
||||||
{
|
{
|
||||||
if (self == anObject)
|
if (self == anObject)
|
||||||
return YES;
|
return YES;
|
||||||
if ([anObject class] == [self class]
|
if ( [self contentsEqual: anObject] )
|
||||||
&& [self contentsEqual: anObject] )
|
|
||||||
return YES;
|
return YES;
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
|
|
|
@ -38,7 +38,8 @@ LIBRARY_NAME=libgnustep-base
|
||||||
# the installing person may set it on the `make' command line.
|
# the installing person may set it on the `make' command line.
|
||||||
DEFS= -DGNUSTEP_INSTALL_PREFIX=$(GNUSTEP_SYSTEM_ROOT) \
|
DEFS= -DGNUSTEP_INSTALL_PREFIX=$(GNUSTEP_SYSTEM_ROOT) \
|
||||||
-DPLATFORM_OS=\"@PLATFORM_OS@\" \
|
-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.
|
# Grep for these names to build the legally-required "AUTHORS" file.
|
||||||
FILE_AUTHORS = \
|
FILE_AUTHORS = \
|
||||||
|
|
|
@ -109,6 +109,18 @@ static NSString* platform =
|
||||||
#else
|
#else
|
||||||
nil;
|
nil;
|
||||||
#endif
|
#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 */
|
/* Declaration from find_exec.c */
|
||||||
extern char *objc_find_executable(const char *name);
|
extern char *objc_find_executable(const char *name);
|
||||||
|
@ -125,14 +137,20 @@ objc_executable_location( void )
|
||||||
static NSString *
|
static NSString *
|
||||||
bundle_object_name(NSString *path, NSString* executable)
|
bundle_object_name(NSString *path, NSString* executable)
|
||||||
{
|
{
|
||||||
NSString *name;
|
NSString *name, *subpath;
|
||||||
|
|
||||||
if (executable)
|
if (executable)
|
||||||
name = [path stringByAppendingPathComponent: executable];
|
{
|
||||||
|
subpath = [path stringByAppendingPathComponent: gnustep_target_dir];
|
||||||
|
subpath = [subpath stringByAppendingPathComponent: library_combo];
|
||||||
|
name = [subpath stringByAppendingPathComponent: executable];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name = [[path lastPathComponent] stringByDeletingPathExtension];
|
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;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -482,8 +500,6 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
||||||
<main bundle>/Resources/<bundlePath>/<language.lproj>
|
<main bundle>/Resources/<bundlePath>/<language.lproj>
|
||||||
<main bundle>/<bundlePath>
|
<main bundle>/<bundlePath>
|
||||||
<main bundle>/<bundlePath>/<language.lproj>
|
<main bundle>/<bundlePath>/<language.lproj>
|
||||||
<$GNUSTEP_LIBRARY_PATH>/<bundlePath>
|
|
||||||
<$GNUSTEP_LIBRARY_PATH>/<bundlePath>/<language.lproj>
|
|
||||||
*/
|
*/
|
||||||
+ (NSArray *) _bundleResourcePathsWithRootPath: (NSString *)rootPath
|
+ (NSArray *) _bundleResourcePathsWithRootPath: (NSString *)rootPath
|
||||||
subPath: (NSString *)bundlePath
|
subPath: (NSString *)bundlePath
|
||||||
|
@ -511,18 +527,6 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
||||||
while ((language = [enumerate nextObject]))
|
while ((language = [enumerate nextObject]))
|
||||||
[array addObject: _bundle_resource_path(primary, bundlePath, language)];
|
[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;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,10 @@
|
||||||
#include <Foundation/NSBundle.h>
|
#include <Foundation/NSBundle.h>
|
||||||
#include <Foundation/NSData.h>
|
#include <Foundation/NSData.h>
|
||||||
#include <Foundation/NSLock.h>
|
#include <Foundation/NSLock.h>
|
||||||
|
#include <Foundation/NSProcessInfo.h>
|
||||||
|
#include <Foundation/NSDictionary.h>
|
||||||
|
|
||||||
static NSString* NSCharacterSet_PATH = @"NSCharacterSets";
|
static NSString* NSCharacterSet_PATH = @"gnustep/NSCharacterSets";
|
||||||
|
|
||||||
static NSString* gnustep_libdir =
|
|
||||||
#ifdef GNUSTEP_INSTALL_LIBDIR
|
|
||||||
@GNUSTEP_INSTALL_LIBDIR;
|
|
||||||
#else
|
|
||||||
nil;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* A simple array for caching standard bitmap sets */
|
/* A simple array for caching standard bitmap sets */
|
||||||
#define MAX_STANDARD_SETS 12
|
#define MAX_STANDARD_SETS 12
|
||||||
|
@ -67,8 +62,37 @@ static NSLock* cache_lock = nil;
|
||||||
+ (NSCharacterSet *) _bitmapForSet: (NSString *)setname number: (int)number
|
+ (NSCharacterSet *) _bitmapForSet: (NSString *)setname number: (int)number
|
||||||
{
|
{
|
||||||
NSCharacterSet* set;
|
NSCharacterSet* set;
|
||||||
NSString *path;
|
NSString *user_path, *local_path, *system_path;
|
||||||
NSBundle *gstep_base_bundle = [NSBundle bundleWithPath: gnustep_libdir];
|
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)
|
if (!cache_lock)
|
||||||
cache_lock = [NSLock new];
|
cache_lock = [NSLock new];
|
||||||
|
@ -78,27 +102,76 @@ static NSLock* cache_lock = nil;
|
||||||
if (cache_set[number] == nil)
|
if (cache_set[number] == nil)
|
||||||
{
|
{
|
||||||
NS_DURING
|
NS_DURING
|
||||||
path = [gstep_base_bundle pathForResource:setname
|
|
||||||
ofType:@"dat"
|
/* Gather up the paths */
|
||||||
inDirectory:NSCharacterSet_PATH];
|
/* Search user first */
|
||||||
/* This is for testing purposes only! Look in uninstalled dir */
|
user_path = [user_bundle pathForResource:setname
|
||||||
if (path == nil || [path length] == 0)
|
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:
|
NS_DURING
|
||||||
setname];
|
/* Load the character set file */
|
||||||
path = [path stringByAppendingPathExtension: @"dat"];
|
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
|
[NSException raise:NSGenericException
|
||||||
format:@"Could not find bitmap file %s", [setname cString]];
|
format:@"Could not find bitmap file %s",
|
||||||
|
[setname cString]];
|
||||||
/* NOT REACHED */
|
/* 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
|
NS_HANDLER
|
||||||
[cache_lock unlock];
|
[cache_lock unlock];
|
||||||
[localException raise];
|
[localException raise];
|
||||||
|
|
|
@ -347,8 +347,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
// NSRange location and length types will remain unsigned (hence
|
// NSRange location and length types will remain unsigned (hence
|
||||||
// the lack of a less-than-zero check).
|
// the lack of a less-than-zero check).
|
||||||
size = [self length];
|
size = [self length];
|
||||||
if (aRange.location >= size ||
|
if (aRange.location > size ||
|
||||||
aRange.length >= size ||
|
aRange.length > size ||
|
||||||
NSMaxRange( aRange ) > size)
|
NSMaxRange( aRange ) > size)
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
[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
|
// so that we can be sure that we don't get a range exception raised
|
||||||
// after we have allocated memory.
|
// after we have allocated memory.
|
||||||
l = [self length];
|
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
|
[NSException raise: NSRangeException
|
||||||
format: @"Range: (%u, %u) Size: %d",
|
format: @"Range: (%u, %u) Size: %d",
|
||||||
aRange.location, aRange.length, l];
|
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
|
// NSRange location and length types will remain unsigned (hence
|
||||||
// the lack of a less-than-zero check).
|
// the lack of a less-than-zero check).
|
||||||
size = [self length];
|
size = [self length];
|
||||||
if (aRange.location >= size ||
|
if (aRange.location > size ||
|
||||||
aRange.length >= size ||
|
aRange.length > size ||
|
||||||
NSMaxRange( aRange ) > size)
|
NSMaxRange( aRange ) > size)
|
||||||
{
|
{
|
||||||
// Raise an exception.
|
// Raise an exception.
|
||||||
|
@ -902,8 +902,8 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
// NSRange location and length types will remain unsigned (hence
|
// NSRange location and length types will remain unsigned (hence
|
||||||
// the lack of a less-than-zero check).
|
// the lack of a less-than-zero check).
|
||||||
size = [self length];
|
size = [self length];
|
||||||
if (aRange.location >= size ||
|
if (aRange.location > size ||
|
||||||
aRange.length >= size ||
|
aRange.length > size ||
|
||||||
NSMaxRange( aRange ) > size)
|
NSMaxRange( aRange ) > size)
|
||||||
{
|
{
|
||||||
// Raise an exception.
|
// Raise an exception.
|
||||||
|
@ -1434,22 +1434,10 @@ readContentsOfFile(NSString* path, void** buf, unsigned* len)
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) init
|
|
||||||
{
|
|
||||||
return [self initWithBytesNoCopy: 0 length: 0];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initWithBytesNoCopy: (void*)aBuffer
|
- (id) initWithBytesNoCopy: (void*)aBuffer
|
||||||
length: (unsigned int)bufferSize
|
length: (unsigned int)bufferSize
|
||||||
{
|
{
|
||||||
self = [super init];
|
return [super initWithBytesNoCopy: aBuffer length: bufferSize];
|
||||||
if (self)
|
|
||||||
{
|
|
||||||
bytes = aBuffer;
|
|
||||||
if (bytes)
|
|
||||||
length = bufferSize;
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -30,6 +30,11 @@
|
||||||
#include <gnustep/base/NSException.h>
|
#include <gnustep/base/NSException.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
@interface NSDictionaryNonCore : NSDictionary
|
||||||
|
@end
|
||||||
|
@interface NSMutableDictionaryNonCore: NSMutableDictionary
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSDictionary
|
@implementation NSDictionary
|
||||||
|
|
||||||
static Class NSDictionary_concrete_class;
|
static Class NSDictionary_concrete_class;
|
||||||
|
@ -57,8 +62,12 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
NSDictionary_concrete_class = [NSGDictionary class];
|
if (self == [NSDictionary class])
|
||||||
NSMutableDictionary_concrete_class = [NSGMutableDictionary class];
|
{
|
||||||
|
NSDictionary_concrete_class = [NSGDictionary class];
|
||||||
|
NSMutableDictionary_concrete_class = [NSGMutableDictionary class];
|
||||||
|
behavior_class_add_class (self, [NSDictionaryNonCore class]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ allocWithZone: (NSZone*)z
|
+ allocWithZone: (NSZone*)z
|
||||||
|
@ -66,6 +75,43 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
return NSAllocateObject([self _concreteClass], 0, z);
|
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
|
+ dictionary
|
||||||
{
|
{
|
||||||
return [[[self alloc] init]
|
return [[[self alloc] init]
|
||||||
|
@ -149,15 +195,6 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
autorelease];
|
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 */
|
/* Override superclass's designated initializer */
|
||||||
- init
|
- init
|
||||||
{
|
{
|
||||||
|
@ -203,24 +240,6 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
autorelease];
|
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
|
- (BOOL) isEqual: other
|
||||||
{
|
{
|
||||||
if ([other isKindOfClass:[NSDictionary class]])
|
if ([other isKindOfClass:[NSDictionary class]])
|
||||||
|
@ -235,25 +254,20 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
{
|
{
|
||||||
id k, e = [self keyEnumerator];
|
id k, e = [self keyEnumerator];
|
||||||
while ((k = [e nextObject]))
|
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]])
|
if (![[self objectForKey:k] isEqual:[other objectForKey:k]])
|
||||||
return NO;
|
return NO; */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* xxx Recheck this. */
|
/* xxx Recheck this. */
|
||||||
return YES;
|
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
|
- (NSArray*) allKeys
|
||||||
{
|
{
|
||||||
id e = [self keyEnumerator];
|
id e = [self keyEnumerator];
|
||||||
|
@ -305,12 +319,6 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSEnumerator*) objectEnumerator
|
|
||||||
{
|
|
||||||
[self subclassResponsibility:_cmd];
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- copyWithZone: (NSZone*)z
|
- copyWithZone: (NSZone*)z
|
||||||
{
|
{
|
||||||
/* a deep copy */
|
/* a deep copy */
|
||||||
|
@ -343,17 +351,20 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
|
|
||||||
@implementation NSMutableDictionary
|
@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
|
+ allocWithZone: (NSZone*)z
|
||||||
{
|
{
|
||||||
return NSAllocateObject([self _mutableConcreteClass], 0, z);
|
return NSAllocateObject([self _mutableConcreteClass], 0, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ dictionaryWithCapacity: (unsigned)numItems
|
|
||||||
{
|
|
||||||
return [[[self alloc] initWithCapacity:numItems]
|
|
||||||
autorelease];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is the designated initializer */
|
/* This is the designated initializer */
|
||||||
- initWithCapacity: (unsigned)numItems
|
- initWithCapacity: (unsigned)numItems
|
||||||
{
|
{
|
||||||
|
@ -361,6 +372,26 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
return 0;
|
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 */
|
/* Override superclass's designated initializer */
|
||||||
- initWithObjects: (id*)objects
|
- initWithObjects: (id*)objects
|
||||||
forKeys: (NSObject**)keys
|
forKeys: (NSObject**)keys
|
||||||
|
@ -372,16 +403,6 @@ static Class NSMutableDictionary_concrete_class;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setObject:anObject forKey:(NSObject *)aKey
|
|
||||||
{
|
|
||||||
[self subclassResponsibility:_cmd];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) removeObjectForKey:(NSObject *)aKey
|
|
||||||
{
|
|
||||||
[self subclassResponsibility:_cmd];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) removeAllObjects
|
- (void) removeAllObjects
|
||||||
{
|
{
|
||||||
id k, e = [self keyEnumerator];
|
id k, e = [self keyEnumerator];
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
#include <Foundation/NSUtilities.h>
|
#include <Foundation/NSUtilities.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
|
|
||||||
|
@class NSDictionaryNonCore;
|
||||||
|
@class NSMutableDictionaryNonCore;
|
||||||
|
|
||||||
@interface NSGDictionaryKeyEnumerator : NSEnumerator
|
@interface NSGDictionaryKeyEnumerator : NSEnumerator
|
||||||
{
|
{
|
||||||
NSDictionary *dictionary;
|
NSDictionary *dictionary;
|
||||||
|
@ -81,7 +84,10 @@
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [NSGDictionary class])
|
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
|
- objectForKey: aKey
|
||||||
|
@ -108,9 +114,14 @@
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [NSGMutableDictionary class])
|
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 */
|
/* This is the designated initializer */
|
||||||
/* Comes from Dictionary.m
|
/* Comes from Dictionary.m
|
||||||
- initWithCapacity: (unsigned)numItems
|
- initWithCapacity: (unsigned)numItems
|
||||||
|
|
|
@ -40,7 +40,7 @@ NSSelectorFromString(NSString *aSelectorName)
|
||||||
Class
|
Class
|
||||||
NSClassFromString(NSString *aClassName)
|
NSClassFromString(NSString *aClassName)
|
||||||
{
|
{
|
||||||
return objc_get_class ([aClassName cString]);
|
return objc_lookup_class ([aClassName cString]);
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *NSStringFromClass(Class aClass)
|
NSString *NSStringFromClass(Class aClass)
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Directory that contains the time zone data. */
|
/* 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
|
/* Location of time zone abbreviation dictionary. It is a text file
|
||||||
with each line comprised of the abbreviation, a whitespace, and the
|
with each line comprised of the abbreviation, a whitespace, and the
|
||||||
|
|
|
@ -1228,6 +1228,8 @@ NSZoneFromPointer (void *ptr)
|
||||||
inline void*
|
inline void*
|
||||||
NSZoneMalloc (NSZone *zone, size_t size)
|
NSZoneMalloc (NSZone *zone, size_t size)
|
||||||
{
|
{
|
||||||
|
if (!zone)
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
return (zone->malloc)(zone, size);
|
return (zone->malloc)(zone, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1240,18 +1242,24 @@ NSZoneCalloc (NSZone *zone, size_t elems, size_t bytes)
|
||||||
inline void*
|
inline void*
|
||||||
NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
|
NSZoneRealloc (NSZone *zone, void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
|
if (!zone)
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
return (zone->realloc)(zone, ptr, size);
|
return (zone->realloc)(zone, ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
NSRecycleZone (NSZone *zone)
|
NSRecycleZone (NSZone *zone)
|
||||||
{
|
{
|
||||||
|
if (!zone)
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
(zone->recycle)(zone);
|
(zone->recycle)(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
NSZoneFree (NSZone *zone, void *ptr)
|
NSZoneFree (NSZone *zone, void *ptr)
|
||||||
{
|
{
|
||||||
|
if (!zone)
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
(zone->free)(zone, ptr);
|
(zone->free)(zone, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1259,6 +1267,8 @@ void
|
||||||
NSSetZoneName (NSZone *zone, NSString *name)
|
NSSetZoneName (NSZone *zone, NSString *name)
|
||||||
{
|
{
|
||||||
/* FIXME: Not thread safe. But will it matter? */
|
/* FIXME: Not thread safe. But will it matter? */
|
||||||
|
if (!zone)
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
if (zone->name != nil)
|
if (zone->name != nil)
|
||||||
[zone->name release];
|
[zone->name release];
|
||||||
if (name == nil)
|
if (name == nil)
|
||||||
|
@ -1270,6 +1280,8 @@ NSSetZoneName (NSZone *zone, NSString *name)
|
||||||
inline NSString*
|
inline NSString*
|
||||||
NSZoneName (NSZone *zone)
|
NSZoneName (NSZone *zone)
|
||||||
{
|
{
|
||||||
|
if (!zone)
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
return zone->name;
|
return zone->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,6 +1305,8 @@ NSZoneRegisterChunk (NSZone *zone, void *chunk)
|
||||||
{
|
{
|
||||||
NSZone **zoneptr = chunk;
|
NSZone **zoneptr = chunk;
|
||||||
|
|
||||||
|
if (!zone)
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
*zoneptr = zone;
|
*zoneptr = zone;
|
||||||
return zoneptr+1;
|
return zoneptr+1;
|
||||||
}
|
}
|
||||||
|
@ -1308,6 +1322,8 @@ NSZoneChunkOverhead (void)
|
||||||
inline BOOL
|
inline BOOL
|
||||||
NSZoneCheck (NSZone *zone)
|
NSZoneCheck (NSZone *zone)
|
||||||
{
|
{
|
||||||
|
if (!zone)
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
return (zone->check)(zone);
|
return (zone->check)(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1315,5 +1331,7 @@ NSZoneCheck (NSZone *zone)
|
||||||
inline struct NSZoneStats
|
inline struct NSZoneStats
|
||||||
NSZoneStats (NSZone *zone)
|
NSZoneStats (NSZone *zone)
|
||||||
{
|
{
|
||||||
|
if (!zone)
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
return (zone->stats)(zone);
|
return (zone->stats)(zone);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,12 @@ behavior_class_add_class (Class class, Class behavior)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (behavior_debug)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Adding behavior to class %s\n",
|
||||||
|
class->name);
|
||||||
|
}
|
||||||
|
|
||||||
/* Add instance methods */
|
/* Add instance methods */
|
||||||
if (behavior_debug)
|
if (behavior_debug)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,7 @@ thread-except \
|
||||||
nscharacterset \
|
nscharacterset \
|
||||||
NSData-test
|
NSData-test
|
||||||
|
|
||||||
# The Objective-C source files to be compiled
|
# The tool Objective-C source files to be compiled
|
||||||
test01_OBJC_FILES = test01.m
|
test01_OBJC_FILES = test01.m
|
||||||
test02_OBJC_FILES = test02.m
|
test02_OBJC_FILES = test02.m
|
||||||
heap_OBJC_FILES = heap.m
|
heap_OBJC_FILES = heap.m
|
||||||
|
@ -117,12 +117,21 @@ thread-except_OBJC_FILES = thread-except.m
|
||||||
nscharacterset_OBJC_FILES = nscharacterset.m
|
nscharacterset_OBJC_FILES = nscharacterset.m
|
||||||
NSData-test_OBJC_FILES = NSData-test.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)
|
SRCS = $(TOOL_NAME:=.m)
|
||||||
|
|
||||||
HDRS = \
|
HDRS = \
|
||||||
server.h
|
server.h
|
||||||
|
|
||||||
BUNDLE_NAME=LoadMe
|
|
||||||
DYNAMIC_MFILES = \
|
DYNAMIC_MFILES = \
|
||||||
LoadMe.m \
|
LoadMe.m \
|
||||||
MyCategory.m \
|
MyCategory.m \
|
||||||
|
@ -139,5 +148,6 @@ DIST_FILES = $(SRCS) $(HDRS) $(DYNAMIC_MFILES) $(DYNAMIC_HFILES) \
|
||||||
-include Makefile.preamble
|
-include Makefile.preamble
|
||||||
|
|
||||||
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/tool.make
|
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/tool.make
|
||||||
|
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/bundle.make
|
||||||
|
|
||||||
-include Makefile.postamble
|
-include Makefile.postamble
|
||||||
|
|
|
@ -14,7 +14,7 @@ main()
|
||||||
id o1, o2, o3;
|
id o1, o2, o3;
|
||||||
unsigned int p;
|
unsigned int p;
|
||||||
|
|
||||||
behavior_set_debug(1);
|
behavior_set_debug(0);
|
||||||
|
|
||||||
[NSAutoreleasePool enableDoubleReleaseCheck:YES];
|
[NSAutoreleasePool enableDoubleReleaseCheck:YES];
|
||||||
pool = [[NSAutoreleasePool alloc] init];
|
pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
|
@ -9,6 +9,7 @@ main()
|
||||||
id enumerator;
|
id enumerator;
|
||||||
id objects, keys;
|
id objects, keys;
|
||||||
id key;
|
id key;
|
||||||
|
BOOL ok;
|
||||||
|
|
||||||
behavior_set_debug(0);
|
behavior_set_debug(0);
|
||||||
|
|
||||||
|
@ -38,6 +39,10 @@ main()
|
||||||
|
|
||||||
b = [a mutableCopy];
|
b = [a mutableCopy];
|
||||||
assert([b count]);
|
assert([b count]);
|
||||||
|
|
||||||
|
ok = [b isEqual: a];
|
||||||
|
assert(ok);
|
||||||
|
|
||||||
[b setObject:@"formi" forKey:@"ant"];
|
[b setObject:@"formi" forKey:@"ant"];
|
||||||
[b removeObjectForKey:@"horse"];
|
[b removeObjectForKey:@"horse"];
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSGeometry.h>
|
#include <Foundation/NSGeometry.h>
|
||||||
|
#include <Foundation/NSArray.h>
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -14,11 +15,15 @@ int main()
|
||||||
NSPoint p;
|
NSPoint p;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
NSValue *v1, *v2;
|
NSValue *v1, *v2;
|
||||||
NSNumber *n1, *n2;
|
NSNumber *n1, *n2, *n3, *n4, *n5;
|
||||||
|
NSArray *a1, *a2;
|
||||||
|
|
||||||
// Numbers
|
// Numbers
|
||||||
n1 = [NSNumber numberWithUnsignedShort:30];
|
n1 = [NSNumber numberWithUnsignedShort:30];
|
||||||
n2 = [NSNumber numberWithDouble:2.7];
|
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",
|
printf("Number(n1) as int %d, as float %f\n",
|
||||||
[n1 intValue], [n1 floatValue]);
|
[n1 intValue], [n1 floatValue]);
|
||||||
printf("n1 times n2=%f as int to get %d\n",
|
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 as string: %s\n", [[n2 stringValue] cString]);
|
||||||
printf("n2 compare:n1 is %d\n", [n2 compare:n1]);
|
printf("n2 compare:n1 is %d\n", [n2 compare:n1]);
|
||||||
printf("n1 compare:n2 is %d\n", [n1 compare:n2]);
|
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
|
// Test values, Geometry
|
||||||
rect = NSMakeRect(1.0, 103.3, 40.0, 843.);
|
rect = NSMakeRect(1.0, 103.3, 40.0, 843.);
|
||||||
|
|
Loading…
Reference in a new issue