mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
NSSet additions, better NSDebugLog, added defs
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2854 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f0ed2cd3b8
commit
99692ecb51
11 changed files with 183 additions and 18 deletions
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
|||
Tue Jul 14 16:26:36 1998 Adam Fedor <fedor@doc.com>
|
||||
|
||||
* src/Makefile.postamble (gnustep-base): Fixup dir creation.
|
||||
(Foundation): Likewise.
|
||||
|
||||
* src/externs.m: New NSDebugLogging variable.
|
||||
* src/include/NSObjCRuntime: Change NSDebugLog so it works when
|
||||
DEBUG is defined and NSDebugLogging is set.
|
||||
|
||||
* src/include/Foundation.h: Include NSTimer.h
|
||||
* src/include/NSObject.h: Define +instanceMethodSignatureForSelector:
|
||||
|
||||
Tue Jul 14 10:06:31 1998 Masatake Yamato <masata-y@is.aist-nara.ac.jp>
|
||||
|
||||
* checks/nsset.m : Added new testing functions.
|
||||
(intersects_set_test): Likewise.
|
||||
(is_subset_of_set_test): Likewise.
|
||||
|
||||
* src/include/NSSet.h ([NSSet -setWithObjects:]): Remove the type
|
||||
declaration of arguments, "NSArray *". The arguments should be
|
||||
declared as id.
|
||||
|
||||
* src/NSSet.m ([NSSet -isSubsetOfSet:otherSet]): Implement.
|
||||
([NSSet -intersectsSet:otherSet]): Likewise.
|
||||
|
||||
Wed Jul 15 12:45:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* src/Invocation.m: Rewrote ([-invoke]) to retrieve return values
|
||||
|
|
|
@ -10,6 +10,19 @@
|
|||
|
||||
@itemize @bullet
|
||||
|
||||
@item Implement [NSDeserializer +deserializePropertyListLazilyFromData:atCursor:length:mutableContainers:]
|
||||
[3 NSProxy] (980712)
|
||||
|
||||
@item Implement [NSDeserialiser - deserializeObjectAt:ofObjCType:fromData:atCursor:] [1] (980712)
|
||||
|
||||
@item Implement [NSSerialiser - serializeObjectAt:ofObjCType:fromData:] [1] (980712)
|
||||
|
||||
@item Implement [NSSet - description] and [descriptionWithLocale:] [1] (980712)
|
||||
|
||||
@item Improve initWithFormat releated methods for NSString and find out how to implemente the locale stuff [4 OPENSTEP/Rhapsody] (980712)
|
||||
|
||||
@item Finish implementing the filesystem related NSString methods [3] (980712)
|
||||
|
||||
@item Make gstep-base 64bit clean [5, 64bit machine] (980629)
|
||||
|
||||
@item Make gstep-base smaller. Perhaps we can get rid of classes that
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <Foundation/NSPortCoder.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSSet.h>
|
||||
#include <Foundation/NSTimer.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
|
||||
|
|
|
@ -43,9 +43,12 @@ extern NSLog_printf_handler *_NSLog_printf_handler;
|
|||
extern void NSLog (NSString* format, ...);
|
||||
extern void NSLogv (NSString* format, va_list args);
|
||||
|
||||
/* Debug logging which can be enabled/disabled */
|
||||
#ifdef DEBUGLOG
|
||||
#define NSDebugLog(format, args...) NSLog(format, ## args)
|
||||
/* Debug logging which can be enabled/disabled by defining DEBUG
|
||||
when compiling and also setting the NSDebugLogging variable */
|
||||
#ifdef DEBUG
|
||||
extern int NSDebugLogging;
|
||||
#define NSDebugLog(format, args...) \
|
||||
do { if (NSDebugLogging) NSLog(format, ## args); } while (0)
|
||||
#else
|
||||
#define NSDebugLog(format, args...)
|
||||
#endif
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
|
||||
+ (IMP) instanceMethodForSelector: (SEL)aSelector;
|
||||
- (IMP) methodForSelector: (SEL)aSelector;
|
||||
+ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector;
|
||||
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector;
|
||||
|
||||
- (NSString*) description;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
+ set;
|
||||
+ setWithArray: (NSArray*)array;
|
||||
+ setWithObject: anObject;
|
||||
+ setWithObjects: (NSArray*)objects, ...;
|
||||
+ setWithObjects: anObject, ...;
|
||||
- initWithArray: (NSArray*)array;
|
||||
- initWithObjects: (id)objects, ...;
|
||||
- initWithObjects: (id*)objects
|
||||
|
|
|
@ -86,9 +86,10 @@ after-distclean::
|
|||
|
||||
# Local links to the include files
|
||||
gnustep/base: FORCE
|
||||
rm -rf gnustep
|
||||
mkdir gnustep
|
||||
cd gnustep ; $(LN_S) ../include base
|
||||
if [ ! -d gnustep ]; then \
|
||||
mkdir gnustep; \
|
||||
fi
|
||||
cd gnustep ; rm -f base ; $(LN_S) ../include base;
|
||||
# Make necessary links to source headers if compiling in seperate dir
|
||||
# These are separate directories because one contains the .h files
|
||||
# generated during the build; the other contains the unchanged sources.
|
||||
|
@ -101,7 +102,9 @@ gnustep/base: FORCE
|
|||
# This deletion is necessary, because the CVS repository contains
|
||||
# an emtpy `Foundation' directory that used to hold the OpenStep headers.
|
||||
Foundation: FORCE
|
||||
rm -rf Foundation
|
||||
if [ -d Foundation ]; then \
|
||||
rm -rf Foundation; \
|
||||
fi
|
||||
$(LN_S) $(srcdir)/include Foundation
|
||||
|
||||
# Creation of NSValue and NSNumber concrete classes from templates
|
||||
|
|
|
@ -272,10 +272,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
if ([s isEqual: gnustep_target_cpu])
|
||||
path = [path stringByDeletingLastPathComponent];
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Debug (NSBundle): Found main in %s\n",
|
||||
[path cString]);
|
||||
#endif
|
||||
NSDebugLog(@"(NSBundle): Found main in %@\n", path);
|
||||
/* We do alloc and init separately so initWithPath: knows
|
||||
we are the _mainBundle */
|
||||
_mainBundle = [NSBundle alloc];
|
||||
|
|
|
@ -249,14 +249,46 @@ static Class NSMutableSet_concrete_class;
|
|||
|
||||
- (BOOL) intersectsSet: (NSSet*) otherSet
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
id o = nil, e = nil;
|
||||
|
||||
// -1. If this set is empty, this method should return NO.
|
||||
if ([self count] == 0) return NO;
|
||||
|
||||
// 0. Loop for all members in otherSet
|
||||
e = [otherSet objectEnumerator];
|
||||
while ((o = [e nextObject])) // 1. pick a member from otherSet.
|
||||
{
|
||||
if ([self member: o]) // 2. check the member is in this set(self).
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) isSubsetOfSet: (NSSet*) otherSet
|
||||
{
|
||||
[self notImplemented:_cmd];
|
||||
return NO;
|
||||
id o = nil, e = nil;
|
||||
|
||||
// -1. members of this set(self) <= that of otherSet
|
||||
if ([self count] > [otherSet count]) return NO;
|
||||
|
||||
// 0. Loop for all members in this set(self).
|
||||
e = [self objectEnumerator];
|
||||
while ((o = [e nextObject]))
|
||||
{
|
||||
// 1. check the member is in the otherSet.
|
||||
if ([otherSet member: o])
|
||||
{
|
||||
// 1.1 if true -> continue, try to check the next member.
|
||||
continue ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1.2 if false -> return NO;
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
// 2. return YES; all members in this set are also in the otherSet.
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: other
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
creating the potential for deadlock. */
|
||||
NSRecursiveLock *gnustep_global_lock = nil;
|
||||
|
||||
/* Set this variable to print NSDebugLog messages */
|
||||
int NSDebugLogging = NO;
|
||||
|
||||
/* Connection Notification Strings. */
|
||||
|
||||
NSString *ConnectionBecameInvalidNotification =
|
||||
|
|
|
@ -2,8 +2,23 @@
|
|||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
void original_test ();
|
||||
void intersects_set_test();
|
||||
void is_subset_of_set_test ();
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
original_test ();
|
||||
intersects_set_test ();
|
||||
is_subset_of_set_test ();
|
||||
|
||||
printf("Test passed\n");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
void
|
||||
original_test ()
|
||||
{
|
||||
id a, s1, s2;
|
||||
id enumerator;
|
||||
|
@ -22,7 +37,79 @@ main ()
|
|||
|
||||
s2 = [s1 mutableCopy];
|
||||
assert ([s1 isEqual:s2]);
|
||||
|
||||
printf("Test passed\n");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
void
|
||||
intersects_set_test()
|
||||
{
|
||||
id a1 = [NSArray arrayWithObjects: @"abstract factory", @"builder",
|
||||
@"factory method", @"prototype", @"singleton", nil];
|
||||
id s1 = [NSSet setWithArray: a1];
|
||||
|
||||
id a2 = [NSArray arrayWithObjects: @"adapter", @"bridge", @"composite",
|
||||
@"decorator", @"facade", @"flyweight", @"Proxy", nil];
|
||||
id s2 = [NSSet setWithArray: a2];
|
||||
|
||||
id s3 = [NSSet setWithObjects: @"abstract factory", @"adapter", nil];
|
||||
id s4 = [NSSet setWithObject: @"chain of responsibility"];
|
||||
|
||||
id s5 = [NSSet set];
|
||||
assert (![s1 intersectsSet: s2]);
|
||||
assert (![s2 intersectsSet: s1]);
|
||||
|
||||
assert ([s1 intersectsSet: s3]);
|
||||
assert ([s2 intersectsSet: s3]);
|
||||
assert ([s3 intersectsSet: s1]);
|
||||
assert ([s3 intersectsSet: s2]);
|
||||
|
||||
assert (![s1 intersectsSet: s4]);
|
||||
assert (![s2 intersectsSet: s4]);
|
||||
assert (![s4 intersectsSet: s1]);
|
||||
assert (![s4 intersectsSet: s2]);
|
||||
|
||||
assert (![s1 intersectsSet: s5]);
|
||||
assert (![s2 intersectsSet: s5]);
|
||||
assert (![s3 intersectsSet: s5]);
|
||||
assert (![s4 intersectsSet: s5]);
|
||||
assert (![s5 intersectsSet: s5]);
|
||||
|
||||
assert (![s5 intersectsSet: s1]);
|
||||
assert (![s5 intersectsSet: s2]);
|
||||
assert (![s5 intersectsSet: s3]);
|
||||
assert (![s5 intersectsSet: s4]);
|
||||
assert (![s5 intersectsSet: s5]);
|
||||
}
|
||||
|
||||
void
|
||||
is_subset_of_set_test ()
|
||||
{
|
||||
id a1 = [NSArray arrayWithObjects: @"abstract factory", @"builder",
|
||||
@"factory method", @"prototype", @"singleton", nil];
|
||||
id s1 = [NSSet setWithArray: a1];
|
||||
|
||||
id a2 = [NSArray arrayWithObjects: @"adapter", @"bridge", @"composite",
|
||||
@"decorator", @"facade", @"flyweight", @"proxy", nil];
|
||||
id s2 = [NSSet setWithArray: a2];
|
||||
|
||||
id s3 = [NSSet setWithObjects: @"abstract factory", nil];
|
||||
id s4 = [NSSet setWithObjects: @"adapter", @"proxy", nil];
|
||||
id s5 = [NSSet setWithObject: @"chain of responsibility"];
|
||||
|
||||
id s6 = [NSSet set];
|
||||
|
||||
assert ([s3 isSubsetOfSet: s1]);
|
||||
assert ([s4 isSubsetOfSet: s2]);
|
||||
assert ([s6 isSubsetOfSet: s1]);
|
||||
assert ([s6 isSubsetOfSet: s2]);
|
||||
assert ([s6 isSubsetOfSet: s3]);
|
||||
assert ([s6 isSubsetOfSet: s4]);
|
||||
assert ([s6 isSubsetOfSet: s5]);
|
||||
assert ([s6 isSubsetOfSet: s6]);
|
||||
|
||||
assert (![s1 isSubsetOfSet: s6]);
|
||||
assert (![s1 isSubsetOfSet: s5]);
|
||||
assert (![s1 isSubsetOfSet: s4]);
|
||||
assert (![s1 isSubsetOfSet: s3]);
|
||||
assert (![s1 isSubsetOfSet: s2]);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue