/**
This is a really great class ... but it's not really reusable since it's * far too special purpose.
*Here is the afterword for the class.
*"] == NO)
{
/*
* Ensure that well known constants are rendered as 'code'
*/
count = [constants count];
for (pos = 0; pos < count; pos++)
{
NSString *c = [constants objectAtIndex: pos];
r = [tmp rangeOfString: c];
if (r.length > 0)
{
NSString *start;
NSString *end;
if (r.location > 0)
{
start = [tmp substringToIndex: r.location];
}
else
{
start = nil;
}
if (NSMaxRange(r) < [tmp length])
{
end = [tmp substringFromIndex: NSMaxRange(r)];
}
else
{
end = nil;
}
if ((start == nil || snuggleStart(start) == YES)
&& (end == nil || snuggleEnd(end) == YES))
{
NSString *sub;
if (start != nil || end != nil)
{
sub = [tmp substringWithRange: r];
}
else
{
sub = nil;
}
if (start != nil)
{
[a insertObject: start atIndex: l++];
}
[a insertObject: @"" atIndex: l++];
if (sub != nil)
{
[a replaceObjectAtIndex: l withObject: sub];
}
l++;
[a insertObject: @"
" atIndex: l];
if (end != nil)
{
[a insertObject: end atIndex: ++l];
}
}
}
}
}
/*
* Ensure that method arguments are rendered as 'var'
*/
if (l == 0 || [[a objectAtIndex: l-1] isEqual: @""] == NO)
{
count = [args count];
for (pos = 0; pos < count; pos++)
{
NSString *c = [args objectAtIndex: pos];
r = [tmp rangeOfString: c];
if (r.length > 0)
{
NSString *start;
NSString *end;
if (r.location > 0)
{
start = [tmp substringToIndex: r.location];
}
else
{
start = nil;
}
if (NSMaxRange(r) < [tmp length])
{
end = [tmp substringFromIndex: NSMaxRange(r)];
}
else
{
end = nil;
}
if ((start == nil || snuggleStart(start) == YES)
&& (end == nil || snuggleEnd(end) == YES))
{
NSString *sub;
if (start != nil || end != nil)
{
sub = [tmp substringWithRange: r];
}
else
{
sub = nil;
}
if (start != nil)
{
[a insertObject: start atIndex: l++];
}
[a insertObject: @"" atIndex: l++];
if (sub != nil)
{
[a replaceObjectAtIndex: l withObject: sub];
}
l++;
[a insertObject: @"" atIndex: l];
if (end != nil)
{
[a insertObject: end atIndex: ++l];
}
}
}
}
}
/*
* Ensure that methods are rendered as references.
* First look for format with class name in square brackets.
*/
r = [tmp rangeOfString: @"["];
if (r.length > 0)
{
unsigned sPos = NSMaxRange(r);
pos = sPos;
r = NSMakeRange(pos, [tmp length] - pos);
r = [tmp rangeOfString: @"]" options: NSLiteralSearch range: r];
if (r.length > 0)
{
unsigned ePos = r.location;
NSString *cName = nil;
NSString *mName = nil;
unichar c;
if (pos < ePos
&& [identStart characterIsMember:
(c = [tmp characterAtIndex: pos])] == YES)
{
pos++;
while (pos < ePos)
{
c = [tmp characterAtIndex: pos];
if ([identifier characterIsMember: c] == NO)
{
break;
}
pos++;
}
if (c == '(')
{
pos++;
if (pos < ePos
&& [identStart characterIsMember:
(c = [tmp characterAtIndex: pos])] == YES)
{
while (pos < ePos)
{
c = [tmp characterAtIndex: pos];
if ([identifier characterIsMember: c] == NO)
{
break;
}
pos++;
}
if (c == ')')
{
pos++;
r = NSMakeRange(sPos, pos - sPos);
cName = [tmp substringWithRange: r];
if (pos < ePos)
{
c = [tmp characterAtIndex: pos];
}
}
}
if (cName == nil)
{
pos = ePos; // Bad class name!
}
}
else
{
r = NSMakeRange(sPos, pos - sPos);
cName = [tmp substringWithRange: r];
}
}
if (pos < ePos && (c == '+' || c == '-'))
{
unsigned mStart = pos;
pos++;
if (pos < ePos
&& [identStart characterIsMember:
(c = [tmp characterAtIndex: pos])] == YES)
{
while (pos < ePos)
{
c = [tmp characterAtIndex: pos];
if (c != ':'
&& [identifier characterIsMember: c] == NO)
{
break;
}
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'
*/
if (pos == ePos && pos - mStart > 1)
{
r = NSMakeRange(mStart, pos - mStart);
mName = [tmp substringWithRange: r];
}
}
}
if (mName != nil)
{
NSString *start;
NSString *end;
NSString *sub;
NSString *ref;
if (sPos > 0)
{
start = [tmp substringToIndex: sPos];
}
else
{
start = nil;
}
if (ePos < [tmp length])
{
end = [tmp substringFromIndex: ePos];
}
else
{
end = nil;
}
if (start != nil || end != nil)
{
sub = [tmp substringWithRange:
NSMakeRange(sPos, ePos - sPos)];
}
else
{
sub = nil;
}
if (start != nil)
{
[a insertObject: start atIndex: l++];
}
if (cName == nil)
{
ref = [NSString stringWithFormat:
@"", mName];
}
else
{
ref = [NSString stringWithFormat:
@"",
mName, cName];
}
[a insertObject: ref atIndex: l++];
if (sub != nil)
{
[a replaceObjectAtIndex: l withObject: sub];
}
l++;
[a insertObject: @"" atIndex: l];
if (end != nil)
{
[a insertObject: end atIndex: ++l];
}
hadMethod = YES;
}
}
}
/*
* Now handle bare method names for current class ... outside brackets.
*/
if (hadMethod == NO && ([tmp hasPrefix: @"-"] || [tmp hasPrefix: @"+"]))
{
unsigned ePos = [tmp length];
NSString *mName = nil;
unsigned c;
pos = 1;
if (pos < ePos
&& [identStart characterIsMember:
(c = [tmp characterAtIndex: pos])] == YES)
{
while (pos < ePos)
{
c = [tmp characterAtIndex: pos];
if (c != ':'
&& [identifier characterIsMember: c] == NO)
{
break;
}
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;
NSString *sub;
NSString *ref;
mName = [tmp substringWithRange: NSMakeRange(0, pos)];
if (pos < [tmp length])
{
end = [tmp substringFromIndex: pos];
sub = [tmp substringToIndex: pos];
}
else
{
end = nil;
sub = nil;
}
ref = [NSString stringWithFormat:
@"", mName];
[a insertObject: ref atIndex: l++];
if (sub != nil)
{
[a replaceObjectAtIndex: l withObject: sub];
}
l++;
[a insertObject: @"" atIndex: l];
if (end != nil)
{
[a insertObject: end atIndex: ++l];
}
hadMethod = YES;
}
}
}
}
return a;
}
@end