mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 17:12:03 +00:00
Fixups for keyed archiving under windows.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22269 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2a3dbbcb03
commit
887b27f9b1
4 changed files with 41 additions and 18 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2006-01-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSPropertyList.m: When generating binary plist, fix bug
|
||||||
|
in case where we have to increase table size.
|
||||||
|
* Source/NSKeyedArchiver.m: Update to use binary plist format
|
||||||
|
by default rather than xml format ... MacOS-X compatible and
|
||||||
|
works when libxml2 is not available.
|
||||||
|
* Source/NSKeyedUnarchiver.m: Print NSLog error if attempting to
|
||||||
|
decode an xml archive when no libxml2 is available.
|
||||||
|
|
||||||
2006-01-08 Richard Frith-Macdonald <rfm@gnu.org>
|
2006-01-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSPathUtilities.m: be more consistent in use of defined values
|
* Source/NSPathUtilities.m: be more consistent in use of defined values
|
||||||
|
|
|
@ -786,7 +786,7 @@ static NSDictionary *makeReference(unsigned ref)
|
||||||
_obj = [NSMutableArray new]; // Array of objects.
|
_obj = [NSMutableArray new]; // Array of objects.
|
||||||
[_obj addObject: @"$null"]; // Placeholder.
|
[_obj addObject: @"$null"]; // Placeholder.
|
||||||
|
|
||||||
_format = NSPropertyListXMLFormat_v1_0; // FIXME ... should be binary.
|
_format = NSPropertyListBinaryFormat_v1_0;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -745,6 +745,13 @@ static NSMapTable globalClassMap = 0;
|
||||||
errorDescription: &error];
|
errorDescription: &error];
|
||||||
if (_archive == nil)
|
if (_archive == nil)
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_LIBXML
|
||||||
|
if (format == NSPropertyListXMLFormat_v1_0)
|
||||||
|
{
|
||||||
|
NSLog(@"Unable to parse XML archive as the base "
|
||||||
|
@"library was not configured with libxml2 support.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
DESTROY(self);
|
DESTROY(self);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -2483,7 +2483,8 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
[plData getBytes: postfix range: NSMakeRange(length-32, 32)];
|
[plData getBytes: postfix range: NSMakeRange(length-32, 32)];
|
||||||
offset_size = postfix[6];
|
offset_size = postfix[6];
|
||||||
index_size = postfix[7];
|
index_size = postfix[7];
|
||||||
table_start = (postfix[28] << 24) + (postfix[29] << 16) + (postfix[30] << 8) + postfix[31];
|
table_start = (postfix[28] << 24) + (postfix[29] << 16)
|
||||||
|
+ (postfix[30] << 8) + postfix[31];
|
||||||
if (offset_size < 1 || offset_size > 4)
|
if (offset_size < 1 || offset_size > 4)
|
||||||
{
|
{
|
||||||
[NSException raise: NSGenericException
|
[NSException raise: NSGenericException
|
||||||
|
@ -2492,9 +2493,9 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
}
|
}
|
||||||
else if (index_size < 1 || index_size > 4)
|
else if (index_size < 1 || index_size > 4)
|
||||||
{
|
{
|
||||||
|
DESTROY(self); // Bad format
|
||||||
[NSException raise: NSGenericException
|
[NSException raise: NSGenericException
|
||||||
format: @"Unknown table size %d", index_size];
|
format: @"Unknown table size %d", index_size];
|
||||||
DESTROY(self); // Bad format
|
|
||||||
}
|
}
|
||||||
else if (table_start > length - 32)
|
else if (table_start > length - 32)
|
||||||
{
|
{
|
||||||
|
@ -2541,8 +2542,10 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
unsigned char buffer[offset_size];
|
unsigned char buffer[offset_size];
|
||||||
int i;
|
int i;
|
||||||
unsigned long num = 0;
|
unsigned long num = 0;
|
||||||
|
NSRange r;
|
||||||
|
|
||||||
[data getBytes: &buffer range: NSMakeRange(table_start + offset_size*index, offset_size)];
|
r = NSMakeRange(table_start + offset_size*index, offset_size);
|
||||||
|
[data getBytes: &buffer range: r];
|
||||||
for (i = 0; i < offset_size; i++)
|
for (i = 0; i < offset_size; i++)
|
||||||
{
|
{
|
||||||
num = (num << 8) + buffer[i];
|
num = (num << 8) + buffer[i];
|
||||||
|
@ -2998,27 +3001,32 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
|
|
||||||
@implementation BinaryPLGenerator
|
@implementation BinaryPLGenerator
|
||||||
|
|
||||||
+ (void) serializePropertyList: (id)aPropertyList intoData: (NSMutableData *)destination
|
+ (void) serializePropertyList: (id)aPropertyList
|
||||||
|
intoData: (NSMutableData *)destination
|
||||||
{
|
{
|
||||||
BinaryPLGenerator *gen;
|
BinaryPLGenerator *gen;
|
||||||
|
|
||||||
gen = [[BinaryPLGenerator alloc] initWithPropertyList: aPropertyList intoData: destination];
|
gen = [[BinaryPLGenerator alloc]
|
||||||
|
initWithPropertyList: aPropertyList intoData: destination];
|
||||||
[gen generate];
|
[gen generate];
|
||||||
RELEASE(gen);
|
RELEASE(gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithPropertyList: (id) aPropertyList intoData: (NSMutableData *)destination
|
- (id) initWithPropertyList: (id) aPropertyList
|
||||||
|
intoData: (NSMutableData *)destination
|
||||||
{
|
{
|
||||||
ASSIGN(root, aPropertyList);
|
ASSIGN(root, aPropertyList);
|
||||||
ASSIGN(dest, destination);
|
ASSIGN(dest, destination);
|
||||||
|
[dest setLength: 0];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
RELEASE(root);
|
DESTROY(root);
|
||||||
[self cleanup];
|
[self cleanup];
|
||||||
|
DESTROY(dest);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3029,6 +3037,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
|
|
||||||
- (void) setup
|
- (void) setup
|
||||||
{
|
{
|
||||||
|
[dest setLength: 0];
|
||||||
if (index_size == 1)
|
if (index_size == 1)
|
||||||
{
|
{
|
||||||
table_size = 256;
|
table_size = 256;
|
||||||
|
@ -3048,8 +3057,6 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
|
|
||||||
table = malloc(table_size * sizeof(int));
|
table = malloc(table_size * sizeof(int));
|
||||||
|
|
||||||
// Always restart the destination data
|
|
||||||
[dest setLength: 0];
|
|
||||||
objectsToDoList = [[NSMutableArray alloc] init];
|
objectsToDoList = [[NSMutableArray alloc] init];
|
||||||
objectList = [[NSMutableArray alloc] init];
|
objectList = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
|
@ -3059,7 +3066,6 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
|
|
||||||
- (void) cleanup
|
- (void) cleanup
|
||||||
{
|
{
|
||||||
DESTROY(dest);
|
|
||||||
DESTROY(objectsToDoList);
|
DESTROY(objectsToDoList);
|
||||||
DESTROY(objectList);
|
DESTROY(objectList);
|
||||||
if (table != NULL)
|
if (table != NULL)
|
||||||
|
@ -3112,7 +3118,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
unsigned int last_offset;
|
unsigned int last_offset;
|
||||||
|
|
||||||
table_start = [dest length];
|
table_start = [dest length];
|
||||||
// This is a bit to much, as the length
|
// This is a bit too much, as the length
|
||||||
// of the last object is added.
|
// of the last object is added.
|
||||||
last_offset = table_start;
|
last_offset = table_start;
|
||||||
|
|
||||||
|
@ -3135,7 +3141,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
[NSException raise: NSRangeException
|
||||||
format: @"Object table offset out of bounds %d.", last_offset];
|
format: @"Object table offset out of bounds %d.", last_offset];
|
||||||
}
|
}
|
||||||
|
|
||||||
len = [objectList count];
|
len = [objectList count];
|
||||||
|
@ -3349,12 +3355,12 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
[dest appendBytes: [string cString] length: len];
|
[dest appendBytes: [string cString] length: len];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
code = 0x5F;
|
code = 0x5F;
|
||||||
[dest appendBytes: &code length: 1];
|
[dest appendBytes: &code length: 1];
|
||||||
[self storeCount: len];
|
[self storeCount: len];
|
||||||
[dest appendBytes: [string cString] length: len];
|
[dest appendBytes: [string cString] length: len];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3387,7 +3393,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
}
|
}
|
||||||
[dest appendBytes: buffer length: sizeof(unichar)*len];
|
[dest appendBytes: buffer length: sizeof(unichar)*len];
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3484,7 +3490,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
[NSException raise: NSGenericException
|
[NSException raise: NSGenericException
|
||||||
format: @"Attempt to store number with unknown ObjC type"];
|
format: @"Attempt to store number with unknown ObjC type"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3639,7 +3645,7 @@ GSPropertyListMake(id obj, NSDictionary *loc, BOOL xml,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"Unknown object class %@", object);
|
NSLog(@"Unknown object class %@", object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue