NSObject and NSRunLoop updates for MacOS-X compatibility

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14349 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-08-27 14:24:54 +00:00
parent 4892d558c5
commit 4bdb090e57
4 changed files with 84 additions and 0 deletions

View file

@ -138,6 +138,7 @@
+ (IMP) instanceMethodForSelector: (SEL)aSelector;
+ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector;
+ (BOOL) instancesRespondToSelector: (SEL)aSelector;
+ (BOOL) isSubclassOfClass: (Class)aClass;
+ (id) new;
+ (void) poseAsClass: (Class)aClassObject;
+ (id) setVersion: (int)aVersion;
@ -306,6 +307,7 @@ GS_EXPORT NSRecursiveLock *gnustep_global_lock;
#include <Foundation/NSDate.h>
@interface NSObject (TimedPerformers)
+ (void) cancelPreviousPerformRequestsWithTarget: (id)obj;
+ (void) cancelPreviousPerformRequestsWithTarget: (id)obj
selector: (SEL)s
object: (id)arg;

View file

@ -67,6 +67,8 @@ GS_EXPORT NSString * const NSDefaultRunLoopMode;
- (void) addPort: (NSPort*)port
forMode: (NSString*)mode;
- (void) cancelPerformSelectorsWithTarget: (id)target;
- (void) cancelPerformSelector: (SEL)aSelector
target: (id)target
argument: (id)argument;

View file

@ -1494,6 +1494,14 @@ static BOOL double_release_check_enabled = NO;
return NO;
}
/**
* Returns YES if the receiver is aClass or a subclass of aClass.
*/
+ (BOOL) isSubclassOfClass: (Class)aClass
{
return GSObjCIsKindOf(self, aClass);
}
/**
* Causes the receiver to execute the method implementation corresponding
* to aSelector and returns the result.<br />

View file

@ -1192,6 +1192,39 @@ if (0) {
@implementation NSObject (TimedPerformers)
/**
* Cancels any perform operations set up for the specified target
* in the current run loop.
*/
+ (void) cancelPreviousPerformRequestsWithTarget: (id)target
{
NSMutableArray *perf = [[NSRunLoop currentRunLoop] _timedPerformers];
unsigned count = [perf count];
if (count > 0)
{
GSTimedPerformer *array[count];
IF_NO_GC(RETAIN(target));
[perf getObjects: array];
while (count-- > 0)
{
GSTimedPerformer *p = array[count];
if (p->target == target)
{
[perf removeObjectAtIndex: count];
}
}
RELEASE(target);
}
}
/**
* Cancels any perform operations set up for the specified target
* in the current loop, but only if the vaslue of aSelector and argument
* with which the performs were set up exactly match those supplied.
*/
+ (void) cancelPreviousPerformRequestsWithTarget: (id)target
selector: (SEL)aSelector
object: (id)arg
@ -2087,6 +2120,45 @@ if (0) {
forMode: (NSString*)mode];
}
/**
* Cancels any perform operations set up for the specified target
* in the receiver.
*/
- (void) cancelPerformSelectorsWithTarget: (id) target
{
NSMapEnumerator enumerator;
GSRunLoopCtxt *context;
void *mode;
enumerator = NSEnumerateMapTable(_contextMap);
while (NSNextMapEnumeratorPair(&enumerator, &mode, (void**)&context))
{
if (context != nil)
{
GSIArray performers = context->performers;
unsigned count = GSIArrayCount(performers);
while (count--)
{
GSRunLoopPerformer *p;
p = GSIArrayItemAtIndex(performers, count).obj;
if (p->target == target)
{
GSIArrayRemoveItemAtIndex(performers, count);
}
}
}
}
NSEndMapTableEnumeration(&enumerator);
}
/**
* Cancels any perform operations set up for the specified target
* in the receiver, but only if the vaslue of aSelector and argument
* with which the performs were set up exactly match those supplied.
*/
- (void) cancelPerformSelector: (SEL)aSelector
target: (id) target
argument: (id) argument