mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Add diagnostic code and implement lookup for metods in informal protocols
This commit is contained in:
parent
fa30cfa93a
commit
57f066442e
6 changed files with 115 additions and 20 deletions
|
@ -256,7 +256,6 @@ Base_AGSDOC_FLAGS = \
|
|||
-MacrosTemplate Functions \
|
||||
-TypedefsTemplate TypesAndConstants \
|
||||
-VariablesTemplate TypesAndConstants \
|
||||
-Verbose YES \
|
||||
-WordMap '{\
|
||||
}' -Up Base
|
||||
|
||||
|
@ -272,7 +271,6 @@ BaseAdditions_AGSDOC_FLAGS = \
|
|||
-MacrosTemplate Functions \
|
||||
-TypedefsTemplate TypesAndConstants \
|
||||
-VariablesTemplate TypesAndConstants \
|
||||
-Verbose YES \
|
||||
-WordMap '{\
|
||||
}' -Up BaseAdditions
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
unsigned ssect;
|
||||
unsigned sssect;
|
||||
}
|
||||
- (NSArray*) find: (NSString*)key;
|
||||
- (NSString*) globalRef: (NSString*)ref type: (NSString*)type;
|
||||
- (void) makeRefs: (GSXMLNode*)node;
|
||||
- (void) mergeRefs: (NSDictionary*)more override: (BOOL)flag;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
#import "AGSIndex.h"
|
||||
#import "GNUstepBase/NSString+GNUstepBase.h"
|
||||
#import "GNUstepBase/NSMutableString+GNUstepBase.h"
|
||||
|
@ -57,29 +58,31 @@ mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src, BOOL override)
|
|||
[stack addObject: k];
|
||||
if (d == nil)
|
||||
{
|
||||
if ([s isKindOfClass: [NSString class]] == YES)
|
||||
if ([s isKindOfClass: [NSString class]])
|
||||
{
|
||||
[dst setObject: s forKey: k];
|
||||
}
|
||||
else if ([s isKindOfClass: [NSArray class]] == YES)
|
||||
else if ([s isKindOfClass: [NSArray class]])
|
||||
{
|
||||
[dst setObject: s forKey: k];
|
||||
}
|
||||
else if ([s isKindOfClass: [NSDictionary class]] == YES)
|
||||
else if ([s isKindOfClass: [NSDictionary class]])
|
||||
{
|
||||
d = [[NSMutableDictionary alloc] initWithCapacity: [s count]];
|
||||
[dst setObject: d forKey: k];
|
||||
RELEASE(d);
|
||||
/* Fall through to populate the new dictionary.
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Unexpected class in merge %@ ignored", stack);
|
||||
d = nil;
|
||||
}
|
||||
}
|
||||
|
||||
if (d != nil)
|
||||
{
|
||||
if ([d isKindOfClass: [NSString class]] == YES)
|
||||
if ([d isKindOfClass: [NSString class]])
|
||||
{
|
||||
if ([s isKindOfClass: [NSString class]] == NO)
|
||||
{
|
||||
|
@ -99,7 +102,7 @@ mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src, BOOL override)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ([d isKindOfClass: [NSArray class]] == YES)
|
||||
else if ([d isKindOfClass: [NSArray class]])
|
||||
{
|
||||
if ([s isKindOfClass: [NSArray class]] == NO)
|
||||
{
|
||||
|
@ -118,7 +121,7 @@ mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src, BOOL override)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ([d isKindOfClass: [NSDictionary class]] == YES)
|
||||
else if ([d isKindOfClass: [NSDictionary class]])
|
||||
{
|
||||
if ([s isKindOfClass: [NSDictionary class]] == NO)
|
||||
{
|
||||
|
@ -202,6 +205,54 @@ setDirectory(NSMutableDictionary *dict, NSString *path)
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
static void
|
||||
findKey(id refs, NSString *key, NSMutableArray *path, NSMutableArray *found)
|
||||
{
|
||||
if ([refs isKindOfClass: [NSDictionary class]])
|
||||
{
|
||||
if ([refs objectForKey: key])
|
||||
{
|
||||
[found addObject: AUTORELEASE([path copy])];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSEnumerator *e = [refs keyEnumerator];
|
||||
NSString *k;
|
||||
|
||||
while ((k = [e nextObject]) != nil)
|
||||
{
|
||||
[path addObject: k];
|
||||
findKey([refs objectForKey: k], key, path, found);
|
||||
[path removeLastObject];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ([refs isKindOfClass: [NSArray class]])
|
||||
{
|
||||
if ([refs containsObject: key])
|
||||
{
|
||||
[found addObject: AUTORELEASE([path copy])];
|
||||
}
|
||||
}
|
||||
else if ([refs isEqual: key])
|
||||
{
|
||||
[found addObject: AUTORELEASE([path copy])];
|
||||
}
|
||||
}
|
||||
|
||||
/** Looks for a string as a key or value in the index,
|
||||
* and returns the paths to any occurrences found.
|
||||
* Returns nil if the string is not found.
|
||||
*/
|
||||
- (NSArray*) find: (NSString*)key
|
||||
{
|
||||
NSMutableArray *path = [NSMutableArray arrayWithCapacity: 10];
|
||||
NSMutableArray *found = [NSMutableArray arrayWithCapacity: 10];
|
||||
|
||||
findKey(refs, key, path, found);
|
||||
return ([found count] ? found : nil);
|
||||
}
|
||||
|
||||
- (NSString*) globalRef: (NSString*)ref type: (NSString*)type
|
||||
{
|
||||
NSDictionary *t;
|
||||
|
@ -767,13 +818,29 @@ setDirectory(NSMutableDictionary *dict, NSString *path)
|
|||
if ([*u length] > 0 && [*u characterAtIndex: [*u length] - 1] == ')')
|
||||
{
|
||||
*u = [*u substringToIndex: [*u rangeOfString: @"("].location];
|
||||
s = [t objectForKey: *u];
|
||||
if (s != nil)
|
||||
if ((s = [t objectForKey: *u]) != nil)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
/* For a method lookup, try an informal protocol of the class
|
||||
*/
|
||||
if ([*u length] > 0 && [type isEqual: @"method"])
|
||||
{
|
||||
NSString *p = [NSString stringWithFormat: @"(%@)", *u];
|
||||
|
||||
if ((s = [t objectForKey: p]) != nil)
|
||||
{
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey: @"Warn"])
|
||||
{
|
||||
NSLog(@"Warning - found %@ only in informal protocol of %@",
|
||||
ref, *u);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try all superclasses in turn.
|
||||
*/
|
||||
|
|
|
@ -91,8 +91,8 @@ static BOOL snuggleStart(NSString *t)
|
|||
* And finally, here is the actual class description ... outside the chapter.
|
||||
* This is the class description for <code>AGSOutput</code>, including some
|
||||
* sample uses of GSDoc, such as cross-references (see [NSString]).
|
||||
* Functions, like escapeType(), are automatically referenced (if they are
|
||||
* found).
|
||||
* Functions, (recognised as an identifier immediately followed by open and
|
||||
* closing brackets), are automatically referenced (if they are found).
|
||||
*/
|
||||
@implementation AGSOutput
|
||||
|
||||
|
|
|
@ -66,7 +66,6 @@ BaseTools_AGSDOC_FLAGS = \
|
|||
-HeaderDirectory ../Tools \
|
||||
-Standards YES \
|
||||
-DTDs ../Tools \
|
||||
-Verbose YES \
|
||||
-WordMap '{\
|
||||
}' -Up BaseTools
|
||||
|
||||
|
|
|
@ -1021,6 +1021,10 @@ main(int argc, char **argv, char **env)
|
|||
NSDictionary *dict;
|
||||
|
||||
[projectRefs mergeRefs: originalIndex override: NO];
|
||||
if (verbose)
|
||||
{
|
||||
NSLog(@"Initialised projectRefs from %@", refsFile);
|
||||
}
|
||||
dict = [mgr fileAttributesAtPath: refsFile traverseLink: YES];
|
||||
rDate = [dict fileModificationDate];
|
||||
}
|
||||
|
@ -1596,8 +1600,10 @@ main(int argc, char **argv, char **env)
|
|||
count = [gFiles count];
|
||||
if (count > 0)
|
||||
{
|
||||
NSDictionary *projectIndex;
|
||||
NSMutableArray *merged
|
||||
= [[NSMutableArray alloc] initWithCapacity: count];
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSDictionary *projectIndex;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -1685,6 +1691,7 @@ main(int argc, char **argv, char **env)
|
|||
* accumulate index info in project references
|
||||
*/
|
||||
[projectRefs mergeRefs: [localRefs refs] override: NO];
|
||||
[merged addObject: gsdocfile];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1693,10 +1700,20 @@ main(int argc, char **argv, char **env)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (informalProtocols != nil) {
|
||||
if (verbose)
|
||||
{
|
||||
NSLog(@"Merged indexes into projectRefs from %@", merged);
|
||||
}
|
||||
|
||||
if (informalProtocols != nil)
|
||||
{
|
||||
[projectRefs addInformalProtocols: informalProtocols];
|
||||
DESTROY(informalProtocols);
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
NSLog(@"Added informal protocols into projectRefs");
|
||||
}
|
||||
}
|
||||
DESTROY(arp);
|
||||
|
||||
/*
|
||||
|
@ -1712,6 +1729,7 @@ main(int argc, char **argv, char **env)
|
|||
}
|
||||
}
|
||||
DESTROY(originalIndex);
|
||||
DESTROY(merged);
|
||||
}
|
||||
|
||||
globalRefs = [AGSIndex new];
|
||||
|
@ -1833,11 +1851,13 @@ main(int argc, char **argv, char **env)
|
|||
/*
|
||||
* Merge any "plain project" references.
|
||||
*/
|
||||
if (projects != nil)
|
||||
if ([projects count] > 0)
|
||||
{
|
||||
NSEnumerator *e = [projects keyEnumerator];
|
||||
NSString *k;
|
||||
NSEnumerator *e = [projects keyEnumerator];
|
||||
NSMutableArray *merged;
|
||||
NSString *k;
|
||||
|
||||
merged = [NSMutableArray arrayWithCapacity: [projects count]];
|
||||
while ((k = [e nextObject]) != nil)
|
||||
{
|
||||
if ([mgr isReadableFileAtPath: k] == NO)
|
||||
|
@ -1873,15 +1893,25 @@ main(int argc, char **argv, char **env)
|
|||
[tmp setDirectory: p];
|
||||
[globalRefs mergeRefs: [tmp refs] override: YES];
|
||||
RELEASE(tmp);
|
||||
[merged addObject: k];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
NSLog(@"Merged indexes into globalRefs from %@", merged);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Accumulate project index info into global index
|
||||
*/
|
||||
[globalRefs mergeRefs: [projectRefs refs] override: YES];
|
||||
if (verbose)
|
||||
{
|
||||
NSLog(@"Merged indexes from projectRefs into globalRefs");
|
||||
}
|
||||
|
||||
RELEASE(pool);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue