mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 11:41:05 +00:00
Merge branch 'master' into object_outline
This commit is contained in:
commit
6545df37d5
27 changed files with 344 additions and 212 deletions
|
@ -4,6 +4,7 @@
|
|||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
"_prototypePopUp"
|
||||
);
|
||||
Super = IBPalette;
|
||||
};
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -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>
|
||||
Date: 2004
|
||||
Date: 2024, 2004
|
||||
|
||||
This file is part of GNUstep.
|
||||
|
||||
|
@ -23,14 +23,15 @@
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include <InterfaceBuilder/InterfaceBuilder.h>
|
||||
|
||||
#include "GormNSPopUpButton.h"
|
||||
|
||||
@interface ControlsPalette: IBPalette <IBViewResourceDraggingDelegates>
|
||||
{
|
||||
IBOutlet NSPopUpButton *_prototypePopUp;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
@ -62,16 +63,28 @@
|
|||
|
||||
- (void) finishInstantiate
|
||||
{
|
||||
NSView *contents;
|
||||
id v;
|
||||
NSView *contentView = [originalWindow contentView];
|
||||
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];
|
||||
v = [[GormNSPopUpButton alloc] initWithFrame: NSMakeRect(73, 159, 70, 22)];
|
||||
[v addItemWithTitle: @"Item 1"];
|
||||
[v addItemWithTitle: @"Item 2"];
|
||||
[v addItemWithTitle: @"Item 3"];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
[contentView addSubview: _prototypePopUp];
|
||||
AUTORELEASE(_prototypePopUp);
|
||||
}
|
||||
|
||||
- (void) willInspectObject: (NSNotification *)notification
|
||||
|
|
|
@ -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"
|
||||
|
||||
Class _gormnspopupbuttonCellClass = 0;
|
||||
|
@ -65,6 +89,7 @@ Class _gormnspopupbuttonCellClass = 0;
|
|||
* Override this here, since themes may override it.
|
||||
* Always want to show the menu view since it's editable.
|
||||
*/
|
||||
/*
|
||||
- (void) attachPopUpWithFrame: (NSRect)cellFrame
|
||||
inView: (NSView *)controlView
|
||||
{
|
||||
|
@ -127,4 +152,6 @@ Class _gormnspopupbuttonCellClass = 0;
|
|||
name: NSMenuDidSendActionNotification
|
||||
object: _menu];
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
|
|
@ -70,27 +70,20 @@
|
|||
if (sender == typeMatrix)
|
||||
{
|
||||
BOOL pullsDown = [[sender selectedCell] tag] == YES ? YES : NO;
|
||||
id selectedItem;
|
||||
id cell = [object cell];
|
||||
NSArray *itemArray = [[object itemArray] copy];
|
||||
NSEnumerator *en = [itemArray objectEnumerator];
|
||||
id o = nil;
|
||||
|
||||
[object removeAllItems];
|
||||
[object setPullsDown: pullsDown];
|
||||
selectedItem = [object selectedItem];
|
||||
[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)
|
||||
while ((o = [en nextObject]) != nil)
|
||||
{
|
||||
// TODO: This should be configurable in the future
|
||||
[cell setPreferredEdge: NSMaxYEdge];
|
||||
[cell setMenuItem: nil];
|
||||
[cell setMenuItem: selectedItem];
|
||||
id<NSMenuItem> mi = nil;
|
||||
|
||||
[object addItemWithTitle: [o title]];
|
||||
mi = [object lastItem];
|
||||
[mi setAction: NULL]; // @selector(_popUpItemAction:)];
|
||||
[mi setTarget: nil];
|
||||
}
|
||||
}
|
||||
else if (sender == autoenableSwitch)
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -4,15 +4,16 @@
|
|||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
formatTable,
|
||||
detachButton,
|
||||
addThousandSeparatorSwitch,
|
||||
commaPointSwitch,
|
||||
formatForm,
|
||||
formatTable,
|
||||
localizeSwitch,
|
||||
negativeField,
|
||||
negativeRedSwitch,
|
||||
positiveField,
|
||||
detachButton
|
||||
zeroField
|
||||
);
|
||||
Super = IBInspector;
|
||||
};
|
||||
|
|
Binary file not shown.
|
@ -31,15 +31,16 @@
|
|||
|
||||
@interface GormNumberFormatterAttributesInspector : IBInspector
|
||||
{
|
||||
id addThousandSeparatorSwitch;
|
||||
id commaPointSwitch;
|
||||
id formatForm;
|
||||
id formatTable;
|
||||
id localizeSwitch;
|
||||
id negativeField;
|
||||
id negativeRedSwitch;
|
||||
id positiveField;
|
||||
id detachButton;
|
||||
IBOutlet id addThousandSeparatorSwitch;
|
||||
IBOutlet id commaPointSwitch;
|
||||
IBOutlet id formatForm;
|
||||
IBOutlet id formatTable;
|
||||
IBOutlet id negativeRedSwitch;
|
||||
IBOutlet id detachButton;
|
||||
IBOutlet id localizeSwitch;
|
||||
IBOutlet id positiveField;
|
||||
IBOutlet id negativeField;
|
||||
IBOutlet id zeroField;
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -51,8 +51,10 @@ extern NSArray *predefinedNumberFormats;
|
|||
else
|
||||
{
|
||||
NSNumberFormatter *fmtr = [[NSNumberFormatter alloc] init];
|
||||
[fmtr setFormat: [NSNumberFormatter defaultFormat]];
|
||||
|
||||
[fmtr setFormat: [NSNumberFormatter defaultFormat]];
|
||||
[[positiveField cell] setFormatter: fmtr];
|
||||
[[zeroField cell] setFormatter: fmtr];
|
||||
[[negativeField cell] setFormatter: fmtr];
|
||||
}
|
||||
}
|
||||
|
@ -61,14 +63,17 @@ extern NSArray *predefinedNumberFormats;
|
|||
|
||||
- (void) updateAppearanceFieldsWithFormat: (NSString *)format;
|
||||
{
|
||||
|
||||
[[[positiveField cell] formatter] setFormat: format];
|
||||
[[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] setObjectValue:
|
||||
[NSDecimalNumber decimalNumberWithString: @"-123456.789"]];
|
||||
[NSDecimalNumber decimalNumberWithString: @"-123456.789"]];
|
||||
}
|
||||
|
||||
- (void) ok: (id)sender
|
||||
|
@ -98,28 +103,27 @@ extern NSArray *predefinedNumberFormats;
|
|||
zeroFmt = [NSNumberFormatter zeroFormatAtIndex:row];
|
||||
negativeFmt = [NSNumberFormatter negativeFormatAtIndex: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)
|
||||
{
|
||||
NSUInteger idx;
|
||||
|
||||
positiveFmt = [[sender cellAtIndex:0] stringValue];
|
||||
zeroFmt = [[sender cellAtIndex:1] stringValue];
|
||||
negativeFmt = [[sender cellAtIndex:2] stringValue];
|
||||
minValue = [[sender cellAtIndex:3] stringValue];
|
||||
maxValue = [[sender cellAtIndex:4] stringValue];
|
||||
positiveFmt = [[sender cellAtIndex: 0] stringValue];
|
||||
zeroFmt = [[sender cellAtIndex: 1] stringValue];
|
||||
negativeFmt = [[sender cellAtIndex: 2] stringValue];
|
||||
minValue = [[sender cellAtIndex: 3] stringValue];
|
||||
maxValue = [[sender cellAtIndex: 4] stringValue];
|
||||
NSDebugLog(@"min,max: %@, %@", minValue, maxValue);
|
||||
|
||||
fullFmt = [NSString stringWithFormat:@"%@;%@;%@",
|
||||
|
|
|
@ -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>
|
||||
|
||||
* ANNOUNCE
|
||||
|
|
|
@ -885,7 +885,7 @@ NSImage *browserImage = nil;
|
|||
*/
|
||||
- (id) loadClass: (id)sender
|
||||
{
|
||||
NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", nil];
|
||||
NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", @"m", @"mm", nil];
|
||||
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
|
||||
int result;
|
||||
|
||||
|
@ -922,7 +922,7 @@ NSImage *browserImage = nil;
|
|||
message,
|
||||
nil, nil, nil);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
NS_ENDHANDLER;
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
|
|
@ -1869,7 +1869,7 @@
|
|||
|
||||
- (BOOL) parseHeader: (NSString *)headerPath
|
||||
{
|
||||
OCHeaderParser *ochp = AUTORELEASE([[OCHeaderParser alloc] initWithContentsOfFile: headerPath]);
|
||||
OCHeaderParser *ochp = [[OCHeaderParser alloc] initWithContentsOfFile: headerPath];
|
||||
BOOL result = NO;
|
||||
|
||||
if(ochp != nil)
|
||||
|
@ -1885,12 +1885,15 @@
|
|||
{
|
||||
NSArray *methods = [cls methods];
|
||||
NSArray *ivars = [cls ivars];
|
||||
NSString *superClass = [cls superClassName];
|
||||
NSArray *properties = [cls properties];
|
||||
NSString *superClass = [cls superClassName]; // == nil) ? @"NSObject":[cls superClassName];
|
||||
NSString *className = [cls className];
|
||||
NSEnumerator *ien = [ivars objectEnumerator];
|
||||
NSEnumerator *men = [methods objectEnumerator];
|
||||
NSEnumerator *pen = [properties objectEnumerator];
|
||||
OCMethod *method = nil;
|
||||
OCIVar *ivar = nil;
|
||||
OCProperty *property = nil;
|
||||
NSMutableArray *actions = [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) &&
|
||||
[cls isCategory] == NO)
|
||||
{
|
||||
|
@ -1958,13 +1971,25 @@
|
|||
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)
|
||||
{
|
||||
result = NO;
|
||||
RELEASE(ochp);
|
||||
[NSException raise: NSGenericException
|
||||
format: @"The superclass %@ of class %@ is not known, please parse it.",
|
||||
superClass, className];
|
||||
|
@ -1973,6 +1998,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
RELEASE(ochp);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1851,8 +1851,11 @@ static void _real_close(GormDocument *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];
|
||||
while ((obj = [enumerator nextObject]) != nil)
|
||||
{
|
||||
|
|
|
@ -222,7 +222,6 @@
|
|||
NSPoint initialLocation;
|
||||
BOOL **selectedCells = [self _selectedCells];
|
||||
id selectedCell = [self selectedCell];
|
||||
id **cells = nil;
|
||||
|
||||
/*
|
||||
* Pathological case -- ignore mouse down
|
||||
|
@ -241,7 +240,7 @@
|
|||
column: &column
|
||||
forPoint: lastLocation])
|
||||
{
|
||||
if ([cells[row][column] isEnabled])
|
||||
if ([_cells[row][column] isEnabled])
|
||||
{
|
||||
if ((_mode == NSRadioModeMatrix) && _selectedCell != nil)
|
||||
{
|
||||
|
@ -251,11 +250,11 @@
|
|||
selectedCell = nil;
|
||||
_selectedRow = _selectedColumn = -1;
|
||||
}
|
||||
[cells[row][column] setState: NSOnState];
|
||||
[_cells[row][column] setState: NSOnState];
|
||||
[self drawCellAtRow: row column: column];
|
||||
[_window flushWindow];
|
||||
selectedCells[row][column] = YES;
|
||||
[self _setSelectedCell: cells[row][column]];
|
||||
[self _setSelectedCell: _cells[row][column]];
|
||||
_selectedRow = row;
|
||||
_selectedColumn = column;
|
||||
}
|
||||
|
|
|
@ -1447,9 +1447,14 @@ static BOOL currently_displaying = NO;
|
|||
|
||||
- (void) postDraw: (NSRect) rect
|
||||
{
|
||||
if ([parent respondsToSelector: @selector(postDrawForView:)])
|
||||
[parent performSelector: @selector(postDrawForView:)
|
||||
withObject: self];
|
||||
if (parent != nil)
|
||||
{
|
||||
if ([parent respondsToSelector: @selector(postDrawForView:)])
|
||||
{
|
||||
[parent performSelector: @selector(postDrawForView:)
|
||||
withObject: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawRect: (NSRect) rect
|
||||
|
|
|
@ -5,17 +5,15 @@
|
|||
PACKAGE_NAME = gorm
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
|
||||
#
|
||||
# Subprojects
|
||||
#
|
||||
|
||||
|
||||
SUBPROJECTS = \
|
||||
Tests
|
||||
|
||||
#
|
||||
# Library
|
||||
#
|
||||
|
||||
LIBRARY_VAR=GMOBJCHEADERPARSER
|
||||
LIBRARY_NAME=GormObjCHeaderParser
|
||||
GormObjCHeaderParser_HEADER_FILES_DIR=.
|
||||
|
@ -24,13 +22,11 @@ ADDITIONAL_INCLUDE_DIRS = -I..
|
|||
#
|
||||
# Additional libraries
|
||||
#
|
||||
|
||||
GormObjCHeaderParser_LIBRARIES_DEPEND_UPON += -lgnustep-gui -l$(FOUNDATION_LIBRARY_NAME)
|
||||
|
||||
#
|
||||
# Header files
|
||||
#
|
||||
|
||||
GormObjCHeaderParser_HEADER_FILES= \
|
||||
GormObjCHeaderParser.h \
|
||||
NSScanner+OCHeaderParser.h \
|
||||
|
@ -39,13 +35,12 @@ OCHeaderParser.h \
|
|||
OCIVar.h \
|
||||
OCIVarDecl.h \
|
||||
OCMethod.h \
|
||||
OCProperty.h \
|
||||
ParserFunctions.h
|
||||
|
||||
|
||||
#
|
||||
# Class files
|
||||
#
|
||||
|
||||
GormObjCHeaderParser_OBJC_FILES= \
|
||||
NSScanner+OCHeaderParser.m \
|
||||
OCClass.m \
|
||||
|
@ -53,12 +48,12 @@ OCHeaderParser.m \
|
|||
OCIVar.m \
|
||||
OCIVarDecl.m \
|
||||
OCMethod.m \
|
||||
OCProperty.m \
|
||||
ParserFunctions.m
|
||||
|
||||
#
|
||||
# C files
|
||||
#
|
||||
|
||||
GormObjCHeaderParser_C_FILES=
|
||||
|
||||
HEADERS_INSTALL = $(GormObjCHeaderParser_HEADER_FILES)
|
||||
|
|
|
@ -41,6 +41,7 @@ FOUNDATION_EXPORT const unsigned char GormObjCHeaderParserVersionString[];
|
|||
#include <GormObjCHeaderParser/OCIVar.h>
|
||||
#include <GormObjCHeaderParser/OCIVarDecl.h>
|
||||
#include <GormObjCHeaderParser/OCMethod.h>
|
||||
#include <GormObjCHeaderParser/OCProperty.h>
|
||||
#include <GormObjCHeaderParser/ParserFunctions.h>
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,26 +31,31 @@
|
|||
|
||||
@interface OCClass : NSObject
|
||||
{
|
||||
NSMutableArray *ivars;
|
||||
NSMutableArray *methods;
|
||||
NSMutableArray *protocols;
|
||||
NSString *className;
|
||||
NSString *superClassName;
|
||||
NSString *classString;
|
||||
BOOL isCategory;
|
||||
NSMutableArray *_ivars;
|
||||
NSMutableArray *_methods;
|
||||
NSMutableArray *_protocols;
|
||||
NSMutableArray *_properties;
|
||||
NSString *_className;
|
||||
NSString *_superClassName;
|
||||
NSString *_classString;
|
||||
BOOL _isCategory;
|
||||
}
|
||||
|
||||
- (id) initWithString: (NSString *)string;
|
||||
- (NSArray *) methods;
|
||||
- (void) addMethod: (NSString *)name isAction: (BOOL) flag;
|
||||
- (void) addMethod: (NSString *)name isAction: (BOOL)flag;
|
||||
- (NSArray *) ivars;
|
||||
- (void) addIVar: (NSString *)name isOutlet: (BOOL) flag;
|
||||
- (void) addIVar: (NSString *)name isOutlet: (BOOL)flag;
|
||||
- (NSString *) className;
|
||||
- (void) setClassName: (NSString *)name;
|
||||
- (NSString *) superClassName;
|
||||
- (void) setSuperClassName: (NSString *)name;
|
||||
- (BOOL) isCategory;
|
||||
- (void) setIsCategory: (BOOL)flag;
|
||||
- (NSArray *) properties;
|
||||
|
||||
- (void) parse;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,38 +24,44 @@
|
|||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include <GormObjCHeaderParser/OCClass.h>
|
||||
#include <GormObjCHeaderParser/OCMethod.h>
|
||||
#include <GormObjCHeaderParser/OCIVar.h>
|
||||
#include <GormObjCHeaderParser/OCIVarDecl.h>
|
||||
#include <GormObjCHeaderParser/NSScanner+OCHeaderParser.h>
|
||||
#include <GormObjCHeaderParser/ParserFunctions.h>
|
||||
#include "GormObjCHeaderParser/OCClass.h"
|
||||
#include "GormObjCHeaderParser/OCMethod.h"
|
||||
#include "GormObjCHeaderParser/OCProperty.h"
|
||||
#include "GormObjCHeaderParser/OCIVar.h"
|
||||
#include "GormObjCHeaderParser/OCIVarDecl.h"
|
||||
#include "GormObjCHeaderParser/NSScanner+OCHeaderParser.h"
|
||||
#include "GormObjCHeaderParser/ParserFunctions.h"
|
||||
|
||||
@implementation OCClass
|
||||
- (id) initWithString: (NSString *)string
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
methods = [[NSMutableArray alloc] init];
|
||||
ivars = [[NSMutableArray alloc] init];
|
||||
ASSIGN(classString, string);
|
||||
_methods = [[NSMutableArray alloc] init];
|
||||
_ivars = [[NSMutableArray alloc] init];
|
||||
_properties = [[NSMutableArray alloc] init];
|
||||
_protocols = [[NSMutableArray alloc] init];
|
||||
_superClassName = nil;
|
||||
ASSIGN(_classString, string);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(methods);
|
||||
RELEASE(ivars);
|
||||
RELEASE(classString);
|
||||
RELEASE(className);
|
||||
RELEASE(superClassName);
|
||||
RELEASE(_methods);
|
||||
RELEASE(_ivars);
|
||||
RELEASE(_properties);
|
||||
RELEASE(_protocols);
|
||||
RELEASE(_classString);
|
||||
RELEASE(_className);
|
||||
RELEASE(_superClassName);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSArray *) methods
|
||||
{
|
||||
return methods;
|
||||
return _methods;
|
||||
}
|
||||
|
||||
- (void) addMethod: (NSString *)name isAction: (BOOL) flag
|
||||
|
@ -63,12 +69,12 @@
|
|||
OCMethod *method = AUTORELEASE([[OCMethod alloc] init]);
|
||||
[method setName: name];
|
||||
[method setIsAction: flag];
|
||||
[methods addObject: method];
|
||||
[_methods addObject: method];
|
||||
}
|
||||
|
||||
- (NSArray *) ivars
|
||||
{
|
||||
return ivars;
|
||||
return _ivars;
|
||||
}
|
||||
|
||||
- (void) addIVar: (NSString *)name isOutlet: (BOOL) flag
|
||||
|
@ -76,42 +82,47 @@
|
|||
OCIVar *ivar = AUTORELEASE([[OCIVar alloc] init]);
|
||||
[ivar setName: name];
|
||||
[ivar setIsOutlet: flag];
|
||||
[ivars addObject: ivar];
|
||||
[_ivars addObject: ivar];
|
||||
}
|
||||
|
||||
- (NSString *) className
|
||||
{
|
||||
return className;
|
||||
return _className;
|
||||
}
|
||||
|
||||
- (void) setClassName: (NSString *)name
|
||||
{
|
||||
ASSIGN(className, name);
|
||||
ASSIGN(_className, name);
|
||||
}
|
||||
|
||||
- (NSString *) superClassName
|
||||
{
|
||||
return superClassName;
|
||||
return _superClassName;
|
||||
}
|
||||
|
||||
- (void) setSuperClassName: (NSString *)name
|
||||
{
|
||||
ASSIGN(superClassName,name);
|
||||
ASSIGN(_superClassName,name);
|
||||
}
|
||||
|
||||
- (BOOL) isCategory
|
||||
{
|
||||
return isCategory;
|
||||
return _isCategory;
|
||||
}
|
||||
|
||||
- (void) setIsCategory: (BOOL)flag
|
||||
{
|
||||
isCategory = flag;
|
||||
_isCategory = flag;
|
||||
}
|
||||
|
||||
- (NSArray *) properties
|
||||
{
|
||||
return _properties;
|
||||
}
|
||||
|
||||
- (void) _strip
|
||||
{
|
||||
NSScanner *stripScanner = [NSScanner scannerWithString: classString];
|
||||
NSScanner *stripScanner = [NSScanner scannerWithString: _classString];
|
||||
NSString *resultString = @"";
|
||||
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||
|
||||
|
@ -120,13 +131,13 @@
|
|||
NSString *string = nil;
|
||||
[stripScanner scanUpToCharactersFromSet: wsnl intoString: &string];
|
||||
resultString = [resultString stringByAppendingString: string];
|
||||
if(![stripScanner isAtEnd])
|
||||
if (![stripScanner isAtEnd])
|
||||
{
|
||||
resultString = [resultString stringByAppendingString: @" "];
|
||||
}
|
||||
}
|
||||
|
||||
ASSIGN(classString, resultString);
|
||||
ASSIGN(_classString, resultString);
|
||||
}
|
||||
|
||||
- (void) parse
|
||||
|
@ -141,94 +152,134 @@
|
|||
|
||||
// get the interface line... look ahead...
|
||||
[self _strip];
|
||||
scanner = [NSScanner scannerWithString: classString];
|
||||
if(lookAhead(classString, @"{"))
|
||||
{
|
||||
[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...
|
||||
NSDebugLog(@"_classString = %@", _classString);
|
||||
scanner = [NSScanner scannerWithString: _classString];
|
||||
if (lookAhead(_classString, @"@implementation"))
|
||||
{
|
||||
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,@"("))
|
||||
[scanner scanUpToAndIncludingString: @"@implementation" intoString: NULL];
|
||||
[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)
|
||||
{
|
||||
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)
|
||||
if (_classString != nil)
|
||||
{
|
||||
NSScanner *propertiesScan = [NSScanner scannerWithString: _classString];
|
||||
while ([propertiesScan isAtEnd] == NO)
|
||||
{
|
||||
// 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]];
|
||||
}
|
||||
}
|
||||
}
|
||||
NSString *propertiesLine = nil;
|
||||
OCProperty *property = nil;
|
||||
|
||||
// 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];
|
||||
[propertiesScan scanUpToString: @";" intoString: &propertiesLine];
|
||||
[propertiesScan scanString: @";" intoString: NULL];
|
||||
property = AUTORELEASE([[OCProperty alloc] initWithString: propertiesLine]);
|
||||
[property parse];
|
||||
[_properties addObject: property];
|
||||
}
|
||||
}
|
||||
|
||||
// scan each method...
|
||||
if(methodsString != nil)
|
||||
if (methodsString != nil)
|
||||
{
|
||||
NSScanner *methodScan = [NSScanner scannerWithString: methodsString];
|
||||
while(![methodScan isAtEnd])
|
||||
while ([methodScan isAtEnd] == NO)
|
||||
{
|
||||
NSString *methodLine = nil;
|
||||
OCMethod *method = nil;
|
||||
|
@ -237,8 +288,8 @@
|
|||
[methodScan scanString: @";" intoString: NULL];
|
||||
method = AUTORELEASE([[OCMethod alloc] initWithString: methodLine]);
|
||||
[method parse];
|
||||
[methods addObject: method];
|
||||
}
|
||||
[_methods addObject: method];
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -166,9 +166,10 @@
|
|||
|
||||
if(classString != nil && [classString length] != 0)
|
||||
{
|
||||
cls = AUTORELEASE([[OCClass alloc] initWithString: classString]);
|
||||
cls = [[OCClass alloc] initWithString: classString];
|
||||
[cls parse];
|
||||
[classes addObject: cls];
|
||||
RELEASE(cls);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,6 +159,5 @@
|
|||
[ivar parse];
|
||||
[ivars addObject: ivar];
|
||||
}
|
||||
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
*/
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include "ParserFunctions.h"
|
||||
|
||||
BOOL lookAhead(NSString *stringToScan, NSString *stringToFind)
|
||||
|
@ -36,13 +35,13 @@ BOOL lookAhead(NSString *stringToScan, NSString *stringToFind)
|
|||
BOOL lookAheadForToken(NSString *stringToScan, NSString *stringToFind)
|
||||
{
|
||||
NSScanner *scanner = [NSScanner scannerWithString: stringToScan];
|
||||
NSString *resultString = @""; // [NSString stringWithString: @""];
|
||||
NSString *resultString = @"";
|
||||
|
||||
[scanner setCharactersToBeSkipped: nil];
|
||||
[scanner scanString: stringToFind intoString: &resultString];
|
||||
if([resultString isEqualToString: stringToFind])
|
||||
{
|
||||
NSString *postTokenString = @""; // [NSString stringWithString: @""];
|
||||
NSString *postTokenString = @"";
|
||||
NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||
|
||||
[scanner scanCharactersFromSet: wsnl intoString: &postTokenString];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Tests Makefile for Gorm ObjC Parser Library.
|
||||
# Tests Makefile for GNUstep GUI Library.
|
||||
#
|
||||
# Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
#
|
||||
|
@ -45,21 +45,24 @@ include $(GNUSTEP_MAKEFILES)/common.make
|
|||
TOP_DIR := $(shell dirname $(CURDIR))
|
||||
|
||||
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::
|
||||
(\
|
||||
ADDITIONAL_INCLUDE_DIRS="-I$(TOP_DIR)/."
|
||||
ADDITIONAL_LIB_DIRS="-L$(TOP_DIR)/$(GNUSTEP_OBJ_DIR)";\
|
||||
LD_LIBRARY_PATH="$(TOP_DIR)/$(GNUSTEP_OBJ_DIR):${LD_LIBRARY_PATH}";\
|
||||
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)/Source/$(GNUSTEP_OBJ_DIR)";\
|
||||
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_LIB_DIRS;\
|
||||
export LD_LIBRARY_PATH;\
|
||||
export PATH;\
|
||||
env;\
|
||||
if [ "$(DEBUG)" = "" ]; then \
|
||||
gnustep-tests GormObjCHeaderParser;\
|
||||
gnustep-tests parser;\
|
||||
else \
|
||||
gnustep-tests --debug GormObjCHeaderParser;\
|
||||
gnustep-tests --debug parser;\
|
||||
fi; \
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue