Lots of gsdoc updates

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11148 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2001-10-15 14:42:56 +00:00
parent 91e8e0a6ea
commit 3d357aba9f
11 changed files with 664 additions and 121 deletions

View file

@ -1,3 +1,19 @@
2001-10-15 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GNUmakefile:
* Source/GSXML.m:
* Headers/Foundation/GSXML.h: Build and install dummy version if
libxml is not available.
* Tools/GNUmakefile:
* Tools/AGSIndex.h:
* Tools/AGSIndex.m:
* Tools/AGSOutput.h:
* Tools/AGSOutput.m:
* Tools/AGSParser.h:
* Tools/AGSParser.m:
* Tools/autogsdoc.m: Many bugfixes and additions, bew code to
generate indexes.
2001-10-15 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/AGSOutput.m: Added new 'unit' pseudo-markup to permit

View file

@ -169,6 +169,7 @@ GSMime.m \
GSSet.m \
GSString.m \
GSValue.m \
GSXML.m \
NSAttributedString.m \
NSArchiver.m \
NSArray.m \
@ -246,10 +247,6 @@ NSZone.m \
externs.m \
objc-load.m
ifeq ($(HAVE_LIBXML),1)
BASE_MFILES += GSXML.m
endif
ifeq ($(WITH_FFI),libffi)
GNU_MFILES += cifframe.m
BASE_MFILES += GSFFIInvocation.m
@ -282,6 +279,7 @@ tzfile.h
FOUNDATION_HEADERS = \
Foundation.h \
GSMime.h \
GSXML.h \
NSArchiver.h \
NSArray.h \
NSAttributedString.h \
@ -351,10 +349,6 @@ objc-load.h \
NSURL.h \
NSURLHandle.h
ifeq ($(HAVE_LIBXML),1)
FOUNDATION_HEADERS += GSXML.h
endif
UNICODE_HEADERS = \
unicode/caseconv.h \
unicode/cop.h \

View file

@ -28,6 +28,8 @@
#include <config.h>
#ifdef HAVE_LIBXML
#include <Foundation/GSXML.h>
#include <Foundation/NSData.h>
#include <Foundation/NSValue.h>
@ -2134,3 +2136,64 @@ fatalErrorFunction(void *ctx, const char *msg, ...)
}
}
@end
#else
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSCoder.h>
/*
* Build dummy implementations of the classes if libxml is not available
*/
@interface GSXMLDummy : NSObject
@end
@interface GSXMLAttribute : GSXMLDummy
@end
@interface GSXMLDocument : GSXMLDummy
@end
@interface GSXMLHandler : GSXMLDummy
@end
@interface GSXMLNamespace : GSXMLDummy
@end
@interface GSXMLNode : GSXMLDummy
@end
@interface GSSAXHandler : GSXMLDummy
@end
@implementation GSXMLDummy
+ (id) allocWithZone: (NSZone*)z
{
NSLog(@"Not built with libxml ... %@ unusable in %@",
NSStringFromClass(self), NSStringFromSelector(_cmd));
return nil;
}
- (id) init
{
NSLog(@"Not built with libxml ... %@ unusable in %@",
NSStringFromClass([self class]), NSStringFromSelector(_cmd));
RELEASE(self);
return nil;
}
- (id) initWithCoder: (NSCoder*)aCoder
{
NSLog(@"Not built with libxml ... %@ unusable in %@",
NSStringFromClass([self class]), NSStringFromSelector(_cmd));
RELEASE(self);
return nil;
}
@end
@implementation GSXMLAttribute
@end
@implementation GSXMLDocument
@end
@implementation GSXMLHandler
@end
@implementation GSXMLNamespace
@end
@implementation GSXMLNode
@end
@implementation GSSAXHandler
@end
#endif

View file

@ -28,16 +28,26 @@
@implementation NSEnumerator
- (NSArray *)allObjects
- (NSArray*) allObjects
{
NSMutableArray *array;
id obj;
NSMutableArray *array;
id obj;
SEL nsel;
IMP nimp;
SEL asel;
IMP aimp;
array = [NSMutableArray arrayWithCapacity:10];
array = [NSMutableArray arrayWithCapacity: 10];
while((obj = [self nextObject]))
[array addObject:obj];
nsel = @selector(nextObject);
nimp = [self methodForSelector: nsel];
asel = @selector(addObject:);
aimp = [array methodForSelector: asel];
while ((obj = (*nimp)(self, nsel)) != nil)
{
(*aimp)(array, asel, obj);
}
return array;
}

38
Tools/AGSIndex.h Normal file
View file

@ -0,0 +1,38 @@
/**
<title>AGSIndex ... a class to create references for a gsdoc file</title>
Copyright <copy>(C) 2001 Free Software Foundation, Inc.</copy>
Written by: <author name="Richard Frith-Macdonald">
<email>richard@brainstorm.co.uk</email></author>
Created: October 2001
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.
*/
#include <Foundation/GSXML.h>
@interface AGSIndex : NSObject
{
NSMutableDictionary *refs;
NSString *base; // Not retained
NSString *unit; // Not retained
}
- (void) makeRefs: (GSXMLNode*)node;
- (void) mergeRefs: (NSDictionary*)more;
- (NSMutableDictionary*) refs;
- (void) setGlobalRef: (NSString*)ref type: (NSString*)type;
- (void) setUnitRef: (NSString*)ref type: (NSString*)type;
@end

363
Tools/AGSIndex.m Normal file
View file

@ -0,0 +1,363 @@
/**
<title>AGSIndex ... a class to create references for a gsdoc file</title>
Copyright <copy>(C) 2001 Free Software Foundation, Inc.</copy>
Written by: <author name="Richard Frith-Macdonald">
<email>richard@brainstorm.co.uk</email></author>
Created: October 2001
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.
*/
#include <Foundation/Foundation.h>
#include "AGSIndex.h"
static int XML_ELEMENT_NODE;
static int XML_TEXT_NODE;
static void
mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src)
{
static NSMutableArray *stack = nil;
NSEnumerator *e = [src keyEnumerator];
NSString *k;
if (stack == nil)
{
stack = [[NSMutableArray alloc] initWithCapacity: 8];
}
while ((k = [e nextObject]) != nil)
{
id s = [src objectForKey: k];
id d = [dst objectForKey: k];
[stack addObject: k];
if (d == nil)
{
if ([s isKindOfClass: [NSString class]] == YES)
{
[dst setObject: s forKey: k];
}
else if ([s isKindOfClass: [NSDictionary class]] == YES)
{
d = [[NSMutableDictionary alloc] initWithCapacity: [s count]];
[dst setObject: d forKey: k];
RELEASE(d);
}
else
{
NSLog(@"Unexpected class in merge %@ ignored", stack);
d = nil;
}
}
if (d != nil)
{
if ([d isKindOfClass: [s class]] == NO)
{
NSLog(@"Class missmatch in merge for %@", stack);
}
else if ([d isKindOfClass: [NSString class]] == YES)
{
if ([d isEqual: s] == NO)
{
NSLog(@"String missmatch in merge for %@", stack);
}
}
else if ([d isKindOfClass: [NSDictionary class]] == YES)
{
mergeDictionaries(d, s);
}
}
[stack removeLastObject];
}
}
@implementation AGSIndex
+ (void) initialize
{
if (self == [AGSIndex class])
{
/*
* Cache XML node information.
*/
XML_ELEMENT_NODE = [GSXMLNode typeFromDescription: @"XML_ELEMENT_NODE"];
XML_TEXT_NODE = [GSXMLNode typeFromDescription: @"XML_TEXT_NODE"];
}
}
- (void) dealloc
{
RELEASE(refs);
[super dealloc];
}
- (id) init
{
refs = [[NSMutableDictionary alloc] initWithCapacity: 8];
return self;
}
/**
* Given the root node of a gsdoc document, we traverse the tree
* looking for interestng nodes, and recording their names in a
* dictionary of references. The references are held in a tree
* consisting of dictionaries with strings at the leaves -<br />
* method method-name class-name file-name<br />
* method method-name category-name file-name<br />
* method method-name protocol-name file-name<br />
* ivariable variable-name class-name file-name<br />
* class class-name file-name<br />
* category category-name file-name<br />
* protocol protocol-name file-name<br />
* function function-name file-name<br />
* type type-name file-name<br />
* constant constant-name file-name<br />
* variable variable-name file-name<br />
* entry entry-name file-name ref<br />
* label label-name file-name ref<br />
* In addition to the tree providing file reference information we
* store a record of the superclasses of each class.
*/
- (void) makeRefs: (GSXMLNode*)node
{
GSXMLNode *children = [node children];
GSXMLNode *next = [node next];
BOOL newUnit = NO;
if ([node type] == XML_ELEMENT_NODE)
{
NSString *name = [node name];
NSDictionary *prop = [node propertiesAsDictionary];
if ([name isEqual: @"category"] == YES)
{
newUnit = YES;
unit = [NSString stringWithFormat: @"%@(%@)",
[prop objectForKey: @"class"], [prop objectForKey: @"name"]];
[self setGlobalRef: unit type: name];
}
else if ([name isEqual: @"class"] == YES)
{
NSString *tmp;
newUnit = YES;
unit = [prop objectForKey: @"name"];
[self setGlobalRef: unit type: name];
tmp = [prop objectForKey: @"super"];
if (tmp != nil)
{
[self setGlobalRef: unit type: @"super"];
}
}
else if ([name isEqual: @"gsdoc"] == YES)
{
base = [prop objectForKey: @"base"];
if (base == nil)
{
NSLog(@"No 'base' document name supplied in gsdoc element");
return;
}
}
else if ([name isEqual: @"ivariable"] == YES)
{
NSString *tmp = [prop objectForKey: @"name"];
[self setUnitRef: tmp type: name];
}
else if ([name isEqual: @"entry"] || [name isEqual: @"label"])
{
NSMutableDictionary *all;
NSMutableDictionary *byFile;
NSString *text;
NSString *val;
text = [children content];
children = nil;
all = [refs objectForKey: name];
if (all == nil)
{
all = [[NSMutableDictionary alloc] initWithCapacity: 8];
[refs setObject: all forKey: name];
RELEASE(all);
}
byFile = [all objectForKey: base];
if (byFile == nil)
{
byFile = [[NSMutableDictionary alloc] initWithCapacity: 2];
[all setObject: byFile forKey: base];
RELEASE(byFile);
}
val = [prop objectForKey: @"id"];
if (val == nil)
{
val = text;
}
[byFile setObject: val forKey: @"text"];
}
else if ([name isEqual: @"method"] == YES)
{
NSString *sel = @"";
GSXMLNode *tmp = children;
sel = [prop objectForKey: @"factory"];
if (sel != nil && [sel boolValue] == YES)
{
sel = @"+";
}
else
{
sel = @"-";
}
children = nil;
while (tmp != nil)
{
if ([tmp type] == XML_ELEMENT_NODE)
{
if ([[tmp name] isEqual: @"sel"] == YES)
{
GSXMLNode *t = [tmp children];
while (t != nil)
{
if ([t type] == XML_TEXT_NODE)
{
sel = [sel stringByAppendingString: [t content]];
}
t = [t next];
}
}
else if ([[tmp name] isEqual: @"arg"] == NO)
{
children = tmp;
break;
}
else if ([[tmp name] isEqual: @"vararg"] == YES)
{
sel = [sel stringByAppendingString: @",..."];
children = [tmp next];
break;
}
}
tmp = [tmp next];
}
if ([sel length] > 1)
{
[self setUnitRef: sel type: name];
}
}
else if ([name isEqual: @"protocol"] == YES)
{
newUnit = YES;
unit = [prop objectForKey: @"name"];
[self setGlobalRef: unit type: name];
}
else if ([name isEqual: @"constant"] == YES
|| [name isEqual: @"EOEntity"] == YES
|| [name isEqual: @"EOModel"] == YES
|| [name isEqual: @"function"] == YES
|| [name isEqual: @"macro"] == YES
|| [name isEqual: @"type"] == YES
|| [name isEqual: @"variable"] == YES)
{
NSString *tmp = [prop objectForKey: @"name"];
[self setGlobalRef: tmp type: name];
}
else
{
}
}
if (children != nil)
{
[self makeRefs: children];
}
if (newUnit == YES)
{
unit = nil;
}
if (next != nil)
{
[self makeRefs: next];
}
}
- (void) mergeRefs: (NSDictionary*)more
{
mergeDictionaries(refs, more);
}
- (NSMutableDictionary*) refs
{
return refs;
}
- (void) setGlobalRef: (NSString*)ref
type: (NSString*)type
{
NSMutableDictionary *t;
NSString *old;
t = [refs objectForKey: type];
if (t == nil)
{
t = [NSMutableDictionary new];
[refs setObject: t forKey: type];
RELEASE(t);
}
old = [t objectForKey: ref];
if (old != nil && [old isEqual: base] == NO)
{
NSLog(@"Warning ... %@ %@ appears in %@ and %@ ... using the latter",
type, ref, old, base);
}
[t setObject: base forKey: ref];
}
- (void) setUnitRef: (NSString*)ref
type: (NSString*)type
{
NSMutableDictionary *t;
NSMutableDictionary *r;
NSString *old;
t = [refs objectForKey: type];
if (t == nil)
{
t = [NSMutableDictionary new];
[refs setObject: t forKey: type];
RELEASE(t);
}
r = [t objectForKey: ref];
if (r == nil)
{
r = [NSMutableDictionary new];
[t setObject: r forKey: ref];
RELEASE(r);
}
old = [r objectForKey: unit];
if (old != nil && [old isEqual: base] == NO)
{
NSLog(@"Warning ... %@ %@ %@ appears in %@ and %@ ... using the latter",
type, ref, unit, old, base);
}
[r setObject: base forKey: unit];
}
@end

View file

@ -22,6 +22,13 @@
#include "AGSOutput.h"
static NSString *escapeType(NSString *str)
{
str = [str stringByReplacingString: @"<" withString: @"&lt;"];
str = [str stringByReplacingString: @">" withString: @"&gt;"];
return str;
}
static BOOL snuggleEnd(NSString *t)
{
static NSCharacterSet *set = nil;
@ -193,32 +200,36 @@ static BOOL snuggleStart(NSString *t)
[str appendString: @"\"http://www.gnustep.org/gsdoc-0_6_6.xml\">\n"];
[str appendFormat: @"<gsdoc"];
tmp = [info objectForKey: @"Base"];
tmp = [info objectForKey: @"base"];
if (tmp != nil)
{
[str appendString: @" base=\""];
[str appendString: tmp];
[str appendString: @"\""];
}
tmp = [info objectForKey: @"Next"];
tmp = [info objectForKey: @"next"];
if (tmp != nil)
{
[str appendString: @" next=\""];
[str appendString: tmp];
[str appendString: @"\""];
}
tmp = [info objectForKey: @"Prev"];
tmp = [info objectForKey: @"prev"];
if (tmp != nil)
{
[str appendString: @" prev=\""];
[str appendString: tmp];
[str appendString: @"\""];
}
tmp = [info objectForKey: @"Up"];
tmp = [info objectForKey: @"up"];
if (tmp != nil)
{
[str appendString: @" up=\""];
[str appendString: tmp];
[str appendString: @"\""];
}
[str appendString: @">\n"];
@ -400,7 +411,7 @@ static BOOL snuggleStart(NSString *t)
NSArray *sels = [d objectForKey: @"Sels"];
NSArray *types = [d objectForKey: @"Types"];
NSString *name = [d objectForKey: @"Name"];
NSString *tmp;
NSString *comment;
unsigned i;
BOOL isInitialiser = NO;
NSString *override = nil;
@ -408,79 +419,91 @@ static BOOL snuggleStart(NSString *t)
args = [d objectForKey: @"Args"]; // Used when splitting.
tmp = [d objectForKey: @"Comment"];
comment = [d objectForKey: @"Comment"];
/**
* Check special markup which should be removed from the text
* actually placed in the gsdoc method documentation ... the
* special markup is included in the gsdoc markup differently.
*/
if (tmp != nil)
if (comment != nil)
{
NSMutableString *m = nil;
NSRange r;
do
{
r = [tmp rangeOfString: @"<init>"];
r = [comment rangeOfString: @"<init />"];
if (r.length == 0)
r = [comment rangeOfString: @"<init/>"];
if (r.length == 0)
r = [comment rangeOfString: @"<init>"];
if (r.length > 0)
{
if (m == nil)
{
m = [tmp mutableCopy];
m = [comment mutableCopy];
}
[m deleteCharactersInRange: r];
tmp = m;
comment = m;
isInitialiser = YES;
}
} while (r.length > 0);
do
{
r = [tmp rangeOfString: @"<override-subclass>"];
r = [comment rangeOfString: @"<override-subclass />"];
if (r.length == 0)
r = [comment rangeOfString: @"<override-subclass/>"];
if (r.length == 0)
r = [comment rangeOfString: @"<override-subclass>"];
if (r.length > 0)
{
if (m == nil)
{
m = [tmp mutableCopy];
m = [comment mutableCopy];
}
[m deleteCharactersInRange: r];
tmp = m;
comment = m;
override = @"subclass";
}
} while (r.length > 0);
do
{
r = [tmp rangeOfString: @"<override-never>"];
r = [comment rangeOfString: @"<override-never />"];
if (r.length == 0)
r = [comment rangeOfString: @"<override-never/>"];
if (r.length == 0)
r = [comment rangeOfString: @"<override-never>"];
if (r.length > 0)
{
if (m == nil)
{
m = [tmp mutableCopy];
m = [comment mutableCopy];
}
[m deleteCharactersInRange: r];
tmp = m;
comment = m;
override = @"never";
}
} while (r.length > 0);
r = [tmp rangeOfString: @"<standards>"];
r = [comment rangeOfString: @"<standards>"];
if (r.length > 0)
{
unsigned i = r.location;
r = NSMakeRange(i, [tmp length] - i);
r = [tmp rangeOfString: @"</standards>"
r = NSMakeRange(i, [comment length] - i);
r = [comment rangeOfString: @"</standards>"
options: NSLiteralSearch
range: r];
if (r.length > 0)
{
r = NSMakeRange(i, NSMaxRange(r) - i);
standards = [tmp substringWithRange: r];
standards = [comment substringWithRange: r];
if (m == nil)
{
m = [tmp mutableCopy];
m = [comment mutableCopy];
}
[m deleteCharactersInRange: r];
tmp = m;
comment = m;
}
else
{
@ -489,12 +512,12 @@ static BOOL snuggleStart(NSString *t)
}
if (m != nil)
{
RELEASE(m);
AUTORELEASE(m);
}
}
[str appendString: @" <method type=\""];
[str appendString: [d objectForKey: @"ReturnType"]];
[str appendString: escapeType([d objectForKey: @"ReturnType"])];
if ([name hasPrefix: @"+"] == YES)
{
[str appendString: @"\" factory=\"yes"];
@ -518,18 +541,21 @@ static BOOL snuggleStart(NSString *t)
if (i < [args count])
{
[str appendString: @" <arg type=\""];
[str appendString: [types objectAtIndex: i]];
[str appendString: escapeType([types objectAtIndex: i])];
[str appendString: @"\">"];
[str appendString: [args objectAtIndex: i]];
[str appendString: @"</arg>\n"];
}
}
if ([[d objectForKey: @"VarArg"] boolValue] == YES)
{
[str appendString: @"<vararg />\n"];
}
[str appendString: @" <desc>\n"];
tmp = [d objectForKey: @"Comment"];
if (tmp != nil)
if (comment != nil)
{
[self reformat: tmp withIndent: 12 to: str];
[self reformat: comment withIndent: 12 to: str];
}
[str appendString: @" </desc>\n"];
if (standards != nil)
@ -1229,6 +1255,15 @@ static BOOL snuggleStart(NSString *t)
}
pos++;
}
/*
* Varags methods end with ',...'
*/
if (ePos - pos >= 4
&& [[tmp substringWithRange: NSMakeRange(pos, 4)]
isEqual: @",..."])
{
pos += 4;
}
/*
* The end of the method name should be immediately
* before the closing square bracket at 'ePos'
@ -1329,6 +1364,16 @@ static BOOL snuggleStart(NSString *t)
}
pos++;
}
/*
* Varags methods end with ',...'
*/
if (ePos - pos >= 4
&& [[tmp substringWithRange: NSMakeRange(pos, 4)]
isEqual: @",..."])
{
pos += 4;
c = [tmp characterAtIndex: pos];
}
if (pos > 1 && (pos == ePos || c == ',' || c == '.' || c == ';'))
{
NSString *end;

View file

@ -57,7 +57,7 @@
NSCharacterSet *spacenl; // Blanks excluding newline
}
- (NSDictionary*) info;
- (NSMutableDictionary*) info;
- (id) init; /** <init> Simple initialiser */
- (NSMutableDictionary*) parseFile: (NSString*)name isSource: (BOOL)isSource;
- (NSString*) parseIdentifier;

View file

@ -35,7 +35,7 @@
[super dealloc];
}
- (NSDictionary*) info
- (NSMutableDictionary*) info
{
return info;
}

View file

@ -47,7 +47,7 @@ CTOOL_NAME = gdomap
TEST_TOOL_NAME = locale_alias
# The source files to be compiled
autogsdoc_OBJC_FILES = autogsdoc.m AGSParser.m AGSOutput.m
autogsdoc_OBJC_FILES = autogsdoc.m AGSParser.m AGSOutput.m AGSIndex.m
gdomap_C_FILES = gdomap.c
gdnc_OBJC_FILES = gdnc.m
gsdoc_OBJC_FILES = gsdoc.m

View file

@ -109,14 +109,14 @@
following markup is removed from the text and handled specially -
</p>
<list>
<item><strong>&lt;init&gt;</strong>
<item><strong>&lt;init /&gt;</strong>
The method is marked as being the designated initialiser for the class.
</item>
<item><strong>&lt;override-subclass&gt;</strong>
<item><strong>&lt;override-subclass /&gt;</strong>
The method is marked as being one which subclasses must override
(eg an abstract method).
</item>
<item><strong>&lt;override-never&gt;</strong>
<item><strong>&lt;override-never /&gt;</strong>
The method is marked as being one which subclasses should <em>NOT</em>
override.
</item>
@ -161,19 +161,30 @@
command line.
</item>
</list>
<section>
<heading>Inter-document linkage</heading>
<p>
When supplied with a list of documents to process, the tool will
set up linkage between documents using the gsdoc 'prev', 'next',
and 'up' attributes.
</p>
<p>
The first document processed will be the 'up' link for all
subsequent documents.
</p>
<p>
The 'prev' and 'next' links will be set up to link the documents
in the order in which they are processed.
</p>
</section>
</chapter>
*/
#include "AGSParser.h"
#include "AGSOutput.h"
#include <config.h>
#if HAVE_LIBXML
#include <Foundation/GSXML.h>
static int XML_ELEMENT_NODE;
#endif
#include "AGSParser.h"
#include "AGSOutput.h"
#include "AGSIndex.h"
int
main(int argc, char **argv, char **env)
@ -185,8 +196,11 @@ main(int argc, char **argv, char **env)
NSFileManager *mgr;
NSString *documentationDirectory;
NSString *sourceDirectory;
AGSIndex *indexer;
AGSParser *parser;
AGSOutput *output;
NSString *up = nil;
NSString *prev = nil;
CREATE_AUTORELEASE_POOL(pool);
#ifdef GS_PASS_ARGUMENTS
@ -209,6 +223,7 @@ main(int argc, char **argv, char **env)
mgr = [NSFileManager defaultManager];
indexer = [AGSIndex new];
parser = [AGSParser new];
output = [AGSOutput new];
@ -221,25 +236,33 @@ main(int argc, char **argv, char **env)
{
i++; // Skip next value ... it is a default.
}
else if ([arg hasSuffix: @".h"])
else if ([arg hasSuffix: @".h"] || [arg hasSuffix: @".m"])
{
NSString *ddir;
NSString *sdir;
NSString *file;
NSString *generated;
BOOL isSource = [arg hasSuffix: @".m"];
file = [[arg lastPathComponent] stringByDeletingPathExtension];
if (sourceDirectory == nil)
if (isSource == YES)
{
sdir = [arg stringByDeletingLastPathComponent];
sdir = arg;
}
else
{
sdir = sourceDirectory;
if (sourceDirectory == nil)
{
sdir = [arg stringByDeletingLastPathComponent];
}
else
{
sdir = sourceDirectory;
}
sdir = [sdir stringByAppendingPathComponent: file];
sdir = [sdir stringByAppendingPathExtension: @"m"];
}
sdir = [sdir stringByAppendingPathComponent: file];
sdir = [sdir stringByAppendingPathExtension: @"m"];
if (documentationDirectory == nil)
{
@ -265,74 +288,65 @@ main(int argc, char **argv, char **env)
[parser parseFile: sdir isSource: YES];
}
[[parser info] setObject: file forKey: @"base"];
if (up == nil)
{
up = file;
}
else
{
[[parser info] setObject: up forKey: @"up"];
}
if (prev != nil)
{
[[parser info] setObject: prev forKey: @"prev"];
}
prev = file;
if (i < [args count] - 1)
{
unsigned j = i + 1;
while (j < [args count])
{
NSString *name = [args objectAtIndex: j++];
if ([name hasSuffix: @".h"] || [name hasSuffix: @".m"])
{
name = [[name lastPathComponent]
stringByDeletingPathExtension];
[[parser info] setObject: name forKey: @"next"];
break;
}
}
}
generated = [output output: [parser info]];
#if HAVE_LIBXML
{
NSData *data;
GSXMLParser *parser;
/*
* Cache XML node information.
*/
XML_ELEMENT_NODE
= [GSXMLNode typeFromDescription: @"XML_ELEMENT_NODE"];
data = [generated dataUsingEncoding: NSUTF8StringEncoding];
parser = [GSXMLParser parser];
[parser substituteEntities: YES];
[parser doValidityChecking: YES];
if ([parser parse: data] == NO || [parser parse: nil] == NO)
{
NSLog(@"WARNING %@ did not produce a valid document", arg);
}
if (![[[[parser doc] root] name] isEqualToString: @"gsdoc"])
{
NSLog(@"not a gsdoc document - because name node is %@",
[[[parser doc] root] name]);
return 1;
}
}
#endif
if ([generated writeToFile: ddir atomically: YES] == NO)
{
NSLog(@"Sorry unable to write %@", ddir);
}
}
else if ([arg hasSuffix: @".m"])
{
NSString *ddir;
NSString *file;
file = [[arg lastPathComponent] stringByDeletingPathExtension];
if (documentationDirectory == nil)
{
ddir = [arg stringByDeletingLastPathComponent];
}
else
{
ddir = documentationDirectory;
CREATE_AUTORELEASE_POOL(pool);
GSXMLParser *parser;
parser = [GSXMLParser parserWithContentsOfFile: ddir];
[parser substituteEntities: YES];
[parser doValidityChecking: YES];
if ([parser parse] == NO)
{
NSLog(@"WARNING %@ did not produce a valid document", arg);
}
if (![[[[parser doc] root] name] isEqualToString: @"gsdoc"])
{
NSLog(@"not a gsdoc document - because name node is %@",
[[[parser doc] root] name]);
return 1;
}
[indexer makeRefs: [[parser doc] root]];
RELEASE(pool);
}
ddir = [ddir stringByAppendingPathComponent: file];
ddir = [ddir stringByAppendingPathExtension: @"gsdoc"];
if ([mgr isReadableFileAtPath: arg] == NO)
{
NSLog(@"No readable file at '%@' ... skipping", arg);
continue;
}
/*
* If we have been given a '.m' file, we assume that it contains
* interface details to be exported ... so we parse it first as
* if it were a header file, and then again as a source file.
*/
[parser reset];
[parser parseFile: arg isSource: NO];
[parser parseFile: arg isSource: YES];
[output output: [parser info] file: ddir];
}
else
{