mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Various tidyups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@12085 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
237c04eca6
commit
6524175a99
4 changed files with 98 additions and 48 deletions
|
@ -1,3 +1,11 @@
|
|||
2002-01-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Foundation/NSArchiver.h: tidyups
|
||||
* Source/NSDictionary.m: tidyups
|
||||
* Tools/AGSParser.m: a couple of declaration parsing fixes added,
|
||||
along with quite a bit of debugging. Function declaration parsing
|
||||
not yet working.
|
||||
|
||||
2002-01-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSDistributedNotificationCentre.m: Use NSHost user default
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
@interface NSDictionary : NSObject <NSCoding, NSCopying, NSMutableCopying>
|
||||
+ (id) dictionary;
|
||||
+ (id) dictionaryWithContentsOfFile: (NSString*)path;
|
||||
+ (id) dictionaryWithDictionary: (NSDictionary*)aDict;
|
||||
+ (id) dictionaryWithDictionary: (NSDictionary*)otherDictionary;
|
||||
+ (id) dictionaryWithObject: (id)object forKey: (id)key;
|
||||
+ (id) dictionaryWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
|
||||
+ (id) dictionaryWithObjects: (id*)objects
|
||||
forKeys: (id*)keys
|
||||
count: (unsigned)count;
|
||||
+ (id) dictionaryWithObjectsAndKeys: (id)object, ...;
|
||||
+ (id) dictionaryWithObjectsAndKeys: (id)firstObject, ...;
|
||||
|
||||
- (NSArray*) allKeys;
|
||||
- (NSArray*) allKeysForObject: (id)anObject;
|
||||
|
@ -51,10 +51,9 @@
|
|||
|
||||
- (id) initWithContentsOfFile: (NSString*)path;
|
||||
- (id) initWithDictionary: (NSDictionary*)otherDictionary;
|
||||
- (id) initWithDictionary: (NSDictionary*)otherDictionary
|
||||
copyItems: (BOOL)shouldCopy;
|
||||
- (id) initWithDictionary: (NSDictionary*)other copyItems: (BOOL)shouldCopy;
|
||||
- (id) initWithObjects: (NSArray*)objects forKeys: (NSArray*)keys;
|
||||
- (id) initWithObjectsAndKeys: (id)object, ...;
|
||||
- (id) initWithObjectsAndKeys: (id)firstObject, ...;
|
||||
- (id) initWithObjects: (id*)objects
|
||||
forKeys: (id*)keys
|
||||
count: (unsigned)count; // Primitive
|
||||
|
@ -64,11 +63,11 @@
|
|||
- (NSArray*) keysSortedByValueUsingSelector: (SEL)comp;
|
||||
- (NSEnumerator*) objectEnumerator; // Primitive
|
||||
- (id) objectForKey: (id)aKey; // Primitive
|
||||
- (NSArray*) objectsForKeys: (NSArray*)keys notFoundMarker: (id)anObject;
|
||||
- (NSArray*) objectsForKeys: (NSArray*)keys notFoundMarker: (id)marker;
|
||||
|
||||
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxilliaryFile;
|
||||
- (BOOL) writeToFile: (NSString*)path atomically: (BOOL)useAuxiliaryFile;
|
||||
#ifndef STRICT_OPENSTEP
|
||||
- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxilliaryFile;
|
||||
- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile;
|
||||
#endif
|
||||
@end
|
||||
|
||||
|
|
|
@ -87,14 +87,14 @@ static Class NSMutableDataMallocClass;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (id) initForWritingWithMutableData: (NSMutableData*)anObject
|
||||
- (id) initForWritingWithMutableData: (NSMutableData*)mdata
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
NSZone *zone = [self zone];
|
||||
|
||||
_data = RETAIN(anObject);
|
||||
_data = RETAIN(mdata);
|
||||
if ([self directDataAccess] == YES)
|
||||
{
|
||||
_dst = _data;
|
||||
|
@ -951,24 +951,25 @@ static Class NSMutableDataMallocClass;
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (void) serializeHeaderAt: (unsigned)locationInData
|
||||
version: (unsigned)v
|
||||
classes: (unsigned)cc
|
||||
objects: (unsigned)oc
|
||||
pointers: (unsigned)pc
|
||||
- (void) serializeHeaderAt: (unsigned)positionInData
|
||||
version: (unsigned)systemVersion
|
||||
classes: (unsigned)classCount
|
||||
objects: (unsigned)objectCount
|
||||
pointers: (unsigned)pointerCount
|
||||
{
|
||||
unsigned headerLength = strlen(PREFIX)+36;
|
||||
char header[headerLength+1];
|
||||
unsigned dataLength = [_data length];
|
||||
|
||||
sprintf(header, "%s%08x:%08x:%08x:%08x:", PREFIX, v, cc, oc, pc);
|
||||
sprintf(header, "%s%08x:%08x:%08x:%08x:", PREFIX, systemVersion, classCount,
|
||||
objectCount, pointerCount);
|
||||
|
||||
if (locationInData + headerLength <= dataLength)
|
||||
if (positionInData + headerLength <= dataLength)
|
||||
{
|
||||
[_data replaceBytesInRange: NSMakeRange(locationInData, headerLength)
|
||||
[_data replaceBytesInRange: NSMakeRange(positionInData, headerLength)
|
||||
withBytes: header];
|
||||
}
|
||||
else if (locationInData == dataLength)
|
||||
else if (positionInData == dataLength)
|
||||
{
|
||||
[_data appendBytes: header length: headerLength];
|
||||
}
|
||||
|
|
|
@ -176,12 +176,14 @@
|
|||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
static NSSet *qualifiers = nil;
|
||||
static NSSet *keep = nil;
|
||||
NSString *baseType = nil;
|
||||
NSString *declName = nil;
|
||||
NSMutableArray *a1;
|
||||
NSMutableArray *a2;
|
||||
NSString *s;
|
||||
BOOL isTypedef = NO;
|
||||
BOOL needScalarType = NO;
|
||||
|
||||
if (qualifiers == nil)
|
||||
{
|
||||
|
@ -200,6 +202,15 @@
|
|||
@"volatile",
|
||||
nil];
|
||||
RETAIN(qualifiers);
|
||||
keep = [NSSet setWithObjects:
|
||||
@"const",
|
||||
@"long",
|
||||
@"short",
|
||||
@"signed",
|
||||
@"unsigned",
|
||||
@"volatile",
|
||||
nil];
|
||||
RETAIN(keep);
|
||||
}
|
||||
|
||||
a1 = [NSMutableArray array];
|
||||
|
@ -228,21 +239,17 @@
|
|||
{
|
||||
isTypedef = YES;
|
||||
}
|
||||
[a1 addObject: s];
|
||||
if ([keep member: s] != nil)
|
||||
{
|
||||
[a1 addObject: s];
|
||||
if ([s isEqual: @"const"] == NO && [s isEqual: @"volatile"] == NO)
|
||||
{
|
||||
needScalarType = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
baseType = s;
|
||||
if (baseType == nil)
|
||||
{
|
||||
/*
|
||||
* If there is no identifier here, the line must have been
|
||||
* something like 'unsigned *length' so we must set the default
|
||||
* base type of 'int'
|
||||
*/
|
||||
baseType = @"int";
|
||||
}
|
||||
|
||||
/**
|
||||
* We handle struct, union, and enum declarations by skipping the
|
||||
* stuff enclosed in curly braces. If there was an identifier
|
||||
|
@ -253,6 +260,7 @@
|
|||
|| [s isEqualToString: @"union"] == YES
|
||||
|| [s isEqualToString: @"enum"] == YES)
|
||||
{
|
||||
baseType = s;
|
||||
s = [self parseIdentifier];
|
||||
if (s == nil)
|
||||
{
|
||||
|
@ -266,20 +274,44 @@
|
|||
{
|
||||
[self skipBlock];
|
||||
}
|
||||
s = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
baseType = s;
|
||||
if (baseType == nil)
|
||||
{
|
||||
/*
|
||||
* If there is no identifier here, the line must have been
|
||||
* something like 'unsigned *length' so we must set the default
|
||||
* base type of 'int'
|
||||
*/
|
||||
baseType = @"int";
|
||||
}
|
||||
else if (needScalarType == YES
|
||||
&& [s isEqualToString: @"char"] == NO
|
||||
&& [s isEqualToString: @"int"] == NO)
|
||||
{
|
||||
/*
|
||||
* If we had something like 'unsigned' in the qualifiers, we must
|
||||
* have a 'char' or an 'int', and if we didn't find one we should
|
||||
* insert one and use what we found as the variable name.
|
||||
*/
|
||||
baseType = @"int";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = nil; // s used as baseType
|
||||
}
|
||||
}
|
||||
|
||||
declName = [self parseDeclaratorInto: a2];
|
||||
if (declName == nil)
|
||||
if (s == nil)
|
||||
{
|
||||
/*
|
||||
* If there is no identifier here, the line must have been
|
||||
* something like 'unsigned length' and we assumed that 'length'
|
||||
* was the base type rather than the declared name.
|
||||
* The fix is to set the base type to be 'int' and use the value
|
||||
* we had as the declaration name.
|
||||
*/
|
||||
declName = baseType;
|
||||
baseType = @"int";
|
||||
declName = [self parseDeclaratorInto: a2];
|
||||
}
|
||||
else
|
||||
{
|
||||
declName = s;
|
||||
}
|
||||
|
||||
[a1 addObject: baseType];
|
||||
|
@ -332,6 +364,7 @@
|
|||
else
|
||||
{
|
||||
[self log: @"unexpected char (%c) parsing declaration", buffer[pos]];
|
||||
[self skipStatement];
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -466,9 +499,9 @@ fail:
|
|||
/*
|
||||
* Must be some sort of declaration ...
|
||||
*/
|
||||
// pos--;
|
||||
// [self parseDeclIsSource: isSource];
|
||||
[self skipStatementLine];
|
||||
pos--;
|
||||
[self parseDeclIsSource: isSource];
|
||||
// [self skipStatementLine];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1223,6 +1256,7 @@ fail:
|
|||
if ((token = [self parseIdentifier]) == nil)
|
||||
{
|
||||
[self log: @"method list with error after '@'"];
|
||||
[self skipStatementLine];
|
||||
return nil;
|
||||
}
|
||||
if ([token isEqual: @"end"] == YES)
|
||||
|
@ -1236,12 +1270,11 @@ fail:
|
|||
* normal C statement, it ends with a semicolon.
|
||||
*/
|
||||
[self skipStatementLine];
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self log: @"@method list with unknown directive '%@'", token];
|
||||
return nil;
|
||||
[self skipStatementLine];
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1258,7 +1291,16 @@ fail:
|
|||
/*
|
||||
* Some statement other than a method ... skip and delete comments.
|
||||
*/
|
||||
[self skipStatementLine];
|
||||
if (flag == YES)
|
||||
{
|
||||
[self log: @"interface with bogus line ... we expect methods"];
|
||||
[self skipStatementLine];
|
||||
}
|
||||
else
|
||||
{
|
||||
pos--;
|
||||
[self parseDeclIsSource: YES];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue