2001-12-17 14:31:42 +00:00
|
|
|
|
/** NSCoder - coder object for serialization and persistance.
|
1996-01-23 02:32:49 +00:00
|
|
|
|
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1995-04-09 01:53:53 +00:00
|
|
|
|
From skeleton by: Adam Fedor <fedor@boulder.colorado.edu>
|
1995-04-03 22:59:20 +00:00
|
|
|
|
Date: Mar 1995
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
|
This file is part of the GNUstep Base Library.
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Library General Public License for more details.
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
|
License along with this library; if not, write to the Free
|
2005-05-22 03:32:16 +00:00
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
2001-12-18 16:54:15 +00:00
|
|
|
|
|
|
|
|
|
<title>NSCoder class reference</title>
|
|
|
|
|
$Date$ $Revision$
|
1995-04-04 16:21:18 +00:00
|
|
|
|
*/
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
2003-06-07 01:24:41 +00:00
|
|
|
|
#include "config.h"
|
2003-07-31 23:49:32 +00:00
|
|
|
|
#include "GNUstepBase/preface.h"
|
2003-06-07 01:24:41 +00:00
|
|
|
|
#include "Foundation/NSData.h"
|
2006-04-09 16:16:07 +00:00
|
|
|
|
#include "Foundation/NSDebug.h"
|
2003-06-07 01:24:41 +00:00
|
|
|
|
#include "Foundation/NSCoder.h"
|
|
|
|
|
#include "Foundation/NSSerialization.h"
|
1995-04-03 22:59:20 +00:00
|
|
|
|
|
|
|
|
|
@implementation NSCoder
|
|
|
|
|
|
1996-05-07 18:08:01 +00:00
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSCoder class])
|
2000-06-26 09:22:17 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
1996-05-07 18:08:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-01-23 02:32:49 +00:00
|
|
|
|
- (void) encodeValueOfObjCType: (const char*)type
|
2000-06-26 09:22:17 +00:00
|
|
|
|
at: (const void*)address
|
1996-01-23 02:32:49 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
1996-01-23 02:32:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) decodeValueOfObjCType: (const char*)type
|
2000-06-26 09:22:17 +00:00
|
|
|
|
at: (void*)address
|
1996-01-23 02:32:49 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
1996-01-23 02:32:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodeDataObject: (NSData*)data
|
1996-01-23 02:32:49 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
1996-01-23 02:32:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (NSData*) decodeDataObject
|
1996-01-23 02:32:49 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
1996-01-23 02:32:49 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (unsigned int) versionForClassName: (NSString*)className
|
1996-01-23 02:32:49 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
1998-10-11 06:26:40 +00:00
|
|
|
|
return NSNotFound;
|
1996-01-23 02:32:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-04-03 22:59:20 +00:00
|
|
|
|
// Encoding Data
|
|
|
|
|
|
1995-04-09 01:53:53 +00:00
|
|
|
|
- (void) encodeArrayOfObjCType: (const char*)type
|
2000-06-26 09:22:17 +00:00
|
|
|
|
count: (unsigned)count
|
|
|
|
|
at: (const void*)array
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
unsigned i;
|
|
|
|
|
unsigned size = objc_sizeof_type(type);
|
|
|
|
|
const char *where = array;
|
|
|
|
|
IMP imp;
|
1995-04-09 01:53:53 +00:00
|
|
|
|
|
2000-06-26 09:22:17 +00:00
|
|
|
|
imp = [self methodForSelector: @selector(encodeValueOfObjCType:at:)];
|
1995-04-09 01:53:53 +00:00
|
|
|
|
for (i = 0; i < count; i++, where += size)
|
2000-06-26 09:22:17 +00:00
|
|
|
|
{
|
|
|
|
|
(*imp)(self, @selector(encodeValueOfObjCType:at:), type, where);
|
|
|
|
|
}
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodeBycopyObject: (id)anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self encodeObject: anObject];
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodeByrefObject: (id)anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self encodeObject: anObject];
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodeBytes: (void*)d length: (unsigned)l
|
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
const char *type = @encode(unsigned char);
|
|
|
|
|
const unsigned char *where = (const unsigned char*)d;
|
|
|
|
|
IMP imp;
|
1998-03-23 20:49:54 +00:00
|
|
|
|
|
2000-06-26 09:22:17 +00:00
|
|
|
|
imp = [self methodForSelector: @selector(encodeValueOfObjCType:at:)];
|
1998-10-09 15:37:06 +00:00
|
|
|
|
(*imp)(self, @selector(encodeValueOfObjCType:at:),
|
2000-06-26 09:22:17 +00:00
|
|
|
|
@encode(unsigned), &l);
|
1998-03-23 20:49:54 +00:00
|
|
|
|
while (l-- > 0)
|
1998-10-09 15:37:06 +00:00
|
|
|
|
(*imp)(self, @selector(encodeValueOfObjCType:at:), type, where++);
|
1998-03-23 20:49:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeConditionalObject: (id)anObject
|
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self encodeObject: anObject];
|
1998-03-23 20:49:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeObject: (id)anObject
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self encodeValueOfObjCType: @encode(id) at: &anObject];
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodePropertyList: (id)plist
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2006-05-20 13:24:53 +00:00
|
|
|
|
id anObject;
|
2000-06-26 09:22:17 +00:00
|
|
|
|
|
2006-05-20 13:24:53 +00:00
|
|
|
|
anObject = plist ? (id)[NSSerializer serializePropertyList: plist] : nil;
|
1998-12-18 17:25:15 +00:00
|
|
|
|
[self encodeValueOfObjCType: @encode(id) at: &anObject];
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodePoint: (NSPoint)point
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self encodeValueOfObjCType: @encode(NSPoint) at: &point];
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodeRect: (NSRect)rect
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self encodeValueOfObjCType: @encode(NSRect) at: &rect];
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodeRootObject: (id)rootObject
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self encodeObject: rootObject];
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodeSize: (NSSize)size
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
[self encodeValueOfObjCType: @encode(NSSize) at: &size];
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) encodeValuesOfObjCTypes: (const char*)types,...
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
va_list ap;
|
|
|
|
|
IMP imp;
|
|
|
|
|
|
|
|
|
|
imp = [self methodForSelector: @selector(encodeValueOfObjCType:at:)];
|
1995-04-09 01:53:53 +00:00
|
|
|
|
va_start(ap, types);
|
|
|
|
|
while (*types)
|
|
|
|
|
{
|
1999-06-24 19:30:29 +00:00
|
|
|
|
(*imp)(self, @selector(encodeValueOfObjCType:at:), types,
|
|
|
|
|
va_arg(ap, void*));
|
1995-04-09 01:53:53 +00:00
|
|
|
|
types = objc_skip_typespec(types);
|
|
|
|
|
}
|
|
|
|
|
va_end(ap);
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Decoding Data
|
|
|
|
|
|
1995-04-09 01:53:53 +00:00
|
|
|
|
- (void) decodeArrayOfObjCType: (const char*)type
|
2000-06-26 09:22:17 +00:00
|
|
|
|
count: (unsigned)count
|
|
|
|
|
at: (void*)address
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
unsigned i;
|
|
|
|
|
unsigned size = objc_sizeof_type(type);
|
|
|
|
|
char *where = address;
|
|
|
|
|
IMP imp;
|
|
|
|
|
|
|
|
|
|
imp = [self methodForSelector: @selector(decodeValueOfObjCType:at:)];
|
1995-04-09 01:53:53 +00:00
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++, where += size)
|
2000-06-26 09:22:17 +00:00
|
|
|
|
{
|
|
|
|
|
(*imp)(self, @selector(decodeValueOfObjCType:at:), type, where);
|
|
|
|
|
}
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void*) decodeBytesWithReturnedLength: (unsigned*)l
|
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
unsigned count;
|
|
|
|
|
const char *type = @encode(unsigned char);
|
|
|
|
|
unsigned char *where;
|
|
|
|
|
unsigned char *array;
|
|
|
|
|
IMP imp;
|
|
|
|
|
|
|
|
|
|
imp = [self methodForSelector: @selector(decodeValueOfObjCType:at:)];
|
1998-03-23 20:49:54 +00:00
|
|
|
|
|
1998-10-09 15:37:06 +00:00
|
|
|
|
(*imp)(self, @selector(decodeValueOfObjCType:at:),
|
2000-06-26 09:22:17 +00:00
|
|
|
|
@encode(unsigned), &count);
|
1998-03-23 20:49:54 +00:00
|
|
|
|
*l = count;
|
1999-09-28 11:10:34 +00:00
|
|
|
|
array = NSZoneMalloc(NSDefaultMallocZone(), count);
|
1999-09-13 04:11:39 +00:00
|
|
|
|
where = array;
|
1998-03-23 20:49:54 +00:00
|
|
|
|
while (count-- > 0)
|
2000-06-26 09:22:17 +00:00
|
|
|
|
{
|
|
|
|
|
(*imp)(self, @selector(decodeValueOfObjCType:at:), type, where++);
|
|
|
|
|
}
|
1998-03-23 20:49:54 +00:00
|
|
|
|
|
1998-09-30 08:29:58 +00:00
|
|
|
|
[NSData dataWithBytesNoCopy: array length: count];
|
1998-03-23 20:49:54 +00:00
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) decodeObject
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
id o;
|
|
|
|
|
|
|
|
|
|
[self decodeValueOfObjCType: @encode(id) at: &o];
|
|
|
|
|
return AUTORELEASE(o);
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1995-04-09 01:53:53 +00:00
|
|
|
|
- (id) decodePropertyList
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
id o;
|
|
|
|
|
id d;
|
|
|
|
|
|
1998-12-18 17:25:15 +00:00
|
|
|
|
[self decodeValueOfObjCType: @encode(id) at: &d];
|
2000-06-26 09:22:17 +00:00
|
|
|
|
if (d != nil)
|
1998-12-18 17:25:15 +00:00
|
|
|
|
{
|
|
|
|
|
o = [NSDeserializer deserializePropertyListFromData: d
|
|
|
|
|
mutableContainers: NO];
|
2000-06-26 09:22:17 +00:00
|
|
|
|
RELEASE(d);
|
1998-12-18 17:25:15 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2000-06-26 09:22:17 +00:00
|
|
|
|
{
|
|
|
|
|
o = nil;
|
|
|
|
|
}
|
1998-10-09 10:58:19 +00:00
|
|
|
|
return o;
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1995-04-09 01:53:53 +00:00
|
|
|
|
- (NSPoint) decodePoint
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
NSPoint point;
|
|
|
|
|
|
|
|
|
|
[self decodeValueOfObjCType: @encode(NSPoint) at: &point];
|
1995-04-04 16:21:18 +00:00
|
|
|
|
return point;
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1995-04-09 01:53:53 +00:00
|
|
|
|
- (NSRect) decodeRect
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
NSRect rect;
|
|
|
|
|
|
|
|
|
|
[self decodeValueOfObjCType: @encode(NSRect) at: &rect];
|
1995-04-04 16:21:18 +00:00
|
|
|
|
return rect;
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-04-09 01:53:53 +00:00
|
|
|
|
- (NSSize) decodeSize
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
NSSize size;
|
|
|
|
|
|
|
|
|
|
[self decodeValueOfObjCType: @encode(NSSize) at: &size];
|
1995-04-04 16:21:18 +00:00
|
|
|
|
return size;
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
1995-04-04 16:21:18 +00:00
|
|
|
|
|
1998-03-23 20:49:54 +00:00
|
|
|
|
- (void) decodeValuesOfObjCTypes: (const char*)types,...
|
1995-04-03 22:59:20 +00:00
|
|
|
|
{
|
2000-06-26 09:22:17 +00:00
|
|
|
|
va_list ap;
|
|
|
|
|
IMP imp;
|
|
|
|
|
|
|
|
|
|
imp = [self methodForSelector: @selector(decodeValueOfObjCType:at:)];
|
1995-04-09 01:53:53 +00:00
|
|
|
|
va_start(ap, types);
|
|
|
|
|
while (*types)
|
|
|
|
|
{
|
1998-10-09 15:37:06 +00:00
|
|
|
|
(*imp)(self, @selector(decodeValueOfObjCType:at:),
|
2000-06-26 09:22:17 +00:00
|
|
|
|
types, va_arg(ap, void*));
|
1995-04-09 01:53:53 +00:00
|
|
|
|
types = objc_skip_typespec(types);
|
|
|
|
|
}
|
|
|
|
|
va_end(ap);
|
1995-04-03 22:59:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-06 14:02:59 +00:00
|
|
|
|
// Managing Zones
|
|
|
|
|
|
|
|
|
|
- (NSZone*) objectZone
|
|
|
|
|
{
|
|
|
|
|
return NSDefaultMallocZone();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setObjectZone: (NSZone*)zone
|
|
|
|
|
{
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Getting a Version
|
|
|
|
|
|
|
|
|
|
- (unsigned int) systemVersion
|
|
|
|
|
{
|
2004-06-22 22:40:40 +00:00
|
|
|
|
//PENDING(ABR)- should probably mult major version by 1000, not 100, since,
|
|
|
|
|
// e.g., 2.0.0 is going to be <1000
|
2002-06-06 14:02:59 +00:00
|
|
|
|
return (((GNUSTEP_BASE_MAJOR_VERSION * 100)
|
|
|
|
|
+ GNUSTEP_BASE_MINOR_VERSION) * 100) + GNUSTEP_BASE_SUBMINOR_VERSION;
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-22 09:37:07 +00:00
|
|
|
|
|
|
|
|
|
// Keyed archiving extensions
|
|
|
|
|
|
|
|
|
|
- (BOOL) allowsKeyedCoding
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) containsValueForKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) decodeBoolForKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (const uint8_t*) decodeBytesForKey: (NSString*)aKey
|
|
|
|
|
returnedLength: (unsigned*)alength
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (double) decodeDoubleForKey: (NSString*)aKey
|
2005-02-22 11:22:44 +00:00
|
|
|
|
{
|
2004-01-22 09:37:07 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (float) decodeFloatForKey: (NSString*)aKey
|
2005-02-22 11:22:44 +00:00
|
|
|
|
{
|
2004-01-22 09:37:07 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) decodeIntForKey: (NSString*)aKey
|
2005-02-22 11:22:44 +00:00
|
|
|
|
{
|
2004-01-22 09:37:07 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int32_t) decodeInt32ForKey: (NSString*)aKey
|
2005-02-22 11:22:44 +00:00
|
|
|
|
{
|
2004-01-22 09:37:07 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int64_t) decodeInt64ForKey: (NSString*)aKey
|
2005-02-22 11:22:44 +00:00
|
|
|
|
{
|
2004-01-22 09:37:07 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) decodeObjectForKey: (NSString*)aKey
|
2005-02-22 11:22:44 +00:00
|
|
|
|
{
|
2004-01-22 09:37:07 +00:00
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeBool: (BOOL) aBool forKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeBytes: (const uint8_t*)aPointer
|
|
|
|
|
length: (unsigned)length
|
|
|
|
|
forKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeConditionalObject: (id)anObject forKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeDouble: (double)aDouble forKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeFloat: (float)aFloat forKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeInt: (int)anInteger forKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeInt32: (int32_t)anInteger forKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeInt64: (int64_t)anInteger forKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeObject: (id)anObject forKey: (NSString*)aKey
|
|
|
|
|
{
|
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-06 14:02:59 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation NSCoder (GNUstep)
|
2000-06-30 11:59:59 +00:00
|
|
|
|
- (void) decodeArrayOfObjCType: (const char*)type
|
|
|
|
|
count: (unsigned)count
|
|
|
|
|
at: (void*)buf
|
|
|
|
|
withName: (id*)name
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
if (name)
|
|
|
|
|
{
|
|
|
|
|
*name = [self decodeObject];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(void)[self decodeObject];
|
|
|
|
|
}
|
|
|
|
|
[self decodeArrayOfObjCType: type count: count at: buf];
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-28 15:41:35 +00:00
|
|
|
|
/** <override-dummy />
|
|
|
|
|
*/
|
2000-06-30 11:59:59 +00:00
|
|
|
|
- (void) decodeIndent
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) decodeObjectAt: (id*)anObject
|
|
|
|
|
withName: (id*)name
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
[self decodeValueOfObjCType: @encode(id) at: anObject withName: name];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) decodeValueOfCType: (const char*)type
|
|
|
|
|
at: (void*)buf
|
|
|
|
|
withName: (id*)name
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
[self decodeValueOfObjCType: type at: buf withName: name];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) decodeValueOfObjCType: (const char*)type
|
|
|
|
|
at: (void*)buf
|
|
|
|
|
withName: (id*)name
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
if (name != 0)
|
|
|
|
|
{
|
|
|
|
|
*name = [self decodeObject];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(void)[self decodeObject];
|
|
|
|
|
}
|
|
|
|
|
[self decodeValueOfObjCType: type at: buf];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeArrayOfObjCType: (const char*)type
|
|
|
|
|
count: (unsigned)count
|
|
|
|
|
at: (const void*)buf
|
|
|
|
|
withName: (id)name
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
[self encodeObject: name];
|
|
|
|
|
[self encodeArrayOfObjCType: type count: count at: buf];
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-28 15:41:35 +00:00
|
|
|
|
/** <override-dummy />
|
|
|
|
|
*/
|
2000-06-30 11:59:59 +00:00
|
|
|
|
- (void) encodeIndent
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeValueOfCType: (const char*)type
|
|
|
|
|
at: (const void*)buf
|
|
|
|
|
withName: (id)name
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
[self encodeValueOfObjCType: type at: buf withName: name];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeValueOfObjCType: (const char*)type
|
|
|
|
|
at: (const void*)buf
|
|
|
|
|
withName: (id)name
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
[self encodeObject: name];
|
|
|
|
|
[self encodeValueOfObjCType: type at: buf];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeObjectAt: (id*)anObject
|
|
|
|
|
withName: (id)name
|
|
|
|
|
{
|
2006-04-09 16:16:07 +00:00
|
|
|
|
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
|
2000-06-30 11:59:59 +00:00
|
|
|
|
[self encodeValueOfObjCType: @encode(id) at: anObject withName: name];
|
|
|
|
|
}
|
2004-01-22 09:37:07 +00:00
|
|
|
|
|
2004-01-25 18:39:20 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "GSPrivate.h"
|
|
|
|
|
|
|
|
|
|
@implementation _NSKeyedCoderOldStyleArray
|
|
|
|
|
- (const void*) bytes
|
|
|
|
|
{
|
|
|
|
|
return _a;
|
|
|
|
|
}
|
|
|
|
|
- (unsigned) count
|
|
|
|
|
{
|
|
|
|
|
return _c;
|
|
|
|
|
}
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
DESTROY(_d);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
- (id) initWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
|
|
|
|
id o;
|
|
|
|
|
void *address;
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
_c = [aCoder decodeIntForKey: @"NS.count"];
|
|
|
|
|
_t[0] = (char)[aCoder decodeIntForKey: @"NS.type"];
|
|
|
|
|
_t[1] = '\0';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* We decode the size from the remote end, but discard it as we
|
|
|
|
|
* are probably safer to use the local size of the datatype involved.
|
|
|
|
|
*/
|
|
|
|
|
_s = [aCoder decodeIntForKey: @"NS.size"];
|
|
|
|
|
_s = objc_sizeof_type(_t);
|
|
|
|
|
|
|
|
|
|
_d = o = [[NSMutableData alloc] initWithLength: _c * _s];
|
|
|
|
|
_a = address = [o mutableBytes];
|
|
|
|
|
for (i = 0; i < _c; i++)
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: _t at: address];
|
|
|
|
|
address += _s;
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithObjCType: (const char*)t count: (int)c at: (const void*)a
|
|
|
|
|
{
|
|
|
|
|
_t[0] = *t;
|
|
|
|
|
_t[1] = '\0';
|
|
|
|
|
_s = objc_sizeof_type(_t);
|
|
|
|
|
_c = c;
|
|
|
|
|
_a = a;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
2004-01-22 09:37:07 +00:00
|
|
|
|
|
2004-01-25 18:39:20 +00:00
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
[aCoder encodeInt: _c forKey: @"NS.count"];
|
|
|
|
|
[aCoder encodeInt: *_t forKey: @"NS.type"];
|
|
|
|
|
[aCoder encodeInt: _s forKey: @"NS.size"];
|
|
|
|
|
for (i = 0; i < _c; i++)
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeValueOfObjCType: _t at: _a];
|
|
|
|
|
_a += _s;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (unsigned) size
|
|
|
|
|
{
|
|
|
|
|
return _s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (const char*) type
|
|
|
|
|
{
|
|
|
|
|
return _t;
|
|
|
|
|
}
|
1995-04-03 22:59:20 +00:00
|
|
|
|
@end
|
2004-01-25 18:39:20 +00:00
|
|
|
|
|