Tidied coding.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3097 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1998-10-21 14:02:33 +00:00
parent 26ee1a0254
commit 244f5a7f23
2 changed files with 15 additions and 34 deletions

View file

@ -143,34 +143,23 @@
- (void) encodeWithCoder: aCoder - (void) encodeWithCoder: aCoder
{ {
[aCoder encodeValueOfObjCType:@encode(unsigned) at:&_count [aCoder encodeValueOfObjCType:@encode(unsigned) at:&_count];
withName:@"Concrete String count"];
[aCoder encodeArrayOfObjCType:@encode(unsigned char) [aCoder encodeArrayOfObjCType:@encode(unsigned char)
count:_count count:_count
at:_contents_chars at:_contents_chars];
withName:@"Concrete String content_chars"];
} }
- initWithCoder: aCoder - initWithCoder: aCoder
{ {
#if 0
[aCoder decodeValueOfObjCType:@encode(char*) at:&_contents_chars
withName:NULL];
_count = strlen(_contents_chars);
_zone = NSZoneFromPointer(_contents_chars);
#else
[aCoder decodeValueOfObjCType:@encode(unsigned) [aCoder decodeValueOfObjCType:@encode(unsigned)
at:&_count at:&_count];
withName:NULL];
if (_count > 0) { if (_count > 0) {
_zone = fastZone(self); _zone = fastZone(self);
_contents_chars = NSZoneMalloc(_zone, _count); _contents_chars = NSZoneMalloc(_zone, _count);
[aCoder decodeArrayOfObjCType:@encode(unsigned char) [aCoder decodeArrayOfObjCType:@encode(unsigned char)
count:_count count:_count
at:_contents_chars at:_contents_chars];
withName:NULL];
} }
#endif
return self; return self;
} }

View file

@ -34,6 +34,7 @@
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <Foundation/NSGString.h> #include <Foundation/NSGString.h>
#include <Foundation/NSData.h> #include <Foundation/NSData.h>
#include <Foundation/NSCoder.h>
#include <gnustep/base/IndexedCollection.h> #include <gnustep/base/IndexedCollection.h>
#include <gnustep/base/IndexedCollectionPrivate.h> #include <gnustep/base/IndexedCollectionPrivate.h>
#include <Foundation/NSValue.h> #include <Foundation/NSValue.h>
@ -254,24 +255,20 @@
- (void) encodeWithCoder: aCoder - (void) encodeWithCoder: aCoder
{ {
[aCoder encodeValueOfObjCType:@encode(int) at:&_count [aCoder encodeValueOfObjCType:@encode(int) at:&_count];
withName:@"Concrete String count"];
[aCoder encodeArrayOfObjCType:@encode(unichar) [aCoder encodeArrayOfObjCType:@encode(unichar)
count:_count count:_count
at:_contents_chars at:_contents_chars];
withName:@"Concrete String content_chars"];
} }
- initWithCoder: aCoder - initWithCoder: aCoder
{ {
[aCoder decodeValueOfObjCType:@encode(int) at:&_count [aCoder decodeValueOfObjCType:@encode(int) at:&_count];
withName:NULL];
_zone = fastZone(self); _zone = fastZone(self);
_contents_chars = NSZoneMalloc(_zone, sizeof(unichar)*_count); _contents_chars = NSZoneMalloc(_zone, sizeof(unichar)*_count);
[aCoder decodeArrayOfObjCType:@encode(unichar) [aCoder decodeArrayOfObjCType:@encode(unichar)
count:_count count:_count
at:_contents_chars at:_contents_chars];
withName:NULL];
return self; return self;
} }
@ -533,28 +530,23 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
- (void) encodeWithCoder: aCoder // *** changed to unichar - (void) encodeWithCoder: aCoder // *** changed to unichar
{ {
[aCoder encodeValueOfObjCType:@encode(unsigned) at:&_capacity [aCoder encodeValueOfObjCType:@encode(unsigned) at:&_capacity];
withName:@"String capacity"]; [aCoder encodeValueOfObjCType:@encode(int) at:&_count];
[aCoder encodeValueOfObjCType:@encode(int) at:&_count
withName:@"Concrete String count"];
[aCoder encodeArrayOfObjCType:@encode(unichar) [aCoder encodeArrayOfObjCType:@encode(unichar)
count:_count count:_count
at:_contents_chars at:_contents_chars];
withName:@"Concrete String content_chars"];
} }
- initWithCoder: aCoder // *** changed to unichar - initWithCoder: aCoder // *** changed to unichar
{ {
unsigned cap; unsigned cap;
[aCoder decodeValueOfObjCType:@encode(unsigned) at:&cap withName:NULL]; [aCoder decodeValueOfObjCType:@encode(unsigned) at:&cap];
[self initWithCapacity:cap]; [self initWithCapacity:cap];
[aCoder decodeValueOfObjCType:@encode(int) at:&_count [aCoder decodeValueOfObjCType:@encode(int) at:&_count];
withName:NULL];
[aCoder decodeArrayOfObjCType:@encode(unichar) [aCoder decodeArrayOfObjCType:@encode(unichar)
count:_count count:_count
at:_contents_chars at:_contents_chars];
withName:NULL];
return self; return self;
} }