home *** CD-ROM | disk | FTP | other *** search
- /*
- * Categories on NSArray and NSDictionary that allow them to be
- * sent over the wire like a regular object. Currently only NSString,
- * NSData and NSNumber implement the NXTransport protocol so only those
- * classes can be sent by value over the wire.
- *
- * No guarantee is made for the fitness of this code for any particular
- * use. No warranty expressed or implied. Use at your own risk!
- *
- * Randy Tidd
- * NeXT Premium Developer Support
- */
- #import "FoundationExtensions.h"
- #import "FoundationExtensionsPrivate.h"
- #import <remote/transport.h>
- #import <foundation/NSException.h>
- #import <foundation/NSObject.h>
-
- @implementation NSObject (OldDOExtensions)
-
- /*
- * The +name and -name categories are necessary because the DO system
- * sometimes asks a class for it's name for error messages. You may
- * already have this category defined in your code, in which case you
- * should remove one of them.
- */
- + (const char *)name
- {
- return [[self description] cString];
- }
-
- - (const char *)name
- {
- return [[self description] cString];
- }
-
- /*
- * These encodeUsing: and decodeUsing: categories are necessary because in some
- * circumstances, DO asks an object that is to be encoded bycopy if it responds to
- * these methods. However, the methods are never sent, they should never be sent
- * to an NSObject, thus these implementations just raise an exception.
- *
- * encodeRemotelyFor:freeAfterEncoding:isBycopy: should be implemented for all
- * NSObject subclasses, and that, in addition to the two methods below, will
- * make all NSObjects implement the NXTransport protocol.
- */
- - encodeUsing:sender
- {
- [NSException raise:NSInternalInconsistencyException
- format:@"*** Attempt to encode an NSObject with old DO: this is not supported!"];
- return self;
- }
-
- - decodeUsing:sender
- {
- [NSException raise:NSInternalInconsistencyException
- format:@"*** Attempt to decode an NSObject with old DO: this is not supported!"];
- return self;
- }
-
- @end
-
- @implementation NSArray (OldDOExtensions)
-
- - encodeRemotelyFor:connection freeAfterEncoding:(BOOL *)flag isBycopy:(BOOL)isBycopy
- {
- *flag = YES;
- return [[_NSArrayPlaceHolder alloc] initWithArray:self];
- }
-
- @end
-
- @implementation NSDictionary (OldDOExtensions)
-
- - encodeRemotelyFor:connection freeAfterEncoding:(BOOL *)flag isBycopy:(BOOL)isBycopy
- {
- *flag = YES;
- return [[_NSDictionaryPlaceHolder alloc] initWithDictionary:self];
- }
-
- @end
-