Merge branch 'master' into object_outline

This commit is contained in:
Gregory John Casamento 2024-12-25 06:03:24 -05:00
commit 6545df37d5
27 changed files with 344 additions and 212 deletions

View file

@ -4,6 +4,7 @@
Actions = ( Actions = (
); );
Outlets = ( Outlets = (
"_prototypePopUp"
); );
Super = IBPalette; Super = IBPalette;
}; };

View file

@ -1,10 +1,10 @@
/** /**
main.m ControlsPalette.m
Copyright (C) 2004 Free Software Foundation, Inc. Copyright (C) 2024 Free Software Foundation, Inc.
Author: Gregory John Casamento <greg_casamento@yahoo.com> Author: Gregory John Casamento <greg_casamento@yahoo.com>
Date: 2004 Date: 2024, 2004
This file is part of GNUstep. This file is part of GNUstep.
@ -23,14 +23,15 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/ */
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#include <InterfaceBuilder/InterfaceBuilder.h> #include <InterfaceBuilder/InterfaceBuilder.h>
#include "GormNSPopUpButton.h" #include "GormNSPopUpButton.h"
@interface ControlsPalette: IBPalette <IBViewResourceDraggingDelegates> @interface ControlsPalette: IBPalette <IBViewResourceDraggingDelegates>
{
IBOutlet NSPopUpButton *_prototypePopUp;
}
@end @end
@ -62,16 +63,28 @@
- (void) finishInstantiate - (void) finishInstantiate
{ {
NSView *contents; NSView *contentView = [originalWindow contentView];
id v; NSArray *allItems = nil;
NSEnumerator *en = nil;
id item = nil;
_prototypePopUp = [[GormNSPopUpButton alloc] initWithFrame: NSMakeRect(71.0, 157.0, 102.0, 24.0)];
[_prototypePopUp addItemWithTitle: @"Item #0"];
[_prototypePopUp addItemWithTitle: @"Item #1"];
[_prototypePopUp addItemWithTitle: @"Item #2"];
[_prototypePopUp setAutoenablesItems: YES];
allItems = [[_prototypePopUp menu] itemArray];
en = [allItems objectEnumerator];
while ((item = [en nextObject]) != nil)
{
[item setTarget: nil];
[item setAction: NULL]; // @selector(_popUpItemAction:)];
[item setEnabled: YES];
}
contents = [originalWindow contentView]; [contentView addSubview: _prototypePopUp];
v = [[GormNSPopUpButton alloc] initWithFrame: NSMakeRect(73, 159, 70, 22)]; AUTORELEASE(_prototypePopUp);
[v addItemWithTitle: @"Item 1"];
[v addItemWithTitle: @"Item 2"];
[v addItemWithTitle: @"Item 3"];
[contents addSubview: v];
RELEASE(v);
} }
- (void) willInspectObject: (NSNotification *)notification - (void) willInspectObject: (NSNotification *)notification

View file

@ -1,5 +1,29 @@
#include <GormCore/GormCore.h> /**
main.m
Copyright (C) 2024 Free Software Foundation, Inc.
Author: Gregory John Casamento <greg_casamento@yahoo.com>
Date: 2024
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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/
#include <GormCore/GormCore.h>
#include "GormNSPopUpButton.h" #include "GormNSPopUpButton.h"
Class _gormnspopupbuttonCellClass = 0; Class _gormnspopupbuttonCellClass = 0;
@ -65,6 +89,7 @@ Class _gormnspopupbuttonCellClass = 0;
* Override this here, since themes may override it. * Override this here, since themes may override it.
* Always want to show the menu view since it's editable. * Always want to show the menu view since it's editable.
*/ */
/*
- (void) attachPopUpWithFrame: (NSRect)cellFrame - (void) attachPopUpWithFrame: (NSRect)cellFrame
inView: (NSView *)controlView inView: (NSView *)controlView
{ {
@ -127,4 +152,6 @@ Class _gormnspopupbuttonCellClass = 0;
name: NSMenuDidSendActionNotification name: NSMenuDidSendActionNotification
object: _menu]; object: _menu];
} }
*/
@end @end

View file

@ -70,27 +70,20 @@
if (sender == typeMatrix) if (sender == typeMatrix)
{ {
BOOL pullsDown = [[sender selectedCell] tag] == YES ? YES : NO; BOOL pullsDown = [[sender selectedCell] tag] == YES ? YES : NO;
id selectedItem; NSArray *itemArray = [[object itemArray] copy];
id cell = [object cell]; NSEnumerator *en = [itemArray objectEnumerator];
id o = nil;
[object removeAllItems];
[object setPullsDown: pullsDown]; [object setPullsDown: pullsDown];
selectedItem = [object selectedItem]; while ((o = [en nextObject]) != nil)
[object selectItem: nil];
[object selectItem: selectedItem];
[cell setUsesItemFromMenu: YES];
// Set up the form...
[pullDownTitleForm setEnabled: pullsDown];
[[pullDownTitleForm cellAtIndex: 0]
setStringValue: pullsDown ? [object title] : @""];
[pullDownArrowPopUp setEnabled: pullsDown];
if (pullsDown)
{ {
// TODO: This should be configurable in the future id<NSMenuItem> mi = nil;
[cell setPreferredEdge: NSMaxYEdge];
[cell setMenuItem: nil]; [object addItemWithTitle: [o title]];
[cell setMenuItem: selectedItem]; mi = [object lastItem];
[mi setAction: NULL]; // @selector(_popUpItemAction:)];
[mi setTarget: nil];
} }
} }
else if (sender == autoenableSwitch) else if (sender == autoenableSwitch)

View file

@ -4,15 +4,16 @@
Actions = ( Actions = (
); );
Outlets = ( Outlets = (
formatTable,
detachButton,
addThousandSeparatorSwitch, addThousandSeparatorSwitch,
commaPointSwitch, commaPointSwitch,
formatForm, formatForm,
formatTable,
localizeSwitch, localizeSwitch,
negativeField, negativeField,
negativeRedSwitch, negativeRedSwitch,
positiveField, positiveField,
detachButton zeroField
); );
Super = IBInspector; Super = IBInspector;
}; };

View file

@ -31,15 +31,16 @@
@interface GormNumberFormatterAttributesInspector : IBInspector @interface GormNumberFormatterAttributesInspector : IBInspector
{ {
id addThousandSeparatorSwitch; IBOutlet id addThousandSeparatorSwitch;
id commaPointSwitch; IBOutlet id commaPointSwitch;
id formatForm; IBOutlet id formatForm;
id formatTable; IBOutlet id formatTable;
id localizeSwitch; IBOutlet id negativeRedSwitch;
id negativeField; IBOutlet id detachButton;
id negativeRedSwitch; IBOutlet id localizeSwitch;
id positiveField; IBOutlet id positiveField;
id detachButton; IBOutlet id negativeField;
IBOutlet id zeroField;
} }
@end @end

View file

@ -51,8 +51,10 @@ extern NSArray *predefinedNumberFormats;
else else
{ {
NSNumberFormatter *fmtr = [[NSNumberFormatter alloc] init]; NSNumberFormatter *fmtr = [[NSNumberFormatter alloc] init];
[fmtr setFormat: [NSNumberFormatter defaultFormat]];
[fmtr setFormat: [NSNumberFormatter defaultFormat]];
[[positiveField cell] setFormatter: fmtr]; [[positiveField cell] setFormatter: fmtr];
[[zeroField cell] setFormatter: fmtr];
[[negativeField cell] setFormatter: fmtr]; [[negativeField cell] setFormatter: fmtr];
} }
} }
@ -61,14 +63,17 @@ extern NSArray *predefinedNumberFormats;
- (void) updateAppearanceFieldsWithFormat: (NSString *)format; - (void) updateAppearanceFieldsWithFormat: (NSString *)format;
{ {
[[[positiveField cell] formatter] setFormat: format]; [[[positiveField cell] formatter] setFormat: format];
[[positiveField cell] setObjectValue: [[positiveField cell] setObjectValue:
[NSDecimalNumber decimalNumberWithString: @"123456.789"]]; [NSDecimalNumber decimalNumberWithString: @"123456.789"]];
[[[zeroField cell] formatter] setFormat: format];
[[zeroField cell] setObjectValue:
[NSDecimalNumber decimalNumberWithString: @"0.000"]];
[[[negativeField cell] formatter] setFormat: format]; [[[negativeField cell] formatter] setFormat: format];
[[negativeField cell] setObjectValue: [[negativeField cell] setObjectValue:
[NSDecimalNumber decimalNumberWithString: @"-123456.789"]]; [NSDecimalNumber decimalNumberWithString: @"-123456.789"]];
} }
- (void) ok: (id)sender - (void) ok: (id)sender
@ -98,28 +103,27 @@ extern NSArray *predefinedNumberFormats;
zeroFmt = [NSNumberFormatter zeroFormatAtIndex:row]; zeroFmt = [NSNumberFormatter zeroFormatAtIndex:row];
negativeFmt = [NSNumberFormatter negativeFormatAtIndex:row]; negativeFmt = [NSNumberFormatter negativeFormatAtIndex:row];
fullFmt = [NSNumberFormatter formatAtIndex:row]; fullFmt = [NSNumberFormatter formatAtIndex:row];
// Update Appearance samples
[self updateAppearanceFieldsWithFormat: fullFmt];
// Update editable format fields
[[formatForm cellAtIndex:0] setStringValue: VSTR(positiveFmt)];
[[formatForm cellAtIndex:1] setStringValue: VSTR(zeroFmt)];
[[formatForm cellAtIndex:2] setStringValue: VSTR(negativeFmt)];
[fmtr setFormat:fullFmt]; // Update Appearance samples
[self updateAppearanceFieldsWithFormat: fullFmt];
// Update editable format fields
[[formatForm cellAtIndex:0] setStringValue: VSTR(positiveFmt)];
[[formatForm cellAtIndex:1] setStringValue: VSTR(zeroFmt)];
[[formatForm cellAtIndex:2] setStringValue: VSTR(negativeFmt)];
[fmtr setFormat:fullFmt];
} }
} }
else if (sender == formatForm) else if (sender == formatForm)
{ {
NSUInteger idx; NSUInteger idx;
positiveFmt = [[sender cellAtIndex:0] stringValue]; positiveFmt = [[sender cellAtIndex: 0] stringValue];
zeroFmt = [[sender cellAtIndex:1] stringValue]; zeroFmt = [[sender cellAtIndex: 1] stringValue];
negativeFmt = [[sender cellAtIndex:2] stringValue]; negativeFmt = [[sender cellAtIndex: 2] stringValue];
minValue = [[sender cellAtIndex:3] stringValue]; minValue = [[sender cellAtIndex: 3] stringValue];
maxValue = [[sender cellAtIndex:4] stringValue]; maxValue = [[sender cellAtIndex: 4] stringValue];
NSDebugLog(@"min,max: %@, %@", minValue, maxValue); NSDebugLog(@"min,max: %@, %@", minValue, maxValue);
fullFmt = [NSString stringWithFormat:@"%@;%@;%@", fullFmt = [NSString stringWithFormat:@"%@;%@;%@",

View file

@ -1,3 +1,8 @@
2024-12-25 Gregory John Casamento <greg.casamento@gmail.com>
* GormObjCHeaderParser/OCClass.m: Improve parsing
to allow getting information from .m files/categories.
2023-01-15 Gregory John Casamento <greg.casamento@gmail.com> 2023-01-15 Gregory John Casamento <greg.casamento@gmail.com>
* ANNOUNCE * ANNOUNCE

View file

@ -885,7 +885,7 @@ NSImage *browserImage = nil;
*/ */
- (id) loadClass: (id)sender - (id) loadClass: (id)sender
{ {
NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", nil]; NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", @"m", @"mm", nil];
NSOpenPanel *oPanel = [NSOpenPanel openPanel]; NSOpenPanel *oPanel = [NSOpenPanel openPanel];
int result; int result;
@ -922,7 +922,7 @@ NSImage *browserImage = nil;
message, message,
nil, nil, nil); nil, nil, nil);
} }
NS_ENDHANDLER NS_ENDHANDLER;
} }
return nil; return nil;

View file

@ -1869,7 +1869,7 @@
- (BOOL) parseHeader: (NSString *)headerPath - (BOOL) parseHeader: (NSString *)headerPath
{ {
OCHeaderParser *ochp = AUTORELEASE([[OCHeaderParser alloc] initWithContentsOfFile: headerPath]); OCHeaderParser *ochp = [[OCHeaderParser alloc] initWithContentsOfFile: headerPath];
BOOL result = NO; BOOL result = NO;
if(ochp != nil) if(ochp != nil)
@ -1885,12 +1885,15 @@
{ {
NSArray *methods = [cls methods]; NSArray *methods = [cls methods];
NSArray *ivars = [cls ivars]; NSArray *ivars = [cls ivars];
NSString *superClass = [cls superClassName]; NSArray *properties = [cls properties];
NSString *superClass = [cls superClassName]; // == nil) ? @"NSObject":[cls superClassName];
NSString *className = [cls className]; NSString *className = [cls className];
NSEnumerator *ien = [ivars objectEnumerator]; NSEnumerator *ien = [ivars objectEnumerator];
NSEnumerator *men = [methods objectEnumerator]; NSEnumerator *men = [methods objectEnumerator];
NSEnumerator *pen = [properties objectEnumerator];
OCMethod *method = nil; OCMethod *method = nil;
OCIVar *ivar = nil; OCIVar *ivar = nil;
OCProperty *property = nil;
NSMutableArray *actions = [NSMutableArray array]; NSMutableArray *actions = [NSMutableArray array];
NSMutableArray *outlets = [NSMutableArray array]; NSMutableArray *outlets = [NSMutableArray array];
@ -1911,6 +1914,16 @@
} }
} }
while((property = (OCProperty *)[pen nextObject]) != nil)
{
if([property isOutlet])
{
[outlets addObject: [property name]];
}
}
NSLog(@"outlets = %@", outlets);
if(([self isKnownClass: superClass] || superClass == nil) && if(([self isKnownClass: superClass] || superClass == nil) &&
[cls isCategory] == NO) [cls isCategory] == NO)
{ {
@ -1958,13 +1971,25 @@
withOutlets: outlets]; withOutlets: outlets];
} }
} }
else if([cls isCategory] && [self isKnownClass: className]) else if([cls isCategory])
{ {
[self addActions: actions forClassNamed: className]; if ([self isKnownClass: className])
{
[self addActions: actions forClassNamed: className];
[self addActions: outlets forClassNamed: className];
}
else
{
[self addClassNamed: className
withSuperClassNamed: @"NSObject"
withActions: actions
withOutlets: outlets];
}
} }
else if(superClass != nil && [self isKnownClass: superClass] == NO) else if(superClass != nil && [self isKnownClass: superClass] == NO)
{ {
result = NO; result = NO;
RELEASE(ochp);
[NSException raise: NSGenericException [NSException raise: NSGenericException
format: @"The superclass %@ of class %@ is not known, please parse it.", format: @"The superclass %@ of class %@ is not known, please parse it.",
superClass, className]; superClass, className];
@ -1973,6 +1998,7 @@
} }
} }
RELEASE(ochp);
return result; return result;
} }

View file

@ -1851,8 +1851,11 @@ static void _real_close(GormDocument *self,
[[self window] orderOut: self]; [[self window] orderOut: self];
} }
[[[NSApp delegate] mainMenu] close]; // close the menu during test... if ([delegate respondsToSelector: @selector(mainMenu)])
{
[[delegate mainMenu] close]; // close the menu during test...
}
enumerator = [nameTable objectEnumerator]; enumerator = [nameTable objectEnumerator];
while ((obj = [enumerator nextObject]) != nil) while ((obj = [enumerator nextObject]) != nil)
{ {

View file

@ -222,7 +222,6 @@
NSPoint initialLocation; NSPoint initialLocation;
BOOL **selectedCells = [self _selectedCells]; BOOL **selectedCells = [self _selectedCells];
id selectedCell = [self selectedCell]; id selectedCell = [self selectedCell];
id **cells = nil;
/* /*
* Pathological case -- ignore mouse down * Pathological case -- ignore mouse down
@ -241,7 +240,7 @@
column: &column column: &column
forPoint: lastLocation]) forPoint: lastLocation])
{ {
if ([cells[row][column] isEnabled]) if ([_cells[row][column] isEnabled])
{ {
if ((_mode == NSRadioModeMatrix) && _selectedCell != nil) if ((_mode == NSRadioModeMatrix) && _selectedCell != nil)
{ {
@ -251,11 +250,11 @@
selectedCell = nil; selectedCell = nil;
_selectedRow = _selectedColumn = -1; _selectedRow = _selectedColumn = -1;
} }
[cells[row][column] setState: NSOnState]; [_cells[row][column] setState: NSOnState];
[self drawCellAtRow: row column: column]; [self drawCellAtRow: row column: column];
[_window flushWindow]; [_window flushWindow];
selectedCells[row][column] = YES; selectedCells[row][column] = YES;
[self _setSelectedCell: cells[row][column]]; [self _setSelectedCell: _cells[row][column]];
_selectedRow = row; _selectedRow = row;
_selectedColumn = column; _selectedColumn = column;
} }

View file

@ -1447,9 +1447,14 @@ static BOOL currently_displaying = NO;
- (void) postDraw: (NSRect) rect - (void) postDraw: (NSRect) rect
{ {
if ([parent respondsToSelector: @selector(postDrawForView:)]) if (parent != nil)
[parent performSelector: @selector(postDrawForView:) {
withObject: self]; if ([parent respondsToSelector: @selector(postDrawForView:)])
{
[parent performSelector: @selector(postDrawForView:)
withObject: self];
}
}
} }
- (void) drawRect: (NSRect) rect - (void) drawRect: (NSRect) rect

View file

@ -5,17 +5,15 @@
PACKAGE_NAME = gorm PACKAGE_NAME = gorm
include $(GNUSTEP_MAKEFILES)/common.make include $(GNUSTEP_MAKEFILES)/common.make
# #
# Subprojects # Subprojects
# #
SUBPROJECTS = \
Tests
# #
# Library # Library
# #
LIBRARY_VAR=GMOBJCHEADERPARSER LIBRARY_VAR=GMOBJCHEADERPARSER
LIBRARY_NAME=GormObjCHeaderParser LIBRARY_NAME=GormObjCHeaderParser
GormObjCHeaderParser_HEADER_FILES_DIR=. GormObjCHeaderParser_HEADER_FILES_DIR=.
@ -24,13 +22,11 @@ ADDITIONAL_INCLUDE_DIRS = -I..
# #
# Additional libraries # Additional libraries
# #
GormObjCHeaderParser_LIBRARIES_DEPEND_UPON += -lgnustep-gui -l$(FOUNDATION_LIBRARY_NAME) GormObjCHeaderParser_LIBRARIES_DEPEND_UPON += -lgnustep-gui -l$(FOUNDATION_LIBRARY_NAME)
# #
# Header files # Header files
# #
GormObjCHeaderParser_HEADER_FILES= \ GormObjCHeaderParser_HEADER_FILES= \
GormObjCHeaderParser.h \ GormObjCHeaderParser.h \
NSScanner+OCHeaderParser.h \ NSScanner+OCHeaderParser.h \
@ -39,13 +35,12 @@ OCHeaderParser.h \
OCIVar.h \ OCIVar.h \
OCIVarDecl.h \ OCIVarDecl.h \
OCMethod.h \ OCMethod.h \
OCProperty.h \
ParserFunctions.h ParserFunctions.h
# #
# Class files # Class files
# #
GormObjCHeaderParser_OBJC_FILES= \ GormObjCHeaderParser_OBJC_FILES= \
NSScanner+OCHeaderParser.m \ NSScanner+OCHeaderParser.m \
OCClass.m \ OCClass.m \
@ -53,12 +48,12 @@ OCHeaderParser.m \
OCIVar.m \ OCIVar.m \
OCIVarDecl.m \ OCIVarDecl.m \
OCMethod.m \ OCMethod.m \
OCProperty.m \
ParserFunctions.m ParserFunctions.m
# #
# C files # C files
# #
GormObjCHeaderParser_C_FILES= GormObjCHeaderParser_C_FILES=
HEADERS_INSTALL = $(GormObjCHeaderParser_HEADER_FILES) HEADERS_INSTALL = $(GormObjCHeaderParser_HEADER_FILES)

View file

@ -41,6 +41,7 @@ FOUNDATION_EXPORT const unsigned char GormObjCHeaderParserVersionString[];
#include <GormObjCHeaderParser/OCIVar.h> #include <GormObjCHeaderParser/OCIVar.h>
#include <GormObjCHeaderParser/OCIVarDecl.h> #include <GormObjCHeaderParser/OCIVarDecl.h>
#include <GormObjCHeaderParser/OCMethod.h> #include <GormObjCHeaderParser/OCMethod.h>
#include <GormObjCHeaderParser/OCProperty.h>
#include <GormObjCHeaderParser/ParserFunctions.h> #include <GormObjCHeaderParser/ParserFunctions.h>
#endif #endif

View file

@ -31,26 +31,31 @@
@interface OCClass : NSObject @interface OCClass : NSObject
{ {
NSMutableArray *ivars; NSMutableArray *_ivars;
NSMutableArray *methods; NSMutableArray *_methods;
NSMutableArray *protocols; NSMutableArray *_protocols;
NSString *className; NSMutableArray *_properties;
NSString *superClassName; NSString *_className;
NSString *classString; NSString *_superClassName;
BOOL isCategory; NSString *_classString;
BOOL _isCategory;
} }
- (id) initWithString: (NSString *)string; - (id) initWithString: (NSString *)string;
- (NSArray *) methods; - (NSArray *) methods;
- (void) addMethod: (NSString *)name isAction: (BOOL) flag; - (void) addMethod: (NSString *)name isAction: (BOOL)flag;
- (NSArray *) ivars; - (NSArray *) ivars;
- (void) addIVar: (NSString *)name isOutlet: (BOOL) flag; - (void) addIVar: (NSString *)name isOutlet: (BOOL)flag;
- (NSString *) className; - (NSString *) className;
- (void) setClassName: (NSString *)name; - (void) setClassName: (NSString *)name;
- (NSString *) superClassName; - (NSString *) superClassName;
- (void) setSuperClassName: (NSString *)name; - (void) setSuperClassName: (NSString *)name;
- (BOOL) isCategory; - (BOOL) isCategory;
- (void) setIsCategory: (BOOL)flag; - (void) setIsCategory: (BOOL)flag;
- (NSArray *) properties;
- (void) parse; - (void) parse;
@end @end
#endif #endif

View file

@ -24,38 +24,44 @@
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
#include <GormObjCHeaderParser/OCClass.h> #include "GormObjCHeaderParser/OCClass.h"
#include <GormObjCHeaderParser/OCMethod.h> #include "GormObjCHeaderParser/OCMethod.h"
#include <GormObjCHeaderParser/OCIVar.h> #include "GormObjCHeaderParser/OCProperty.h"
#include <GormObjCHeaderParser/OCIVarDecl.h> #include "GormObjCHeaderParser/OCIVar.h"
#include <GormObjCHeaderParser/NSScanner+OCHeaderParser.h> #include "GormObjCHeaderParser/OCIVarDecl.h"
#include <GormObjCHeaderParser/ParserFunctions.h> #include "GormObjCHeaderParser/NSScanner+OCHeaderParser.h"
#include "GormObjCHeaderParser/ParserFunctions.h"
@implementation OCClass @implementation OCClass
- (id) initWithString: (NSString *)string - (id) initWithString: (NSString *)string
{ {
if((self = [super init]) != nil) if ((self = [super init]) != nil)
{ {
methods = [[NSMutableArray alloc] init]; _methods = [[NSMutableArray alloc] init];
ivars = [[NSMutableArray alloc] init]; _ivars = [[NSMutableArray alloc] init];
ASSIGN(classString, string); _properties = [[NSMutableArray alloc] init];
_protocols = [[NSMutableArray alloc] init];
_superClassName = nil;
ASSIGN(_classString, string);
} }
return self; return self;
} }
- (void) dealloc - (void) dealloc
{ {
RELEASE(methods); RELEASE(_methods);
RELEASE(ivars); RELEASE(_ivars);
RELEASE(classString); RELEASE(_properties);
RELEASE(className); RELEASE(_protocols);
RELEASE(superClassName); RELEASE(_classString);
RELEASE(_className);
RELEASE(_superClassName);
[super dealloc]; [super dealloc];
} }
- (NSArray *) methods - (NSArray *) methods
{ {
return methods; return _methods;
} }
- (void) addMethod: (NSString *)name isAction: (BOOL) flag - (void) addMethod: (NSString *)name isAction: (BOOL) flag
@ -63,12 +69,12 @@
OCMethod *method = AUTORELEASE([[OCMethod alloc] init]); OCMethod *method = AUTORELEASE([[OCMethod alloc] init]);
[method setName: name]; [method setName: name];
[method setIsAction: flag]; [method setIsAction: flag];
[methods addObject: method]; [_methods addObject: method];
} }
- (NSArray *) ivars - (NSArray *) ivars
{ {
return ivars; return _ivars;
} }
- (void) addIVar: (NSString *)name isOutlet: (BOOL) flag - (void) addIVar: (NSString *)name isOutlet: (BOOL) flag
@ -76,42 +82,47 @@
OCIVar *ivar = AUTORELEASE([[OCIVar alloc] init]); OCIVar *ivar = AUTORELEASE([[OCIVar alloc] init]);
[ivar setName: name]; [ivar setName: name];
[ivar setIsOutlet: flag]; [ivar setIsOutlet: flag];
[ivars addObject: ivar]; [_ivars addObject: ivar];
} }
- (NSString *) className - (NSString *) className
{ {
return className; return _className;
} }
- (void) setClassName: (NSString *)name - (void) setClassName: (NSString *)name
{ {
ASSIGN(className, name); ASSIGN(_className, name);
} }
- (NSString *) superClassName - (NSString *) superClassName
{ {
return superClassName; return _superClassName;
} }
- (void) setSuperClassName: (NSString *)name - (void) setSuperClassName: (NSString *)name
{ {
ASSIGN(superClassName,name); ASSIGN(_superClassName,name);
} }
- (BOOL) isCategory - (BOOL) isCategory
{ {
return isCategory; return _isCategory;
} }
- (void) setIsCategory: (BOOL)flag - (void) setIsCategory: (BOOL)flag
{ {
isCategory = flag; _isCategory = flag;
}
- (NSArray *) properties
{
return _properties;
} }
- (void) _strip - (void) _strip
{ {
NSScanner *stripScanner = [NSScanner scannerWithString: classString]; NSScanner *stripScanner = [NSScanner scannerWithString: _classString];
NSString *resultString = @""; NSString *resultString = @"";
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet]; NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
@ -120,13 +131,13 @@
NSString *string = nil; NSString *string = nil;
[stripScanner scanUpToCharactersFromSet: wsnl intoString: &string]; [stripScanner scanUpToCharactersFromSet: wsnl intoString: &string];
resultString = [resultString stringByAppendingString: string]; resultString = [resultString stringByAppendingString: string];
if(![stripScanner isAtEnd]) if (![stripScanner isAtEnd])
{ {
resultString = [resultString stringByAppendingString: @" "]; resultString = [resultString stringByAppendingString: @" "];
} }
} }
ASSIGN(classString, resultString); ASSIGN(_classString, resultString);
} }
- (void) parse - (void) parse
@ -141,94 +152,134 @@
// get the interface line... look ahead... // get the interface line... look ahead...
[self _strip]; [self _strip];
scanner = [NSScanner scannerWithString: classString]; NSDebugLog(@"_classString = %@", _classString);
if(lookAhead(classString, @"{")) scanner = [NSScanner scannerWithString: _classString];
{ if (lookAhead(_classString, @"@implementation"))
[scanner scanUpToString: @"@interface" intoString: NULL];
[scanner scanUpToString: @"{" intoString: &interfaceLine];
iscan = [NSScanner scannerWithString: interfaceLine]; // reset scanner...
}
else // if there is no "{", then there are no ivars...
{
[scanner scanUpToString: @"@interface" intoString: NULL];
[scanner scanUpToCharactersFromSet: pmcs intoString: &interfaceLine];
iscan = [NSScanner scannerWithString: interfaceLine]; // reset scanner...
}
// look ahead...
if(lookAhead(interfaceLine, @":"))
{
NSString *cn = nil, *scn = nil;
[iscan scanUpToAndIncludingString: @"@interface" intoString: NULL];
[iscan scanUpToString: @":" intoString: &cn];
className = [cn stringByTrimmingCharactersInSet: wsnl];
RETAIN(className);
[iscan scanString: @":" intoString: NULL];
[iscan scanUpToCharactersFromSet: wsnl intoString: &scn];
superClassName = [scn stringByTrimmingCharactersInSet: wsnl];
RETAIN(superClassName);
}
else // category...
{ {
NSString *cn = nil; NSString *cn = nil;
[iscan scanUpToAndIncludingString: @"@interface" intoString: NULL];
[iscan scanUpToCharactersFromSet: wsnl intoString: &cn];
className = [cn stringByTrimmingCharactersInSet: wsnl];
RETAIN(className);
// check to see if it's a category on an existing interface... [scanner scanUpToAndIncludingString: @"@implementation" intoString: NULL];
if(lookAhead(interfaceLine,@"(")) [scanner scanUpToCharactersFromSet: wsnl intoString: &cn];
_className = [cn stringByTrimmingCharactersInSet: wsnl];
RETAIN(_className);
NSDebugLog(@"_className = %@", _className);
}
else
{
if (lookAhead(_classString, @"{"))
{ {
isCategory = YES; [scanner scanUpToString: @"@interface" intoString: NULL];
[scanner scanUpToString: @"{" intoString: &interfaceLine];
iscan = [NSScanner scannerWithString: interfaceLine]; // reset scanner...
}
else // if there is no "{", then there are no ivars...
{
[scanner scanUpToString: @"@interface" intoString: NULL];
[scanner scanUpToCharactersFromSet: pmcs intoString: &interfaceLine];
iscan = [NSScanner scannerWithString: interfaceLine]; // reset scanner...
}
// look ahead...
if (lookAhead(interfaceLine, @":"))
{
NSString *cn = nil, *scn = nil;
[iscan scanUpToAndIncludingString: @"@interface" intoString: NULL];
[iscan scanUpToString: @":" intoString: &cn];
_className = [cn stringByTrimmingCharactersInSet: wsnl];
RETAIN(_className);
[iscan scanString: @":" intoString: NULL];
[iscan scanUpToCharactersFromSet: wsnl intoString: &scn];
[self setSuperClassName: [scn stringByTrimmingCharactersInSet: wsnl]];
}
else // category...
{
NSString *cn = nil;
[iscan scanUpToAndIncludingString: @"@interface" intoString: NULL];
[iscan scanUpToCharactersFromSet: wsnl intoString: &cn];
_className = [cn stringByTrimmingCharactersInSet: wsnl];
RETAIN(_className);
// check to see if it's a category on an existing interface...
if (lookAhead(interfaceLine,@"("))
{
_isCategory = YES;
}
}
if (_isCategory == NO)
{
NSScanner *ivarScan = nil;
// put the ivars into a a string...
[scanner scanUpToAndIncludingString: @"{" intoString: NULL];
[scanner scanUpToString: @"}" intoString: &ivarsString];
[scanner scanString: @"}" intoString: NULL];
if (ivarsString != nil)
{
// scan each ivar...
ivarScan = [NSScanner scannerWithString: ivarsString];
while(![ivarScan isAtEnd])
{
NSString *ivarLine = nil;
OCIVarDecl *ivarDecl = nil;
[ivarScan scanUpToString: @";" intoString: &ivarLine];
[ivarScan scanString: @";" intoString: NULL];
ivarDecl = AUTORELEASE([[OCIVarDecl alloc] initWithString: ivarLine]);
[ivarDecl parse];
[_ivars addObjectsFromArray: [ivarDecl ivars]];
}
}
}
else
{
NSString *cn = nil;
NSScanner *cs = [NSScanner scannerWithString: _classString];
[cs scanUpToAndIncludingString: @"@interface" intoString: NULL];
[cs scanUpToCharactersFromSet: wsnl intoString: &cn];
_className = [cn stringByTrimmingCharactersInSet: wsnl];
RETAIN(_className);
NSDebugLog(@"_className = %@", _className);
}
// put the methods into a string...
if (ivarsString != nil)
{
[scanner scanUpToString: @"@end" intoString: &methodsString];
}
else //
{
scanner = [NSScanner scannerWithString: _classString];
[scanner scanUpToAndIncludingString: interfaceLine intoString: NULL];
[scanner scanUpToString: @"@end" intoString: &methodsString];
} }
} }
if(isCategory == NO) if (_classString != nil)
{ {
NSScanner *ivarScan = nil; NSScanner *propertiesScan = [NSScanner scannerWithString: _classString];
while ([propertiesScan isAtEnd] == NO)
// put the ivars into a a string...
[scanner scanUpToAndIncludingString: @"{" intoString: NULL];
[scanner scanUpToString: @"}" intoString: &ivarsString];
[scanner scanString: @"}" intoString: NULL];
if(ivarsString != nil)
{ {
// scan each ivar... NSString *propertiesLine = nil;
ivarScan = [NSScanner scannerWithString: ivarsString]; OCProperty *property = nil;
while(![ivarScan isAtEnd])
{
NSString *ivarLine = nil;
OCIVarDecl *ivarDecl = nil;
[ivarScan scanUpToString: @";" intoString: &ivarLine];
[ivarScan scanString: @";" intoString: NULL];
ivarDecl = AUTORELEASE([[OCIVarDecl alloc] initWithString: ivarLine]);
[ivarDecl parse];
[ivars addObjectsFromArray: [ivarDecl ivars]];
}
}
}
// put the methods into a string... [propertiesScan scanUpToString: @";" intoString: &propertiesLine];
if(ivarsString != nil) [propertiesScan scanString: @";" intoString: NULL];
{ property = AUTORELEASE([[OCProperty alloc] initWithString: propertiesLine]);
[scanner scanUpToString: @"@end" intoString: &methodsString]; [property parse];
} [_properties addObject: property];
else // }
{
scanner = [NSScanner scannerWithString: classString];
[scanner scanUpToAndIncludingString: interfaceLine intoString: NULL];
[scanner scanUpToString: @"@end" intoString: &methodsString];
} }
// scan each method... // scan each method...
if(methodsString != nil) if (methodsString != nil)
{ {
NSScanner *methodScan = [NSScanner scannerWithString: methodsString]; NSScanner *methodScan = [NSScanner scannerWithString: methodsString];
while(![methodScan isAtEnd]) while ([methodScan isAtEnd] == NO)
{ {
NSString *methodLine = nil; NSString *methodLine = nil;
OCMethod *method = nil; OCMethod *method = nil;
@ -237,8 +288,8 @@
[methodScan scanString: @";" intoString: NULL]; [methodScan scanString: @";" intoString: NULL];
method = AUTORELEASE([[OCMethod alloc] initWithString: methodLine]); method = AUTORELEASE([[OCMethod alloc] initWithString: methodLine]);
[method parse]; [method parse];
[methods addObject: method]; [_methods addObject: method];
} }
} }
} }
@end @end

View file

@ -166,9 +166,10 @@
if(classString != nil && [classString length] != 0) if(classString != nil && [classString length] != 0)
{ {
cls = AUTORELEASE([[OCClass alloc] initWithString: classString]); cls = [[OCClass alloc] initWithString: classString];
[cls parse]; [cls parse];
[classes addObject: cls]; [classes addObject: cls];
RELEASE(cls);
} }
} }

View file

@ -159,6 +159,5 @@
[ivar parse]; [ivar parse];
[ivars addObject: ivar]; [ivars addObject: ivar];
} }
} }
@end @end

View file

@ -23,7 +23,6 @@
*/ */
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
#include "ParserFunctions.h" #include "ParserFunctions.h"
BOOL lookAhead(NSString *stringToScan, NSString *stringToFind) BOOL lookAhead(NSString *stringToScan, NSString *stringToFind)
@ -36,13 +35,13 @@ BOOL lookAhead(NSString *stringToScan, NSString *stringToFind)
BOOL lookAheadForToken(NSString *stringToScan, NSString *stringToFind) BOOL lookAheadForToken(NSString *stringToScan, NSString *stringToFind)
{ {
NSScanner *scanner = [NSScanner scannerWithString: stringToScan]; NSScanner *scanner = [NSScanner scannerWithString: stringToScan];
NSString *resultString = @""; // [NSString stringWithString: @""]; NSString *resultString = @"";
[scanner setCharactersToBeSkipped: nil]; [scanner setCharactersToBeSkipped: nil];
[scanner scanString: stringToFind intoString: &resultString]; [scanner scanString: stringToFind intoString: &resultString];
if([resultString isEqualToString: stringToFind]) if([resultString isEqualToString: stringToFind])
{ {
NSString *postTokenString = @""; // [NSString stringWithString: @""]; NSString *postTokenString = @"";
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet]; NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
[scanner scanCharactersFromSet: wsnl intoString: &postTokenString]; [scanner scanCharactersFromSet: wsnl intoString: &postTokenString];

View file

@ -1,5 +1,5 @@
# #
# Tests Makefile for Gorm ObjC Parser Library. # Tests Makefile for GNUstep GUI Library.
# #
# Copyright (C) 2011 Free Software Foundation, Inc. # Copyright (C) 2011 Free Software Foundation, Inc.
# #
@ -45,21 +45,24 @@ include $(GNUSTEP_MAKEFILES)/common.make
TOP_DIR := $(shell dirname $(CURDIR)) TOP_DIR := $(shell dirname $(CURDIR))
all:: all::
@(echo If you want to run the gnustep-gui testsuite, please type \'make check\') @(echo If you want to run the gorm-objcheaderparser testsuite, please type \'make check\')
check:: check::
(\ (\
ADDITIONAL_INCLUDE_DIRS="-I$(TOP_DIR)/." ADDITIONAL_INCLUDE_DIRS="-I$(TOP_DIR)/Headers -I$(TOP_DIR)/Source/$(GNUSTEP_TARGET_DIR) -I$(TOP_DIR)/Headers/Additions";\
ADDITIONAL_LIB_DIRS="-L$(TOP_DIR)/$(GNUSTEP_OBJ_DIR)";\ ADDITIONAL_LIB_DIRS="-L$(TOP_DIR)/Source/$(GNUSTEP_OBJ_DIR)";\
LD_LIBRARY_PATH="$(TOP_DIR)/$(GNUSTEP_OBJ_DIR):${LD_LIBRARY_PATH}";\ LD_LIBRARY_PATH="$(TOP_DIR)/Source/$(GNUSTEP_OBJ_DIR):${LD_LIBRARY_PATH}";\
PATH="$(TOP_DIR)/Tools/$(GNUSTEP_OBJ_DIR):${PATH}";\
export GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES;\
export ADDITIONAL_INCLUDE_DIRS;\ export ADDITIONAL_INCLUDE_DIRS;\
export ADDITIONAL_LIB_DIRS;\ export ADDITIONAL_LIB_DIRS;\
export LD_LIBRARY_PATH;\ export LD_LIBRARY_PATH;\
export PATH;\ export PATH;\
env;\
if [ "$(DEBUG)" = "" ]; then \ if [ "$(DEBUG)" = "" ]; then \
gnustep-tests GormObjCHeaderParser;\ gnustep-tests parser;\
else \ else \
gnustep-tests --debug GormObjCHeaderParser;\ gnustep-tests --debug parser;\
fi; \ fi; \
) )