Improve merging of indexes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11762 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2001-12-15 09:05:19 +00:00
parent 28c46d40b7
commit a54280104d
4 changed files with 38 additions and 16 deletions

View file

@ -1,5 +1,7 @@
2001-12-15 Richard Frith-Macdonald <rfm@gnu.org> 2001-12-15 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/AGSIndex.h: improve merge control
* Tools/AGSIndex.m: ditto
* Tools/AGSHtml.h: new methods for cleaner indexing. * Tools/AGSHtml.h: new methods for cleaner indexing.
* Tools/AGSHtml.m: new methods for cleaner indexing. * Tools/AGSHtml.m: new methods for cleaner indexing.
* Tools/AGSParser.m: minor bugfixes. * Tools/AGSParser.m: minor bugfixes.

View file

@ -33,7 +33,7 @@
} }
- (NSString*) globalRef: (NSString*)ref type: (NSString*)type; - (NSString*) globalRef: (NSString*)ref type: (NSString*)type;
- (void) makeRefs: (GSXMLNode*)node; - (void) makeRefs: (GSXMLNode*)node;
- (void) mergeRefs: (NSDictionary*)more; - (void) mergeRefs: (NSDictionary*)more override: (BOOL)flag;
- (NSMutableDictionary*) refs; - (NSMutableDictionary*) refs;
- (void) setDirectory: (NSString*)path; - (void) setDirectory: (NSString*)path;
- (void) setGlobalRef: (NSString*)ref type: (NSString*)type; - (void) setGlobalRef: (NSString*)ref type: (NSString*)type;

View file

@ -28,7 +28,7 @@ static int XML_ELEMENT_NODE;
static int XML_TEXT_NODE; static int XML_TEXT_NODE;
static void static void
mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src) mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src, BOOL override)
{ {
static NSMutableArray *stack = nil; static NSMutableArray *stack = nil;
NSEnumerator *e = [src keyEnumerator]; NSEnumerator *e = [src keyEnumerator];
@ -64,20 +64,35 @@ mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src)
} }
if (d != nil) if (d != nil)
{ {
if ([d isKindOfClass: [s class]] == NO) if ([d isKindOfClass: [NSString class]] == YES)
{ {
NSLog(@"Class missmatch in merge for %@", stack); if ([s isKindOfClass: [NSString class]] == NO)
}
else if ([d isKindOfClass: [NSString class]] == YES)
{
if ([d isEqual: s] == NO)
{ {
NSLog(@"String missmatch in merge for %@", stack); NSLog(@"Class missmatch in merge for %@.", stack);
}
else if ([d isEqual: s] == NO)
{
if (override == YES)
{
[dst setObject: s forKey: k];
}
else
{
NSLog(@"String missmatch in merge for %@. S:%@, D:%@",
stack, s, d);
}
} }
} }
else if ([d isKindOfClass: [NSDictionary class]] == YES) else if ([d isKindOfClass: [NSDictionary class]] == YES)
{ {
mergeDictionaries(d, s); if ([s isKindOfClass: [NSDictionary class]] == NO)
{
NSLog(@"Class missmatch in merge for %@.", stack);
}
else
{
mergeDictionaries(d, s, override);
}
} }
} }
[stack removeLastObject]; [stack removeLastObject];
@ -329,9 +344,14 @@ setDirectory(NSMutableDictionary *dict, NSString *path)
} }
} }
- (void) mergeRefs: (NSDictionary*)more /**
* Merge a dictionary containing references into the current
* index. The flag may be used to specify that references
* being merged in should override any pre-existing values.
*/
- (void) mergeRefs: (NSDictionary*)more override: (BOOL)flag
{ {
mergeDictionaries(refs, more); mergeDictionaries(refs, more, flag);
} }
- (NSMutableDictionary*) refs - (NSMutableDictionary*) refs

View file

@ -438,7 +438,7 @@ main(int argc, char **argv, char **env)
NSString *p; NSString *p;
tmp = [AGSIndex new]; tmp = [AGSIndex new];
[tmp mergeRefs: dict]; [tmp mergeRefs: dict override: NO];
RELEASE(dict); RELEASE(dict);
/* /*
* Adjust path to external project files ... * Adjust path to external project files ...
@ -449,7 +449,7 @@ main(int argc, char **argv, char **env)
p = [k stringByDeletingLastPathComponent]; p = [k stringByDeletingLastPathComponent];
} }
[tmp setDirectory: p]; [tmp setDirectory: p];
[indexer mergeRefs: [tmp refs]]; [indexer mergeRefs: [tmp refs] override: NO];
RELEASE(tmp); RELEASE(tmp);
} }
} }
@ -664,7 +664,7 @@ main(int argc, char **argv, char **env)
/* /*
* accumulate index info in project references * accumulate index info in project references
*/ */
[prjRefs mergeRefs: [locRefs refs]]; [prjRefs mergeRefs: [locRefs refs] override: NO];
} }
else if (isDocumentation) else if (isDocumentation)
{ {
@ -681,7 +681,7 @@ main(int argc, char **argv, char **env)
/* /*
* accumulate project index info into global index * accumulate project index info into global index
*/ */
[indexer mergeRefs: [prjRefs refs]]; [indexer mergeRefs: [prjRefs refs] override: YES];
for (i = 1; i < [args count]; i++) for (i = 1; i < [args count]; i++)
{ {