2000-02-28 16:23:53 +00:00
|
|
|
|
/* This tool converts documentation in gsdoc format to another format
|
|
|
|
|
At present (and for the forseeable future), the only format supported
|
|
|
|
|
is HTML.
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2000 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
|
Created: February 2000
|
|
|
|
|
|
|
|
|
|
This file is part of the GNUstep Project
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public
|
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2000-06-20 14:21:35 +00:00
|
|
|
|
/*
|
|
|
|
|
Before doing anything else - you need to install the Gnome xml parser library!
|
|
|
|
|
|
|
|
|
|
I build gsdoc using the 2.0.0 release of the parser.
|
|
|
|
|
|
|
|
|
|
You can find out how to get this from http://www.xmlsoft.org
|
|
|
|
|
|
|
|
|
|
Once you have installed the xml parser library, you can build gsdoc
|
|
|
|
|
and install it.
|
|
|
|
|
|
|
|
|
|
Run gsdoc giving it the name of a gsdoc file as an argument, and it will
|
|
|
|
|
produce an html output file.
|
|
|
|
|
|
|
|
|
|
This is an alpha release of the software - please send fixes and improvements
|
|
|
|
|
to rfm@gnu.org
|
|
|
|
|
|
|
|
|
|
Volunteers to write gsdoc->info or gsdoc->TeX or any other translators are
|
|
|
|
|
very welcome.
|
|
|
|
|
*/
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
/*
|
|
|
|
|
Parameters:
|
|
|
|
|
--makeRefs=ReferencesFileName
|
|
|
|
|
With this option, gsdoc reads gsdoc files and create ReferencesFileName.gsdocrefs files which can be used as --refs to make links between elements
|
|
|
|
|
|
|
|
|
|
--projectName=TheProjectName
|
|
|
|
|
Set the project name to "TheProjectName"
|
|
|
|
|
It is used fo index titles,...
|
|
|
|
|
|
|
|
|
|
--refs=ARefFile (or --refs=ARefDirectory)
|
|
|
|
|
Use ARefFile.gsdocrefs (or files whith extensions .gsdocrefs in ARefDirectory directory) as references files.
|
|
|
|
|
It's enable to make links bettwen documentations
|
|
|
|
|
|
|
|
|
|
--makeIndex=MyIndexFileName
|
|
|
|
|
Create an index of the parsed files and save it as MyIndexName.gsdoc
|
|
|
|
|
You have to set --makeIndexTemplate option
|
|
|
|
|
|
|
|
|
|
--makeIndexTemplate=MyIndexTemplateFileName
|
|
|
|
|
The file used as index template for makeIndex option
|
|
|
|
|
|
|
|
|
|
--define-XXX=YYY
|
|
|
|
|
Used to define a constant named XXX with value YYY
|
|
|
|
|
in .gsdoc file, all [[infoDictionary.XXX]] texts are replaced with YYY
|
|
|
|
|
|
|
|
|
|
--verbose=X
|
|
|
|
|
Level of traces from 0 to ...
|
|
|
|
|
|
|
|
|
|
--location=file://usr/doc/gnustep/MyProject (or --location=http://www.gnustep.org/gnustep/MyProject)
|
|
|
|
|
Location of the installed documentation (it helps to make kinks between projects)
|
|
|
|
|
|
|
|
|
|
file1 file2
|
|
|
|
|
.gsdoc files
|
|
|
|
|
*/
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
#include <Foundation/Foundation.h>
|
2000-06-20 13:17:22 +00:00
|
|
|
|
|
|
|
|
|
#if HAVE_LIBXML
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
2000-06-20 13:17:22 +00:00
|
|
|
|
#include <libxml/parser.h>
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString* PathExtension_GSDocRefs=@"gsdocrefs";
|
|
|
|
|
NSString* PathExtension_GSDoc=@"gsdoc";
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSString* PathExtension_HTML=@"html";
|
2000-08-13 16:00:14 +00:00
|
|
|
|
int verbose=0;
|
|
|
|
|
NSString* location=nil;
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
// In text, replace keys from variables with their values
|
|
|
|
|
// variables is like something like this
|
|
|
|
|
// {
|
|
|
|
|
// "[[key1]]" = "value1";
|
|
|
|
|
// "[[key2]]" = "value2";
|
|
|
|
|
// };
|
|
|
|
|
NSString* TextByReplacingVariablesInText(NSString* text,NSDictionary* variables)
|
|
|
|
|
{
|
|
|
|
|
NSEnumerator* variablesEnum = [variables keyEnumerator];
|
|
|
|
|
id key=nil;
|
|
|
|
|
while ((key = [variablesEnum nextObject]))
|
|
|
|
|
{
|
|
|
|
|
id value=[variables objectForKey:key];
|
|
|
|
|
text=[text stringByReplacingString:key
|
|
|
|
|
withString:[value description]];
|
|
|
|
|
};
|
|
|
|
|
return text;
|
|
|
|
|
};
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// ====================================================================
|
|
|
|
|
// GSDocParser
|
2000-02-28 16:23:53 +00:00
|
|
|
|
@interface GSDocParser : NSObject
|
|
|
|
|
{
|
|
|
|
|
NSString *baseName;
|
|
|
|
|
NSString *currName;
|
|
|
|
|
NSString *fileName;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString *nextName; //"Next" Link filename
|
|
|
|
|
NSString *prevName; //"Previous" Link filename
|
|
|
|
|
NSString *upName; //"Up" Link filename
|
|
|
|
|
NSString *styleSheetURL; // Style sheet
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSMutableDictionary *indexes;
|
|
|
|
|
NSUserDefaults *defs;
|
|
|
|
|
NSFileManager *mgr;
|
|
|
|
|
xmlDocPtr doc;
|
|
|
|
|
}
|
|
|
|
|
- (NSString*) getProp: (const char*)name fromNode: (xmlNodePtr)node;
|
|
|
|
|
- (NSMutableDictionary*) indexForType: (NSString*)type;
|
|
|
|
|
- (id) initWithFileName: (NSString*)name;
|
|
|
|
|
- (NSString*) parseText: (xmlNodePtr)node;
|
2000-03-17 13:13:08 +00:00
|
|
|
|
- (NSString*) parseText: (xmlNodePtr)node end: (xmlNodePtr*)endNode;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
static xmlParserInputPtr
|
|
|
|
|
loader(const char *url, const char* eid, xmlParserCtxtPtr *ctxt)
|
|
|
|
|
{
|
|
|
|
|
extern xmlParserInputPtr xmlNewInputFromFile();
|
|
|
|
|
xmlParserInputPtr ret = 0;
|
|
|
|
|
|
|
|
|
|
if (strncmp(eid, "-//GNUstep//DTD ", 16) == 0)
|
|
|
|
|
{
|
|
|
|
|
char buf[BUFSIZ];
|
|
|
|
|
char *ptr;
|
|
|
|
|
NSString *name;
|
|
|
|
|
NSString *file;
|
|
|
|
|
|
|
|
|
|
strcpy(buf, &eid[16]);
|
|
|
|
|
for (ptr = buf; *ptr != '\0' && *ptr != '/'; ptr++)
|
|
|
|
|
{
|
|
|
|
|
if (*ptr == '.')
|
|
|
|
|
{
|
|
|
|
|
*ptr = '_';
|
|
|
|
|
}
|
|
|
|
|
else if (isspace(*ptr))
|
|
|
|
|
{
|
|
|
|
|
*ptr = '-';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*ptr = '\0';
|
|
|
|
|
name = [NSString stringWithCString: buf];
|
|
|
|
|
file = [NSBundle pathForGNUstepResource: name
|
|
|
|
|
ofType: @"dtd"
|
|
|
|
|
inDirectory: @"DTDs"];
|
|
|
|
|
if (file == nil)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"unable to find GNUstep DTD - '%@' for '%s'", name, eid);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ret = xmlNewInputFromFile(ctxt, [file cString]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"don't know how to load entity '%s' id '%s'", url, eid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// ====================================================================
|
2000-02-28 16:23:53 +00:00
|
|
|
|
@implementation GSDocParser
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
if (doc != 0)
|
|
|
|
|
{
|
|
|
|
|
xmlFreeDoc(doc);
|
|
|
|
|
doc = 0;
|
|
|
|
|
}
|
|
|
|
|
DESTROY(defs);
|
|
|
|
|
DESTROY(indexes);
|
|
|
|
|
DESTROY(baseName);
|
|
|
|
|
DESTROY(nextName);
|
|
|
|
|
DESTROY(prevName);
|
|
|
|
|
DESTROY(upName);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
DESTROY(styleSheetURL);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
DESTROY(currName);
|
|
|
|
|
DESTROY(fileName);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) getProp: (const char*)name fromNode: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
xmlAttrPtr attr = node->properties;
|
|
|
|
|
|
|
|
|
|
while (attr != 0 && strcmp(attr->name, name) != 0)
|
|
|
|
|
{
|
|
|
|
|
attr = attr->next;
|
|
|
|
|
}
|
2000-03-11 21:58:40 +00:00
|
|
|
|
if (attr == 0 || attr->children == 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-03-11 21:58:40 +00:00
|
|
|
|
return [self parseText: attr->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSMutableDictionary*) indexForType: (NSString*)type
|
|
|
|
|
{
|
|
|
|
|
NSMutableDictionary *dict = [indexes objectForKey: type];
|
|
|
|
|
|
|
|
|
|
if (dict == nil)
|
|
|
|
|
{
|
|
|
|
|
dict = [NSMutableDictionary new];
|
|
|
|
|
[indexes setObject: dict forKey: type];
|
|
|
|
|
RELEASE(dict);
|
|
|
|
|
}
|
|
|
|
|
return dict;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithFileName: (NSString*)name
|
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if ((self=[self init]))
|
|
|
|
|
{
|
|
|
|
|
xmlNodePtr cur;
|
|
|
|
|
extern int xmlDoValidityCheckingDefaultValue;
|
|
|
|
|
xmlExternalEntityLoader ldr;
|
|
|
|
|
NSString *s;
|
|
|
|
|
NSFileManager *m;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
xmlDoValidityCheckingDefaultValue = 1;
|
|
|
|
|
ldr = xmlGetExternalEntityLoader();
|
|
|
|
|
if (ldr != (xmlExternalEntityLoader)loader)
|
|
|
|
|
{
|
|
|
|
|
xmlSetExternalEntityLoader((xmlExternalEntityLoader)loader);
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
/*
|
2000-06-20 14:21:35 +00:00
|
|
|
|
* Ensure we have a valid file name.
|
|
|
|
|
*/
|
2000-08-13 16:00:14 +00:00
|
|
|
|
s = [name pathExtension];
|
|
|
|
|
m = [NSFileManager defaultManager];
|
|
|
|
|
if ([m fileExistsAtPath: name] == NO && [s length] == 0)
|
|
|
|
|
{
|
|
|
|
|
s = [name stringByAppendingPathExtension:PathExtension_GSDoc];
|
|
|
|
|
if ([m fileExistsAtPath: s] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"No such document - %@", name);
|
|
|
|
|
[self dealloc];
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
name = s;
|
|
|
|
|
}
|
|
|
|
|
fileName = [name copy];
|
|
|
|
|
/*
|
|
|
|
|
* Build an XML tree from the file.
|
2000-02-28 16:23:53 +00:00
|
|
|
|
*/
|
2000-08-13 16:00:14 +00:00
|
|
|
|
doc = xmlParseFile([name cString]);
|
|
|
|
|
if (doc == NULL)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"unparseable document - %@", fileName);
|
|
|
|
|
[self dealloc];
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
/*
|
2000-02-28 16:23:53 +00:00
|
|
|
|
* Check that the document is of the right kind
|
|
|
|
|
*/
|
2000-08-13 16:00:14 +00:00
|
|
|
|
cur = doc->children;
|
|
|
|
|
if (cur == NULL)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"empty document - %@", fileName);
|
|
|
|
|
[self dealloc];
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
cur = cur->next;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (strcmp(cur->name, "gsdoc") != 0)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"document of the wrong type, root node != gsdoc");
|
|
|
|
|
[self dealloc];
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
baseName = [self getProp: "base" fromNode: cur];
|
|
|
|
|
if (baseName == nil)
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
//baseName = @"gsdoc";
|
|
|
|
|
ASSIGN(baseName,[fileName stringByDeletingPathExtension]);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RETAIN(baseName);
|
|
|
|
|
}
|
|
|
|
|
nextName = RETAIN([self getProp: "next" fromNode: cur]); // get the "next" link
|
|
|
|
|
prevName = RETAIN([self getProp: "prev" fromNode: cur]); // get the "prev" link
|
|
|
|
|
upName = RETAIN([self getProp: "up" fromNode: cur]); // get the "up" link
|
|
|
|
|
styleSheetURL = RETAIN([self getProp: "stylesheeturl" fromNode: cur]);//Get the style sheet if any
|
|
|
|
|
defs = RETAIN([NSUserDefaults standardUserDefaults]);
|
|
|
|
|
s = [defs stringForKey: @"BaseName"];
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(baseName, s);
|
|
|
|
|
}
|
|
|
|
|
currName = [baseName copy];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
indexes = [NSMutableDictionary new];
|
|
|
|
|
};
|
2000-02-28 16:23:53 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseText: (xmlNodePtr)node
|
2000-03-17 13:13:08 +00:00
|
|
|
|
{
|
|
|
|
|
xmlNodePtr endNode;
|
|
|
|
|
NSString *result;
|
|
|
|
|
|
|
|
|
|
result = [self parseText: node end: &endNode];
|
|
|
|
|
if (endNode != 0)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Unexpected node type in text node - %d", endNode->type);
|
|
|
|
|
result = nil;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseText: (xmlNodePtr)node end: (xmlNodePtr*)endNode
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// ====================================================================
|
2000-02-28 16:23:53 +00:00
|
|
|
|
@interface GSDocHtml : GSDocParser
|
|
|
|
|
{
|
|
|
|
|
NSMutableDictionary *refToFile;
|
|
|
|
|
NSMutableArray *contents;
|
|
|
|
|
NSMutableArray *footnotes;
|
|
|
|
|
unsigned labelIndex;
|
|
|
|
|
unsigned footnoteIndex;
|
|
|
|
|
unsigned contentsIndex;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSString* projectName; // ProjectName
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSMutableDictionary* fileReferences; // References for the current file (constructed when parsing this file)
|
|
|
|
|
NSMutableDictionary* generalReferences; // General References (coming from documentations References)
|
|
|
|
|
NSMutableDictionary* variablesDictionary; // "User Variables"
|
|
|
|
|
NSString* currentClassName; // Currently Parsed Class Name if any
|
|
|
|
|
NSString* currentCategoryName; // Currently Parsed Category Name if any
|
|
|
|
|
NSString* currentProtocolName; // Currently Parsed Protocol Name if any
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSArray* typesTypes; // Types for Types
|
|
|
|
|
NSArray* classesTypes; // Types for Classes
|
|
|
|
|
NSArray* protocolsTypes; // Types for Protocols
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSArray* filesTypes; // Types for Files
|
2000-08-13 16:00:14 +00:00
|
|
|
|
BOOL writeFlag; // YES if we'll write the result
|
2000-08-16 14:08:08 +00:00
|
|
|
|
BOOL processFileReferencesFlag; // YES if we'll add references to file references
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
- (id)init;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
- (NSString*) addLink: (NSString*)ref withText: (NSString*)text;
|
|
|
|
|
- (void) appendContents: (NSArray*)array toString: (NSMutableString*)text;
|
|
|
|
|
- (void) appendFootnotesToString: (NSMutableString*)text;
|
|
|
|
|
- (void) appendIndex: (NSString*)type toString: (NSMutableString*)text;
|
|
|
|
|
- (NSString*) parseAuthor: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseBlock: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseBody: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseChapter: (xmlNodePtr)node contents: (NSMutableArray*)array;
|
|
|
|
|
- (NSString*) parseDef: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseDesc: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseDocument;
|
|
|
|
|
- (NSString*) parseEmbed: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseExample: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseFunction: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseHead: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseItem: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseList: (xmlNodePtr)node;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
- (NSString*) parseVariable: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseIVariable: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseConstant: (xmlNodePtr)node;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
- (NSString*) parseMacro: (xmlNodePtr)node;
|
|
|
|
|
- (NSString*) parseMethod: (xmlNodePtr)node;
|
2000-03-10 11:47:52 +00:00
|
|
|
|
- (NSArray*) parseStandards: (xmlNodePtr)node;
|
2000-03-17 13:13:08 +00:00
|
|
|
|
- (NSString*) parseText: (xmlNodePtr)node end: (xmlNodePtr*)endNode;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
- (void) setEntry: (NSString*)entry
|
2000-08-13 16:00:14 +00:00
|
|
|
|
withExternalCompleteRef: (NSString*)externalCompleteRef
|
|
|
|
|
withExternalRef: (NSString*)externalRef
|
|
|
|
|
withRef: (NSString*)ref
|
2000-02-28 16:23:53 +00:00
|
|
|
|
inIndexOfType: (NSString*)type;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
-(NSArray*)contents;
|
|
|
|
|
-(NSDictionary*)fileReferences;
|
|
|
|
|
-(void)setGeneralReferences:(NSDictionary*)dict;
|
|
|
|
|
-(void)setVariablesDictionary:(NSDictionary*)dict;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
-(NSString*)linkedItem:(NSString*)item
|
|
|
|
|
ofTypes:(NSArray*)types;
|
|
|
|
|
-(NSDictionary*)findSymbolForKey:(NSString*)key_
|
|
|
|
|
ofTypes:(NSArray*)types;
|
2000-08-24 17:24:40 +00:00
|
|
|
|
-(NSString*)linkForSymbolKey:(NSString*)key_
|
|
|
|
|
ofTypes:(NSArray*)types
|
|
|
|
|
withText:(NSString*)text;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
-(NSString*)linkForSymbol:(NSDictionary*)symbol
|
|
|
|
|
withText:(NSString*)text;
|
|
|
|
|
-(void)setWriteFlag:(BOOL)flag;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
-(void)setProcessFileReferencesFlag:(BOOL)flag;
|
|
|
|
|
-(void)setProjectName:(NSString*)projectName_;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// ====================================================================
|
2000-02-28 16:23:53 +00:00
|
|
|
|
@implementation GSDocHtml
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
- (id)init
|
|
|
|
|
{
|
|
|
|
|
if ((self=[super init]))
|
|
|
|
|
{
|
|
|
|
|
writeFlag=YES;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
processFileReferencesFlag=YES;
|
|
|
|
|
typesTypes=[NSArray arrayWithObjects:@"type",@"class",@"define",nil];
|
|
|
|
|
RETAIN(typesTypes);
|
|
|
|
|
classesTypes=[NSArray arrayWithObjects:@"class",@"define",nil];
|
|
|
|
|
RETAIN(classesTypes);
|
|
|
|
|
protocolsTypes=[NSArray arrayWithObjects:@"protocol",@"define",nil];
|
|
|
|
|
RETAIN(protocolsTypes);
|
2000-08-24 17:24:40 +00:00
|
|
|
|
filesTypes=[NSArray arrayWithObjects:@"file",nil];
|
|
|
|
|
RETAIN(filesTypes);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
return self;
|
|
|
|
|
};
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
- (NSString*) addLink: (NSString*)ref withText: (NSString*)text
|
|
|
|
|
{
|
|
|
|
|
NSString *file = [refToFile objectForKey: ref];
|
|
|
|
|
|
|
|
|
|
if (file == nil)
|
|
|
|
|
{
|
|
|
|
|
return [NSString stringWithFormat: @"<a href=\"#%@\">%@</a>", ref, text];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return [NSString stringWithFormat: @"<a href=\"%@#%@\">%@</a>",
|
|
|
|
|
file, ref, text];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) appendContents: (NSArray*)array toString: (NSMutableString*)text
|
|
|
|
|
{
|
|
|
|
|
unsigned count = [array count];
|
|
|
|
|
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendString: @"<ul>\r\n"];
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
NSDictionary *dict = [array objectAtIndex: i];
|
|
|
|
|
NSString *title = [dict objectForKey: @"Title"];
|
|
|
|
|
NSString *ref = [dict objectForKey: @"Ref"];
|
|
|
|
|
NSArray *sub = [dict objectForKey: @"Contents"];
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<li>%@\r\n",
|
|
|
|
|
[self addLink: ref withText: title]];
|
|
|
|
|
[self appendContents: sub toString: text];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</ul>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) appendFootnotesToString: (NSMutableString*)text
|
|
|
|
|
{
|
|
|
|
|
unsigned count = [footnotes count];
|
|
|
|
|
|
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendString: @"<h2>Footnotes</h2>\r\n"];
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
NSString *note = [footnotes objectAtIndex: i];
|
|
|
|
|
NSString *ref = [NSString stringWithFormat: @"foot-%u", i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<a name=\"%@\">footnote %u</a> -\r\n", ref, i];
|
|
|
|
|
[text appendString: note];
|
|
|
|
|
[text appendString: @"<hr>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) appendIndex: (NSString*)type toString: (NSMutableString*)text
|
|
|
|
|
{
|
|
|
|
|
NSDictionary *dict = [self indexForType: type];
|
|
|
|
|
NSEnumerator *enumerator;
|
|
|
|
|
NSArray *keys;
|
|
|
|
|
NSString *key;
|
|
|
|
|
|
|
|
|
|
keys = [dict keysSortedByValueUsingSelector: @selector(compare:)];
|
|
|
|
|
enumerator = [keys objectEnumerator];
|
|
|
|
|
[text appendString: @"<ul>\r\n"];
|
|
|
|
|
while ((key = [enumerator nextObject]) != nil)
|
|
|
|
|
{
|
|
|
|
|
NSString *name = [dict objectForKey: key];
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<li>%@\r\n",
|
|
|
|
|
[self addLink: key withText: name]];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</ul>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
DESTROY(contents);
|
|
|
|
|
DESTROY(footnotes);
|
2000-08-16 14:08:08 +00:00
|
|
|
|
DESTROY(projectName);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
DESTROY(fileReferences);
|
|
|
|
|
DESTROY(generalReferences);
|
|
|
|
|
DESTROY(variablesDictionary);
|
|
|
|
|
DESTROY(currentClassName);
|
|
|
|
|
DESTROY(currentCategoryName);
|
|
|
|
|
DESTROY(currentProtocolName);
|
2000-08-16 14:08:08 +00:00
|
|
|
|
DESTROY(typesTypes);
|
|
|
|
|
DESTROY(classesTypes);
|
|
|
|
|
DESTROY(protocolsTypes);
|
2000-08-24 17:24:40 +00:00
|
|
|
|
DESTROY(filesTypes);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithFileName: (NSString*)name
|
|
|
|
|
{
|
|
|
|
|
self = [super initWithFileName: name];
|
2000-02-29 10:19:04 +00:00
|
|
|
|
if (self != nil)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-02-29 10:19:04 +00:00
|
|
|
|
mgr = RETAIN([NSFileManager defaultManager]);
|
|
|
|
|
refToFile = [NSMutableDictionary new];
|
|
|
|
|
contents = [NSMutableArray new];
|
|
|
|
|
footnotes = [NSMutableArray new];
|
|
|
|
|
if ([defs boolForKey: @"Monolithic"] == YES)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
ASSIGN(currName, [baseName stringByAppendingPathExtension:PathExtension_HTML]);
|
2000-02-29 10:19:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-02-29 10:19:04 +00:00
|
|
|
|
BOOL flag = NO;
|
|
|
|
|
|
|
|
|
|
if ([mgr fileExistsAtPath: baseName isDirectory: &flag] == NO)
|
|
|
|
|
{
|
|
|
|
|
if ([mgr createDirectoryAtPath: baseName attributes: nil] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Unable to create directory '%@'", baseName);
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (flag == NO)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-02-29 10:19:04 +00:00
|
|
|
|
NSLog(@"The file '%@' is not a directory", baseName);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
RELEASE(self);
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-02-29 10:19:04 +00:00
|
|
|
|
ASSIGN(currName,
|
2000-08-24 17:24:40 +00:00
|
|
|
|
[baseName stringByAppendingPathComponent: @"index.html"]);
|
2000-02-29 10:19:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseAuthor: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
NSString *name = [self getProp: "name" fromNode: node];
|
|
|
|
|
NSString *email = nil;
|
2000-03-05 10:50:24 +00:00
|
|
|
|
NSString *ename = nil;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSString *url = nil;
|
|
|
|
|
NSString *desc = nil;
|
|
|
|
|
|
|
|
|
|
if (name == nil)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Missing or illegal author name");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "email") == 0)
|
|
|
|
|
{
|
|
|
|
|
email = [self getProp: "email" fromNode: node];
|
2000-03-11 21:58:40 +00:00
|
|
|
|
ename = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
if (node != 0 && strcmp(node->name, "url") == 0)
|
|
|
|
|
{
|
|
|
|
|
url = [self getProp: "url" fromNode: node];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
if (node != 0 && strcmp(node->name, "desc") == 0)
|
|
|
|
|
{
|
|
|
|
|
desc = [self parseDesc: node];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[text appendString: @"<dt>"];
|
|
|
|
|
if (url == nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"%@\r\n", name];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<a href=\"%@\">%@</a>\r\n", url, name];
|
|
|
|
|
}
|
|
|
|
|
if (email != nil)
|
|
|
|
|
{
|
2000-03-05 10:50:24 +00:00
|
|
|
|
if ([ename length] == 0)
|
|
|
|
|
ename = email;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[text appendFormat: @" (<a href=\"mailto:%@\"><code>%@</code></a>)\r\n",
|
2000-03-05 10:50:24 +00:00
|
|
|
|
email, ename];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
[text appendString: @"<dd>\r\n"];
|
|
|
|
|
if (desc != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: desc];
|
|
|
|
|
}
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseBlock: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
if (node == 0)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"nul node when expecting block");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "class") == 0
|
2000-06-21 11:04:41 +00:00
|
|
|
|
|| strcmp(node->name, "jclass") == 0
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|| strcmp(node->name, "category") == 0
|
|
|
|
|
|| strcmp(node->name, "protocol") == 0
|
|
|
|
|
|| strcmp(node->name, "function") == 0
|
|
|
|
|
|| strcmp(node->name, "macro") == 0
|
|
|
|
|
|| strcmp(node->name, "type") == 0
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|| strcmp(node->name, "variable") == 0
|
|
|
|
|
|| strcmp(node->name, "ivariable") == 0
|
|
|
|
|
|| strcmp(node->name, "constant") == 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
return [self parseDef: node];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "list") == 0
|
|
|
|
|
|| strcmp(node->name, "enum") == 0
|
|
|
|
|
|| strcmp(node->name, "deflist") == 0
|
|
|
|
|
|| strcmp(node->name, "qalist") == 0)
|
|
|
|
|
{
|
|
|
|
|
return [self parseList: node];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "p") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *elem = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (elem == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
return [NSString stringWithFormat: @"<p>\r\n%@</p>\r\n", elem];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "example") == 0)
|
|
|
|
|
{
|
|
|
|
|
return [self parseExample: node];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "embed") == 0)
|
|
|
|
|
{
|
|
|
|
|
return [self parseEmbed: node];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NSLog(@"unknown block type - %s", node->name);
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseBody: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
CREATE_AUTORELEASE_POOL(arp);
|
|
|
|
|
BOOL needContents = NO;
|
|
|
|
|
NSMutableArray *back = [NSMutableArray arrayWithCapacity: 2];
|
|
|
|
|
NSMutableArray *body = [NSMutableArray arrayWithCapacity: 4];
|
|
|
|
|
NSMutableArray *front = [NSMutableArray arrayWithCapacity: 2];
|
|
|
|
|
NSString *chapter;
|
|
|
|
|
unsigned count;
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* Parse the front (unnumbered chapters) storing the html for each
|
|
|
|
|
* chapter as a separate string in the 'front' array.
|
|
|
|
|
*/
|
|
|
|
|
if (node != 0 && strcmp(node->name, "front") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
xmlNodePtr f = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (f != 0 && strcmp(f->name, "contents") == 0)
|
|
|
|
|
{
|
|
|
|
|
needContents = YES;
|
|
|
|
|
f = f->next;
|
|
|
|
|
}
|
|
|
|
|
while (f != 0 && strcmp(f->name, "chapter") == 0)
|
|
|
|
|
{
|
|
|
|
|
chapter = [self parseChapter: f contents: contents];
|
|
|
|
|
if (chapter == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
[front addObject: chapter];
|
|
|
|
|
f = f->next;
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Parse the main body of the document, storing the html for each
|
|
|
|
|
* chapter as a separate string in the 'body' array.
|
|
|
|
|
*/
|
|
|
|
|
while (node != 0 && strcmp(node->name, "chapter") == 0)
|
|
|
|
|
{
|
|
|
|
|
chapter = [self parseChapter: node contents: contents];
|
|
|
|
|
if (chapter == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
[body addObject: chapter];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Parse the back unnumbered part of the document, storing the html for each
|
|
|
|
|
* chapter as a separate string in the 'back' array.
|
|
|
|
|
*/
|
|
|
|
|
if (node != 0 && strcmp(node->name, "back") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
while (node != 0 && strcmp(node->name, "chapter") == 0)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
chapter = [self parseChapter: node contents: contents];
|
|
|
|
|
if (chapter == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
[back addObject: chapter];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Ok - parsed all the chapters of the document, so we have stored the
|
|
|
|
|
* document structure and can output a contents list.
|
|
|
|
|
*/
|
|
|
|
|
if (needContents)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<h1>Contents</h1>\r\n"];
|
|
|
|
|
[self appendContents: contents toString: text];
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Now output all the chapters.
|
|
|
|
|
*/
|
|
|
|
|
count = [front count];
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
chapter = [front objectAtIndex: i];
|
|
|
|
|
[text appendString: chapter];
|
|
|
|
|
}
|
|
|
|
|
count = [body count];
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
chapter = [body objectAtIndex: i];
|
|
|
|
|
[text appendString: chapter];
|
|
|
|
|
}
|
|
|
|
|
count = [back count];
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
chapter = [back objectAtIndex: i];
|
|
|
|
|
[text appendString: chapter];
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Now output any indices requested.
|
|
|
|
|
*/
|
|
|
|
|
while (node != 0 && strcmp(node->name, "index") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *type = [self getProp: "type" fromNode: node];
|
|
|
|
|
|
|
|
|
|
if (type != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<h1>%@ index</h1>\r\n", type];
|
|
|
|
|
[self appendIndex: type toString: text];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
[self appendFootnotesToString: text];
|
|
|
|
|
[text appendString: @"</body>\r\n"];
|
|
|
|
|
RELEASE(arp);
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseChapter: (xmlNodePtr)node contents: (NSMutableArray*)array
|
|
|
|
|
{
|
|
|
|
|
CREATE_AUTORELEASE_POOL(arp);
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
const char *type = node->name;
|
|
|
|
|
const char *next;
|
|
|
|
|
const char *h;
|
|
|
|
|
NSString *head;
|
|
|
|
|
NSString *ref;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString* nodeId=nil;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSMutableDictionary *dict;
|
|
|
|
|
NSMutableArray *subs;
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
nodeId=[self getProp: "id" fromNode: node];
|
|
|
|
|
ref = nodeId;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = [NSString stringWithFormat: @"cont-%u", contentsIndex++];
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node == 0 || strcmp(node->name, "heading") != 0)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"%s without heading", type);
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-03-11 21:58:40 +00:00
|
|
|
|
head = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(type, "chapter") == 0)
|
|
|
|
|
{
|
|
|
|
|
next = "section";
|
|
|
|
|
h = "h2";
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(type, "section") == 0)
|
|
|
|
|
{
|
|
|
|
|
next = "subsect";
|
|
|
|
|
h = "h3";
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(type, "subsect") == 0)
|
|
|
|
|
{
|
|
|
|
|
next = "subsubsect";
|
|
|
|
|
h = "h4";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
next = "";
|
|
|
|
|
h = "h5";
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if (!nodeId || ([nodeId length]>0 && ![nodeId isEqual:@"#"]))
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
[self setEntry:head
|
2000-08-16 14:08:08 +00:00
|
|
|
|
withExternalCompleteRef:[NSString stringWithFormat:@"%@##%@##%@",projectName,currName,head]
|
2000-08-13 16:00:14 +00:00
|
|
|
|
withExternalRef:head
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType:[NSString stringWithCString:type]];
|
|
|
|
|
};
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* Build content information and add it to the array at this level.
|
|
|
|
|
*/
|
|
|
|
|
subs = [NSMutableArray new];
|
|
|
|
|
dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
head, @"Title",
|
|
|
|
|
ref, @"Ref",
|
|
|
|
|
subs, @"Contents", nil];
|
|
|
|
|
RELEASE(subs);
|
|
|
|
|
[array addObject: dict];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Put heading in string.
|
|
|
|
|
*/
|
|
|
|
|
[text appendFormat: @"<%s><a name=\"%@\">%@</a></%s>\r\n", h, ref, head, h];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Try to parse block data up to the next subsection.
|
|
|
|
|
*/
|
|
|
|
|
while (node != 0 && strcmp(node->name, next) != 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *block = [self parseBlock: node];
|
|
|
|
|
|
|
|
|
|
if (block == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
[text appendString: block];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (node != 0 && strcmp(node->name, next) == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *chapter = [self parseChapter: node contents: subs];
|
|
|
|
|
|
|
|
|
|
if (chapter == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
[text appendString: chapter];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
[dict setObject: text forKey: @"Text"];
|
|
|
|
|
RELEASE(arp);
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseDef: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if ((strcmp(node->name, "class") == 0)
|
|
|
|
|
|| (strcmp(node->name, "jclass") == 0))
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
NSString *className = [self getProp: "name" fromNode: node];
|
|
|
|
|
NSString *superName = [self getProp: "super" fromNode: node];
|
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
NSString *declared = nil;
|
|
|
|
|
NSString *desc = nil;
|
|
|
|
|
NSMutableArray *conform = [NSMutableArray array];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSMutableArray *ivariables = [NSMutableArray array];//Instance Variables
|
|
|
|
|
NSMutableArray *factoryMethods = [NSMutableArray array]; //Factory Methods
|
|
|
|
|
NSMutableArray *instanceMethods = [NSMutableArray array]; // Instance Methods
|
|
|
|
|
NSMutableArray *standards = [NSMutableArray array]; // Standards
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (className == nil)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Missing class name");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = className;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// We're working on "className"
|
|
|
|
|
ASSIGN(currentClassName,className);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Clear the methods index so it will contain only values from this class.
|
|
|
|
|
*/
|
|
|
|
|
[[self indexForType: @"method"] removeAllObjects];
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "declared") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
declared = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "conform") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *s = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
[conform addObject: s];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
if (node != 0 && strcmp(node->name, "desc") == 0)
|
|
|
|
|
{
|
|
|
|
|
desc = [self parseDesc: node];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
|
|
|
|
while (node != 0 && strcmp(node->name, "ivariable") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *s = [self parseIVariable:node];
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
[ivariables addObject: s];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
2000-06-21 11:04:41 +00:00
|
|
|
|
while (node != 0 && ((strcmp(node->name, "method") == 0)
|
|
|
|
|
|| (strcmp(node->name, "jmethod") == 0)))
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// Is It a factory method ?
|
|
|
|
|
BOOL factoryMethod=[[self getProp: "factory" fromNode: node] boolValue];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSString *s = [self parseMethod: node];
|
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (factoryMethod)
|
|
|
|
|
[factoryMethods addObject: s];
|
|
|
|
|
else
|
|
|
|
|
[instanceMethods addObject: s];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "standard") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *s = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
[standards addObject: s];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: className
|
|
|
|
|
withExternalCompleteRef:className
|
|
|
|
|
withExternalRef:className
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"class"];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[text appendFormat: @"<h2><a name=\"%@\">%@</a></h2>\r\n",
|
2000-08-13 16:00:14 +00:00
|
|
|
|
ref, className];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (declared != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<p><b>Declared in:</b> %@</p>\r\n", declared];
|
|
|
|
|
}
|
|
|
|
|
if (superName != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<p><b>Inherits from:</b> %@</p>\r\n",
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[self linkedItem:superName
|
|
|
|
|
ofTypes:classesTypes]];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
if ([conform count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[text appendString: @"<p><b>Conforms to:</b>"];
|
|
|
|
|
for (i=0;i<[conform count];i++)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSString* conformItem=[conform objectAtIndex: i];
|
|
|
|
|
conformItem=[self linkedItem:conformItem
|
|
|
|
|
ofTypes:protocolsTypes];
|
|
|
|
|
[text appendFormat: @"%@ %@\r\n",
|
|
|
|
|
(i>0 ? @"," : @""),
|
|
|
|
|
conformItem];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
if ([standards count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<p><b>Standards:</b> %@\r\n",
|
|
|
|
|
[standards objectAtIndex: 0]];
|
|
|
|
|
for (i = 1; i < [standards count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @", %@\r\n", [standards objectAtIndex: i]];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (desc != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<hr>\r\n%@\r\n", desc];
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendString: @"<h2>Instance Variables</h2>\r\n"];
|
|
|
|
|
[self appendIndex: @"ivariable" toString:text];
|
|
|
|
|
|
|
|
|
|
[text appendString: @"<h2>Methods</h2>\r\n"];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[self appendIndex: @"method" toString: text];
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if ([ivariables count] > 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendString: @"<hr><h2>Instance Variables</h2>\r\n"];
|
|
|
|
|
for (i = 0; i < [ivariables count]; i++)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendString: [ivariables objectAtIndex: i]];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
|
|
|
|
if ([factoryMethods count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
[text appendString: @"<hr><h2>Class Methods</h2>\r\n"];
|
|
|
|
|
for (i = 0; i < [factoryMethods count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: [factoryMethods objectAtIndex: i]];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if ([instanceMethods count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
[text appendString: @"<hr><h2>Instances Methods</h2>\r\n"];
|
|
|
|
|
for (i = 0; i < [instanceMethods count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: [instanceMethods objectAtIndex: i]];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// We've finished working on "className"
|
|
|
|
|
ASSIGN(currentClassName,nil);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "category") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *className = [self getProp: "class" fromNode: node];
|
|
|
|
|
NSString *catName = [self getProp: "name" fromNode: node];
|
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
NSString *declared = nil;
|
|
|
|
|
NSString *desc = nil;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSMutableArray *conform = [NSMutableArray array];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSMutableArray *factoryMethods = [NSMutableArray array];
|
|
|
|
|
NSMutableArray *instanceMethods = [NSMutableArray array];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSMutableArray *standards = [NSMutableArray array];
|
|
|
|
|
NSString *name;
|
|
|
|
|
|
|
|
|
|
if (className == nil || catName == nil)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Missing category or class name");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-08-16 14:08:08 +00:00
|
|
|
|
name = [NSString stringWithFormat: @"%@ (%@)",className,catName];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = name;
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
// We works on a class & category
|
|
|
|
|
ASSIGN(currentClassName,className);
|
|
|
|
|
ASSIGN(currentCategoryName,catName);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* Clear the methods index so it will contain only values from this class.
|
|
|
|
|
*/
|
|
|
|
|
[[self indexForType: @"method"] removeAllObjects];
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "declared") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
declared = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-16 14:08:08 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "conform") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *s = [self parseText: node->children];
|
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
[conform addObject: s];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "desc") == 0)
|
|
|
|
|
{
|
|
|
|
|
desc = [self parseDesc: node];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "method") == 0)
|
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
BOOL factoryMethod=[[self getProp: "factory" fromNode: node] boolValue];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSString *s = [self parseMethod: node];
|
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (factoryMethod)
|
|
|
|
|
[factoryMethods addObject: s];
|
|
|
|
|
else
|
|
|
|
|
[instanceMethods addObject: s];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "standard") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *s = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
[standards addObject: s];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: name
|
|
|
|
|
withExternalCompleteRef:[NSString stringWithFormat:@"%@(%@)",className,catName]
|
|
|
|
|
withExternalRef:[NSString stringWithFormat:@"%@(%@)",className,catName]
|
|
|
|
|
withRef:ref
|
|
|
|
|
inIndexOfType: @"category"];
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<h2>%@ <a name=\"%@\">(%@)</a></h2>\r\n",
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[self linkedItem:className
|
|
|
|
|
ofTypes:classesTypes],
|
2000-08-13 16:00:14 +00:00
|
|
|
|
ref,
|
|
|
|
|
catName];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (declared != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<p><b>Declared in:</b> %@</p>\r\n", declared];
|
|
|
|
|
}
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if ([conform count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendString: @"<p><b>Conforms to:</b>\r\n"];
|
|
|
|
|
for (i=0;i<[conform count];i++)
|
|
|
|
|
{
|
|
|
|
|
NSString* conformItem=[conform objectAtIndex: i];
|
|
|
|
|
conformItem=[self linkedItem:conformItem
|
|
|
|
|
ofTypes:protocolsTypes];
|
|
|
|
|
[text appendFormat: @"%@ %@\r\n",
|
|
|
|
|
(i>0 ? @"," : @""),
|
|
|
|
|
conformItem];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</p>\r\n"];
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if ([standards count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<p><b>Standards:</b> %@\r\n",
|
|
|
|
|
[standards objectAtIndex: 0]];
|
|
|
|
|
for (i = 1; i < [standards count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @", %@\r\n", [standards objectAtIndex: i]];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (desc != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<hr>\r\n%@\r\n", desc];
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendString: @"<h2>Methods</h2>\r\n"];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[self appendIndex: @"method" toString: text];
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if ([factoryMethods count] > 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendString: @"<hr><h2>Class Methods</h2>\r\n"];
|
|
|
|
|
for (i = 0; i < [factoryMethods count]; i++)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendString: [factoryMethods objectAtIndex: i]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ([instanceMethods count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendString: @"<hr><h2>Instances Methods</h2>\r\n"];
|
|
|
|
|
for (i = 0; i < [instanceMethods count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: [instanceMethods objectAtIndex: i]];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-08-16 14:08:08 +00:00
|
|
|
|
// We've finished working on this class/category
|
|
|
|
|
ASSIGN(currentClassName,nil);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
ASSIGN(currentCategoryName,nil);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "protocol") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *protName = [self getProp: "name" fromNode: node];
|
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
NSString *declared = nil;
|
|
|
|
|
NSString *desc = nil;
|
|
|
|
|
NSMutableArray *methods = [NSMutableArray array];
|
|
|
|
|
NSMutableArray *standards = [NSMutableArray array];
|
|
|
|
|
|
|
|
|
|
if (protName == nil)
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
NSLog(@"Missing protocol name");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (ref == nil)
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
ref = protName;
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// Works on "protName"
|
|
|
|
|
ASSIGN(currentProtocolName,protName);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* Clear the methods index so it will contain only values from this class.
|
|
|
|
|
*/
|
|
|
|
|
[[self indexForType: @"method"] removeAllObjects];
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "declared") == 0)
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
declared = [self parseText: node->children];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "desc") == 0)
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
desc = [self parseDesc: node];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "method") == 0)
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
NSString *s = [self parseMethod: node];
|
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
[methods addObject: s];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "standard") == 0)
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
NSString *s = [self parseText: node->children];
|
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
[standards addObject: s];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: protName
|
|
|
|
|
withExternalCompleteRef:protName
|
|
|
|
|
withExternalRef:protName
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"protocol"];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[text appendFormat: @"<h2><a name=\"%@\">%@ Protocol</a></h2>\r\n",
|
2000-08-13 16:00:14 +00:00
|
|
|
|
ref, protName];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (declared != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<p><b>Declared in:</b> %@</p>\r\n", declared];
|
|
|
|
|
}
|
|
|
|
|
if ([standards count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<p><b>Standards:</b> %@\r\n",
|
|
|
|
|
[standards objectAtIndex: 0]];
|
|
|
|
|
for (i = 1; i < [standards count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @", %@\r\n", [standards objectAtIndex: i]];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (desc != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<hr>\r\n%@\r\n", desc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self appendIndex: @"method" toString: text];
|
|
|
|
|
|
|
|
|
|
if ([methods count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendString: @"<hr>\r\n"];
|
|
|
|
|
for (i = 0; i < [methods count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: [methods objectAtIndex: i]];
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
|
|
|
|
// Finished working on "protName"
|
|
|
|
|
ASSIGN(currentProtocolName,nil);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "function") == 0)
|
|
|
|
|
{
|
|
|
|
|
return [self parseFunction: node];
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "macro") == 0)
|
|
|
|
|
{
|
|
|
|
|
return [self parseMacro: node];
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "type") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *typeName = [self getProp: "name" fromNode: node];
|
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
NSString *declared = nil;
|
|
|
|
|
NSString *desc = nil;
|
|
|
|
|
NSString *spec = nil;
|
|
|
|
|
NSMutableArray *standards = [NSMutableArray array];
|
|
|
|
|
|
|
|
|
|
if (typeName == nil)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Missing type name");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = typeName;
|
|
|
|
|
}
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "typespec") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
spec = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
if (spec == nil)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Missing type specification");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (node != 0 && strcmp(node->name, "declared") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
declared = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "desc") == 0)
|
|
|
|
|
{
|
|
|
|
|
desc = [self parseDesc: node];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "standard") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *s = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
[standards addObject: s];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: typeName
|
|
|
|
|
withExternalCompleteRef:typeName
|
|
|
|
|
withExternalRef:typeName
|
|
|
|
|
withRef: ref inIndexOfType: @"type"];
|
|
|
|
|
[text appendFormat: @"<h3><a name=\"%@\">%@</a></h3>\r\n",
|
|
|
|
|
ref, typeName];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (declared != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<p><b>Declared in:</b> %@</p>\r\n", declared];
|
|
|
|
|
}
|
|
|
|
|
if ([standards count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<p><b>Standards:</b> %@\r\n",
|
|
|
|
|
[standards objectAtIndex: 0]];
|
|
|
|
|
for (i = 1; i < [standards count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @", %@\r\n", [standards objectAtIndex: i]];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<b>typedef</b> %@ %@<br>\r\n", spec, typeName];
|
|
|
|
|
|
|
|
|
|
if (desc != nil)
|
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendFormat: @"\r\n%@\r\n<hr>\r\n", desc];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "variable") == 0)
|
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
return [self parseVariable:node];
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "constant") == 0)
|
|
|
|
|
{
|
|
|
|
|
return [self parseConstant:node];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Definition of unknown type - %s", node->name);
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseDesc: (xmlNodePtr)node
|
|
|
|
|
{
|
2000-03-05 17:22:57 +00:00
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node == 0)
|
|
|
|
|
{
|
|
|
|
|
return @"";
|
|
|
|
|
}
|
2000-03-05 17:22:57 +00:00
|
|
|
|
while (node != 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-03-05 17:22:57 +00:00
|
|
|
|
if (strcmp(node->name, "list") == 0
|
|
|
|
|
|| strcmp(node->name, "enum") == 0
|
|
|
|
|
|| strcmp(node->name, "deflist") == 0
|
|
|
|
|
|| strcmp(node->name, "qalist") == 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-03-05 17:22:57 +00:00
|
|
|
|
[text appendString: [self parseList: node]];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-03-05 17:22:57 +00:00
|
|
|
|
else if (strcmp(node->name, "p") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *elem = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-03-05 17:22:57 +00:00
|
|
|
|
if (elem != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<p>\r\n%@</p>\r\n", elem];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "example") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: [self parseExample: node]];
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "embed") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: [self parseEmbed: node]];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-06-21 11:04:41 +00:00
|
|
|
|
xmlNodePtr old = node;
|
|
|
|
|
|
2000-03-17 13:13:08 +00:00
|
|
|
|
[text appendString: [self parseText: node end: &node]];
|
2000-06-21 11:04:41 +00:00
|
|
|
|
/*
|
|
|
|
|
* If we found text, the node will have been advanced, but if
|
|
|
|
|
* it failed we need to advance ourselves.
|
|
|
|
|
*/
|
|
|
|
|
if (node == old)
|
|
|
|
|
node = node->next;
|
2000-03-17 13:13:08 +00:00
|
|
|
|
continue;
|
2000-03-05 17:22:57 +00:00
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-03-05 17:22:57 +00:00
|
|
|
|
node = node->next;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-03-05 17:22:57 +00:00
|
|
|
|
return text;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseDocument
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
xmlNodePtr cur = doc->children->next->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSString *text;
|
|
|
|
|
NSString *body;
|
|
|
|
|
NSString *head;
|
|
|
|
|
|
|
|
|
|
if (cur == 0 || strcmp(cur->name, "head") != 0)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"head missing from document");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
if ((head = [self parseHead: cur]) == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
cur = cur->next;
|
|
|
|
|
if (cur == 0 || strcmp(cur->name, "body") != 0)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"body missing from document");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
if ((body = [self parseBody: cur]) == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text = [NSString stringWithFormat: @"<html>%@%@\r\n</html>\r\n", head, body];
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// Don't write result if !writeFlag
|
|
|
|
|
if (writeFlag && [defs boolForKey: @"Monolithic"] == YES)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// Replace "UserVariables" in text
|
|
|
|
|
text=TextByReplacingVariablesInText(text,variablesDictionary);
|
|
|
|
|
|
|
|
|
|
// Write the result
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[text writeToFile: currName atomically: YES];
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseEmbed: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
return @"An Embed";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseExample: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *elem = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
NSString *cap = [self getProp: "caption" fromNode: node];
|
|
|
|
|
|
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = [NSString stringWithFormat: @"label-%u", labelIndex++];
|
|
|
|
|
}
|
|
|
|
|
if (elem == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
if (cap == nil)
|
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: @"example"
|
|
|
|
|
withExternalCompleteRef:nil
|
|
|
|
|
withExternalRef:nil
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"label"];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[text appendFormat: @"<a name=\"%@\">example</a>\r\n", ref];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: cap
|
|
|
|
|
withExternalCompleteRef:nil
|
|
|
|
|
withExternalRef:nil
|
|
|
|
|
withRef:ref
|
|
|
|
|
inIndexOfType: @"label"];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[text appendFormat: @"<a name=\"%@\">%@</a>\r\n", ref, cap];
|
|
|
|
|
}
|
|
|
|
|
[text appendFormat: @"<pre>\r\n%@\r\n</pre>\r\n", elem];
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseFunction: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
NSString *type = [self getProp: "type" fromNode: node];
|
|
|
|
|
NSString *name = [self getProp: "name" fromNode: node];
|
|
|
|
|
NSString *desc = nil;
|
|
|
|
|
NSString *declared = nil;
|
|
|
|
|
NSMutableString *args = [NSMutableString stringWithString: @"("];
|
|
|
|
|
|
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = [NSString stringWithFormat: @"function-%u", labelIndex++];
|
|
|
|
|
}
|
|
|
|
|
if (type == nil)
|
|
|
|
|
{
|
|
|
|
|
type = @"int";
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
//Avoid ((xxx))
|
|
|
|
|
else if ([type hasPrefix:@"("] && [type hasSuffix:@")"])
|
|
|
|
|
type =[[type stringWithoutPrefix:@"("] stringWithoutSuffix:@")"];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
type=[self linkedItem:type
|
|
|
|
|
ofTypes:typesTypes];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "arg") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *arg = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSString *typ = [self getProp: "type" fromNode: node];
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (arg == nil)
|
|
|
|
|
return nil;
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if ([args length] > 1)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
[args appendString: @", "];
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (typ != nil)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
//Avoid ((xxx))
|
|
|
|
|
if ([typ hasPrefix:@"("] && [typ hasSuffix:@")"])
|
|
|
|
|
typ =[[typ stringWithoutPrefix:@"("] stringWithoutSuffix:@")"];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
typ=[self linkedItem:typ
|
|
|
|
|
ofTypes:typesTypes];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[args appendString: typ];
|
|
|
|
|
[args appendString: @" "];
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[args appendString: arg];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "vararg") == 0)
|
|
|
|
|
{
|
|
|
|
|
if ([args length] > 1)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
[args appendString: @", ..."];
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
else
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
[args appendString: @"..."];
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
[args appendString: @")"];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "declared") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
declared = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(node->name, "desc") == 0)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
desc = [self parseDesc: node];
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
else
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
NSLog(@"Unexpected node in function definition - %s", node->name);
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: name
|
|
|
|
|
withExternalCompleteRef:name
|
|
|
|
|
withExternalRef:name
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"function"];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[text appendFormat: @"<h2><a name=\"%@\">%@</a></h2>\r\n", ref, name];
|
|
|
|
|
if (declared != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<p><b>Declared in:</b> %@</p>\r\n", declared];
|
|
|
|
|
}
|
|
|
|
|
[text appendFormat: @"<b>Prototype:</b> %@ %@%@<br>\r\n", type, name, args];
|
|
|
|
|
|
|
|
|
|
if (desc != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: desc];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"\r\n<hr>\r\n"];
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseHead: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
NSString *abstract;
|
|
|
|
|
NSString *title;
|
|
|
|
|
NSString *copyright;
|
|
|
|
|
NSString *date;
|
|
|
|
|
NSString *version;
|
|
|
|
|
BOOL hadAuthor = NO;
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (node == 0 || strcmp(node->name, "title") != 0
|
2000-03-11 21:58:40 +00:00
|
|
|
|
|| (title = [self parseText: node->children]) == nil)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
NSLog(@"head without title");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
[text appendFormat: @"<head>\r\n<title>%@</title>\r\n", title];
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry:title
|
2000-08-24 17:24:40 +00:00
|
|
|
|
withExternalCompleteRef:[currName stringByDeletingPathExtension]
|
|
|
|
|
withExternalRef:[currName stringByDeletingPathExtension]
|
|
|
|
|
withRef: [currName stringByDeletingPathExtension]
|
2000-08-13 16:00:14 +00:00
|
|
|
|
inIndexOfType:@"file"];
|
|
|
|
|
|
|
|
|
|
if ([styleSheetURL length]>0)
|
|
|
|
|
[text appendFormat: @"<link rel=stylesheet type=\"text/css\" href=\"%@\">\r\n",styleSheetURL];
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[text appendString: @"</head>\r\n"];
|
|
|
|
|
[text appendString: @"<body>\r\n"];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if ([prevName length]>0)
|
2000-06-21 11:04:41 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
//Avoid empty link
|
|
|
|
|
NSString* test=TextByReplacingVariablesInText(prevName,variablesDictionary);
|
|
|
|
|
if ([test length]>0)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if ([[prevName pathExtension] isEqual:PathExtension_HTML] == YES)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendFormat: @"<a href=\"%@\">[Previous]</a>\n", prevName];
|
|
|
|
|
else
|
|
|
|
|
[text appendFormat: @"<a href=\"%@.html\">[Previous]</a>\n", prevName];
|
|
|
|
|
};
|
2000-06-21 11:04:41 +00:00
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if ([upName length]>0)
|
2000-06-21 11:04:41 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString* test=TextByReplacingVariablesInText(upName,variablesDictionary);
|
|
|
|
|
if ([test length]>0)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if ([[upName pathExtension] isEqual:PathExtension_HTML] == YES)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendFormat: @"<a href=\"%@\">[Up]</a>\n", upName];
|
|
|
|
|
else
|
|
|
|
|
[text appendFormat: @"<a href=\"%@.html\">[Up]</a>\n", upName];
|
|
|
|
|
};
|
2000-06-21 11:04:41 +00:00
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if ([nextName length]>0)
|
2000-06-21 11:04:41 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
//Avoid empty link
|
|
|
|
|
NSString* test=TextByReplacingVariablesInText(nextName,variablesDictionary);
|
|
|
|
|
if ([test length]>0)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if ([[nextName pathExtension] isEqual:PathExtension_HTML] == YES)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendFormat: @"<a href=\"%@\">[Next]</a>\n", nextName];
|
|
|
|
|
else
|
|
|
|
|
[text appendFormat: @"<a href=\"%@.html\">[Next]</a>\n", nextName];
|
|
|
|
|
};
|
|
|
|
|
};
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<h1>%@</h1>\r\n", title];
|
|
|
|
|
|
|
|
|
|
node = node->next;
|
|
|
|
|
while (node != 0 && strcmp(node->name, "author") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *author = [self parseAuthor: node];
|
|
|
|
|
|
|
|
|
|
if (author == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
if (hadAuthor == NO)
|
|
|
|
|
{
|
|
|
|
|
hadAuthor = YES;
|
|
|
|
|
[text appendString: @"<h3>Authors</h3>\r\n<dl>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: author];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
if (hadAuthor == YES)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"</dl>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (node != 0 && strcmp(node->name, "version") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
version = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
[text appendFormat: @"<p>Version: %@</p>\r\n", version];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (node != 0 && strcmp(node->name, "date") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
date = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
[text appendFormat: @"<p>Date: %@</p>\r\n", date];
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-05 17:22:57 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "abstract") == 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
abstract = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
2000-03-05 17:22:57 +00:00
|
|
|
|
[text appendFormat: @"<blockquote>%@</blockquote>\r\n", abstract];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-05 17:22:57 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "copy") == 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
copyright = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
2000-03-05 17:22:57 +00:00
|
|
|
|
[text appendFormat: @"<p>Copyright: %@</p>\r\n", copyright];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseItem: (xmlNodePtr)node
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "class") == 0
|
|
|
|
|
|| strcmp(node->name, "category") == 0
|
|
|
|
|
|| strcmp(node->name, "protocol") == 0
|
|
|
|
|
|| strcmp(node->name, "function") == 0
|
|
|
|
|
|| strcmp(node->name, "macro") == 0
|
|
|
|
|
|| strcmp(node->name, "type") == 0
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|| strcmp(node->name, "variable") == 0
|
|
|
|
|
|| strcmp(node->name, "ivariable") == 0
|
|
|
|
|
|| strcmp(node->name, "constant") == 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
return [self parseDef: node];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "list") == 0
|
|
|
|
|
|| strcmp(node->name, "enum") == 0
|
|
|
|
|
|| strcmp(node->name, "deflist") == 0
|
|
|
|
|
|| strcmp(node->name, "qalist") == 0)
|
|
|
|
|
{
|
|
|
|
|
return [self parseList: node];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "p") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *elem = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (elem == nil)
|
|
|
|
|
{
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
return [NSString stringWithFormat: @"<p>\r\n%@</p>\r\n", elem];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "example") == 0)
|
|
|
|
|
{
|
|
|
|
|
return [self parseExample: node];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "embed") == 0)
|
|
|
|
|
{
|
|
|
|
|
return [self parseEmbed: node];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [self parseText: node];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseList: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
|
|
|
|
|
if (strcmp(node->name, "list") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<ul>\r\n"];
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "item") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<li>%@\r\n", [self parseItem: node]];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</ul>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "enum") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<ol>\r\n"];
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "item") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<li>%@\r\n", [self parseItem: node]];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</ol>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "deflist") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<dl>\r\n"];
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(node->name, "term") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<dt>%@\r\n",
|
2000-03-11 21:58:40 +00:00
|
|
|
|
[self parseText: node->children]];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node == 0 || strcmp(node->name, "desc") != 0)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"term without desc");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-03-05 15:45:45 +00:00
|
|
|
|
[text appendFormat: @"<dd>%@\r\n", [self parseDesc: node]];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</dl>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<dl>\r\n"];
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(node->name, "question") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<dt>%@\r\n",
|
2000-03-11 21:58:40 +00:00
|
|
|
|
[self parseText: node->children]];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node == 0 || strcmp(node->name, "answer") != 0)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"term without desc");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-03-11 21:58:40 +00:00
|
|
|
|
[text appendFormat: @"<dt>%@\r\n", [self parseBlock: node->children]];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</dl>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// Parse Variable, IVariable or constant
|
|
|
|
|
- (NSString*) parseVariable: (xmlNodePtr)variableNode
|
|
|
|
|
orConstant: (xmlNodePtr)constantNode
|
|
|
|
|
ofType:(NSString*)type_
|
|
|
|
|
{
|
|
|
|
|
xmlNodePtr node=(variableNode ? variableNode : constantNode);
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
NSString *name = [self getProp: "name" fromNode: node];
|
|
|
|
|
NSString *type = variableNode ? [self getProp: "type" fromNode: node] : nil;
|
|
|
|
|
NSString *posttype = variableNode ? [self getProp: "posttype" fromNode: node] : nil;
|
|
|
|
|
NSString *value = [self getProp: "value" fromNode: node];
|
|
|
|
|
NSString *role = [self getProp: "role" fromNode: node];
|
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
NSString *declared = nil;
|
|
|
|
|
NSString *desc = nil;
|
|
|
|
|
NSMutableArray *standards = [NSMutableArray array];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSString *completeRefName=nil;
|
|
|
|
|
NSString* linkedType=nil;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (name == nil)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Missing variable/constant name");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (variableNode!=NULL && type == nil)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Missing variable type");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
2000-08-16 14:08:08 +00:00
|
|
|
|
|
|
|
|
|
if (type)
|
|
|
|
|
linkedType=[self linkedItem:type
|
|
|
|
|
ofTypes:typesTypes];
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = name;
|
|
|
|
|
}
|
|
|
|
|
node = node->children;
|
|
|
|
|
|
|
|
|
|
if (node != 0 && strcmp(node->name, "declared") == 0)
|
|
|
|
|
{
|
|
|
|
|
declared = [self parseText: node->children];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (node != 0 && strcmp(node->name, "desc") == 0)
|
|
|
|
|
{
|
|
|
|
|
desc = [self parseDesc: node];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (node != 0 && strcmp(node->name, "standard") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *s = [self parseText: node->children];
|
|
|
|
|
|
|
|
|
|
if (s != nil)
|
|
|
|
|
{
|
|
|
|
|
[standards addObject: s];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentClassName)
|
|
|
|
|
completeRefName=[NSString stringWithFormat:@"%@::%@",currentClassName,name];
|
|
|
|
|
else
|
|
|
|
|
completeRefName=name;
|
|
|
|
|
|
|
|
|
|
[self setEntry: name
|
|
|
|
|
withExternalCompleteRef:completeRefName
|
|
|
|
|
withExternalRef:name
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType:type_];
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<h2><a name=\"%@\">%@</a></h2>\r\n", ref, name];
|
|
|
|
|
if (declared != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<p><b>Declared in:</b> %@</p>\r\n", declared];
|
|
|
|
|
}
|
|
|
|
|
if ([standards count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<p><b>Standards:</b> %@\r\n",
|
|
|
|
|
[standards objectAtIndex: 0]];
|
|
|
|
|
for (i = 1; i < [standards count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @", %@\r\n", [standards objectAtIndex: i]];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ([role isEqual: @"except"])
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<p>Exception name</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
else if ([role isEqual: @"defaults"])
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<p>Defaults system key</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
else if ([role isEqual: @"notify"])
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<p>Notification name</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
else if ([role isEqual: @"key"])
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<p>Dictionary key</p>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value == nil)
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[text appendFormat: @"%@ <b>%@</b>%@<br>\r\n",
|
|
|
|
|
linkedType ? linkedType : @"",
|
|
|
|
|
name,
|
|
|
|
|
(posttype ? posttype : @"")];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[text appendFormat: @"%@ <b>%@</b>%@ = %@<br>\r\n",
|
|
|
|
|
linkedType ? linkedType : @"",
|
|
|
|
|
name,
|
|
|
|
|
(posttype ? posttype : @""),
|
|
|
|
|
value];
|
|
|
|
|
};
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
|
|
|
|
if (desc != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"\r\n%@\r\n", desc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Parse Variable
|
|
|
|
|
- (NSString*) parseVariable: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
return [self parseVariable:node
|
|
|
|
|
orConstant:NULL
|
|
|
|
|
ofType:@"variable"];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//Parse Instance Variable
|
|
|
|
|
- (NSString*) parseIVariable: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
return [self parseVariable:node
|
|
|
|
|
orConstant:NULL
|
|
|
|
|
ofType:@"ivariable"];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Parse Constant
|
|
|
|
|
- (NSString*) parseConstant: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
return [self parseVariable:NULL
|
|
|
|
|
orConstant:node
|
|
|
|
|
ofType:@"constant"];
|
|
|
|
|
};
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
- (NSString*) parseMacro: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
NSString *name = [self getProp: "name" fromNode: node];
|
|
|
|
|
NSString *desc = nil;
|
|
|
|
|
NSString *declared = nil;
|
|
|
|
|
NSMutableString *args = [NSMutableString stringWithString: @"("];
|
|
|
|
|
|
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = [NSString stringWithFormat: @"macro-%u", labelIndex++];
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "arg") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *arg = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSString *typ = [self getProp: "type" fromNode: node];
|
|
|
|
|
|
|
|
|
|
if (arg == nil) return nil;
|
|
|
|
|
if ([args length] > 1)
|
|
|
|
|
{
|
|
|
|
|
[args appendString: @", "];
|
|
|
|
|
}
|
|
|
|
|
if (typ != nil)
|
|
|
|
|
{
|
|
|
|
|
[args appendString: typ];
|
|
|
|
|
[args appendString: @" "];
|
|
|
|
|
}
|
|
|
|
|
[args appendString: arg];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "vararg") == 0)
|
|
|
|
|
{
|
|
|
|
|
if ([args length] > 1)
|
|
|
|
|
{
|
|
|
|
|
[args appendString: @", ..."];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[args appendString: @"..."];
|
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
if ([args length] == 1)
|
|
|
|
|
{
|
|
|
|
|
args = nil;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[args appendString: @")"];
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "declared") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
declared = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(node->name, "desc") == 0)
|
|
|
|
|
{
|
|
|
|
|
desc = [self parseDesc: node];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Unexpected node in function definition - %s", node->name);
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: name
|
|
|
|
|
withExternalCompleteRef:name
|
|
|
|
|
withExternalRef:name
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"macro"];
|
|
|
|
|
[text appendFormat: @"<h3><a name=\"%@\">%@</a></h3>\r\n", ref, name];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (declared != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<p><b>Declared in:</b> %@</p>\r\n", declared];
|
|
|
|
|
}
|
|
|
|
|
if (args == nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<b>Declaration:</b> %@<br>\r\n", name];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<b>Declaration:</b> %@%@<br>\r\n", name, args];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (desc != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: desc];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"\r\n<hr>\r\n"];
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) parseMethod: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
NSString *type = [self getProp: "type" fromNode: node];
|
|
|
|
|
NSString *over = [self getProp: "override" fromNode: node];
|
|
|
|
|
BOOL factory = [[self getProp: "factory" fromNode: node] boolValue];
|
|
|
|
|
BOOL desInit = [[self getProp: "init" fromNode: node] boolValue];
|
|
|
|
|
NSMutableString *lText = [NSMutableString string];
|
|
|
|
|
NSMutableString *sText = [NSMutableString string];
|
2000-06-21 11:04:41 +00:00
|
|
|
|
BOOL isJava = (strcmp(node->name, "jmethod") == 0);
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSString *desc = nil;
|
2000-03-10 11:47:52 +00:00
|
|
|
|
NSArray *standards = nil;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString *methodBlockName=nil;
|
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if (currentCategoryName)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSAssert(currentClassName,@"No Class Name");
|
2000-08-13 16:00:14 +00:00
|
|
|
|
methodBlockName=currentClassName;
|
|
|
|
|
}
|
2000-08-16 14:08:08 +00:00
|
|
|
|
else if (currentClassName)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
methodBlockName=currentClassName;
|
|
|
|
|
}
|
|
|
|
|
else if (currentProtocolName)
|
|
|
|
|
{
|
|
|
|
|
methodBlockName=currentProtocolName;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
methodBlockName=@"unknown";
|
|
|
|
|
};
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSAssert(methodBlockName,@"No methodBlockName");
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = [NSString stringWithFormat: @"method-%u",
|
2000-08-16 14:08:08 +00:00
|
|
|
|
labelIndex++];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if (isJava)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-06-21 11:04:41 +00:00
|
|
|
|
NSMutableString *decl = [NSMutableString string];
|
|
|
|
|
NSMutableString *args = [NSMutableString stringWithString: @"("];
|
|
|
|
|
NSString *name = [self getProp: "name" fromNode: node];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if (factory)
|
|
|
|
|
{
|
|
|
|
|
[decl appendString: @"static "];
|
|
|
|
|
}
|
|
|
|
|
if (type == nil)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
type = @"Object";
|
|
|
|
|
//Avoid ((xxx))
|
|
|
|
|
else if ([type hasPrefix:@"("] && [type hasSuffix:@")"])
|
|
|
|
|
type =[[type stringWithoutPrefix:@"("] stringWithoutSuffix:@")"];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
type=[self linkedItem:type
|
|
|
|
|
ofTypes:typesTypes];
|
2000-06-21 11:04:41 +00:00
|
|
|
|
[decl appendString: type];
|
|
|
|
|
[decl appendString: @" "];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-06-21 11:04:41 +00:00
|
|
|
|
node = node->children;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-06-21 11:04:41 +00:00
|
|
|
|
while (node != 0 && strcmp(node->name, "arg") == 0)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *arg = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSString *typ = [self getProp: "type" fromNode: node];
|
|
|
|
|
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if (arg == nil) break;
|
|
|
|
|
if ([args length] > 1)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-06-21 11:04:41 +00:00
|
|
|
|
[args appendString: @", "];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if (typ != nil)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
//Avoid ((xxx))
|
|
|
|
|
if ([typ hasPrefix:@"("] && [typ hasSuffix:@")"])
|
|
|
|
|
typ =[[typ stringWithoutPrefix:@"("] stringWithoutSuffix:@")"];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
typ=[self linkedItem:typ
|
|
|
|
|
ofTypes:typesTypes];
|
2000-06-21 11:04:41 +00:00
|
|
|
|
[args appendString: typ];
|
|
|
|
|
[args appendString: @" "];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-06-21 11:04:41 +00:00
|
|
|
|
[args appendString: arg];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
node = node->next;
|
2000-06-21 11:04:41 +00:00
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "vararg") == 0)
|
|
|
|
|
{
|
|
|
|
|
if ([args length] > 1)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-06-21 11:04:41 +00:00
|
|
|
|
[args appendString: @", ..."];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[args appendString: @"..."];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-06-21 11:04:41 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
[args appendString: @")"];
|
|
|
|
|
|
|
|
|
|
[lText appendString: decl];
|
|
|
|
|
[lText appendString: @"<b>"];
|
|
|
|
|
[lText appendString: name];
|
|
|
|
|
[lText appendString: @"</b>"];
|
|
|
|
|
[lText appendString: args];
|
|
|
|
|
[sText appendString: decl];
|
|
|
|
|
[sText appendString: name];
|
|
|
|
|
[sText appendString: args];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (factory)
|
|
|
|
|
{
|
|
|
|
|
[lText appendString: @"+ ("];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-06-21 11:04:41 +00:00
|
|
|
|
[lText appendString: @"- ("];
|
|
|
|
|
}
|
|
|
|
|
if (type == nil)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
type = @"id";
|
|
|
|
|
//Avoid ((xxx))
|
|
|
|
|
else if ([type hasPrefix:@"("] && [type hasSuffix:@")"])
|
|
|
|
|
type =[[type stringWithoutPrefix:@"("] stringWithoutSuffix:@")"];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
type=[self linkedItem:type
|
|
|
|
|
ofTypes:typesTypes];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-06-21 11:04:41 +00:00
|
|
|
|
[lText appendString: type];
|
|
|
|
|
[lText appendString: @")"];
|
|
|
|
|
|
|
|
|
|
node = node->children;
|
|
|
|
|
while (node != 0 && strcmp(node->name, "sel") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *sel = [self parseText: node->children];
|
|
|
|
|
|
|
|
|
|
if (sel == nil) return nil;
|
|
|
|
|
[sText appendString: sel];
|
|
|
|
|
[lText appendFormat: @" <b>%@</b>", sel];
|
|
|
|
|
node = node->next;
|
|
|
|
|
if (node != 0 && strcmp(node->name, "arg") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *arg = [self parseText: node->children];
|
|
|
|
|
NSString *typ = [self getProp: "type" fromNode: node];
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (arg == nil)
|
|
|
|
|
return nil;
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if (typ != nil)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
//Avoid ((xxx))
|
|
|
|
|
if ([typ hasPrefix:@"("] && [typ hasSuffix:@")"])
|
|
|
|
|
typ =[[typ stringWithoutPrefix:@"("] stringWithoutSuffix:@")"];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
typ=[self linkedItem:typ
|
|
|
|
|
ofTypes:typesTypes];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[lText appendFormat: @" (%@)%@", typ, arg];
|
|
|
|
|
}
|
2000-06-21 11:04:41 +00:00
|
|
|
|
else
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
[lText appendString: @" "];
|
|
|
|
|
[lText appendString: arg];
|
|
|
|
|
}
|
2000-06-21 11:04:41 +00:00
|
|
|
|
node = node->next;
|
|
|
|
|
if (node != 0 && strcmp(node->name, "vararg") == 0)
|
|
|
|
|
{
|
|
|
|
|
[lText appendString: @", ..."];
|
|
|
|
|
node = node->next;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
break; /* Just a selector */
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-06-21 11:04:41 +00:00
|
|
|
|
|
2000-03-10 11:47:52 +00:00
|
|
|
|
if (node != 0 && strcmp(node->name, "desc") == 0)
|
|
|
|
|
{
|
|
|
|
|
desc = [self parseDesc: node];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (node != 0)
|
|
|
|
|
{
|
2000-03-10 11:47:52 +00:00
|
|
|
|
standards = [self parseStandards: node];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-03-10 11:47:52 +00:00
|
|
|
|
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if (isJava)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: sText
|
2000-08-16 14:08:08 +00:00
|
|
|
|
withExternalCompleteRef:[NSString stringWithFormat:@"%@::%@",methodBlockName,sText]
|
2000-08-13 16:00:14 +00:00
|
|
|
|
withExternalRef:[NSString stringWithFormat:@"%@::%@",methodBlockName,sText]
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"method"];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if (factory)
|
|
|
|
|
{
|
|
|
|
|
NSString *s = [@"+" stringByAppendingString: sText];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: s
|
2000-08-16 14:08:08 +00:00
|
|
|
|
withExternalCompleteRef:[NSString stringWithFormat:@"+%@::%@",methodBlockName,sText]
|
2000-08-13 16:00:14 +00:00
|
|
|
|
withExternalRef:[NSString stringWithFormat:@"+%@::%@",methodBlockName,sText]
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"method"];
|
2000-06-21 11:04:41 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSString *s = [@"-" stringByAppendingString: sText];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[self setEntry: s
|
2000-08-16 14:08:08 +00:00
|
|
|
|
withExternalCompleteRef:[NSString stringWithFormat:@"-%@::%@",methodBlockName,sText]
|
2000-08-13 16:00:14 +00:00
|
|
|
|
withExternalRef:[NSString stringWithFormat:@"-%@::%@",methodBlockName,sText]
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"method"];
|
2000-06-21 11:04:41 +00:00
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[text appendFormat: @"<h3><a name=\"%@\">%@</a></h3>\r\n", ref, sText];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (desInit)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<b>This is the designated initialiser</b><br>\r\n"];
|
|
|
|
|
}
|
2000-06-21 11:04:41 +00:00
|
|
|
|
[text appendFormat: @"%@;<br>\r\n", lText];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if ([over isEqual: @"subclass"])
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"Your subclass <em>must</em> override this "
|
|
|
|
|
@"abstract method.<br>\r\n"];
|
|
|
|
|
}
|
|
|
|
|
else if ([over isEqual: @"never"])
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"Your subclass must <em>not</em> override this "
|
|
|
|
|
@"method.<br>\r\n"];
|
|
|
|
|
}
|
2000-03-10 11:47:52 +00:00
|
|
|
|
if ([standards count] > 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[text appendString: @"Standards:"];
|
|
|
|
|
for (i = 0; i < [standards count]; i++)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @" "];
|
|
|
|
|
[text appendString: [standards objectAtIndex: i]];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"<br>\r\n"];
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
if (desc != nil)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: desc];
|
|
|
|
|
}
|
|
|
|
|
[text appendString: @"\r\n<hr>\r\n"];
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-10 11:47:52 +00:00
|
|
|
|
- (NSArray*) parseStandards: (xmlNodePtr)node
|
|
|
|
|
{
|
|
|
|
|
if (node != 0)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(node->name, "standards") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSMutableArray *a = [NSMutableArray array];
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
node = node->children;
|
2000-03-10 11:47:52 +00:00
|
|
|
|
while (node != 0 && node->name != 0)
|
|
|
|
|
{
|
|
|
|
|
[a addObject: [NSString stringWithCString: node->name]];
|
|
|
|
|
node = node->next;
|
|
|
|
|
}
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Unexpected node in method definition - %s", node->name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-17 13:13:08 +00:00
|
|
|
|
- (NSString*) parseText: (xmlNodePtr)node end: (xmlNodePtr*)endNode
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
|
|
|
|
NSMutableString *text = [NSMutableString string];
|
|
|
|
|
|
2000-03-17 13:13:08 +00:00
|
|
|
|
*endNode = node;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
while (node != 0)
|
|
|
|
|
{
|
|
|
|
|
switch (node->type)
|
|
|
|
|
{
|
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
|
[text appendFormat: @"%s", node->content];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case XML_ENTITY_REF_NODE:
|
|
|
|
|
[text appendFormat: @"%s", node->content];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case XML_ELEMENT_NODE:
|
2000-06-21 11:04:41 +00:00
|
|
|
|
if (strcmp(node->name, "br") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendString: @"<br>"];
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "code") == 0
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|| strcmp(node->name, "em") == 0
|
|
|
|
|
|| strcmp(node->name, "file") == 0
|
|
|
|
|
|| strcmp(node->name, "site") == 0
|
|
|
|
|
|| strcmp(node->name, "strong") == 0
|
|
|
|
|
|| strcmp(node->name, "var") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *elem = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
[text appendFormat: @"<%s>%@</%s>",
|
|
|
|
|
node->name, elem, node->name];
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "entry") == 0
|
|
|
|
|
|| strcmp(node->name, "label") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *elem;
|
|
|
|
|
NSString *ref;
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
elem = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
if (ref == nil)
|
|
|
|
|
{
|
|
|
|
|
ref = [NSString stringWithFormat: @"label-%u",
|
|
|
|
|
labelIndex++];
|
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
|
|
|
|
[self setEntry: elem
|
|
|
|
|
withExternalCompleteRef:[NSString stringWithFormat:@"%@::%@",@"***unknown",elem]
|
|
|
|
|
withExternalRef:[NSString stringWithFormat:@"%@::%@",@"***unknown",elem]
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"label"];
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
if (strcmp(node->name, "label") == 0)
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<a name=\"%@\">%@</a>", ref, elem];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[text appendFormat: @"<a name=\"%@\"></a>", ref];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "footnote") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString *elem;
|
|
|
|
|
NSString *ref;
|
|
|
|
|
|
2000-03-11 21:58:40 +00:00
|
|
|
|
elem = [self parseText: node->children];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
ref = [NSString stringWithFormat: @"foot-%u",
|
|
|
|
|
[footnotes count]];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
|
|
|
|
[self setEntry: elem
|
|
|
|
|
withExternalCompleteRef:[NSString stringWithFormat:@"%@::%@",@"***unknown",elem]
|
|
|
|
|
withExternalRef:[NSString stringWithFormat:@"%@::%@",@"***unknown",elem]
|
|
|
|
|
withRef: ref
|
|
|
|
|
inIndexOfType: @"footnote"];
|
|
|
|
|
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[footnotes addObject: elem];
|
|
|
|
|
[text appendFormat: @" %@ ",
|
|
|
|
|
[self addLink: ref withText: @"see footnote"]];
|
|
|
|
|
}
|
2000-03-05 10:50:24 +00:00
|
|
|
|
else if (strcmp(node->name, "ref") == 0)
|
|
|
|
|
{
|
2000-03-11 21:58:40 +00:00
|
|
|
|
NSString *elem = [self parseText: node->children];
|
2000-03-05 15:45:45 +00:00
|
|
|
|
// NSString *typ = [self getProp: "type" fromNode: node];
|
2000-03-05 10:50:24 +00:00
|
|
|
|
// NSString *cls = [self getProp: "class" fromNode: node];
|
|
|
|
|
NSString *ref = [self getProp: "id" fromNode: node];
|
|
|
|
|
|
|
|
|
|
if ([elem length] == 0)
|
|
|
|
|
{
|
|
|
|
|
elem = ref;
|
|
|
|
|
}
|
|
|
|
|
[text appendString: [self addLink: ref withText: elem]];
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
else if (strcmp(node->name, "uref") == 0)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSString *elem = [self parseText: node->children];
|
|
|
|
|
NSString *ref = [self getProp: "url" fromNode: node];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if ([elem length] == 0)
|
|
|
|
|
elem = ref;
|
|
|
|
|
[text appendFormat: @"<a href=\"%@\">%@</a>", ref, elem];
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(node->name, "prjref") == 0)
|
|
|
|
|
{
|
|
|
|
|
NSString* elem = [self parseText: node->children];
|
|
|
|
|
NSString* prjName = [self getProp: "prjname" fromNode: node];
|
|
|
|
|
NSString* prjFile = [self getProp: "file" fromNode: node];
|
|
|
|
|
NSString* symbolKey=nil;
|
|
|
|
|
NSString* link=nil;
|
|
|
|
|
if ([prjName length]==0)
|
|
|
|
|
prjName=projectName;
|
|
|
|
|
if ([elem length] == 0)
|
|
|
|
|
elem = prjName;
|
|
|
|
|
|
|
|
|
|
symbolKey=[NSString stringWithFormat:@"%@##%@",
|
|
|
|
|
prjName,
|
|
|
|
|
([prjFile length] ? prjFile : @"index")];
|
|
|
|
|
link=[self linkForSymbolKey:symbolKey
|
|
|
|
|
ofTypes:filesTypes
|
|
|
|
|
withText:elem];
|
|
|
|
|
[text appendString:link];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-03-17 13:13:08 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return text;
|
|
|
|
|
}
|
2000-02-28 16:23:53 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2000-03-17 13:13:08 +00:00
|
|
|
|
return text;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
node = node->next;
|
2000-03-17 13:13:08 +00:00
|
|
|
|
*endNode = node;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setEntry: (NSString*)entry
|
2000-08-13 16:00:14 +00:00
|
|
|
|
withExternalCompleteRef:(NSString*)externalCompleteRef
|
|
|
|
|
withExternalRef: (NSString*)externalRef
|
|
|
|
|
withRef: (NSString*)ref
|
2000-02-28 16:23:53 +00:00
|
|
|
|
inIndexOfType: (NSString*)type
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSMutableDictionary* index = nil;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSAssert(entry,@"No entry");
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSAssert1(ref,@"No ref for %@",entry);
|
|
|
|
|
NSAssert1(type,@"No type for %@",entry);
|
|
|
|
|
index=[self indexForType: type];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[index setObject: entry forKey: ref];
|
|
|
|
|
[refToFile setObject: currName forKey: ref];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if (processFileReferencesFlag && externalCompleteRef && externalRef)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSMutableDictionary* typeDict=[fileReferences objectForKey:type];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (!fileReferences)
|
|
|
|
|
{
|
|
|
|
|
fileReferences=[NSMutableDictionary new];
|
|
|
|
|
};
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if (!typeDict)
|
|
|
|
|
{
|
|
|
|
|
typeDict=[NSMutableDictionary dictionary];
|
|
|
|
|
[fileReferences setObject:typeDict
|
|
|
|
|
forKey:type];
|
|
|
|
|
};
|
|
|
|
|
if (![typeDict objectForKey:externalCompleteRef])
|
|
|
|
|
{
|
|
|
|
|
NSMutableDictionary* thisEntry = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
entry, @"title",
|
|
|
|
|
externalRef, @"ref",
|
|
|
|
|
externalCompleteRef,@"completeRef",
|
|
|
|
|
ref, @"fragment",
|
|
|
|
|
type, @"type",
|
2000-08-24 17:24:40 +00:00
|
|
|
|
[currName stringByDeletingPathExtension], @"fileName",
|
2000-08-16 14:08:08 +00:00
|
|
|
|
nil];
|
|
|
|
|
[typeDict setObject:thisEntry
|
|
|
|
|
forKey:externalCompleteRef];
|
|
|
|
|
};
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
-(NSArray*)contents
|
|
|
|
|
{
|
|
|
|
|
return contents;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
-(NSDictionary*)fileReferences
|
|
|
|
|
{
|
|
|
|
|
return fileReferences;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
-(void)setGeneralReferences:(NSDictionary*)dict
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(generalReferences,dict);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
-(void)setVariablesDictionary:(NSDictionary*)dict
|
|
|
|
|
{
|
|
|
|
|
DESTROY(variablesDictionary);
|
|
|
|
|
variablesDictionary=[dict mutableCopy];
|
|
|
|
|
};
|
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
//Return a link for item (something like: <A HREF="TheFile.html#fragment">TheItem</A>) of type types
|
|
|
|
|
-(NSString*)linkedItem:(NSString*)item
|
|
|
|
|
ofTypes:(NSArray*)types
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
NSString* linked=nil;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSRange foundRange=[item rangeOfCharacterFromSet:[NSCharacterSet alphanumericCharacterSet]];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (foundRange.length>0)
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSString* goodItem=nil;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSDictionary* symbol=nil;
|
|
|
|
|
NSRange goodRange=NSMakeRange(foundRange.location,1);
|
2000-08-16 14:08:08 +00:00
|
|
|
|
while (foundRange.length>0 && foundRange.location+foundRange.length<[item length])
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
foundRange=[item rangeOfCharacterFromSet:[NSCharacterSet alphanumericCharacterSet]
|
2000-08-13 16:00:14 +00:00
|
|
|
|
options:0
|
|
|
|
|
range:NSMakeRange(foundRange.location+1,1)];
|
|
|
|
|
if (foundRange.length>0)
|
|
|
|
|
goodRange.length++;
|
|
|
|
|
};
|
2000-08-16 14:08:08 +00:00
|
|
|
|
goodItem=[item substringWithRange:goodRange];
|
|
|
|
|
symbol=[self findSymbolForKey:goodItem
|
|
|
|
|
ofTypes:types];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (symbol)
|
|
|
|
|
{
|
|
|
|
|
linked=[self linkForSymbol:symbol
|
2000-08-16 14:08:08 +00:00
|
|
|
|
withText:goodItem];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (goodRange.location>0)
|
|
|
|
|
{
|
|
|
|
|
linked=[NSString stringWithFormat:@"%@%@",
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[item substringWithRange:NSMakeRange(0,goodRange.location-1)],
|
2000-08-13 16:00:14 +00:00
|
|
|
|
linked];
|
|
|
|
|
};
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if (goodRange.location+goodRange.length<[item length])
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
linked=[NSString stringWithFormat:@"%@%@",
|
|
|
|
|
linked,
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[item substringWithRange:NSMakeRange(goodRange.location+goodRange.length,
|
|
|
|
|
[item length]-(goodRange.location+goodRange.length))]];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
if (!linked)
|
2000-08-16 14:08:08 +00:00
|
|
|
|
linked=item;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
return linked;
|
|
|
|
|
};
|
|
|
|
|
|
2000-08-24 17:24:40 +00:00
|
|
|
|
-(NSString*)linkForSymbolKey:(NSString*)key_
|
|
|
|
|
ofTypes:(NSArray*)types
|
|
|
|
|
withText:(NSString*)text
|
|
|
|
|
{
|
|
|
|
|
NSDictionary* symbol=[self findSymbolForKey:key_
|
|
|
|
|
ofTypes:types];
|
|
|
|
|
if (symbol)
|
|
|
|
|
return [self linkForSymbol:symbol
|
|
|
|
|
withText:text];
|
|
|
|
|
else
|
|
|
|
|
return text;
|
|
|
|
|
};
|
2000-08-13 16:00:14 +00:00
|
|
|
|
|
|
|
|
|
//Return the symbol for key
|
|
|
|
|
-(NSDictionary*)findSymbolForKey:(NSString*)key_
|
2000-08-16 14:08:08 +00:00
|
|
|
|
ofTypes:(NSArray*)types
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
NSDictionary* symbol=nil;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
int i=0;
|
|
|
|
|
for(i=0;!symbol && i<[types count];i++)
|
|
|
|
|
symbol=[[generalReferences objectForKey:[types objectAtIndex:i]]
|
|
|
|
|
objectForKey:key_];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
return symbol;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Return a link for symbol with label text
|
|
|
|
|
-(NSString*)linkForSymbol:(NSDictionary*)symbol
|
|
|
|
|
withText:(NSString*)text
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSString* symbolLocation=[[symbol objectForKey:@"project"] objectForKey:@"location"];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSString* locationTmp=location;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString* common=nil;
|
|
|
|
|
NSString* prefix=@"";
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSString* fragment=nil;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if ([locationTmp length]>0)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
//Equal: no prefix
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if (![locationTmp isEqual:symbolLocation])
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if (![locationTmp hasSuffix:@"/"])
|
|
|
|
|
locationTmp=[locationTmp stringByAppendingString:@"/"];
|
|
|
|
|
if ([symbolLocation length]>0 && ![symbolLocation hasSuffix:@"/"])
|
|
|
|
|
symbolLocation=[symbolLocation stringByAppendingString:@"/"];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
common=[symbolLocation commonPrefixWithString:location
|
|
|
|
|
options:0];
|
|
|
|
|
if ([common length]>0)
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
int i=0;
|
|
|
|
|
NSMutableArray* locationParts=[[[locationTmp componentsSeparatedByString:@"/"] mutableCopy] autorelease];
|
|
|
|
|
NSMutableArray* symbolLocationParts=[[[symbolLocation componentsSeparatedByString:@"/"] mutableCopy] autorelease];
|
|
|
|
|
[locationParts removeLastObject];
|
|
|
|
|
[symbolLocationParts removeLastObject];
|
|
|
|
|
while([locationParts count]>0
|
|
|
|
|
&& [symbolLocationParts count]>0
|
|
|
|
|
&& [[locationParts objectAtIndex:0] isEqual:[symbolLocationParts objectAtIndex:0]])
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[locationParts removeObjectAtIndex:0];
|
|
|
|
|
[symbolLocationParts removeObjectAtIndex:0];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
2000-08-16 14:08:08 +00:00
|
|
|
|
prefix=[NSString string];
|
|
|
|
|
for(i=0;i<[locationParts count];i++)
|
|
|
|
|
prefix=[@".." stringByAppendingPathComponent:prefix];
|
|
|
|
|
for(i=0;i<[symbolLocationParts count];i++)
|
|
|
|
|
prefix=[prefix stringByAppendingPathComponent:[symbolLocationParts objectAtIndex:i]];
|
|
|
|
|
}
|
|
|
|
|
else
|
2000-08-24 17:24:40 +00:00
|
|
|
|
prefix=([symbolLocation length]>0 ? symbolLocation : @"");
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
// No Project Location==> take symbol location
|
2000-08-24 17:24:40 +00:00
|
|
|
|
prefix=([symbolLocation length]>0 ? symbolLocation : @"");
|
|
|
|
|
fragment= [symbol objectForKey:@"fragment"];
|
|
|
|
|
return [NSString stringWithFormat:@"<A HREF=\"%@%@%@\">%@</A>",
|
|
|
|
|
[[prefix stringByAppendingPathComponent:[symbol objectForKey:@"fileName"]]
|
|
|
|
|
stringByAppendingPathExtension:PathExtension_HTML],
|
|
|
|
|
([fragment length]>0 ? @"#" : @""),
|
|
|
|
|
(fragment ? fragment : @""),
|
2000-08-13 16:00:14 +00:00
|
|
|
|
text];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
-(void)setWriteFlag:(BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
writeFlag=flag;
|
|
|
|
|
};
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
-(void)setProcessFileReferencesFlag:(BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
processFileReferencesFlag=flag;
|
|
|
|
|
};
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
-(void)setProjectName:(NSString*)projectName_
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
ASSIGN(projectName,projectName_);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
// Return files list of files in symbols
|
|
|
|
|
//
|
|
|
|
|
// symbols:
|
|
|
|
|
// {
|
2000-08-16 14:08:08 +00:00
|
|
|
|
// class=
|
|
|
|
|
// {
|
|
|
|
|
// "NSString" = { fileName = "NSString.gsdoc"; ...};
|
|
|
|
|
// "NSArray" = { fileName = "NSArray.gsdoc"; ... };
|
|
|
|
|
// ...
|
|
|
|
|
// };
|
|
|
|
|
// type= {
|
|
|
|
|
// ...
|
|
|
|
|
// };
|
|
|
|
|
// ...
|
|
|
|
|
// }
|
2000-08-13 16:00:14 +00:00
|
|
|
|
//
|
|
|
|
|
// Return:
|
|
|
|
|
// ( NSString.gsdoc, NSArray.gsdoc, ... )
|
|
|
|
|
NSArray* FilesFromSymbols(NSDictionary* symbols)
|
|
|
|
|
{
|
|
|
|
|
NSArray* sortedFiles=nil;
|
|
|
|
|
NSMutableArray* files=[[NSMutableArray new] autorelease];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSEnumerator* typesEnumerator = [symbols keyEnumerator];
|
|
|
|
|
id typeKey=nil;
|
|
|
|
|
while ((typeKey = [typesEnumerator nextObject]))
|
|
|
|
|
{
|
|
|
|
|
NSDictionary* type=[symbols objectForKey:typeKey];
|
|
|
|
|
NSEnumerator* symbolsEnumerator = [type keyEnumerator];
|
|
|
|
|
id symbolKey=nil;
|
|
|
|
|
while ((symbolKey = [symbolsEnumerator nextObject]))
|
|
|
|
|
{
|
|
|
|
|
NSDictionary* symbol=[type objectForKey:symbolKey];
|
|
|
|
|
id file=[symbol objectForKey:@"fileName"];
|
|
|
|
|
if (![files containsObject:file])
|
|
|
|
|
[files addObject:file];
|
|
|
|
|
};
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
sortedFiles=[files sortedArrayUsingSelector:@selector(compare:)];
|
|
|
|
|
return sortedFiles;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
// Return list of files found in dir (deep search) which have extension extension
|
|
|
|
|
NSArray* FilesInPathWithExtension(NSString* dir,NSString* extension)
|
|
|
|
|
{
|
|
|
|
|
NSMutableArray* files=[NSMutableArray array];
|
|
|
|
|
NSString *file=nil;
|
|
|
|
|
NSFileManager* fm=[NSFileManager defaultManager];
|
|
|
|
|
NSDirectoryEnumerator *enumerator = [fm enumeratorAtPath:dir];
|
|
|
|
|
while ((file = [enumerator nextObject]))
|
|
|
|
|
{
|
|
|
|
|
BOOL isDirectory=NO;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
file=[dir stringByAppendingPathComponent:file];
|
|
|
|
|
if ([[file pathExtension] isEqual:extension])
|
|
|
|
|
{
|
|
|
|
|
if ([fm fileExistsAtPath:file isDirectory:&isDirectory])
|
|
|
|
|
{
|
|
|
|
|
if (!isDirectory)
|
|
|
|
|
{
|
|
|
|
|
[files addObject:file];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
return files;
|
|
|
|
|
};
|
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
void AddSymbolsToReferencesWithProjectInfo(NSDictionary* symbols,
|
|
|
|
|
NSMutableDictionary* references,
|
|
|
|
|
NSDictionary* projectInfo,
|
|
|
|
|
BOOL override)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSString* projectName=[projectInfo objectForKey:@"projectName"];
|
|
|
|
|
if (symbols)
|
|
|
|
|
{
|
|
|
|
|
NSEnumerator* typesEnumerator = nil;
|
|
|
|
|
id typeKey=nil;
|
|
|
|
|
NSCAssert1([symbols isKindOfClass:[NSDictionary class]],
|
|
|
|
|
@"%@ is not a dictionary",
|
|
|
|
|
symbols);
|
|
|
|
|
typesEnumerator = [symbols keyEnumerator];
|
|
|
|
|
while ((typeKey = [typesEnumerator nextObject]))
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSDictionary* type=[symbols objectForKey:typeKey];
|
|
|
|
|
if (![type isKindOfClass:[NSDictionary class]])
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSLog(@"Warning: Type %@ is not a dictionary",type);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSEnumerator* symbolsEnumerator = [type keyEnumerator];
|
|
|
|
|
id symbolKey=nil;
|
|
|
|
|
NSMutableDictionary* referencesType=[references objectForKey:typeKey];
|
|
|
|
|
if (!referencesType)
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
referencesType=[NSMutableDictionary dictionary];
|
|
|
|
|
[references setObject:referencesType
|
|
|
|
|
forKey:typeKey];
|
|
|
|
|
};
|
|
|
|
|
while ((symbolKey = [symbolsEnumerator nextObject]))
|
|
|
|
|
{
|
|
|
|
|
NSDictionary* symbol=[type objectForKey:symbolKey];
|
|
|
|
|
if (![symbol isKindOfClass:[NSDictionary class]])
|
2000-08-16 14:08:08 +00:00
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSLog(@"Warning: Symbol %@ is not a dictionary",symbol);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSMutableDictionary* symbolNew=[NSMutableDictionary dictionaryWithDictionary:symbol];
|
|
|
|
|
if (verbose>=4)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Project %@ Processing reference %@",
|
|
|
|
|
projectName,
|
|
|
|
|
symbolKey);
|
|
|
|
|
};
|
|
|
|
|
if (projectInfo)
|
|
|
|
|
[symbolNew setObject:projectInfo
|
|
|
|
|
forKey:@"project"];
|
|
|
|
|
NSCAssert(symbolKey,@"No symbolKey");
|
2000-08-16 14:08:08 +00:00
|
|
|
|
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (override || ![referencesType objectForKey:symbolKey])
|
|
|
|
|
[referencesType setObject:symbolNew
|
|
|
|
|
forKey:symbolKey];
|
|
|
|
|
NSCAssert1([symbolNew objectForKey:@"ref"],@"No ref for symbol %@",symbolKey);
|
|
|
|
|
if (override || ![referencesType objectForKey:[symbolNew objectForKey:@"ref"]])
|
|
|
|
|
[referencesType setObject:symbolNew
|
|
|
|
|
forKey:[symbolNew objectForKey:@"ref"]];
|
|
|
|
|
if (projectName)
|
|
|
|
|
{
|
|
|
|
|
NSString* symbolType=[symbolNew objectForKey:@"type"];
|
|
|
|
|
if ([symbolType isEqual:@"file"])
|
|
|
|
|
{
|
|
|
|
|
NSString* fileName=[symbolNew objectForKey:@"fileName"];
|
|
|
|
|
if (fileName)
|
|
|
|
|
{
|
|
|
|
|
NSString* fileRef=nil;
|
|
|
|
|
fileName=[fileName stringByDeletingPathExtension];
|
|
|
|
|
fileRef=[NSString stringWithFormat:@"%@##%@",
|
|
|
|
|
projectName,
|
|
|
|
|
fileName];
|
|
|
|
|
[symbolNew setObject:fileRef
|
|
|
|
|
forKey:@"completeRef"];
|
|
|
|
|
if (override || ![referencesType objectForKey:fileRef])
|
|
|
|
|
[referencesType setObject:symbolNew
|
|
|
|
|
forKey:fileRef];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2000-08-16 14:08:08 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (projectName)
|
|
|
|
|
{
|
|
|
|
|
NSString* fileName=[[projectInfo objectForKey:@"indexfileName"]stringByDeletingPathExtension];
|
|
|
|
|
NSString* fileRef=nil;
|
|
|
|
|
NSMutableDictionary* referencesType=[references objectForKey:@"file"];
|
|
|
|
|
if (!referencesType)
|
|
|
|
|
{
|
|
|
|
|
referencesType=[NSMutableDictionary dictionary];
|
|
|
|
|
[references setObject:referencesType
|
|
|
|
|
forKey:@"file"];
|
|
|
|
|
};
|
|
|
|
|
if (!fileName)
|
|
|
|
|
fileName=@"index";
|
|
|
|
|
fileRef=[NSString stringWithFormat:@"%@##%@",
|
|
|
|
|
projectName,
|
|
|
|
|
fileName];
|
|
|
|
|
if (override || ![referencesType objectForKey:fileRef])
|
|
|
|
|
{
|
|
|
|
|
NSMutableDictionary* symbol=[NSMutableDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
fileRef,@"completeRef",
|
|
|
|
|
fileName,@"fileName",
|
|
|
|
|
fileName,@"ref",
|
|
|
|
|
@"file",@"type",
|
|
|
|
|
nil];
|
|
|
|
|
if (projectInfo)
|
|
|
|
|
[symbol setObject:projectInfo
|
|
|
|
|
forKey:@"project"];
|
|
|
|
|
[referencesType setObject:symbol
|
|
|
|
|
forKey:fileRef];
|
|
|
|
|
};
|
|
|
|
|
};
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
int main(int argc, char **argv, char **env)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-06-29 03:51:06 +00:00
|
|
|
|
NSAutoreleasePool *pool;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
NSProcessInfo *proc;
|
|
|
|
|
NSArray *args;
|
|
|
|
|
unsigned i;
|
2000-06-29 03:51:06 +00:00
|
|
|
|
NSUserDefaults *defs;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString* makeRefsFileName=nil; // makeRefs file name
|
|
|
|
|
NSString* projectName=nil; // project Name
|
|
|
|
|
NSMutableArray* files=nil; // Files to parse
|
|
|
|
|
NSMutableArray* references=nil; // Array of References files/directories
|
|
|
|
|
NSMutableDictionary* generalReferences=nil; // References (information coming from references files/directories)
|
|
|
|
|
NSMutableDictionary* projectReferences=nil; // Project References (references founds by parsing files)
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSString* makeIndexBaseFileName=nil; // makeIndex file name
|
|
|
|
|
NSString* makeIndexFileNameGSDoc=nil; // makeIndex file name with gsdoc extension
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString* makeIndexTemplateFileName=nil; // makeIndex template file name
|
|
|
|
|
NSMutableDictionary* infoDictionary=nil; // user info
|
|
|
|
|
NSDictionary* variablesDictionary=nil; // variables dictionary
|
|
|
|
|
NSMutableDictionary* projectInfo=nil; // Information On Project
|
|
|
|
|
BOOL goOn=YES;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSFileManager* fileManager=nil;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-06-29 03:51:06 +00:00
|
|
|
|
#ifdef GS_PASS_ARGUMENTS
|
|
|
|
|
[NSProcessInfo initializeWithArguments:argv count:argc environment:env];
|
|
|
|
|
#endif
|
|
|
|
|
pool = [NSAutoreleasePool new];
|
|
|
|
|
defs = [NSUserDefaults standardUserDefaults];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[defs registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
@"Yes", @"Monolithic",
|
|
|
|
|
nil]];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
|
|
|
|
proc = [NSProcessInfo processInfo];
|
|
|
|
|
if (proc == nil)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"unable to get process information!");
|
2000-08-13 16:00:14 +00:00
|
|
|
|
goOn=NO;
|
|
|
|
|
};
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
fileManager=[NSFileManager defaultManager];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (goOn)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
args = [proc arguments];
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-08-13 16:00:14 +00:00
|
|
|
|
// First, process arguments
|
|
|
|
|
for (i=1;goOn && i<[args count];i++)
|
2000-02-28 16:23:53 +00:00
|
|
|
|
{
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString* arg = [args objectAtIndex: i];
|
|
|
|
|
// is this an option ?
|
|
|
|
|
if ([arg hasPrefix:@"--"])
|
|
|
|
|
{
|
|
|
|
|
NSString* argWithoutPrefix=[arg stringWithoutPrefix:@"--"];
|
|
|
|
|
NSString* key=nil;
|
|
|
|
|
NSString* value=nil;
|
|
|
|
|
NSArray* parts=[argWithoutPrefix componentsSeparatedByString:@"="];
|
|
|
|
|
key=[parts objectAtIndex:0];
|
|
|
|
|
if ([parts count]>1)
|
|
|
|
|
value=[[parts subarrayWithRange:NSMakeRange(1,[parts count]-1)] componentsJoinedByString:@"="];
|
|
|
|
|
|
|
|
|
|
// makeRefs option
|
|
|
|
|
if ([key isEqualToString:@"makeRefs"])
|
|
|
|
|
{
|
|
|
|
|
makeRefsFileName=value;
|
|
|
|
|
if (makeRefsFileName)
|
|
|
|
|
{
|
|
|
|
|
if (![[makeRefsFileName pathExtension] isEqual:PathExtension_GSDocRefs])
|
|
|
|
|
makeRefsFileName=[makeRefsFileName stringByAppendingPathExtension:PathExtension_GSDocRefs];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
makeRefsFileName=@"";
|
|
|
|
|
}
|
|
|
|
|
// projectName option
|
|
|
|
|
else if ([key isEqualToString:@"projectName"])
|
|
|
|
|
{
|
|
|
|
|
projectName=value;
|
|
|
|
|
NSCAssert([projectName length],@"No project name");
|
|
|
|
|
}
|
|
|
|
|
// refs option
|
|
|
|
|
else if ([key isEqualToString:@"refs"])
|
|
|
|
|
{
|
|
|
|
|
if (!references)
|
|
|
|
|
references=[[NSMutableArray new] autorelease];
|
|
|
|
|
NSCAssert([value length],@"No index");
|
|
|
|
|
[references addObject:value];
|
|
|
|
|
}
|
|
|
|
|
// makeIndex option
|
|
|
|
|
else if ([key isEqualToString:@"makeIndex"])
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
makeIndexBaseFileName=value;
|
|
|
|
|
if (makeIndexBaseFileName)
|
|
|
|
|
makeIndexBaseFileName=[makeIndexBaseFileName stringByDeletingPathExtension];
|
|
|
|
|
else
|
|
|
|
|
makeIndexBaseFileName=@"index";
|
2000-08-13 16:00:14 +00:00
|
|
|
|
}
|
|
|
|
|
// makeIndexTemplate option
|
|
|
|
|
else if ([key isEqualToString:@"makeIndexTemplate"])
|
|
|
|
|
{
|
|
|
|
|
makeIndexTemplateFileName=value;
|
|
|
|
|
NSCAssert([makeIndexTemplateFileName length],@"No makeIndexTemplate filename");
|
|
|
|
|
}
|
|
|
|
|
// Verbose
|
|
|
|
|
else if ([key hasPrefix:@"verbose"])
|
|
|
|
|
{
|
|
|
|
|
NSCAssert1(value,@"No value for %@",key);
|
|
|
|
|
verbose=[value intValue];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
if (verbose>0)
|
|
|
|
|
{
|
|
|
|
|
NSMutableSet* debugSet=[proc debugSet];
|
|
|
|
|
[debugSet addObject:@"dflt"];
|
|
|
|
|
};
|
2000-08-13 16:00:14 +00:00
|
|
|
|
}
|
|
|
|
|
// Location
|
|
|
|
|
else if ([key hasPrefix:@"location"])
|
|
|
|
|
{
|
|
|
|
|
NSCAssert1(value,@"No value for %@",key);
|
|
|
|
|
location=value;
|
|
|
|
|
}
|
|
|
|
|
// define option
|
|
|
|
|
else if ([key hasPrefix:@"define-"])
|
|
|
|
|
{
|
|
|
|
|
if (!infoDictionary)
|
|
|
|
|
infoDictionary=[NSMutableDictionary dictionary];
|
|
|
|
|
NSCAssert1(value,@"No value for %@",key);
|
|
|
|
|
[infoDictionary setObject:value
|
|
|
|
|
forKey:[key stringWithoutPrefix:@"define-"]];
|
|
|
|
|
}
|
|
|
|
|
// unknown option
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Unknown option %@",arg);
|
|
|
|
|
goOn=NO;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// file to parse
|
2000-02-28 16:23:53 +00:00
|
|
|
|
else
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
if (!files)
|
|
|
|
|
files=[NSMutableArray array];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
//FIXME
|
|
|
|
|
//Dirty Hack to handle *.gsdoc and *
|
|
|
|
|
//We need this because sometimes, there is too much files for commande line
|
|
|
|
|
if ([[arg lastPathComponent] hasSuffix:[NSString stringWithFormat:@"*.%@",PathExtension_GSDoc]]
|
|
|
|
|
|| [[arg lastPathComponent]hasSuffix:@"*"])
|
|
|
|
|
{
|
|
|
|
|
NSArray* dirContent=nil;
|
|
|
|
|
int ifile=0;
|
|
|
|
|
arg=[arg stringByDeletingLastPathComponent];
|
|
|
|
|
if ([arg length]==0)
|
|
|
|
|
arg=[fileManager currentDirectoryPath];
|
|
|
|
|
dirContent=[fileManager directoryContentsAtPath:arg];
|
|
|
|
|
for(ifile=0;ifile<[dirContent count];ifile++)
|
|
|
|
|
{
|
|
|
|
|
NSString* file=[dirContent objectAtIndex:ifile];
|
|
|
|
|
if ([[file pathExtension] isEqual:PathExtension_GSDoc])
|
|
|
|
|
{
|
|
|
|
|
[files addObject:file];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
[files addObject:arg];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//Default Values
|
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
|
|
|
|
if (!projectName)
|
|
|
|
|
projectName=@"unknown";
|
|
|
|
|
if ([makeRefsFileName length]==0)
|
|
|
|
|
makeRefsFileName=[projectName stringByAppendingPathExtension:PathExtension_GSDocRefs];
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (makeIndexBaseFileName)
|
|
|
|
|
makeIndexFileNameGSDoc=[makeIndexBaseFileName stringByAppendingPathExtension:PathExtension_GSDoc];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Verify option compatibilities
|
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Construct project references
|
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
BOOL addedSymbols=NO;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSDictionary* previousProjectReferences=nil;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
projectReferences=[[NSMutableDictionary new] autorelease];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[projectReferences setObject:[[NSMutableDictionary new] autorelease]
|
|
|
|
|
forKey:@"symbols"];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
projectInfo=[NSMutableDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
projectName, @"projectName",
|
|
|
|
|
nil];
|
|
|
|
|
if (location)
|
|
|
|
|
[projectInfo setObject:location
|
|
|
|
|
forKey:@"location"];
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (makeIndexBaseFileName)
|
|
|
|
|
[projectInfo setObject:makeIndexBaseFileName
|
|
|
|
|
forKey:@"indexfileName"];
|
|
|
|
|
|
2000-08-16 14:08:08 +00:00
|
|
|
|
|
|
|
|
|
//Read project existing references
|
|
|
|
|
if (makeRefsFileName)
|
|
|
|
|
{
|
|
|
|
|
BOOL isDirectory=NO;
|
|
|
|
|
if ([fileManager fileExistsAtPath:makeRefsFileName
|
|
|
|
|
isDirectory:&isDirectory])
|
|
|
|
|
{
|
|
|
|
|
if (!isDirectory)
|
|
|
|
|
{
|
|
|
|
|
previousProjectReferences=[NSDictionary dictionaryWithContentsOfFile:makeRefsFileName];
|
|
|
|
|
if (previousProjectReferences && [previousProjectReferences objectForKey:@"symbols"])
|
|
|
|
|
{
|
|
|
|
|
AddSymbolsToReferencesWithProjectInfo([previousProjectReferences objectForKey:@"symbols"],
|
|
|
|
|
[projectReferences objectForKey:@"symbols"],
|
2000-08-24 17:24:40 +00:00
|
|
|
|
projectInfo,
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NO);
|
2000-08-24 17:24:40 +00:00
|
|
|
|
addedSymbols=YES;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (!addedSymbols)
|
|
|
|
|
{
|
|
|
|
|
AddSymbolsToReferencesWithProjectInfo(nil,
|
|
|
|
|
[projectReferences objectForKey:@"symbols"],
|
|
|
|
|
projectInfo,
|
|
|
|
|
NO);
|
|
|
|
|
};
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Process references (construct a dictionary of all references)
|
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
|
|
|
|
generalReferences=[[NSMutableDictionary new] autorelease];
|
|
|
|
|
if ([references count]>0)
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
// From last to first so references are taken in first to last priority
|
|
|
|
|
while(goOn && [references count])
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSString* file = [references lastObject];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
BOOL isDirectory=NO;
|
|
|
|
|
if (![fileManager fileExistsAtPath:file isDirectory:&isDirectory])
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Index File %@ doesn't exist",file);
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[references removeLastObject];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (isDirectory)
|
|
|
|
|
{
|
|
|
|
|
NSArray* tmpReferences=FilesInPathWithExtension(file,PathExtension_GSDocRefs);
|
|
|
|
|
if (verbose>=3)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Processing references directory %@",file);
|
|
|
|
|
};
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[references removeLastObject];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[references addObjectsFromArray:tmpReferences];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSDictionary* generalIndexTmp=nil;
|
|
|
|
|
if (verbose>=2)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Processing references file %@",file);
|
|
|
|
|
};
|
|
|
|
|
generalIndexTmp=[NSDictionary dictionaryWithContentsOfFile:file];
|
|
|
|
|
if (!generalIndexTmp)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"File %@ isn't a dictionary",file);
|
|
|
|
|
goOn=NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSDictionary* fileProjectInfo=[generalIndexTmp objectForKey:@"project"];
|
|
|
|
|
NSDictionary* symbols=[generalIndexTmp objectForKey:@"symbols"];
|
|
|
|
|
NSCAssert1(fileProjectInfo,@"No Project Info in %@",file);
|
|
|
|
|
NSCAssert1(symbols,@"No symbols %@",file);
|
2000-08-16 14:08:08 +00:00
|
|
|
|
AddSymbolsToReferencesWithProjectInfo(symbols,
|
|
|
|
|
generalReferences,
|
|
|
|
|
fileProjectInfo,
|
|
|
|
|
YES);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[references removeLastObject];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2000-08-16 14:08:08 +00:00
|
|
|
|
//Variables
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
|
|
|
|
NSMutableDictionary* variablesMutableDictionary=[NSMutableDictionary dictionary];
|
|
|
|
|
NSEnumerator* enumer = [infoDictionary keyEnumerator];
|
|
|
|
|
id key=nil;
|
|
|
|
|
while ((key = [enumer nextObject]))
|
|
|
|
|
{
|
|
|
|
|
id value=[infoDictionary objectForKey:key];
|
|
|
|
|
[variablesMutableDictionary setObject:value
|
|
|
|
|
forKey:[NSString stringWithFormat:@"[[infoDictionary.%@]]",key]];
|
|
|
|
|
};
|
|
|
|
|
[variablesMutableDictionary setObject:[NSCalendarDate calendarDate]
|
|
|
|
|
forKey:@"[[timestampString]]"];
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (makeIndexBaseFileName)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
[variablesMutableDictionary setObject:makeIndexFileNameGSDoc
|
2000-08-13 16:00:14 +00:00
|
|
|
|
forKey:@"[[indexFileName]]"];
|
2000-08-24 17:24:40 +00:00
|
|
|
|
[variablesMutableDictionary setObject:makeIndexBaseFileName
|
2000-08-13 16:00:14 +00:00
|
|
|
|
forKey:@"[[indexBaseFileName]]"];
|
|
|
|
|
};
|
|
|
|
|
if (projectName)
|
|
|
|
|
[variablesMutableDictionary setObject:projectName
|
|
|
|
|
forKey:@"[[projectName]]"];
|
|
|
|
|
variablesDictionary=[[variablesMutableDictionary copy] autorelease];
|
|
|
|
|
|
|
|
|
|
if (verbose>=3)
|
|
|
|
|
{
|
|
|
|
|
NSEnumerator* enumer = [variablesDictionary keyEnumerator];
|
|
|
|
|
id key=nil;
|
|
|
|
|
while ((key = [enumer nextObject]))
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Variables: %@=%@",
|
|
|
|
|
key,
|
|
|
|
|
[variablesDictionary objectForKey:key]);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Find Files to parse
|
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
|
|
|
|
if ([files count]<1)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"No file names given to parse.");
|
|
|
|
|
goOn=NO;
|
2000-02-28 16:23:53 +00:00
|
|
|
|
}
|
2000-08-13 16:00:14 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSMutableArray* tmpNewFiles=[NSMutableArray array];
|
|
|
|
|
for (i=0;goOn && i<[files count];i++)
|
|
|
|
|
{
|
|
|
|
|
NSString* file = [files objectAtIndex: i];
|
|
|
|
|
BOOL isDirectory=NO;
|
|
|
|
|
if (![fileManager fileExistsAtPath:file isDirectory:&isDirectory])
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"File %@ doesn't exist",file);
|
|
|
|
|
goOn=NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (isDirectory)
|
|
|
|
|
{
|
|
|
|
|
NSArray* tmpFiles=FilesInPathWithExtension(file,PathExtension_GSDoc);
|
|
|
|
|
[tmpNewFiles addObjectsFromArray:tmpFiles];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[tmpNewFiles addObject:file];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
files=tmpNewFiles;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
files=(NSMutableArray*)[files sortedArrayUsingSelector:@selector(compare:)];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
|
|
|
|
int pass=0;
|
|
|
|
|
//1st pass: don't write file, just parse them and construct project references
|
|
|
|
|
//2nd pass: parse and write files
|
2000-08-16 14:08:08 +00:00
|
|
|
|
for (pass=0;goOn && pass<2;pass++)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
for (i=0;goOn && i<[files count];i++)
|
|
|
|
|
{
|
|
|
|
|
NSString* file = [files objectAtIndex: i];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSAutoreleasePool* arp=[NSAutoreleasePool new];
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if ([[file stringByDeletingPathExtension] isEqual:makeIndexBaseFileName])//Don't process generated index file
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
if (verbose>=1)
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSLog(@"Pass %d/2 File %d/%d - Ignoring Index File %@ (Process it later)",
|
|
|
|
|
(pass+1),
|
|
|
|
|
(i+1),
|
|
|
|
|
[files count],
|
|
|
|
|
file);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (verbose>=1)
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSLog(@"Pass %d/2 File %d/%d - Processing %@",
|
|
|
|
|
(pass+1),
|
|
|
|
|
(i+1),
|
|
|
|
|
[files count],
|
|
|
|
|
file);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
NS_DURING
|
|
|
|
|
{
|
|
|
|
|
GSDocHtml *p=nil;
|
|
|
|
|
p = [GSDocHtml alloc];
|
|
|
|
|
p = [p initWithFileName: file];
|
|
|
|
|
if (p != nil)
|
|
|
|
|
{
|
|
|
|
|
NSString* previousFile=((i>0) ? [files objectAtIndex:i-1] : @"");
|
|
|
|
|
NSString* nextFile=(((i+1)<[files count]) ? [files objectAtIndex:i+1] : @"");
|
|
|
|
|
NSMutableDictionary* variablesMutableDictionary=nil;
|
|
|
|
|
NSString *result = nil;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[p setProjectName:projectName];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[p setGeneralReferences:generalReferences];
|
|
|
|
|
variablesMutableDictionary=[variablesDictionary mutableCopy];
|
|
|
|
|
[variablesMutableDictionary setObject:[previousFile stringByDeletingPathExtension]
|
|
|
|
|
forKey:@"[[prev]]"];
|
|
|
|
|
[variablesMutableDictionary setObject:[nextFile stringByDeletingPathExtension]
|
|
|
|
|
forKey:@"[[next]]"];
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (makeIndexBaseFileName)
|
|
|
|
|
[variablesMutableDictionary setObject:makeIndexBaseFileName
|
2000-08-13 16:00:14 +00:00
|
|
|
|
forKey:@"[[up]]"];
|
|
|
|
|
[p setVariablesDictionary:variablesMutableDictionary];
|
|
|
|
|
[p setWriteFlag:(pass==1)];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
[p setProcessFileReferencesFlag:(pass==0)];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
result=[p parseDocument];
|
|
|
|
|
if (result == nil)
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSLog(@"Pass %d/2 File %d/%d - Error parsing %@",
|
|
|
|
|
(pass+1),
|
|
|
|
|
(i+1),
|
|
|
|
|
[files count],
|
|
|
|
|
file);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
goOn=NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (verbose>=1)
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSLog(@"Pass %d/2 File %d/%d - Parsed %@ - OK",
|
|
|
|
|
(pass+1),
|
|
|
|
|
(i+1),
|
|
|
|
|
[files count],
|
|
|
|
|
file);
|
|
|
|
|
};
|
|
|
|
|
if (pass==0)
|
|
|
|
|
{
|
|
|
|
|
AddSymbolsToReferencesWithProjectInfo([p fileReferences],
|
|
|
|
|
[projectReferences objectForKey:@"symbols"],
|
|
|
|
|
nil,
|
|
|
|
|
NO);
|
|
|
|
|
AddSymbolsToReferencesWithProjectInfo([p fileReferences],
|
|
|
|
|
generalReferences,
|
|
|
|
|
projectInfo,
|
|
|
|
|
YES);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
RELEASE(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
NS_HANDLER
|
|
|
|
|
{
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSLog(@"Pass %d/2 File %d/%d - Parsing '%@' - %@",
|
|
|
|
|
(pass+1),
|
|
|
|
|
(i+1),
|
|
|
|
|
[files count],
|
|
|
|
|
file,
|
|
|
|
|
[localException reason]);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
goOn=NO;
|
|
|
|
|
}
|
|
|
|
|
NS_ENDHANDLER
|
|
|
|
|
}
|
2000-08-16 14:08:08 +00:00
|
|
|
|
DESTROY(arp);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Process Project References to generate Project Reference File
|
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
|
|
|
|
if (makeRefsFileName)
|
|
|
|
|
{
|
|
|
|
|
[projectReferences setObject:projectInfo forKey:@"project"];
|
|
|
|
|
if (verbose>=1)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Writing References File %@",makeRefsFileName);
|
|
|
|
|
};
|
|
|
|
|
if (![projectReferences writeToFile:makeRefsFileName
|
|
|
|
|
atomically:YES])
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Error creating %@",makeRefsFileName);
|
|
|
|
|
goOn=NO;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Process Project References to generate Index File
|
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (makeIndexBaseFileName)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
NSString* textTemplate=[NSString stringWithContentsOfFile:makeIndexTemplateFileName];
|
|
|
|
|
NSMutableString* textStart=[NSMutableString string];
|
|
|
|
|
NSMutableString* textChapters=[NSMutableString string];
|
|
|
|
|
NSMutableString* textClasses=[NSMutableString string];
|
|
|
|
|
NSMutableString* textCategories=[NSMutableString string];
|
|
|
|
|
NSMutableString* textProtocols=[NSMutableString string];
|
|
|
|
|
NSMutableString* textFunctions=[NSMutableString string];
|
|
|
|
|
NSMutableString* textTypes=[NSMutableString string];
|
|
|
|
|
NSMutableString* textConstants=[NSMutableString string];
|
|
|
|
|
NSMutableString* textVariables=[NSMutableString string];
|
|
|
|
|
NSMutableString* textOthers=[NSMutableString string];
|
|
|
|
|
NSMutableString* textFiles=[NSMutableString string];
|
|
|
|
|
NSMutableString* textStop=[NSMutableString string];
|
|
|
|
|
NSMutableString* text=nil;
|
|
|
|
|
NSMutableDictionary* variablesMutableDictionary=nil;
|
|
|
|
|
NSString* typeTitle=nil;
|
|
|
|
|
NSString* finalText=nil;
|
2000-08-16 14:08:08 +00:00
|
|
|
|
NSDictionary* symbolsByType=[projectReferences objectForKey:@"symbols"];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSString* firstFileName=nil;
|
|
|
|
|
NSEnumerator* typesEnumerator = [symbolsByType keyEnumerator];
|
|
|
|
|
id typeKey=nil;
|
|
|
|
|
if (verbose>=1)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Making Index");
|
|
|
|
|
};
|
|
|
|
|
[textStart appendFormat:@"<chapter>\n<heading>%@</heading>\n",projectName];
|
|
|
|
|
while ((typeKey = [typesEnumerator nextObject]))
|
|
|
|
|
{
|
|
|
|
|
if (verbose>=2)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Making Index for type %@",typeKey);
|
|
|
|
|
};
|
|
|
|
|
text=nil;
|
|
|
|
|
if ([typeKey isEqual:@"ivariable"])
|
|
|
|
|
{
|
|
|
|
|
text=nil;
|
|
|
|
|
typeTitle=@"Instance Variables";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"method"])
|
|
|
|
|
{
|
|
|
|
|
text=nil;
|
|
|
|
|
typeTitle=@"Methods";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"file"])
|
|
|
|
|
{
|
|
|
|
|
text=textFiles;
|
|
|
|
|
typeTitle=@"Files";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"chapter"])
|
|
|
|
|
{
|
|
|
|
|
text=textChapters;
|
|
|
|
|
typeTitle=@"Chapters";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"section"])
|
|
|
|
|
{
|
|
|
|
|
text=nil;
|
|
|
|
|
typeTitle=@"Section";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"ubsect"])
|
|
|
|
|
{
|
|
|
|
|
text=nil;
|
|
|
|
|
typeTitle=@"Subsections";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"class"] || [typeKey isEqual:@"jclass"])
|
|
|
|
|
{
|
|
|
|
|
text=textClasses;
|
|
|
|
|
typeTitle=@"Classes";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"protocol"])
|
|
|
|
|
{
|
|
|
|
|
text=textProtocols;
|
|
|
|
|
typeTitle=@"Protocols";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"category"])
|
|
|
|
|
{
|
|
|
|
|
text=textProtocols;
|
|
|
|
|
typeTitle=@"Categories";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"function"])
|
|
|
|
|
{
|
|
|
|
|
text=textFunctions;
|
|
|
|
|
typeTitle=@"Functions";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"macro"])
|
|
|
|
|
{
|
|
|
|
|
text=textFunctions;
|
|
|
|
|
typeTitle=@"Macros";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"constant"])
|
|
|
|
|
{
|
|
|
|
|
text=textConstants;
|
|
|
|
|
typeTitle=@"Constants";
|
|
|
|
|
}
|
|
|
|
|
else if ([typeKey isEqual:@"variable"])
|
|
|
|
|
{
|
|
|
|
|
text=textVariables;
|
|
|
|
|
typeTitle=@"Global Variables";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text=textOthers;
|
|
|
|
|
typeTitle=@"Others";
|
|
|
|
|
};
|
|
|
|
|
if (text)
|
|
|
|
|
{
|
|
|
|
|
NSArray* symbolKeys = nil;
|
|
|
|
|
NSEnumerator* symbolsEnumerator=nil;
|
|
|
|
|
id symbolKey=nil;
|
|
|
|
|
NSDictionary* typeDict=[symbolsByType objectForKey:typeKey];
|
|
|
|
|
[text appendFormat:@"<section>\n<heading>%@</heading>\n<list>\n",typeTitle];
|
2000-08-16 14:08:08 +00:00
|
|
|
|
symbolKeys = [[typeDict allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
symbolsEnumerator = [symbolKeys objectEnumerator];
|
|
|
|
|
while ((symbolKey = [symbolsEnumerator nextObject]))
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSString* fragment=nil;
|
2000-08-13 16:00:14 +00:00
|
|
|
|
NSDictionary* symbol=[typeDict objectForKey:symbolKey];
|
|
|
|
|
if (text==textFiles && !firstFileName)
|
|
|
|
|
firstFileName=[symbol objectForKey:@"fileName"];
|
|
|
|
|
if (verbose>=4)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Making Index for symbol %@",[symbol objectForKey:@"title"]);
|
|
|
|
|
};
|
2000-08-24 17:24:40 +00:00
|
|
|
|
fragment= [symbol objectForKey:@"fragment"];
|
|
|
|
|
[text appendFormat:@"<item><uref url=\"%@%@%@\">%@</uref></item>\n",
|
|
|
|
|
[[symbol objectForKey:@"fileName"]
|
|
|
|
|
stringByAppendingPathExtension:PathExtension_HTML],
|
|
|
|
|
([fragment length]>0 ? @"#" : @""),
|
|
|
|
|
(fragment ? fragment : @""),
|
2000-08-13 16:00:14 +00:00
|
|
|
|
[symbol objectForKey:@"title"]];
|
|
|
|
|
};
|
|
|
|
|
[text appendString:@"</list>\n</section>\n"];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
[textStop appendString:@"</chapter>\n"];
|
|
|
|
|
finalText=[NSString stringWithFormat:@"%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n",
|
|
|
|
|
textStart,
|
|
|
|
|
textChapters,
|
|
|
|
|
textClasses,
|
|
|
|
|
textCategories,
|
|
|
|
|
textProtocols,
|
|
|
|
|
textFunctions,
|
|
|
|
|
textTypes,
|
|
|
|
|
textConstants,
|
|
|
|
|
textVariables,
|
|
|
|
|
textOthers,
|
|
|
|
|
textFiles,
|
|
|
|
|
textStop];
|
|
|
|
|
variablesMutableDictionary=[variablesDictionary mutableCopy];
|
|
|
|
|
[variablesMutableDictionary setObject:finalText
|
|
|
|
|
forKey:@"[[content]]"];
|
|
|
|
|
[variablesMutableDictionary setObject:[firstFileName stringByDeletingPathExtension]
|
|
|
|
|
forKey:@"[[next]]"];
|
|
|
|
|
finalText=TextByReplacingVariablesInText(textTemplate,variablesMutableDictionary);
|
|
|
|
|
if (verbose>=1)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSLog(@"Writing Index %@",makeIndexFileNameGSDoc);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (![finalText writeToFile:makeIndexFileNameGSDoc
|
2000-08-13 16:00:14 +00:00
|
|
|
|
atomically: YES])
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSLog(@"Error creating %@",makeIndexFileNameGSDoc);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
goOn=NO;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Finally, parse index
|
|
|
|
|
if (goOn)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
if (makeIndexBaseFileName)
|
2000-08-13 16:00:14 +00:00
|
|
|
|
{
|
|
|
|
|
if (verbose>=1)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSLog(@"Processing %@",makeIndexFileNameGSDoc);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
NS_DURING
|
|
|
|
|
{
|
|
|
|
|
GSDocHtml *p=nil;
|
|
|
|
|
p = [GSDocHtml alloc];
|
2000-08-24 17:24:40 +00:00
|
|
|
|
p = [p initWithFileName:makeIndexFileNameGSDoc];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
if (p != nil)
|
|
|
|
|
{
|
|
|
|
|
NSString *result = nil;
|
|
|
|
|
[p setVariablesDictionary:variablesDictionary];
|
|
|
|
|
result=[p parseDocument];
|
|
|
|
|
if (result == nil)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSLog(@"Error parsing %@",makeIndexFileNameGSDoc);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
goOn=NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (verbose>=1)
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSLog(@"Parsed %@ - OK",makeIndexFileNameGSDoc);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
RELEASE(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
NS_HANDLER
|
|
|
|
|
{
|
2000-08-24 17:24:40 +00:00
|
|
|
|
NSLog(@"Parsing '%@' - %@",makeIndexFileNameGSDoc, [localException reason]);
|
2000-08-13 16:00:14 +00:00
|
|
|
|
goOn=NO;
|
|
|
|
|
}
|
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
|
}
|
|
|
|
|
};
|
2000-02-28 16:23:53 +00:00
|
|
|
|
[pool release];
|
2000-08-13 16:00:14 +00:00
|
|
|
|
return (goOn ? 0 : 1);
|
|
|
|
|
};
|
2000-02-28 16:23:53 +00:00
|
|
|
|
|
2000-06-20 13:17:22 +00:00
|
|
|
|
#else
|
2000-06-27 17:38:46 +00:00
|
|
|
|
int
|
2000-06-20 13:17:22 +00:00
|
|
|
|
main()
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"No libxml available");
|
2000-06-27 17:38:46 +00:00
|
|
|
|
return 0;
|
2000-06-20 13:17:22 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|