From 50e7e10525029f847777ab360e66c322a7f77502 Mon Sep 17 00:00:00 2001 From: rfm Date: Tue, 28 Jan 2025 09:47:21 +0000 Subject: [PATCH] Remove incomplete/test API prior to release --- .../NSOperationQueue+GNUstepBase.h | 81 ----- Source/Additions/GNUmakefile | 1 - .../Additions/NSOperationQueue+GNUstepBase.m | 321 ------------------ Source/DocMakefile | 1 - Tests/base/NSOperation/perform.m | 78 ----- 5 files changed, 482 deletions(-) delete mode 100644 Headers/GNUstepBase/NSOperationQueue+GNUstepBase.h delete mode 100644 Source/Additions/NSOperationQueue+GNUstepBase.m delete mode 100644 Tests/base/NSOperation/perform.m diff --git a/Headers/GNUstepBase/NSOperationQueue+GNUstepBase.h b/Headers/GNUstepBase/NSOperationQueue+GNUstepBase.h deleted file mode 100644 index bd76c2075..000000000 --- a/Headers/GNUstepBase/NSOperationQueue+GNUstepBase.h +++ /dev/null @@ -1,81 +0,0 @@ -/** Declaration of extension methods for base additions - - Copyright (C) 2025 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 31 Milk Street #960789 Boston, MA 02196 USA. - -*/ - -#ifndef INCLUDED_NSOperationQueue_GNUstepBase_h -#define INCLUDED_NSOperationQueue_GNUstepBase_h - -#import -#import - -#if defined(__cplusplus) -extern "C" { -#endif - -#if OS_API_VERSION(GS_API_NONE,GS_API_LATEST) - -@interface NSOperationQueue (GNUstepBase) - -/** Wraps a nil terminated list of objects in key/value pairs in a - * dictionary and adds an operation to send a message to aTarget to - * perform aSelector (which takes the map as its single argument). - */ -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withMap: (id)firstkey, ...; - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 - withObject: (id)object3 - withObject: (id)object4; - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 - withObject: (id)object3; - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2; - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1; - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector; - -@end - -#endif /* OS_API_VERSION */ - -#if defined(__cplusplus) -} -#endif - -#endif /* INCLUDED_NSOperationQueue_GNUstepBase_h */ - diff --git a/Source/Additions/GNUmakefile b/Source/Additions/GNUmakefile index b2f7737b7..bd6ea58ca 100644 --- a/Source/Additions/GNUmakefile +++ b/Source/Additions/GNUmakefile @@ -54,7 +54,6 @@ Additions_OBJC_FILES =\ NSMutableString+GNUstepBase.m \ NSNumber+GNUstepBase.m \ NSObject+GNUstepBase.m \ - NSOperationQueue+GNUstepBase.m \ NSPropertyList+GNUstepBase.m \ NSProcessInfo+GNUstepBase.m \ NSStream+GNUstepBase.m \ diff --git a/Source/Additions/NSOperationQueue+GNUstepBase.m b/Source/Additions/NSOperationQueue+GNUstepBase.m deleted file mode 100644 index 5e3c6075c..000000000 --- a/Source/Additions/NSOperationQueue+GNUstepBase.m +++ /dev/null @@ -1,321 +0,0 @@ -/* Implementation of extension methods to base additions - - Copyright (C) 2025 Free Software Foundation, Inc. - - Written by: Richard Frith-Macdonald - - This file is part of the GNUstep Base Library. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 31 Milk Street #960789 Boston, MA 02196 USA. - -*/ -#import "../common.h" -#import "Foundation/NSDictionary.h" -#import "Foundation/NSException.h" -#import "Foundation/NSMapTable.h" -#import "Foundation/NSObject.h" -#import "Foundation/NSOperation.h" -#import "GNUstepBase/GSObjCRuntime.h" -#import "GNUstepBase/NSOperationQueue+GNUstepBase.h" - - -@interface GSTargetOperation : NSOperation -{ - IMP msg; - id target; - SEL selector; - id o1; - id o2; - id o3; - id o4; - enum { - argc_zero = 0, - argc_one = 1, - argc_two = 2, - argc_three = 3, - argc_four = 4 - } argc; -} -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 - withObject: (id)object3 - withObject: (id)object4; -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 - withObject: (id)object3; -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2; -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1; -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector; -@end - -/** - * Extension methods for the NSObjectQueue class - */ -@implementation NSOperationQueue (GNUstepBase) - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withMap: (id)firstKey, ... -{ - GSTargetOperation *top; - NSDictionary *map; - - map = [NSDictionary alloc]; - GS_USEIDPAIRLIST(firstKey, - map = [map initWithObjects: __pairs forKeys: __objects count: __count/2]); - - top = [GSTargetOperation operationWithTarget: aTarget - performSelector: aSelector - withObject: AUTORELEASE(map)]; - [self addOperation: top]; -} - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 - withObject: (id)object3 - withObject: (id)object4 -{ - GSTargetOperation *top = [GSTargetOperation operationWithTarget: aTarget - performSelector: aSelector - withObject: object1 - withObject: object2 - withObject: object3 - withObject: object4]; - [self addOperation: top]; -} - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 - withObject: (id)object3 -{ - GSTargetOperation *top = [GSTargetOperation operationWithTarget: aTarget - performSelector: aSelector - withObject: object1 - withObject: object2 - withObject: object3]; - [self addOperation: top]; -} - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 -{ - GSTargetOperation *top = [GSTargetOperation operationWithTarget: aTarget - performSelector: aSelector - withObject: object1 - withObject: object2]; - [self addOperation: top]; -} - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 -{ - GSTargetOperation *top = [GSTargetOperation operationWithTarget: aTarget - performSelector: aSelector - withObject: object1]; - [self addOperation: top]; -} - -- (void) addOperationWithTarget: (id)aTarget - performSelector: (SEL)aSelector -{ - GSTargetOperation *top = [GSTargetOperation operationWithTarget: aTarget - performSelector: aSelector]; - [self addOperation: top]; -} - -@end - - -@implementation GSTargetOperation - -static IMP -check(Class c, SEL _cmd, id t, SEL s) -{ - IMP msg; - - if (nil == t) - [NSException raise: NSInvalidArgumentException - format: @"%@ null target given", NSStringFromSelector(_cmd)]; - if (0 == s) - [NSException raise: NSInvalidArgumentException - format: @"%@ null selector given", NSStringFromSelector(_cmd)]; - - /* The Apple runtime API would do: - * msg = class_getMethodImplementation(object_getClass(self), aSelector); - * but this cannot ask self for information about any method reached by - * forwarding, so the returned forwarding function would ge a generic one - * rather than one aware of hardware issues with returning structures - * and floating points. We therefore prefer the GNU API which is able to - * use forwarding callbacks to get better type information. - */ - msg = objc_msg_lookup(t, s); - if (!msg) - [NSException raise: NSGenericException - format: @"%@ invalid selector '%s' passed to %s", - t, sel_getName(s), sel_getName(_cmd)]; - - return msg; -} - -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 - withObject: (id)object3 - withObject: (id)object4 -{ - GSTargetOperation *op; - IMP msg = check(self, _cmd, aTarget, aSelector); - - op = [[self alloc] init]; - op->msg = msg; - op->target = RETAIN(aTarget); - op->selector = aSelector; - op->o1 = RETAIN(object1); - op->o2 = RETAIN(object2); - op->o3 = RETAIN(object3); - op->o4 = RETAIN(object4); - op->argc = argc_four; - return AUTORELEASE(op); -} - -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 - withObject: (id)object3 -{ - GSTargetOperation *op; - IMP msg = check(self, _cmd, aTarget, aSelector); - - op = [[self alloc] init]; - op->msg = msg; - op->target = RETAIN(aTarget); - op->selector = aSelector; - op->o1 = RETAIN(object1); - op->o2 = RETAIN(object2); - op->o3 = RETAIN(object3); - op->o4 = nil; - op->argc = argc_three; - return AUTORELEASE(op); -} - -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 - withObject: (id)object2 -{ - GSTargetOperation *op; - IMP msg = check(self, _cmd, aTarget, aSelector); - - op = [[self alloc] init]; - op->msg = msg; - op->target = RETAIN(aTarget); - op->selector = aSelector; - op->o1 = RETAIN(object1); - op->o2 = RETAIN(object2); - op->o3 = nil; - op->o4 = nil; - op->argc = argc_two; - return AUTORELEASE(op); -} - -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector - withObject: (id)object1 -{ - GSTargetOperation *op; - IMP msg = check(self, _cmd, aTarget, aSelector); - - op = [[self alloc] init]; - op->msg = msg; - op->target = RETAIN(aTarget); - op->selector = aSelector; - op->o1 = RETAIN(object1); - op->o2 = nil; - op->o3 = nil; - op->o4 = nil; - op->argc = argc_one; - return AUTORELEASE(op); -} - -+ (instancetype) operationWithTarget: (id)aTarget - performSelector: (SEL)aSelector -{ - GSTargetOperation *op; - IMP msg = check(self, _cmd, aTarget, aSelector); - - op = [[self alloc] init]; - op->msg = msg; - op->target = RETAIN(aTarget); - op->selector = aSelector; - op->o1 = nil; - op->o2 = nil; - op->o3 = nil; - op->o4 = nil; - op->argc = argc_zero; - return AUTORELEASE(op); -} - -- (void) dealloc -{ - RELEASE(target); - if (argc > 0) RELEASE(o1); - if (argc > 1) RELEASE(o2); - if (argc > 2) RELEASE(o3); - if (argc > 3) RELEASE(o4); - DEALLOC -} - -- (void) main -{ - switch (argc) - { - case argc_four: - (*msg)(target, selector, o1, o2, o3, o4); - return; - case argc_three: - (*msg)(target, selector, o1, o2, o3); - return; - case argc_two: - (*msg)(target, selector, o1, o2); - return; - case argc_one: - (*msg)(target, selector, o1); - return; - case argc_zero: - (*msg)(target, selector); - return; - } -} -@end - diff --git a/Source/DocMakefile b/Source/DocMakefile index 195dc48e0..4230b024b 100644 --- a/Source/DocMakefile +++ b/Source/DocMakefile @@ -228,7 +228,6 @@ NSFileHandle+GNUstepBase.h \ NSMutableString+GNUstepBase.h \ NSNumber+GNUstepBase.h \ NSObject+GNUstepBase.h \ -NSOperationQueue+GNUstepBase.h \ NSProcessInfo+GNUstepBase.h \ NSString+GNUstepBase.h \ NSTask+GNUstepBase.h \ diff --git a/Tests/base/NSOperation/perform.m b/Tests/base/NSOperation/perform.m deleted file mode 100644 index c8f6692ee..000000000 --- a/Tests/base/NSOperation/perform.m +++ /dev/null @@ -1,78 +0,0 @@ -#import -#import -#import "ObjectTesting.h" - -@interface MyClass : NSObject -{ - unsigned counter; -} -- (void) count: (NSMapTable*)map; -- (unsigned) counter; -- (void) increment; -- (void) reset; -@end - -@implementation MyClass -- (void) count: (NSDictionary*)map -{ - unsigned c = [map count]; - -// NSLog(@"Count %u for %@", c, map); - counter += c; -} -- (unsigned) counter -{ - return counter; -} -- (void) increment -{ - counter = counter + 1; -} -- (void) reset -{ - counter = 0; -} -@end - -int main() -{ - ENTER_POOL - NSOperationQueue *q; - NSUInteger i; - NSUInteger ran; - NSUInteger want; - NSTimeInterval s; - NSTimeInterval f; - MyClass *o = AUTORELEASE([[MyClass alloc] init]); - - q = AUTORELEASE([[NSOperationQueue alloc] init]); - [q setMaxConcurrentOperationCount: 1]; - - ran = 0; - want = 200; - s = [NSDate timeIntervalSinceReferenceDate]; - for (i = 0; i < want; i++) - { - [q addOperationWithTarget: o - performSelector: @selector(increment)]; - } - [q waitUntilAllOperationsAreFinished]; - f = [NSDate timeIntervalSinceReferenceDate]; - PASS([o counter] == want, "expected number of operations") - NSLog(@"Duration for %d sequential operations %g seconds.", want, (f - s)); - - - [o reset]; - [q addOperationWithTarget: o - performSelector: @selector(count:) - withMap: - @"Key1", @"Val1", - @"Key2", @"Val2", - @"Key3", @"Val3", - nil]; - [q waitUntilAllOperationsAreFinished]; - PASS([o counter] == 3, "map had three keys") - - LEAVE_POOL - return 0; -}