mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 09:31:07 +00:00
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:
parent
358b54ac77
commit
dea07f458d
8 changed files with 299 additions and 183 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2004-01-27 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSArray.m:
|
||||
* Source/NSArray.m:
|
||||
* Source/GSSet.m:
|
||||
* Source/NSSet.m:
|
||||
* Source/GSDictionary.m:
|
||||
* Source/NSDictionary.m:
|
||||
* Source/NSString.m:
|
||||
Implemented keyed decoding in [initWithCoder:].
|
||||
|
||||
2004-01-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSKeyedArchiver.h: Expose internals a bit.
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "Foundation/NSPortCoder.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
// For private method _decodeArrayOfObjectsForKey:
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
|
||||
static SEL eqSel;
|
||||
static SEL oaiSel;
|
||||
|
@ -178,6 +180,15 @@ static Class GSInlineArrayClass;
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *array = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.objects"];
|
||||
|
||||
[self initWithArray: array];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned)
|
||||
at: &_count];
|
||||
if (_count > 0)
|
||||
|
@ -192,6 +203,7 @@ static Class GSInlineArrayClass;
|
|||
count: _count
|
||||
at: _contents_array];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -462,6 +474,15 @@ static Class GSInlineArrayClass;
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *array = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.objects"];
|
||||
|
||||
[self initWithArray: array];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned count;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned)
|
||||
|
@ -478,6 +499,7 @@ static Class GSInlineArrayClass;
|
|||
at: _contents_array];
|
||||
_count = count;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -988,6 +1010,15 @@ static Class GSInlineArrayClass;
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *array = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.objects"];
|
||||
|
||||
return array;
|
||||
}
|
||||
else
|
||||
{
|
||||
GSInlineArray *a;
|
||||
unsigned c;
|
||||
|
||||
|
@ -1002,6 +1033,7 @@ static Class GSInlineArrayClass;
|
|||
}
|
||||
a->_count = c;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithObjects: (id*)objects count: (unsigned)count
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSPortCoder.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
// For private method _decodeArrayOfObjectsForKey:
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
|
||||
|
@ -125,6 +127,17 @@ static SEL objSel;
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *keys = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.keys"];
|
||||
NSArray *objects = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.objects"];
|
||||
|
||||
self = [self initWithObjects: objects forKeys: keys];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned count;
|
||||
id key;
|
||||
id value;
|
||||
|
@ -142,6 +155,7 @@ static SEL objSel;
|
|||
(*imp)(aCoder, sel, type, &value);
|
||||
GSIMapAddPairNoRetain(&map, (GSIMapKey)key, (GSIMapVal)value);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "Foundation/NSPortCoder.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
// For private method _decodeArrayOfObjectsForKey:
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
|
||||
#define GSI_MAP_HAS_VALUE 0
|
||||
#define GSI_MAP_KTYPES GSUNION_OBJ
|
||||
|
@ -187,6 +189,15 @@ static Class mutableSetClass;
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *array = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.objects"];
|
||||
|
||||
return [self initWithArray: array];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned count;
|
||||
id value;
|
||||
SEL sel = @selector(decodeValueOfObjCType:at:);
|
||||
|
@ -203,6 +214,7 @@ static Class mutableSetClass;
|
|||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
/* Designated initialiser */
|
||||
|
|
|
@ -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,6 +554,15 @@ static SEL rlSel;
|
|||
*/
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *array = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.objects"];
|
||||
|
||||
[self initWithArray: array];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned count;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned)
|
||||
|
@ -576,6 +587,7 @@ static SEL rlSel;
|
|||
{
|
||||
self = [self initWithObjects: 0 count: 0];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
// For private method _decodeArrayOfObjectsForKey:
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#include "GSPrivate.h"
|
||||
|
||||
|
@ -203,6 +205,17 @@ static SEL appSel;
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *keys = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.keys"];
|
||||
NSArray *objects = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.objects"];
|
||||
|
||||
self = [self initWithObjects: objects forKeys: keys];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned count;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
|
||||
|
@ -223,7 +236,7 @@ static SEL appSel;
|
|||
NSZoneFree(NSDefaultMallocZone(), keys);
|
||||
NSZoneFree(NSDefaultMallocZone(), vals);
|
||||
}
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
// For private method _decodeArrayOfObjectsForKey:
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
|
||||
@class GSSet;
|
||||
|
@ -150,7 +152,6 @@ static Class NSMutableSet_concrete_class;
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
unsigned count;
|
||||
Class c;
|
||||
|
||||
c = GSObjCClass(self);
|
||||
|
@ -167,6 +168,17 @@ static Class NSMutableSet_concrete_class;
|
|||
return [self initWithCoder: aCoder];
|
||||
}
|
||||
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *array = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
|
||||
@"NS.objects"];
|
||||
|
||||
return [self initWithArray: array];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned count;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
|
||||
if (count > 0)
|
||||
{
|
||||
|
@ -186,6 +198,7 @@ static Class NSMutableSet_concrete_class;
|
|||
#endif
|
||||
}
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
/* <init />
|
||||
|
|
|
@ -3880,6 +3880,14 @@ handle_printf_atsign (FILE *stream,
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
NSString *string = [aCoder decodeObjectForKey: @"NS.string"];
|
||||
|
||||
self = [self initWithString: string];
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned count;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned int) at: &count];
|
||||
|
@ -3952,6 +3960,7 @@ handle_printf_atsign (FILE *stream,
|
|||
{
|
||||
self = [self initWithCStringNoCopy: "" length: 0 freeWhenDone: NO];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue