Initial revision

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1994-11-08 16:44:01 +00:00
parent 6c10c972df
commit 4dcabcf97a
11 changed files with 1172 additions and 0 deletions

View file

@ -0,0 +1,43 @@
@interface NSConnection : NSObject
{
}
- init;
+ (NSConnection*) connectionWithRegisteredName: (NSString*)name
host: (NSString*)host;
+ (NSConnection*) defaultConnection;
+ (NSDistantObject*) rootProxyForConnectionWithRegisteredName: (NSString*)name;
+ (NSArray*) allConnections;
- (BOOL) isValid;
- (BOOL) registerName: (NSString*)name;
- (id) delegate;
- (void) setDelegate: (id)anObject;
- (id) rootObject;
- (NSDistantObject*) rootProxy;
- (void) setRootObject: (id)anObject;
- (NSString*) requestMode;
- (void) setRequestMode: (NSString*)mode;
- (BOOL) independentConversationQueueing;
- (void) setIndependentConversationQueueing: (BOOL)f;
- (NSTimeInterval) replyTimeout;
- (NSTimeInterval) requestTimeout;
- (void) setReplyTimeout: (NSTimeInterval)i;
- (void) setRequestTimeout: (NSTimeInterval)i;
- (NSDictionary*) statistics;
@end
@interface Object (NSConnection_Delegate)
- (BOOL) makeNewConnection: (NSConnection*)c sender: (NSConnection*)ancester;
@end

View file

@ -0,0 +1,31 @@
#ifndef __NSInvocation_h_INCLUDE_GNU
#define __NSInvocation_h_INCLUDE_GNU
#include <objc/Object.h>
@interface NSInvocation : Object
{
id methodSignature;
arglist_t argFrame;
retval_t retFrame;
}
+ (NSInvocation*) invocationWithMethodSignature: (MethodSignature*)ms;
- (void) getArgument: (void*)argumentLocation atIndex: (int)index;
- (void) getReturnValue: (void*)returnLocation;
- (MethodSignature*) methodSignature;
- (SEL) selector;
- (void) setArgument: (void*)argumentLocation atIndex: (int)index;
- (void) setReturnValue: (void*)returnLocation;
- (void) setSelector: (SEL)aSelector;
- (void) setTarget: (id)target;
- (id) target;
- (void) invoke;
- (void) invokeWithTarget: (id)target;
@end
#endif /* __NSInvocation_h_INCLUDE_GNU */

View file

@ -0,0 +1,26 @@
#ifndef __NSMethodSignature_h_INCLUDE_GNU
#define __NSMethodSignature_h_INCLUDE_GNU
#include <foundation/NSObject.h>
@interface NSMethodSignature : NSObject
{
char *types;
char *returnTypes;
unsigned argFrameLength;
unsigned returnFrameLength;
unsigned numArgs;
}
+ (NSMethodSignature*) signatureWithObjCTypes: (const char*)types;
- (NSArgumentInfo) argumentInfoAtIndex: (unsigned)index;
- (unsigned) frameLength;
- (BOOL) isOneway;
- (unsigned) methodReturnLength;
- (char*) methodReturnType;
- (unsigned) numberOfArguments;
@end
#endif /* __NSMethodSignature_h_INCLUDE_GNU */

View file

@ -0,0 +1,60 @@
#ifndef __NSObject_h_INCLUDE_GNU
#define __NSObject_h_INCLUDE_GNU
#include <objc/objc.h>
#include <objc/Protocol.h>
@class NSArchiver
@class NSCoder
@class NSMethodSignature
@class NSString
@interface NSObject
{
Class *isa;
}
+ (void) initialize;
+ (id) alloc;
+ (id) allocWithZone: (NSZone*)z;
+ (id) new;
- (id) copy;
- (void) dealloc;
- (id) init;
- (id) mutableCopy;
+ (Class) class;
+ (Class) superclass;
+ (BOOL) instancesRespondToSelector: (SEL)aSelector;
+ (BOOL) conformsToProtocol: (Protocol*)aProtocol;
+ (IMP) instanceMethodForSelector: (SEL)aSelector;
- (IMP) methodForSelector: (SEL)aSelector;
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector;
+ (NSString*) description;
+ (void) poseAsClass: (Class)aClass;
- (void) doesNotRecognizeSelector: (SEL)aSelector;
+ (void) cancelPreviousPerformRequestsWithTarget: (id)aTarget
selector: (SEL)aSelector
object: (id)anObject;
- (void) performSelector: (SEL)aSelector
object: (id)anObject
afterDelay: (NSTimeInterval)delay;
- (void) forwardInvocation: (NSInvocation*)anInvocation;
- (id) awakAfterUsingCoder: (NSCoder*)aDecoder;
- (Class) classForArchiver;
- (Class) classForCoder;
- (id) replacementObjectForArchiveer: (NSArchiver*)anArchiver;
- (id) replacementObjectForCoder: (NSCoder*)anEncoder;
@end
#endif /* __NSObject_h_INCLUDE_GNU */

169
Source/NSArray.m Normal file
View file

@ -0,0 +1,169 @@
#include <foundation/NSArray.h>
@implementation NSArray
+ (id) allocWithZone: (NSZone*)zone
{
return [self alloc]; /* for now, until we get zones. */
}
+ (id) array
{
return [[[self alloc] init] autorelease];
}
+ (id) arrayWithObject: anObject
{
return [[[[self alloc] init] addObject: anObject] autorelease];
}
+ (id) arrayWithObject: firstObject, ...
{
va_list ap;
Array *n = [[self alloc] init];
id o;
[n addObject:firstObject];
va_start(ap, firstObject);
while ((o = va_arg(ap, id)))
[n addObject:o];
va_end(ap);
return [n autorelease];
}
- (id) initWithArray: (NSArray*)array
{
int i, c;
c = [array count];
[super initWithCapacity:c];
for (i = 0; i < c; i++)
[self addObject:[array objectAtIndex:i]];
return self;
}
- (id) initWithObjects: (id)firstObject, ...
{
va_list ap;
id o;
[super init];
[self addObject:firstObject];
va_start(ap, firstObject);
while ((o = va_arg(ap, id)))
[self addObject:o];
va_end(ap);
return self;
}
- (id) initWithObjects: (id*)objects count: (unsigned int)count
{
[self initWithCapacity:count];
while (count--)
[self addObject:objects[count]];
return self;
}
- (BOOL) containsObject: (id)candidate
{
return [self includesObject:candidate];
}
#if 0
- (unsigned) count; /* inherited */
- (unsigned) indexOfObject: (id)anObject; /* inherited */
#endif
- (unsigned) indexOfObjectIdenticalTo: (id)anObject
{
int i;
for (i = 0; i < _count; i++)
if (anObject == _contents_array[i])
return i;
return UINT_MAX;
}
#if 0
- (id) lastObject; /* inherited */
- (id) objectAtIndex: (unsigned)index;
#endif
- (NSEnumerator*) objectEnumerator
{
[self notImplemented:_cmd];
return nil;
}
- (NSEnumerator*) reverseObjectEnumerator
{
[self notImplemented:_cmd];
return nil;
}
#if 0
- (void) makeObjectsPerform: (SEL)aSelector;
- (void) makeObjectsPerform: (SEL)aSelector withObject: (id)anObject;
#endif
- (id) firstObjectCommonWithArray: (NSArray*)otherArray
{
BOOL is_in_otherArray (id o)
{
return [otherArray containsObject:o];
}
id none_found(arglist_t)
{
return nil;
}
return [self detectObjectByCalling:is_in_otherArray
ifNoneCall:none_found];
}
- (BOOL) isEqualToArray: (NSArray*)otherArray
{
int i;
if (_count != [otherArray count])
return NO;
for (i = 0; i < _count; i++)
if ([_contents_array[i] isEqual:[otherArray objectAtIndex:i]])
return NO;
return YES;
}
- (NSArray*) sortedArrayUsingFunction: (int(*)(id,id,void*))comparator
context: (void*)context
{
id n = [self copy];
int compare(id o1, id o2)
{
return comparator(o1, o2, context);
}
[n sortObjectsByCalling:compare];
return [n autorelease];
}
- (NSArray*) sortedArrayUsingSelector: (SEL)comparator
{
id n = [self copy];
int compare(id o1, id o2)
{
return [o1 perform:comparator with:o2];
}
[n sortObjectsByCalling:compare];
return [n autorelease];
}
- (NSArray*) subarrayWithRange: (NSRange)range
{
id n = [self emptyCopy];
[self notImplemented:_cmd];
return [n autorelease];
}
- (NSString*) componentsJoinedByString: (NSString*)separator
{
}
@end

92
Source/NSInvocation.m Normal file
View file

@ -0,0 +1,92 @@
#include "NSInvocation.h"
@implementation NSInvocation
+ (NSInvocation*) invocationWithMethodSignature: (MethodSignature*)ms
frame: (arglist_t)aFrame
{
NSInvocation *newInv = [self invocationWithMethodSignature:ms];
bcopy(aFrame->arg_ptr, newInv->agrFrame->arg_ptr, [ms frameLength]);
...
return newInv;
}
+ (NSInvocation*) invocationWithMethodSignature: (MethodSignature*)ms
{
int argsize = [ms frameLength];
int retsize = [ms methodReturnLength];
NSInvocation* newInv = [self alloc];
newInv->methodSignature = ms;
newInv->argFrame = malloc(argsize);
newInv->argFrame->arg_ptr = malloc(argsize);
newInv->retFrame = malloc(retsize);
return newInv;
}
- (void) getArgument: (void*)argumentLocation atIndex: (int)index
{
*argumentLocation =
}
- (void) getReturnValue: (void*)returnLocation
{
bcopy(retFrame, returnLocation, [methodSignature methodReturnLength]);
return;
}
- (MethodSignature*) methodSignature
{
return methodSignature;
}
- (SEL) selector
{
SEL s;
[self getArgument:&s atIndex:1];
return s;
}
- (void) setArgument: (void*)argumentLocation atIndex: (int)index;
- (void) setReturnValue: (void*)returnLocation
{
bcopy(returnLocation, retFrame, [methodSignature methodReturnLength]);
return;
}
- (void) setSelector: (SEL)aSelector
{
[self setArgument:&aSelector atIndex:1];
return;
}
- (void) setTarget: (id)aTarget
{
target = aTarget;
return;
}
- (id) target
{
id t;
[self getArgument:&t atIndex:0];
return t;
}
- (void) invoke
{
char *type;
Method* m;
id target;
SEL sel;
IMP imp;
target = *(id*)method_get_first_argument(m, argFrame, &type);
= [target methodForSelector:
__builtin_apply(
- (void) invokeWithTarget: (id)target
{
@end

View file

@ -0,0 +1,80 @@
#include "foundation/NSMethodSignature.h"
#include "objc/objc-malloc.h"
static int
types_get_size_of_arguments(const char *types)
{
const char* type = objc_skip_typespec (types);
return atoi (type);
}
static int
types_get_number_of_arguments (const char *types)
{
int i = 0;
const char* type = types;
while (*type)
{
type = objc_skip_argspec (type);
i += 1;
}
return i - 1;
}
@implementation NSMethodSignature
+ (NSMethodSignature*) signatureWithObjCTypes: (const char*)types
{
int len;
NSMethodSignature *newMs = [NSMethodSignature alloc];
len = strlen(types);
OBJC_MALLOC(newMs->types, char, len);
bcopy(types, newMs->types, len);
len = str??();
OBJC_MALLOC(newMs->returnTypes, char, len);
bcopy(types, newMs->returnTypes, len);
newMs->argFrameLength = types_get_size_of_arguments(types);
newMs->returnFrameLength = objc_size_of_type(types);
newMs->numArgs = types_get_number_of_arguments(types);
return newMs;
}
- (NSArgumentInfo) argumentInfoAtIndex: (unsigned)index
{
return 0;
}
- (unsigned) frameLength
{
return argFrameLength;
}
- (BOOL) isOneway
{
[self notImplemented:_cmd];
return NO;
}
- (unsigned) methodReturnLength
{
return returnFrameLength;
}
- (char*) methodReturnType
{
return "";
}
- (unsigned) numberOfArguments
{
return numArgs;
}
- free
{
OBJC_FREE(types);
return [super free];
}
@end

182
Source/NSObject.m Normal file
View file

@ -0,0 +1,182 @@
#include <foundation/NSObject.h>
#include <foundation/NSMethodSignature.h>
#include <foundation/NSArchiver.h>
#include <foundation/NSCoder.h>
#include "objc/objc-api.h"
@implementation NSObject
+ (void) initialize
{
return;
}
+ (id) alloc
{
return class_create_instance(self);
}
+ (id) allocWithZone: (NSZone*)z
{
return [self alloc]; /* for now, until we get zones */
}
+ (id) new
{
return [[self alloc] init];
}
- (id) copy
{
return [self copyWithZone:0];
}
- (void) dealloc
{
return object_dispose(self);
}
- (id) init
{
return self;
}
- (id) mutableCopy
{
return [self mutableCopyWithZone:0];
}
+ (Class) class
{
return *(object_get_class(self));
}
+ (Class) superclass
{
return *(object_get_super_class(self));
}
+ (BOOL) instancesRespondToSelector: (SEL)aSelector
{
return class_get_instance_method(self, aSel)!=METHOD_NULL;
}
+ (BOOL) conformsToProtocol: (Protocol*)aProtocol
{
int i;
struct objc_protocol_list* proto_list;
for (proto_list = isa->protocols;
proto_list; proto_list = proto_list->next)
{
for (i=0; i < proto_list->count; i++)
{
if ([proto_list->list[i] conformsTo: aProtocol])
return YES;
}
}
if ([self superClass])
return [[self superClass] conformsTo: aProtocol];
else
return NO;
}
+ (IMP) instanceMethodForSelector: (SEL)aSelector
{
return method_get_imp(class_get_instance_method(self, aSel));
}
- (IMP) methodForSelector: (SEL)aSelector
{
return (method_get_imp(object_is_instance(self)
?class_get_instance_method(self->isa, aSel)
:class_get_class_method(self->isa, aSel)));
}
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector
{
[self notImplemented:_cmd];
return nil;
}
+ (NSString*) description
{
return nil;
}
+ (void) poseAsClass: (Class)aClass
{
return class_pose_as(self, aClassObject);
}
- (void) doesNotRecognizeSelector: (SEL)aSelector
{
return [self error:"%s does not recognize %s",
object_get_class_name(self), sel_get_name(aSel)];
}
+ (void) cancelPreviousPerformRequestsWithTarget: (id)aTarget
selector: (SEL)aSelector
object: (id)anObject
{
[self notImplemented:_cmd];
return;
}
- (void) performSelector: (SEL)aSelector
object: (id)anObject
afterDelay: (NSTimeInterval)delay
{
[self notImplemented:_cmd];
return;
}
- (retval_t) forward:(SEL)aSel :(arglist_t)argFrame
{
void *retFrame;
NSMethodSignature *ms = [self methodSignatureForSelector:aSel];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:ms
frame:argFrame];
/* is this right? */
retFrame = alloc([ms methodReturnLength]);
[self forwardInvocation:inv];
[inv getReturnValue:retFrame];
/* where do ms and inv get free'd? */
return retFrame;
}
- (void) forwardInvocation: (NSInvocation*)anInvocation
{
[self doesNotRecognizeSelector:[anInvocation selector]];
return;
}
- (id) awakAfterUsingCoder: (NSCoder*)aDecoder
{
return self;
}
- (Class) classForArchiver
{
return [self classForCoder];
}
- (Class) classForCoder
{
return [self class];
}
- (id) replacementObjectForArchiveer: (NSArchiver*)anArchiver
{
return [self replacementObjectForCoder:anArchiver];
}
- (id) replacementObjectForCoder: (NSCoder*)anEncoder
{
return self;
}
@end
#endif /* __NSNSObject_h_INCLUDE_GNU */

347
Source/NXConnection.m Normal file
View file

@ -0,0 +1,347 @@
/* Implementation of Objective-C method-name-compatible NXConnection
Copyright (C) 1994 Free Software Foundation, Inc.
This file is part of the GNU Objective C Class Library.
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
Date: May 1993
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <remote/NXConnection.h>
#include <remote/NXProxy.h>
#include <objects/ConnectedCoder.h>
#include <assert.h>
static Class* NXConnectionProxyClass;
/* Just to make -encodeRemotelyFor:... work */
@interface NXConnectedCoder : ConnectedCoder
- (void) _doEncodeObject: anObj;
@end
@implementation NXConnection
+ initialize
{
if ([self class] == [NXConnection class])
NXConnectionProxyClass = [NXProxy class];
return self;
}
+ connections: aList
{
id cs = [Connection allConnections];
void add_to_aList(id c)
{
[aList addObject:c];
}
[cs withObjectsCall:add_to_aList];
[cs free];
return self;
}
+ setDefaultProxyClass: (Class*)aClass
{
NXConnectionProxyClass = aClass;
return self;
}
+ (Class*) defaultProxyClass
{
return NXConnectionProxyClass;
}
+ (NXZone*) defaultZone
{
return NX_NOZONE;
}
+ setDefaultZone: (NXZone *)z
{
return self;
}
+ (int) defaultTimeout
{
/* not correct, but it will do for now. */
return [self defaultInTimeout];
}
+ setDefaultTimeout: (int)to
{
/* not correct, but it will do for now. */
return [self setDefaultInTimeout:to];
}
+ registerRoot: anObj fromZone: (NXZone*)z
{
return [Connection newWithRootObject:anObj];
}
+ registerRoot: anObj
{
return [self registerRoot:anObj fromZone:NX_NOZONE];
}
+ registerRoot: anObj withName: (char*)n fromZone: (NXZone*)z
{
return [Connection newRegisteringAtName:n withRootObject:anObj];
}
+ registerRoot: anObj withName: (char*)n
{
return [self registerRoot:anObj withName:n fromZone:NX_NOZONE];
}
+ connectToPort: aPort fromZone: (NXZone*)z
{
return [Connection rootProxyAtPort:aPort];
}
+ connectToPort: aPort
{
return [self connectToPort:aPort fromZone:NX_NOZONE];
}
+ connectToPort: aPort withInPort: anInPort fromZone: (NXZone*)z
{
return [Connection rootProxyAtPort:aPort withInPort:anInPort];
}
+ connectToPort: aPort withInPort: anInPort
{
return [self connectToPort:aPort withInPort:anInPort fromZone:NX_NOZONE];
}
+ connectToName: (char*)n onHost: (char*)h fromZone: (NXZone*)z
{
return [Connection rootProxyAtName:n onHost:h];
}
+ connectToName: (char*)n fromZone: (NXZone*)z
{
return [Connection rootProxyAtName:n];
}
+ connectToName: (char*)n onHost: (char*)h
{
return [self connectToName:n onHost:h fromZone:NX_NOZONE];
}
+ connectToName: (char*)n
{
return [self connectToName:n fromZone:NX_NOZONE];
}
+ (unsigned) count
{
return [Connection connectionsCount];
}
- runInNewThread
{
return [self notImplemented:_cmd];
}
- removeLocal: anObj
{
return [self removeLocalObject:anObj];
}
- removeRemote: anObj
{
return [self removeProxy:anObj];
}
- (List*) localObjects
{
id aList = [[List alloc] init];
id cs = [self localObjects];
void add_to_aList(id c)
{
[aList addObject:c];
}
[cs withObjectsCall:add_to_aList];
[cs free];
return aList;
}
- (List*) remoteObjects
{
id aList = [[List alloc] init];
id cs = [self proxies];
void add_to_aList(id c)
{
[aList addObject:c];
}
[cs withObjectsCall:add_to_aList];
[cs free];
return aList;
}
- getLocal: anObj
{
return [self notImplemented:_cmd];
}
- getRemote: (unsigned)aName
{
return [self proxyForTarget:aName];
}
- newLocal: anObj
{
return [self notImplemented:_cmd];
}
- newRemote: (unsigned)r withProtocol: aProtocol
{
return [[self proxyClass] newForRemote:r connection:self];
}
- insertProxy: anObj
{
return [self addProxy:anObj];
}
- setRoot: anObj
{
return [self setRootObject:anObj];
}
- (Class*) proxyClass
{
/* we might replace this with a per-Connection proxy class. */
return NXConnectionProxyClass;
}
- (Class*) coderClass
{
return [NXConnectedCoder class];
}
@end
@implementation Object (NXConnectionCompatibility)
- encodeRemotelyFor: (NXConnection*)conn
freeAfterEncoding: (BOOL*)fp
isBycopy: (BOOL)f;
{
if (f)
return self;
return [[conn proxyClass] newBogusLocal:self];
}
@end
@implementation NXConnectedCoder
- encodeData:(void *)data ofType:(const char *)type
{
[self encodeValueOfType:type at:data withName:NULL];
return self;
}
- encodeBytes:(const void *)bytes count:(int)count
{
char types[16];
sprintf(types, "[%dc]", count);
[self encodeValueOfType:types at:bytes withName:NULL];
return self;
}
- encodeVM:(const void *)bytes count:(int)count
{
[self notImplemented:_cmd];
return self;
}
- encodeMachPort:(port_t)port
{
[self notImplemented:_cmd];
return self;
}
- encodeObject:anObject
{
[self encodeObject:anObject withName:NULL];
return self;
}
- encodeObjectBycopy:anObject
{
[self encodeObjectBycopy:anObject withName:NULL];
return self;
}
- decodeData:(void *)d ofType:(const char *)t
{
[self decodeValueOfType:t at:d withName:NULL];
return self;
}
- decodeBytes:(void *)bytes count:(int)count
{
char types[16];
sprintf(types, "[%dc]", count);
[self decodeValueOfType:types at:bytes withName:NULL];
return self;
}
- decodeVM:(void **)bytes count:(int *)count
{
[self notImplemented:_cmd];
return self;
}
- decodeMachPort:(port_t *)pp
{
[self notImplemented:_cmd];
return self;
}
/* WARNING: This won't work if the object is a GNU forward object reference */
- (id) decodeObject
{
id o;
[self decodeObjectAt:&o withName:NULL];
return o;
}
- (void) _doEncodeObject: anObj
{
BOOL f = NO;
Class *c;
id o;
assert([[self connection] class] == [NXConnection class]);
/* xxx We have yet to set isBycopy correctly */
o = [anObj encodeRemotelyFor:(NXConnection*)[self connection]
freeAfterEncoding:&f
isBycopy:NO];
c = [o classForConnectedCoder:self];
[self encodeClass:c];
[c encodeObject:o withConnectedCoder:self];
if (f)
[anObj free];
[o free];
}
@end

View file

@ -0,0 +1,59 @@
/* Implementation of Objective-C NeXT-compatible NXProtocolChecker object
Copyright (C) 1993,1994 Free Software Foundation, Inc.
Written by: R. Andrew McCallum <mccallum@cs.rochester.edu>
Dept. of Computer Science, U. of Rochester, Rochester, NY 14627
This file is part of the GNU Objective C Class Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <objc/Object.h>
#include <machkit/NXProtocolChecker.h>
@implementation NXProtocolChecker
{
id target;
id protocol;
}
- initWithObject: anObj forProtocol: aProtocol
{
[super init];
target = anObj;
protocol = aProtocol;
return self;
}
- (BOOL) conformsTo: aProtocol
{
return [protocol conformsTo:aProtocol];
}
- (struct objc_method_description *) descriptionForMethod: (SEL)aSel
{
return [protocol descriptionForMethod:aSel];
}
- forward: (SEL)aSel :(arglist_t)frame
{
if ([protocol descriptionForMethod:aSel])
return [target performv:aSel :frame];
/* Fix this */
return nil;
}
@end

83
Source/NXProxy.m Normal file
View file

@ -0,0 +1,83 @@
/* Implementation of Objective-C method-name-compatible NXProxy
Copyright (C) 1994 Free Software Foundation, Inc.
This file is part of the GNU Objective C Class Library.
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
Date: May 1993
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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 Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <remote/NXProxy.h>
#include <objc/objc-api.h>
#include <assert.h>
@implementation NXProxy
- addReference
{
[self retain];
return self;
}
- (unsigned) references
{
return [self retainCount] + 1;
}
- (unsigned) nameForProxy
{
return [self targetForProxy];
}
- freeProxy
{
[self dealloc];
return nil;
}
- free
{
/* xxx Is this what we want? */
return [self freeProxy];
}
- setProtocolForProxy: (Protocol*)aProtocol
{
return self;
}
- encodeRemotelyFor: (NXConnection*)conn
freeAfterEncoding: (BOOL*)fp
isBycopy: (BOOL)f;
{
return self;
}
/* GNU Connection doesn't use local proxies, but in order for us to have
compatibility with NeXT's -encodeRemotelyFor:freeAfterEncoding:isBycopy
we have to do this ugly thing. */
+ newBogusLocal: (id)anObject
{
NXProxy *newProxy = class_create_instance([NXProxy class]);
newProxy->target = PTR2LONG(anObject);
return newProxy;
}
@end