Implemented keyed decoding for this classes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18491 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2004-01-27 21:51:33 +00:00
parent 358b54ac77
commit dea07f458d
8 changed files with 299 additions and 183 deletions

View file

@ -45,6 +45,8 @@
#include "Foundation/NSDebug.h"
#include "Foundation/NSValue.h"
#include "Foundation/NSNull.h"
// For private method _decodeArrayOfObjectsForKey:
#include "Foundation/NSKeyedArchiver.h"
#include "GNUstepBase/GSCategories.h"
#include "GSPrivate.h"
@ -552,29 +554,39 @@ static SEL rlSel;
*/
- (id) initWithCoder: (NSCoder*)aCoder
{
unsigned count;
[aCoder decodeValueOfObjCType: @encode(unsigned)
at: &count];
if (count > 0)
if ([aCoder allowsKeyedCoding])
{
GS_BEGINIDBUF(contents, count)
NSArray *array = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
@"NS.objects"];
[aCoder decodeArrayOfObjCType: @encode(id)
count: count
at: contents];
self = [self initWithObjects: contents count: count];
#if GS_WITH_GC == 0
while (count-- > 0)
{
[contents[count] release];
}
#endif
GS_ENDIDBUF()
[self initWithArray: array];
}
else
{
self = [self initWithObjects: 0 count: 0];
unsigned count;
[aCoder decodeValueOfObjCType: @encode(unsigned)
at: &count];
if (count > 0)
{
GS_BEGINIDBUF(contents, count)
[aCoder decodeArrayOfObjCType: @encode(id)
count: count
at: contents];
self = [self initWithObjects: contents count: count];
#if GS_WITH_GC == 0
while (count-- > 0)
{
[contents[count] release];
}
#endif
GS_ENDIDBUF()
}
else
{
self = [self initWithObjects: 0 count: 0];
}
}
return self;
}