Get parser to spot unimplemented methods.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22109 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2005-11-28 12:36:47 +00:00
parent 68adb8fba4
commit 96bf1f940e
5 changed files with 121 additions and 33 deletions

View file

@ -1,3 +1,11 @@
2005-11-28 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/AGSOutput.m:
* Tools/AGSParser.h:
* Tools/AGSParser.m:
Update to log warning about unimplemented methods which are not
tagged as "<override-subclass />". ie intentionally empty.
2005-11-22 Richard Frith-Macdonald <rfm@gnu.org> 2005-11-22 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPathUtilities.m: Restructure so that GNUstepConfig() can * Source/NSPathUtilities.m: Restructure so that GNUstepConfig() can

View file

@ -39,26 +39,26 @@
- (NSString*) checkComment: (NSString*)comment - (NSString*) checkComment: (NSString*)comment
unit: (NSString*)unit unit: (NSString*)unit
info: (NSDictionary*)d; info: (NSMutableDictionary*)d;
- (unsigned) fitWords: (NSArray*)a - (unsigned) fitWords: (NSArray*)a
from: (unsigned)start from: (unsigned)start
to: (unsigned)end to: (unsigned)end
maxSize: (unsigned)limit maxSize: (unsigned)limit
output: (NSMutableString*)buf; output: (NSMutableString*)buf;
- (NSArray*) output: (NSDictionary*)d; - (NSArray*) output: (NSMutableDictionary*)d;
- (void) outputDecl: (NSDictionary*)d - (void) outputDecl: (NSMutableDictionary*)d
kind: (NSString*)kind kind: (NSString*)kind
to: (NSMutableString*)str; to: (NSMutableString*)str;
- (void) outputFunction: (NSDictionary*)d to: (NSMutableString*)str; - (void) outputFunction: (NSMutableDictionary*)d to: (NSMutableString*)str;
- (void) outputInstanceVariable: (NSDictionary*)d - (void) outputInstanceVariable: (NSMutableDictionary*)d
to: (NSMutableString*)str to: (NSMutableString*)str
for: (NSString*)unit; for: (NSString*)unit;
- (void) outputMacro: (NSDictionary*)d - (void) outputMacro: (NSMutableDictionary*)d
to: (NSMutableString*)str; to: (NSMutableString*)str;
- (void) outputMethod: (NSDictionary*)d - (void) outputMethod: (NSMutableDictionary*)d
to: (NSMutableString*)str to: (NSMutableString*)str
for: (NSString*)unit; for: (NSString*)unit;
- (void) outputUnit: (NSDictionary*)d to: (NSMutableString*)str; - (void) outputUnit: (NSMutableDictionary*)d to: (NSMutableString*)str;
- (unsigned) reformat: (NSString*)str - (unsigned) reformat: (NSString*)str
withIndent: (unsigned)ind withIndent: (unsigned)ind
to: (NSMutableString*)buf; to: (NSMutableString*)buf;

View file

@ -97,7 +97,10 @@ static BOOL snuggleStart(NSString *t)
unit: (NSString*)unit unit: (NSString*)unit
info: (NSDictionary*)d info: (NSDictionary*)d
{ {
if ([comment length] == 0) NSString *empty = [d objectForKey: @"Empty"];
BOOL hadComment = ([comment length] == 0 ? NO : YES);
if (hadComment == NO)
{ {
comment = @"<em>Description forthcoming.</em>"; comment = @"<em>Description forthcoming.</em>";
if (warn == YES) if (warn == YES)
@ -130,6 +133,38 @@ static BOOL snuggleStart(NSString *t)
} }
} }
} }
if (empty != nil && [empty boolValue] == YES)
{
#if 0
static NSString *today = nil;
if (today == nil)
{
NSCalendarDate *d = [NSCalendarDate date];
today
= RETAIN([d descriptionWithCalendarFormat: @"%d-%m-%Y"]);
}
if (hadComment == NO)
{
comment = @"";
}
comment = [NSString stringWithFormat:
@"<em>Not implemented (as of %@).</em><br />"
@"Please help us by producing an implementation of this "
@"and donating it to the GNUstep project.<br />"
@"You can check the task manager at "
@"https://savannah.gnu.org/projects/gnustep "
@"to see if anyone is already working on it.<br />",
today, comment];
#else
NSString *name = [d objectForKey: @"Name"];
NSLog(@"Warning - No implementation for [%@ %@]", unit, name);
#endif
}
return comment; return comment;
} }
@ -251,7 +286,7 @@ static BOOL snuggleStart(NSString *t)
* Return an array containing the names of any files modified as * Return an array containing the names of any files modified as
* a result of outputing the specified data structure. * a result of outputing the specified data structure.
*/ */
- (NSArray*) output: (NSDictionary*)d - (NSArray*) output: (NSMutableDictionary*)d
{ {
NSMutableString *str = [NSMutableString stringWithCapacity: 10240]; NSMutableString *str = [NSMutableString stringWithCapacity: 10240];
NSDictionary *classes; NSDictionary *classes;
@ -435,8 +470,8 @@ static BOOL snuggleStart(NSString *t)
names = [names sortedArrayUsingSelector: @selector(compare:)]; names = [names sortedArrayUsingSelector: @selector(compare:)];
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
{ {
NSString *name = [names objectAtIndex: i]; NSString *name = [names objectAtIndex: i];
NSDictionary *d = [classes objectForKey: name]; NSMutableDictionary *d = [classes objectForKey: name];
[self outputUnit: d to: str]; [self outputUnit: d to: str];
} }
@ -453,8 +488,8 @@ static BOOL snuggleStart(NSString *t)
names = [names sortedArrayUsingSelector: @selector(compare:)]; names = [names sortedArrayUsingSelector: @selector(compare:)];
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
{ {
NSString *name = [names objectAtIndex: i]; NSString *name = [names objectAtIndex: i];
NSDictionary *d = [categories objectForKey: name]; NSMutableDictionary *d = [categories objectForKey: name];
[self outputUnit: d to: str]; [self outputUnit: d to: str];
} }
@ -471,8 +506,8 @@ static BOOL snuggleStart(NSString *t)
names = [names sortedArrayUsingSelector: @selector(compare:)]; names = [names sortedArrayUsingSelector: @selector(compare:)];
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
{ {
NSString *name = [names objectAtIndex: i]; NSString *name = [names objectAtIndex: i];
NSDictionary *d = [protocols objectForKey: name]; NSMutableDictionary *d = [protocols objectForKey: name];
[self outputUnit: d to: str]; [self outputUnit: d to: str];
} }
@ -493,8 +528,8 @@ static BOOL snuggleStart(NSString *t)
names = [names sortedArrayUsingSelector: @selector(compare:)]; names = [names sortedArrayUsingSelector: @selector(compare:)];
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
{ {
NSString *name = [names objectAtIndex: i]; NSString *name = [names objectAtIndex: i];
NSDictionary *d = [types objectForKey: name]; NSMutableDictionary *d = [types objectForKey: name];
[self outputDecl: d kind: @"type" to: m]; [self outputDecl: d kind: @"type" to: m];
} }
@ -529,8 +564,8 @@ static BOOL snuggleStart(NSString *t)
names = [names sortedArrayUsingSelector: @selector(compare:)]; names = [names sortedArrayUsingSelector: @selector(compare:)];
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
{ {
NSString *name = [names objectAtIndex: i]; NSString *name = [names objectAtIndex: i];
NSDictionary *d = [constants objectForKey: name]; NSMutableDictionary *d = [constants objectForKey: name];
[self outputDecl: d kind: @"constant" to: m]; [self outputDecl: d kind: @"constant" to: m];
} }
@ -565,8 +600,8 @@ static BOOL snuggleStart(NSString *t)
names = [names sortedArrayUsingSelector: @selector(compare:)]; names = [names sortedArrayUsingSelector: @selector(compare:)];
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
{ {
NSString *name = [names objectAtIndex: i]; NSString *name = [names objectAtIndex: i];
NSDictionary *d = [macros objectForKey: name]; NSMutableDictionary *d = [macros objectForKey: name];
[self outputMacro: d to: m]; [self outputMacro: d to: m];
} }
@ -601,8 +636,8 @@ static BOOL snuggleStart(NSString *t)
names = [names sortedArrayUsingSelector: @selector(compare:)]; names = [names sortedArrayUsingSelector: @selector(compare:)];
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
{ {
NSString *name = [names objectAtIndex: i]; NSString *name = [names objectAtIndex: i];
NSDictionary *d = [variables objectForKey: name]; NSMutableDictionary *d = [variables objectForKey: name];
[self outputDecl: d kind: @"variable" to: m]; [self outputDecl: d kind: @"variable" to: m];
} }
@ -637,8 +672,8 @@ static BOOL snuggleStart(NSString *t)
names = [names sortedArrayUsingSelector: @selector(compare:)]; names = [names sortedArrayUsingSelector: @selector(compare:)];
for (i = 0; i < c; i++) for (i = 0; i < c; i++)
{ {
NSString *name = [names objectAtIndex: i]; NSString *name = [names objectAtIndex: i];
NSDictionary *d = [functions objectForKey: name]; NSMutableDictionary *d = [functions objectForKey: name];
[self outputFunction: d to: m]; [self outputFunction: d to: m];
} }
@ -686,7 +721,7 @@ static BOOL snuggleStart(NSString *t)
/** /**
* Uses -split: and -reformat:withIndent:to:. * Uses -split: and -reformat:withIndent:to:.
*/ */
- (void) outputDecl: (NSDictionary*)d - (void) outputDecl: (NSMutableDictionary*)d
kind: (NSString*)kind kind: (NSString*)kind
to: (NSMutableString*)str to: (NSMutableString*)str
{ {
@ -730,7 +765,7 @@ static BOOL snuggleStart(NSString *t)
/** /**
* Uses -split: and -reformat:withIndent:to:. * Uses -split: and -reformat:withIndent:to:.
*/ */
- (void) outputFunction: (NSDictionary*)d to: (NSMutableString*)str - (void) outputFunction: (NSMutableDictionary*)d to: (NSMutableString*)str
{ {
NSArray *aa = [d objectForKey: @"Args"]; NSArray *aa = [d objectForKey: @"Args"];
NSString *pref = [d objectForKey: @"Prefix"]; NSString *pref = [d objectForKey: @"Prefix"];
@ -828,7 +863,7 @@ static BOOL snuggleStart(NSString *t)
/** /**
* Output the gsdoc code for an instance variable. * Output the gsdoc code for an instance variable.
*/ */
- (void) outputInstanceVariable: (NSDictionary*)d - (void) outputInstanceVariable: (NSMutableDictionary*)d
to: (NSMutableString*)str to: (NSMutableString*)str
for: (NSString*)unit for: (NSString*)unit
{ {
@ -865,7 +900,7 @@ static BOOL snuggleStart(NSString *t)
/** /**
* Uses -split: and -reformat:withIndent:to:. * Uses -split: and -reformat:withIndent:to:.
*/ */
- (void) outputMacro: (NSDictionary*)d - (void) outputMacro: (NSMutableDictionary*)d
to: (NSMutableString*)str to: (NSMutableString*)str
{ {
NSString *name = [d objectForKey: @"Name"]; NSString *name = [d objectForKey: @"Name"];
@ -916,7 +951,7 @@ static BOOL snuggleStart(NSString *t)
* Uses -split: and -reformat:withIndent:to:. * Uses -split: and -reformat:withIndent:to:.
* Also has fun with YES, NO, and nil. * Also has fun with YES, NO, and nil.
*/ */
- (void) outputMethod: (NSDictionary*)d - (void) outputMethod: (NSMutableDictionary*)d
to: (NSMutableString*)str to: (NSMutableString*)str
for: (NSString*)unit for: (NSString*)unit
{ {
@ -983,6 +1018,11 @@ static BOOL snuggleStart(NSString *t)
[m deleteCharactersInRange: r]; [m deleteCharactersInRange: r];
comment = m; comment = m;
override = @"subclass"; override = @"subclass";
/*
* If a method should be overridden by subclasses,
* we don't treat it as unimplemented.
*/
[d setObject: @"NO" forKey: @"Empty"];
} }
} while (r.length > 0); } while (r.length > 0);
do do
@ -1055,7 +1095,7 @@ static BOOL snuggleStart(NSString *t)
args = nil; args = nil;
} }
- (void) outputUnit: (NSDictionary*)d to: (NSMutableString*)str - (void) outputUnit: (NSMutableDictionary*)d to: (NSMutableString*)str
{ {
NSString *name = [d objectForKey: @"Name"]; NSString *name = [d objectForKey: @"Name"];
NSString *type = [d objectForKey: @"Type"]; NSString *type = [d objectForKey: @"Type"];

View file

@ -101,6 +101,7 @@
- (void) setupBuffer; - (void) setupBuffer;
- (unsigned) skipArray; - (unsigned) skipArray;
- (unsigned) skipBlock; - (unsigned) skipBlock;
- (unsigned) skipBlock: (BOOL*)isEmpty;
- (unsigned) skipLiteral; - (unsigned) skipLiteral;
- (unsigned) skipRemainderOfLine; - (unsigned) skipRemainderOfLine;
- (unsigned) skipSpaces; - (unsigned) skipSpaces;

View file

@ -2513,7 +2513,17 @@ fail:
} }
else if (term == '{') else if (term == '{')
{ {
[self skipBlock]; BOOL isEmpty;
[self skipBlock: &isEmpty];
if (isEmpty == YES)
{
[method setObject: @"YES" forKey: @"Empty"];
}
else
{
[method setObject: @"NO" forKey: @"Empty"];
}
} }
/* /*
@ -2621,6 +2631,7 @@ fail:
NSArray *a1; NSArray *a1;
NSString *c0; NSString *c0;
NSString *c1; NSString *c1;
NSString *e;
/* /*
* Merge info from implementation into existing version. * Merge info from implementation into existing version.
@ -2668,6 +2679,15 @@ fail:
[self appendComment: c1 to: exist]; [self appendComment: c1 to: exist];
} }
[exist setObject: @"YES" forKey: @"Implemented"]; [exist setObject: @"YES" forKey: @"Implemented"];
/*
* Record if the implementation is not empty.
*/
e = [method objectForKey: @"Empty"];
if (e != nil)
{
[exist setObject: e forKey: @"Empty"];
}
} }
DESTROY(comment); // Don't want this. DESTROY(comment); // Don't want this.
break; break;
@ -3699,8 +3719,14 @@ fail:
* bracket at the start of a block. * bracket at the start of a block.
*/ */
- (unsigned) skipBlock - (unsigned) skipBlock
{
return [self skipBlock: 0];
}
- (unsigned) skipBlock: (BOOL*)isEmpty
{ {
unichar term = '}'; unichar term = '}';
BOOL empty = YES;
if (buffer[pos] == '(') if (buffer[pos] == '(')
{ {
@ -3723,21 +3749,25 @@ fail:
case '\'': case '\'':
case '"': case '"':
empty = NO;
pos--; pos--;
[self skipLiteral]; [self skipLiteral];
break; break;
case '{': case '{':
empty = NO;
pos--; pos--;
[self skipBlock]; [self skipBlock];
break; break;
case '(': case '(':
empty = NO;
pos--; pos--;
[self skipBlock]; [self skipBlock];
break; break;
case '[': case '[':
empty = NO;
pos--; pos--;
[self skipBlock]; [self skipBlock];
break; break;
@ -3745,10 +3775,19 @@ fail:
default: default:
if (c == term) if (c == term)
{ {
if (isEmpty != 0)
{
*isEmpty = empty;
}
return pos; return pos;
} }
empty = NO;
} }
} }
if (isEmpty != 0)
{
*isEmpty = empty;
}
return pos; return pos;
} }