mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
tidied a little
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3051 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
447937bb30
commit
95ff15509f
7 changed files with 116 additions and 69 deletions
|
@ -109,19 +109,19 @@
|
||||||
- (void) forwardInvocation: (NSInvocation*)anInvocation;
|
- (void) forwardInvocation: (NSInvocation*)anInvocation;
|
||||||
|
|
||||||
- (id) awakeAfterUsingCoder: (NSCoder*)aDecoder;
|
- (id) awakeAfterUsingCoder: (NSCoder*)aDecoder;
|
||||||
|
- (Class) classForArchiver;
|
||||||
- (Class) classForCoder;
|
- (Class) classForCoder;
|
||||||
|
- (Class) classForPortCoder;
|
||||||
|
- (id) replacementObjectForArchiver: (NSCoder*)anEncoder;
|
||||||
- (id) replacementObjectForCoder: (NSCoder*)anEncoder;
|
- (id) replacementObjectForCoder: (NSCoder*)anEncoder;
|
||||||
|
- (id) replacementObjectForPortCoder: (NSPortCoder*)anEncoder;
|
||||||
|
|
||||||
|
|
||||||
+ setVersion: (int)aVersion;
|
+ setVersion: (int)aVersion;
|
||||||
+ (int) version;
|
+ (int) version;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSObject (NSPortCoder)
|
|
||||||
- (Class) classForPortCoder;
|
|
||||||
- (id) replacementObjectForPortCoder: (NSPortCoder*)anEncoder;
|
|
||||||
@end
|
|
||||||
|
|
||||||
/* Global lock to be used by classes when operating on any global
|
/* Global lock to be used by classes when operating on any global
|
||||||
data that invoke other methods which also access global; thus,
|
data that invoke other methods which also access global; thus,
|
||||||
creating the potential for deadlock. */
|
creating the potential for deadlock. */
|
||||||
|
@ -143,6 +143,10 @@ NSComparisonResult;
|
||||||
|
|
||||||
enum {NSNotFound = 0x7fffffff};
|
enum {NSNotFound = 0x7fffffff};
|
||||||
|
|
||||||
|
@interface NSObject (GNUstep)
|
||||||
|
+ (id) newWithCoder: (NSCoder*)aCoder inZone: (NSZone*)aZone;
|
||||||
|
@end
|
||||||
|
|
||||||
@interface NSObject (NEXTSTEP)
|
@interface NSObject (NEXTSTEP)
|
||||||
- error:(const char *)aString, ...;
|
- error:(const char *)aString, ...;
|
||||||
- notImplemented:(SEL)aSel;
|
- notImplemented:(SEL)aSel;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <gnustep/base/behavior.h>
|
#include <gnustep/base/behavior.h>
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
|
#include <Foundation/NSCoder.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSGArray.h>
|
#include <Foundation/NSGArray.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
@ -133,13 +134,40 @@ static Class NSMutableArray_concrete_class;
|
||||||
|
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
[self subclassResponsibility:_cmd];
|
unsigned count = [self count];
|
||||||
|
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(unsigned)
|
||||||
|
at: &count];
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
[aCoder encodeObject: [self objectAtIndex: i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aCoder
|
- (id) initWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
[self subclassResponsibility:_cmd];
|
unsigned count;
|
||||||
return nil;
|
|
||||||
|
if ([aCoder systemVersion] == 0) {
|
||||||
|
unsigned dummy;
|
||||||
|
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &dummy];
|
||||||
|
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &dummy];
|
||||||
|
}
|
||||||
|
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
|
||||||
|
if (count > 0) {
|
||||||
|
id contents[count];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
contents[i] = [aCoder decodeObject];
|
||||||
|
}
|
||||||
|
return [self initWithObjects: contents count: count];
|
||||||
|
}
|
||||||
|
return [self initWithObjects: 0 count: 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The NSCopying Protocol */
|
/* The NSCopying Protocol */
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
- (unsigned int) versionForClassName: (NSString*)className
|
- (unsigned int) versionForClassName: (NSString*)className
|
||||||
{
|
{
|
||||||
[self subclassResponsibility:_cmd];
|
[self subclassResponsibility:_cmd];
|
||||||
return 0;
|
return NSNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [NSGArray class]) {
|
if (self == [NSGArray class]) {
|
||||||
|
[self setVersion: 1];
|
||||||
behavior_class_add_class(self, [NSArrayNonCore class]);
|
behavior_class_add_class(self, [NSArrayNonCore class]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +98,11 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (Class) classForCoder
|
||||||
|
{
|
||||||
|
return [NSArray class];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -105,18 +111,9 @@
|
||||||
at: &_count
|
at: &_count
|
||||||
withName: @"Array content count"];
|
withName: @"Array content count"];
|
||||||
|
|
||||||
if ([aCoder isKindOfClass: [NSPortCoder class]] &&
|
for (i = 0; i < _count; i++) {
|
||||||
[(NSPortCoder*)aCoder isBycopy]) {
|
[(id<Encoding>)aCoder encodeObject: _contents_array[i]
|
||||||
for (i = 0; i < _count; i++) {
|
withName: @"Array content"];
|
||||||
[(id<Encoding>)aCoder encodeBycopyObject: _contents_array[i]
|
|
||||||
withName: @"Array content"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (i = 0; i < _count; i++) {
|
|
||||||
[(id<Encoding>)aCoder encodeObject: _contents_array[i]
|
|
||||||
withName: @"Array content"];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +121,15 @@
|
||||||
{
|
{
|
||||||
unsigned count;
|
unsigned count;
|
||||||
|
|
||||||
|
if ([aCoder systemVersion] == 0) {
|
||||||
|
unsigned dummy;
|
||||||
|
[(id<Decoding>)aCoder decodeValueOfCType: @encode(unsigned)
|
||||||
|
at: &dummy
|
||||||
|
withName: NULL];
|
||||||
|
[(id<Decoding>)aCoder decodeValueOfCType: @encode(unsigned)
|
||||||
|
at: &dummy
|
||||||
|
withName: NULL];
|
||||||
|
}
|
||||||
[(id<Decoding>)aCoder decodeValueOfCType: @encode(unsigned)
|
[(id<Decoding>)aCoder decodeValueOfCType: @encode(unsigned)
|
||||||
at: &count
|
at: &count
|
||||||
withName: NULL];
|
withName: NULL];
|
||||||
|
@ -216,6 +222,7 @@
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [NSGMutableArray class]) {
|
if (self == [NSGMutableArray class]) {
|
||||||
|
[self setVersion: 1];
|
||||||
behavior_class_add_class(self, [NSMutableArrayNonCore class]);
|
behavior_class_add_class(self, [NSMutableArrayNonCore class]);
|
||||||
behavior_class_add_class(self, [NSGArray class]);
|
behavior_class_add_class(self, [NSGArray class]);
|
||||||
}
|
}
|
||||||
|
@ -269,6 +276,11 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (Class) classForCoder
|
||||||
|
{
|
||||||
|
return [NSMutableArray class];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) insertObject: (id)anObject atIndex: (unsigned)index
|
- (void) insertObject: (id)anObject atIndex: (unsigned)index
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
|
@ -361,7 +361,6 @@
|
||||||
case '\v':
|
case '\v':
|
||||||
case '\f':
|
case '\f':
|
||||||
case '\\':
|
case '\\':
|
||||||
case '\'' :
|
|
||||||
case '"' :
|
case '"' :
|
||||||
length += 2;
|
length += 2;
|
||||||
break;
|
break;
|
||||||
|
@ -395,7 +394,6 @@
|
||||||
case '\v': *ptr++ = '\\'; *ptr++ = 'v'; break;
|
case '\v': *ptr++ = '\\'; *ptr++ = 'v'; break;
|
||||||
case '\f': *ptr++ = '\\'; *ptr++ = 'f'; break;
|
case '\f': *ptr++ = '\\'; *ptr++ = 'f'; break;
|
||||||
case '\\': *ptr++ = '\\'; *ptr++ = '\\'; break;
|
case '\\': *ptr++ = '\\'; *ptr++ = '\\'; break;
|
||||||
case '\'': *ptr++ = '\\'; *ptr++ = '\''; break;
|
|
||||||
case '"' : *ptr++ = '\\'; *ptr++ = '"'; break;
|
case '"' : *ptr++ = '\\'; *ptr++ = '"'; break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <gnustep/base/o_map.h>
|
#include <gnustep/base/o_map.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
#include <Foundation/NSPortCoder.h>
|
||||||
|
#include <Foundation/NSDistantObject.h>
|
||||||
#include <Foundation/NSZone.h>
|
#include <Foundation/NSZone.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
@ -513,16 +515,45 @@ static BOOL double_release_check_enabled = NO;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (Class) classForArchiver
|
||||||
|
{
|
||||||
|
return [self classForCoder];
|
||||||
|
}
|
||||||
|
|
||||||
- (Class) classForCoder
|
- (Class) classForCoder
|
||||||
{
|
{
|
||||||
return [self class];
|
return [self class];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (Class) classForPortCoder
|
||||||
|
{
|
||||||
|
return [self classForCoder];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) replacementObjectForArchiver: (NSCoder*)anArchiver
|
||||||
|
{
|
||||||
|
return [self replacementObjectForCoder: (NSCoder*)anArchiver];
|
||||||
|
}
|
||||||
|
|
||||||
- (id) replacementObjectForCoder: (NSCoder*)anEncoder
|
- (id) replacementObjectForCoder: (NSCoder*)anEncoder
|
||||||
{
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder
|
||||||
|
{
|
||||||
|
if ([aCoder isBycopy]) {
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
else if ([self isKindOfClass: [NSDistantObject class]]) {
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return [NSDistantObject proxyWithLocal: self
|
||||||
|
connection: [aCoder connection]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* NSObject protocol */
|
/* NSObject protocol */
|
||||||
|
|
||||||
|
@ -746,6 +777,26 @@ static BOOL double_release_check_enabled = NO;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation NSObject (GNUstep)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GNUstep extensions to the OpenStep standard.
|
||||||
|
*/
|
||||||
|
|
||||||
|
+ (id) newWithCoder: (NSCoder*)coder inZone: (NSZone*)zone
|
||||||
|
{
|
||||||
|
id obj;
|
||||||
|
|
||||||
|
obj = [self allocWithZone: zone];
|
||||||
|
if (obj) {
|
||||||
|
obj = [obj initWithCoder: coder];
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation NSObject (NEXTSTEP)
|
@implementation NSObject (NEXTSTEP)
|
||||||
|
|
||||||
|
@ -860,17 +911,6 @@ static BOOL double_release_check_enabled = NO;
|
||||||
withObject:anotherObject];
|
withObject:anotherObject];
|
||||||
}
|
}
|
||||||
|
|
||||||
- perform: (SEL)sel withObject: anObject
|
|
||||||
{
|
|
||||||
return [self performSelector:sel withObject:anObject];
|
|
||||||
}
|
|
||||||
|
|
||||||
- perform: (SEL)sel withObject: anObject withObject: anotherObject
|
|
||||||
{
|
|
||||||
return [self performSelector:sel withObject:anObject
|
|
||||||
withObject:anotherObject];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -475,38 +475,3 @@ static BOOL debug_connected_coder = NO;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation NSObject (NSPortCoder)
|
|
||||||
|
|
||||||
/* By default, Object's encode themselves as proxies across Connection's */
|
|
||||||
- (Class) classForPortCoder
|
|
||||||
{
|
|
||||||
return [self classForCoder];
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline BOOL class_is_kind_of (Class self, Class aClassObject)
|
|
||||||
{
|
|
||||||
Class class;
|
|
||||||
|
|
||||||
for (class = self; class!=Nil; class = class_get_super_class(class))
|
|
||||||
if (class==aClassObject)
|
|
||||||
return YES;
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
- replacementObjectForPortCoder: (NSPortCoder*)aRmc
|
|
||||||
{
|
|
||||||
if ([aRmc isBycopy]) {
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
else if (class_is_kind_of(object_get_class(self->isa),
|
|
||||||
[NSDistantObject class])) {
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return [NSDistantObject proxyWithLocal: self
|
|
||||||
connection: [aRmc connection]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue