diff --git a/ChangeLog b/ChangeLog index 0e73a222a..8644bc3d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +Tue Jul 14 16:26:36 1998 Adam Fedor + + * 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 + + * 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 * src/Invocation.m: Rewrote ([-invoke]) to retrieve return values diff --git a/Documentation/todo.tmpl.texi b/Documentation/todo.tmpl.texi index 3f87dc823..d05386b53 100644 --- a/Documentation/todo.tmpl.texi +++ b/Documentation/todo.tmpl.texi @@ -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 diff --git a/Headers/gnustep/base/Foundation.h b/Headers/gnustep/base/Foundation.h index a36ece882..d8ac0dd83 100644 --- a/Headers/gnustep/base/Foundation.h +++ b/Headers/gnustep/base/Foundation.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include diff --git a/Headers/gnustep/base/NSObjCRuntime.h b/Headers/gnustep/base/NSObjCRuntime.h index e51464117..3cf9fac80 100644 --- a/Headers/gnustep/base/NSObjCRuntime.h +++ b/Headers/gnustep/base/NSObjCRuntime.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 diff --git a/Headers/gnustep/base/NSObject.h b/Headers/gnustep/base/NSObject.h index 93a311bce..92b09066f 100644 --- a/Headers/gnustep/base/NSObject.h +++ b/Headers/gnustep/base/NSObject.h @@ -95,6 +95,7 @@ + (IMP) instanceMethodForSelector: (SEL)aSelector; - (IMP) methodForSelector: (SEL)aSelector; ++ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector; - (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector; - (NSString*) description; diff --git a/Headers/gnustep/base/NSSet.h b/Headers/gnustep/base/NSSet.h index dcfe69e8d..1fbed3b02 100644 --- a/Headers/gnustep/base/NSSet.h +++ b/Headers/gnustep/base/NSSet.h @@ -34,7 +34,7 @@ + set; + setWithArray: (NSArray*)array; + setWithObject: anObject; -+ setWithObjects: (NSArray*)objects, ...; ++ setWithObjects: anObject, ...; - initWithArray: (NSArray*)array; - initWithObjects: (id)objects, ...; - initWithObjects: (id*)objects diff --git a/Source/Makefile.postamble b/Source/Makefile.postamble index 12b3e7424..bba1c0967 100644 --- a/Source/Makefile.postamble +++ b/Source/Makefile.postamble @@ -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 diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 209f02334..a5647ff6d 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -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]; diff --git a/Source/NSSet.m b/Source/NSSet.m index b7449959a..5d403f8d5 100644 --- a/Source/NSSet.m +++ b/Source/NSSet.m @@ -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 diff --git a/Source/externs.m b/Source/externs.m index b35804e66..9447ecc8c 100644 --- a/Source/externs.m +++ b/Source/externs.m @@ -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 = diff --git a/Testing/nsset.m b/Testing/nsset.m index 75757e72e..e88231b11 100644 --- a/Testing/nsset.m +++ b/Testing/nsset.m @@ -2,8 +2,23 @@ #include #include +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]); + }