mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Improvements to header parser.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20411 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d25c893d49
commit
122766b676
6 changed files with 184 additions and 5 deletions
|
@ -1,3 +1,11 @@
|
|||
2004-12-02 06:20 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormObjCHeaderParser/OCClass.m: added code in parse method
|
||||
to use new class for IVar parsing.
|
||||
* GormObjCHeaderParser/OCIVarDecl.[hm]: New class. This
|
||||
class handles the declaration and breaks it into separate
|
||||
ivar objects.
|
||||
|
||||
2004-12-01 02:12 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormClassManager.m: [GormClassManager parseHeader:] altered
|
||||
|
|
|
@ -1625,7 +1625,7 @@
|
|||
else
|
||||
{
|
||||
result = NO;
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
[NSException raise: NSGenericException
|
||||
format: @"The superclass %@ of class %@ is not known, please parse it.",
|
||||
superClass, className];
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ libGormObjCHeaderParser_HEADER_FILES= \
|
|||
OCHeaderParser.h \
|
||||
OCClass.h \
|
||||
OCIVar.h \
|
||||
OCIVarDecl.h \
|
||||
OCMethod.h \
|
||||
NSScanner+OCHeaderParser.h
|
||||
|
||||
|
@ -55,6 +56,7 @@ libGormObjCHeaderParser_OBJC_FILES= \
|
|||
OCHeaderParser.m \
|
||||
OCClass.m \
|
||||
OCIVar.m \
|
||||
OCIVarDecl.m \
|
||||
OCMethod.m \
|
||||
NSScanner+OCHeaderParser.m
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <GormObjCHeaderParser/OCClass.h>
|
||||
#include <GormObjCHeaderParser/OCMethod.h>
|
||||
#include <GormObjCHeaderParser/OCIVar.h>
|
||||
#include <GormObjCHeaderParser/OCIVarDecl.h>
|
||||
#include <GormObjCHeaderParser/NSScanner+OCHeaderParser.h>
|
||||
|
||||
@implementation OCClass
|
||||
|
@ -198,13 +199,13 @@
|
|||
while(![ivarScan isAtEnd])
|
||||
{
|
||||
NSString *ivarLine = nil;
|
||||
OCIVar *ivar = nil;
|
||||
OCIVarDecl *ivarDecl = nil;
|
||||
|
||||
[ivarScan scanUpToString: @";" intoString: &ivarLine];
|
||||
[ivarScan scanString: @";" intoString: NULL];
|
||||
ivar = AUTORELEASE([[OCIVar alloc] initWithString: ivarLine]);
|
||||
[ivar parse];
|
||||
[ivars addObject: ivar];
|
||||
ivarDecl = AUTORELEASE([[OCIVarDecl alloc] initWithString: ivarLine]);
|
||||
[ivarDecl parse];
|
||||
[ivars addObjectsFromArray: [ivarDecl ivars]];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
43
GormObjCHeaderParser/OCIVarDecl.h
Normal file
43
GormObjCHeaderParser/OCIVarDecl.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* OCHeaderParser.h
|
||||
*
|
||||
* Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
* Date: 1999, 2002
|
||||
*
|
||||
* This file is part of GNUstep.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
|
||||
#ifndef INCLUDED_OCIVarDecl_h
|
||||
#define INCLUDED_OCIVarDecl_h
|
||||
|
||||
@class NSMutableArray, NSString;
|
||||
|
||||
@interface OCIVarDecl : NSObject
|
||||
{
|
||||
NSString *ivarString;
|
||||
NSMutableArray *ivars;
|
||||
}
|
||||
|
||||
- (id) initWithString: (NSString *)string;
|
||||
- (NSArray *) ivars;
|
||||
- (void) parse;
|
||||
@end
|
||||
|
||||
#endif
|
125
GormObjCHeaderParser/OCIVarDecl.m
Normal file
125
GormObjCHeaderParser/OCIVarDecl.m
Normal file
|
@ -0,0 +1,125 @@
|
|||
/* OCHeaderParser.m
|
||||
*
|
||||
* Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
* Date: 1999, 2002
|
||||
*
|
||||
* This file is part of GNUstep.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <GormObjCHeaderParser/OCIVar.h>
|
||||
#include <GormObjCHeaderParser/OCIVarDecl.h>
|
||||
#include <GormObjCHeaderParser/NSScanner+OCHeaderParser.h>
|
||||
|
||||
@implementation OCIVarDecl
|
||||
|
||||
- (id) initWithString: (NSString *)string
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
ASSIGN(ivarString, string);
|
||||
ivars = [[NSMutableArray alloc] init];
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASE(self);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSArray *)ivars
|
||||
{
|
||||
return ivars;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(ivarString);
|
||||
RELEASE(ivars);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) _strip
|
||||
{
|
||||
NSScanner *stripScanner = [NSScanner scannerWithString: ivarString];
|
||||
NSString *resultString = [NSString stringWithString: @""];
|
||||
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||
|
||||
while(![stripScanner isAtEnd])
|
||||
{
|
||||
NSString *string = nil;
|
||||
[stripScanner scanUpToCharactersFromSet: wsnl intoString: &string];
|
||||
resultString = [resultString stringByAppendingString: string];
|
||||
if(![stripScanner isAtEnd])
|
||||
{
|
||||
resultString = [resultString stringByAppendingString: @" "];
|
||||
}
|
||||
}
|
||||
|
||||
ASSIGN(ivarString, resultString);
|
||||
}
|
||||
|
||||
- (void) parse
|
||||
{
|
||||
NSRange notFound = NSMakeRange(NSNotFound,0);
|
||||
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||
NSRange range;
|
||||
|
||||
[self _strip];
|
||||
if(NSEqualRanges((range = [ivarString rangeOfString: @","]),notFound) == NO)
|
||||
{
|
||||
OCIVar *ivar = nil;
|
||||
NSScanner *scanner = [NSScanner scannerWithString: ivarString];
|
||||
NSString *tempIvar = nil;
|
||||
BOOL isOutlet = NO;
|
||||
|
||||
// scan the first one in...
|
||||
[scanner scanUpToString: @"," intoString: &tempIvar];
|
||||
[scanner scanString: @"," intoString: NULL];
|
||||
ivar = AUTORELEASE([[OCIVar alloc] initWithString: tempIvar]);
|
||||
[ivar parse];
|
||||
[ivars addObject: ivar];
|
||||
isOutlet = [ivar isOutlet];
|
||||
|
||||
while(![scanner isAtEnd])
|
||||
{
|
||||
NSString *name = nil;
|
||||
OCIVar *newIvar = nil;
|
||||
|
||||
[scanner scanCharactersFromSet: wsnl intoString: NULL];
|
||||
[scanner scanUpToString: @"," intoString: &name];
|
||||
[scanner scanString: @"," intoString: NULL];
|
||||
[scanner scanCharactersFromSet: wsnl intoString: NULL];
|
||||
newIvar = AUTORELEASE([[OCIVar alloc] initWithString: nil]);
|
||||
[newIvar setName: name];
|
||||
[newIvar setIsOutlet: isOutlet];
|
||||
[ivars addObject: newIvar];
|
||||
}
|
||||
}
|
||||
else // for everything else...
|
||||
{
|
||||
OCIVar *ivar = AUTORELEASE([[OCIVar alloc] initWithString: ivarString]);
|
||||
[ivar parse];
|
||||
[ivars addObject: ivar];
|
||||
}
|
||||
|
||||
}
|
||||
@end
|
Loading…
Reference in a new issue