From 32d9ddda8d3848ce21652a7301f6f25c0b02902e Mon Sep 17 00:00:00 2001 From: robvdveer Date: Mon, 29 Jul 2013 11:08:41 +0200 Subject: [PATCH 1/5] oopsy, better validate that 'typedef' too. --- Parsing/GBObjectiveCParser.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Parsing/GBObjectiveCParser.m b/Parsing/GBObjectiveCParser.m index 0e944157..8cc3e269 100644 --- a/Parsing/GBObjectiveCParser.m +++ b/Parsing/GBObjectiveCParser.m @@ -426,8 +426,12 @@ - (BOOL)matchTypedefEnumDefinition { BOOL hasOpenBracket = [[self.tokenizer lookahead:2] matches:@"("]; //ONLY SUPPORTED ARE typedef enum { } name; because that is the only way to bind the name to the enum values. + if(!isTypeDef) + { + return NO; + } - if(isTypeDef && (isTypeDefEnum || isTypeDefOptions) && hasOpenBracket) + if((isTypeDefEnum || isTypeDefOptions) && hasOpenBracket) { [self.tokenizer consume:3]; //consume 'typedef' 'NS_ENUM' and '(' From 58b334b1760f09251224f25b74a700506e4fdbec Mon Sep 17 00:00:00 2001 From: robvdveer Date: Tue, 30 Jul 2013 11:29:29 +0200 Subject: [PATCH 2/5] Supported MACRO decorations in NS_ENUM/NS_OPTION typedefs --- Parsing/GBObjectiveCParser.m | 43 ++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/Parsing/GBObjectiveCParser.m b/Parsing/GBObjectiveCParser.m index 8cc3e269..3c2f1c31 100644 --- a/Parsing/GBObjectiveCParser.m +++ b/Parsing/GBObjectiveCParser.m @@ -466,6 +466,8 @@ - (BOOL)matchTypedefEnumDefinition { //[self.tokenizer consume:1]; [self.tokenizer consumeFrom:@"{" to:@"}" usingBlock:^(PKToken *token, BOOL *consume, BOOL *stop) { + /* ALWAYS start with the name of the Constant */ + GBEnumConstantData *newConstant = [GBEnumConstantData constantWithName:[token stringValue]]; GBSourceInfo *filedata = [tokenizer sourceInfoForToken:token]; [newConstant registerSourceInfo:filedata]; @@ -474,20 +476,27 @@ - (BOOL)matchTypedefEnumDefinition { [self.tokenizer consume:1]; [self.tokenizer resetComments]; + [self consumeMacro]; + if([[self.tokenizer currentToken] matches:@"="]) { [self.tokenizer consume:1]; //collect the stringvalues until a ',' is detected. - NSMutableString *value = [[NSMutableString alloc] init]; + NSMutableArray *values = [NSMutableArray array]; + while(![[tokenizer currentToken] matches:@","] && ![[tokenizer currentToken] matches:@"}"]) { - [value appendString:[[tokenizer currentToken] stringValue]]; - [tokenizer consume:1]; + if(![self consumeMacro]) + { + [values addObject:[[tokenizer currentToken] stringValue]]; + [tokenizer consume:1]; + } } + NSString *value = [values componentsJoinedByString:@" "]; [newConstant setAssignedValue:value]; - } + } if([[self.tokenizer currentToken] matches:@","]) { @@ -518,6 +527,32 @@ - (BOOL)matchTypedefEnumDefinition { return NO; } +-(bool)isTokenUppercaseOnly:(NSString *)token +{ + return [token isEqualToString:[token uppercaseString]]; +} + +-(bool)consumeMacro +{ + //Eat away and MACRO + if( ![[self.tokenizer currentToken] matches:@"="] + && ![[self.tokenizer currentToken] matches:@"}"] + && ![[self.tokenizer currentToken] matches:@","] + && [[self.tokenizer currentToken] isWord] + && [self isTokenUppercaseOnly:[[self.tokenizer currentToken] stringValue]]) + { + [self.tokenizer consume:1]; + + //now a macro may come with bracketed arguments. + if([[self.tokenizer currentToken] matches:@"("]) + { + [self.tokenizer consumeTo:@")" usingBlock:nil]; + } + return YES; + } + return NO; +} + - (BOOL)matchObjectDefinition { // Get data needed for distinguishing between class, category and extension definition. BOOL isInterface = [[self.tokenizer currentToken] matches:@"@interface"]; From 5b98279f80164e68e2cde4e79cc6624a193254ef Mon Sep 17 00:00:00 2001 From: robvdveer Date: Tue, 30 Jul 2013 12:52:20 +0200 Subject: [PATCH 3/5] Consume optional macro at end of typedef declaration --- Parsing/GBObjectiveCParser.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Parsing/GBObjectiveCParser.m b/Parsing/GBObjectiveCParser.m index 3c2f1c31..a9ede3ca 100644 --- a/Parsing/GBObjectiveCParser.m +++ b/Parsing/GBObjectiveCParser.m @@ -508,6 +508,9 @@ - (BOOL)matchTypedefEnumDefinition { [newEnum.constants registerConstant:newConstant]; }]; + //if there is a macro, consume it. + [self consumeMacro]; + //consume ; [self.tokenizer consume:1]; [self.store registerTypedefEnum:newEnum]; From 75370324d4a672102e5730a7ff6c45868a33c79d Mon Sep 17 00:00:00 2001 From: robvdveer Date: Wed, 31 Jul 2013 19:50:03 +0200 Subject: [PATCH 4/5] Managed to get the icons done (fixes issue #380) --- Generating/GBDocSetOutputGenerator.m | 35 ++++++++++++- .../Contents/Resources/nodes-template.xml | 51 ++++++++++++++++--- 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/Generating/GBDocSetOutputGenerator.m b/Generating/GBDocSetOutputGenerator.m index ba9c89dd..7f7f9cdc 100644 --- a/Generating/GBDocSetOutputGenerator.m +++ b/Generating/GBDocSetOutputGenerator.m @@ -129,7 +129,7 @@ - (BOOL)processInfoPlist:(NSError **)error { } - (BOOL)processNodesXml:(NSError **)error { - GBLogInfo(@"Writing DocSet Nodex.xml file..."); + GBLogInfo(@"Writing DocSet Nodes.xml file..."); NSString *templateFilename = @"nodes-template.xml"; NSString *templatePath = [self templatePathForTemplateEndingWith:templateFilename]; if (!templatePath) { @@ -191,7 +191,7 @@ - (BOOL)indexDocSet:(NSError **)error { GBLogInfo(@"Indexing DocSet..."); GBTask *task = [GBTask task]; task.reportIndividualLines = YES; - NSArray *args = [NSArray arrayWithObjects:@"docsetutil", @"index", [self.outputUserPath stringByStandardizingPath], nil]; + NSArray *args = [NSArray arrayWithObjects:@"docsetutil", @"index", @"-debug", @"-verbose",[self.outputUserPath stringByStandardizingPath], nil]; BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) { if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]); if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]); @@ -470,6 +470,37 @@ - (NSArray *)simplifiedObjectsFromObjects:(NSArray *)objects value:(NSString *)v [data setObject:[NSString stringWithFormat:@"%ld", idx++] forKey:@"id"]; [data setObject:[object valueForKey:value] forKey:@"name"]; [data setObject:[self.settings htmlReferenceForObjectFromIndex:object] forKey:@"path"]; + + if([object conformsToProtocol:@protocol(GBObjectDataProviding)]) + { + GBMethodsProvider *provider = [(id)object methods]; + + //if the model or document has multiple members, expand those members + if(provider.methods.count > 0) + { + [data setObject:@"file" forKey:@"type"]; + [data setObject:@"reference" forKey:@"docType"]; + [data setObject:[NSNumber numberWithBool:YES] forKey:@"hasSubNodes"]; + [data setObject:[NSNumber numberWithBool:provider.hasProperties] forKey:@"hasProperties"]; + [data setObject:[NSNumber numberWithBool:provider.hasClassMethods] forKey:@"hasClassMethods"]; + [data setObject:[NSNumber numberWithBool:provider.hasInstanceMethods] forKey:@"hasInstanceMethods"]; + } + else + { + [data setObject:@"section" forKey:@"type"]; + } + } + else if([object isKindOfClass:[GBTypedefEnumData class]]) + { + [data setObject:@"file" forKey:@"type"]; + [data setObject:@"reference" forKey:@"docType"]; + } + else + { + //not a member providing node: just use the 'section' icon. + [data setObject:@"section" forKey:@"type"]; + } + [result addObject:data]; } *index = idx; diff --git a/Templates/docset/Contents/Resources/nodes-template.xml b/Templates/docset/Contents/Resources/nodes-template.xml index e6c108a1..e87d40b2 100644 --- a/Templates/docset/Contents/Resources/nodes-template.xml +++ b/Templates/docset/Contents/Resources/nodes-template.xml @@ -1,5 +1,5 @@ - + {{projectName}} @@ -26,7 +26,7 @@ {{/hasClasses}} {{#hasCategories}} - + {{strings/docset/categoriesTitle}} {{indexFilename}} @@ -36,7 +36,7 @@ {{/hasCategories}} {{#hasProtocols}} - + {{strings/docset/protocolsTitle}} {{indexFilename}} @@ -46,7 +46,7 @@ {{/hasProtocols}} {{#hasConstants}} - + {{strings/docset/constantsTitle}} {{indexFilename}} @@ -73,10 +73,45 @@ Section Node - - {{name}} - {{path}} - + + {{name}} + {{path}} + {{#hasSubNodes}} + + + {{path}} + Overview + overview + + + {{path}} + Tasks + tasks + + {{#hasProperties}} + + {{path}} + Properties + properties + + {{/hasProperties}} + {{#hasClassMethods}} + + {{path}} + Class Methods + class_methods + + {{/hasClassMethods}} + {{#hasInstanceMethods}} + + {{path}} + Instance Methods + instance_methods + + {{/hasInstanceMethods}} + + {{/hasSubNodes}} + EndSection Section NodeRef From 48beb22ee5b1d72777074255d2dbcccdd635e124 Mon Sep 17 00:00:00 2001 From: robvdveer Date: Wed, 31 Jul 2013 19:53:40 +0200 Subject: [PATCH 5/5] pre-merge cleanup --- Generating/GBDocSetOutputGenerator.m | 2 +- Templates/docset/Contents/Resources/nodes-template.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generating/GBDocSetOutputGenerator.m b/Generating/GBDocSetOutputGenerator.m index 7f7f9cdc..6d79c25f 100644 --- a/Generating/GBDocSetOutputGenerator.m +++ b/Generating/GBDocSetOutputGenerator.m @@ -191,7 +191,7 @@ - (BOOL)indexDocSet:(NSError **)error { GBLogInfo(@"Indexing DocSet..."); GBTask *task = [GBTask task]; task.reportIndividualLines = YES; - NSArray *args = [NSArray arrayWithObjects:@"docsetutil", @"index", @"-debug", @"-verbose",[self.outputUserPath stringByStandardizingPath], nil]; + NSArray *args = [NSArray arrayWithObjects:@"docsetutil", @"index", [self.outputUserPath stringByStandardizingPath], nil]; BOOL result = [task runCommand:self.settings.xcrunPath arguments:args block:^(NSString *output, NSString *error) { if (output) GBLogDebug(@"> %@", [output stringByTrimmingWhitespaceAndNewLine]); if (error) GBLogError(@"!> %@", [error stringByTrimmingWhitespaceAndNewLine]); diff --git a/Templates/docset/Contents/Resources/nodes-template.xml b/Templates/docset/Contents/Resources/nodes-template.xml index e87d40b2..0b388914 100644 --- a/Templates/docset/Contents/Resources/nodes-template.xml +++ b/Templates/docset/Contents/Resources/nodes-template.xml @@ -1,5 +1,5 @@ - + {{projectName}}