diff --git a/AppKit/AppKit.xcodeproj/project.pbxproj b/AppKit/AppKit.xcodeproj/project.pbxproj index f6f7244d..d74df793 100644 --- a/AppKit/AppKit.xcodeproj/project.pbxproj +++ b/AppKit/AppKit.xcodeproj/project.pbxproj @@ -1346,6 +1346,14 @@ FE7247A70C0622F2007CBC51 /* NSTextAttachmentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = FE7247A50C0622F2007CBC51 /* NSTextAttachmentCell.m */; }; FE7248510C0676AA007CBC51 /* NSTypesetter_concrete.h in Headers */ = {isa = PBXBuildFile; fileRef = FE72484F0C0676AA007CBC51 /* NSTypesetter_concrete.h */; }; FE7248520C0676AA007CBC51 /* NSTypesetter_concrete.m in Sources */ = {isa = PBXBuildFile; fileRef = FE7248500C0676AA007CBC51 /* NSTypesetter_concrete.m */; }; + FE82867B0D34727900F7489F /* NSApplicationIcon.tiff in Resources */ = {isa = PBXBuildFile; fileRef = FE8286770D34727900F7489F /* NSApplicationIcon.tiff */; }; + FE82867C0D34727900F7489F /* NSSystemInfoPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8286780D34727900F7489F /* NSSystemInfoPanel.h */; settings = {ATTRIBUTES = (Private, ); }; }; + FE82867D0D34727900F7489F /* NSSystemInfoPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = FE8286790D34727900F7489F /* NSSystemInfoPanel.m */; }; + FE82867E0D34727900F7489F /* NSSystemInfoPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = FE82867A0D34727900F7489F /* NSSystemInfoPanel.nib */; }; + FE82867F0D34727900F7489F /* NSApplicationIcon.tiff in Resources */ = {isa = PBXBuildFile; fileRef = FE8286770D34727900F7489F /* NSApplicationIcon.tiff */; }; + FE8286800D34727900F7489F /* NSSystemInfoPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = FE8286780D34727900F7489F /* NSSystemInfoPanel.h */; settings = {ATTRIBUTES = (Private, ); }; }; + FE8286810D34727900F7489F /* NSSystemInfoPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = FE8286790D34727900F7489F /* NSSystemInfoPanel.m */; }; + FE8286820D34727900F7489F /* NSSystemInfoPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = FE82867A0D34727900F7489F /* NSSystemInfoPanel.nib */; }; FE86887F0BC3FFA4009F515C /* NSButtonCell_disclosure_highlighted.tif in Resources */ = {isa = PBXBuildFile; fileRef = FE86887C0BC3FFA4009F515C /* NSButtonCell_disclosure_highlighted.tif */; }; FE8688800BC3FFA4009F515C /* NSButtonCell_disclosure_normal.tif in Resources */ = {isa = PBXBuildFile; fileRef = FE86887D0BC3FFA4009F515C /* NSButtonCell_disclosure_normal.tif */; }; FE8688810BC3FFA4009F515C /* NSButtonCell_disclosure_selected.tif in Resources */ = {isa = PBXBuildFile; fileRef = FE86887E0BC3FFA4009F515C /* NSButtonCell_disclosure_selected.tif */; }; @@ -2148,6 +2156,10 @@ FE7247A50C0622F2007CBC51 /* NSTextAttachmentCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = NSTextAttachmentCell.m; sourceTree = ""; }; FE72484F0C0676AA007CBC51 /* NSTypesetter_concrete.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NSTypesetter_concrete.h; sourceTree = ""; }; FE7248500C0676AA007CBC51 /* NSTypesetter_concrete.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = NSTypesetter_concrete.m; sourceTree = ""; }; + FE8286770D34727900F7489F /* NSApplicationIcon.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = NSApplicationIcon.tiff; sourceTree = ""; }; + FE8286780D34727900F7489F /* NSSystemInfoPanel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NSSystemInfoPanel.h; sourceTree = ""; }; + FE8286790D34727900F7489F /* NSSystemInfoPanel.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = NSSystemInfoPanel.m; sourceTree = ""; }; + FE82867A0D34727900F7489F /* NSSystemInfoPanel.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = NSSystemInfoPanel.nib; sourceTree = ""; }; FE86887C0BC3FFA4009F515C /* NSButtonCell_disclosure_highlighted.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = NSButtonCell_disclosure_highlighted.tif; sourceTree = ""; }; FE86887D0BC3FFA4009F515C /* NSButtonCell_disclosure_normal.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = NSButtonCell_disclosure_normal.tif; sourceTree = ""; }; FE86887E0BC3FFA4009F515C /* NSButtonCell_disclosure_selected.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = NSButtonCell_disclosure_selected.tif; sourceTree = ""; }; @@ -2467,6 +2479,7 @@ 6E2B53C30976075200DA0954 /* NSStringDrawer.m */, 6E2B549C0976075200DA0954 /* NSStringDrawing.h */, 6E2B53C50976075200DA0954 /* NSStringDrawing.m */, + FE8286760D34725900F7489F /* NSSystemInfoPanel */, 6E2B54A60976075200DA0954 /* NSTableColumn.h */, 6E2B53C70976075200DA0954 /* NSTableColumn.m */, 6E2B54A80976075200DA0954 /* NSTableCornerView.h */, @@ -3175,6 +3188,17 @@ path = NSInterfacePart; sourceTree = ""; }; + FE8286760D34725900F7489F /* NSSystemInfoPanel */ = { + isa = PBXGroup; + children = ( + FE8286770D34727900F7489F /* NSApplicationIcon.tiff */, + FE8286780D34727900F7489F /* NSSystemInfoPanel.h */, + FE8286790D34727900F7489F /* NSSystemInfoPanel.m */, + FE82867A0D34727900F7489F /* NSSystemInfoPanel.nib */, + ); + path = NSSystemInfoPanel; + sourceTree = ""; + }; FE8BAF1A0BC9EC0B0007FACA /* NSKeyValueBinding */ = { isa = PBXGroup; children = ( @@ -3556,6 +3580,7 @@ FEA8A98C0CD2CBC000E1E936 /* NSUserInterfaceValidation.h in Headers */, FE8D94AD0CE3A6C700AFB060 /* NSControllerSelectionProxy.h in Headers */, FE8D95220CE4057300AFB060 /* NSMultipleValueBinder.h in Headers */, + FE82867C0D34727900F7489F /* NSSystemInfoPanel.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3897,6 +3922,7 @@ FEA8A98D0CD2CBC000E1E936 /* NSUserInterfaceValidation.h in Headers */, FE8D94AB0CE3A6C700AFB060 /* NSControllerSelectionProxy.h in Headers */, FE8D95200CE4057300AFB060 /* NSMultipleValueBinder.h in Headers */, + FE8286800D34727900F7489F /* NSSystemInfoPanel.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4058,6 +4084,8 @@ FE8688800BC3FFA4009F515C /* NSButtonCell_disclosure_normal.tif in Resources */, FE8688810BC3FFA4009F515C /* NSButtonCell_disclosure_selected.tif in Resources */, C8B239A30BF8EEB500CA33AF /* defaultBindingOptions.plist in Resources */, + FE82867B0D34727900F7489F /* NSApplicationIcon.tiff in Resources */, + FE82867E0D34727900F7489F /* NSSystemInfoPanel.nib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4103,6 +4131,8 @@ FE01AAB80C5D9BCB00AEA51A /* NSButtonCell_disclosure_normal.tif in Resources */, FE01AAB90C5D9BCB00AEA51A /* NSButtonCell_disclosure_selected.tif in Resources */, FE01AABA0C5D9BCB00AEA51A /* defaultBindingOptions.plist in Resources */, + FE82867F0D34727900F7489F /* NSApplicationIcon.tiff in Resources */, + FE8286820D34727900F7489F /* NSSystemInfoPanel.nib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4456,6 +4486,7 @@ FE311FA70CCC430200EBD696 /* KGFont_gdi.m in Sources */, FE8D94AE0CE3A6C700AFB060 /* NSControllerSelectionProxy.m in Sources */, FE8D95230CE4057300AFB060 /* NSMultipleValueBinder.m in Sources */, + FE82867D0D34727900F7489F /* NSSystemInfoPanel.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4789,6 +4820,7 @@ FE311FA90CCC430200EBD696 /* KGFont_gdi.m in Sources */, FE8D94AC0CE3A6C700AFB060 /* NSControllerSelectionProxy.m in Sources */, FE8D95210CE4057300AFB060 /* NSMultipleValueBinder.m in Sources */, + FE8286810D34727900F7489F /* NSSystemInfoPanel.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/AppKit/NSApplication.m b/AppKit/NSApplication.m index 86d65ba6..30287f37 100755 --- a/AppKit/NSApplication.m +++ b/AppKit/NSApplication.m @@ -25,6 +25,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import NSString *NSModalPanelRunLoopMode=@"NSModalPanelRunLoopMode"; NSString *NSEventTrackingRunLoopMode=@"NSEventTrackingRunLoopMode"; @@ -864,7 +865,10 @@ id NSApp=nil; } -(void)orderFrontStandardAboutPanelWithOptions:(NSDictionary *)options { - NSUnimplementedMethod(); + NSSystemInfoPanel *standardAboutPanel = [[NSSystemInfoPanel +standardAboutPanel] retain]; + [standardAboutPanel showInfoPanel:self]; + } -(void)activateContextHelpMode:sender { diff --git a/AppKit/NSImageCell.h b/AppKit/NSImageCell.h index 5ebe5716..f842bd10 100755 --- a/AppKit/NSImageCell.h +++ b/AppKit/NSImageCell.h @@ -35,6 +35,7 @@ typedef enum { } NSImageFrameStyle; @interface NSImageCell : NSCell { + BOOL _animates; NSImageAlignment _imageAlignment; NSImageScaling _imageScaling; NSImageFrameStyle _frameStyle; diff --git a/AppKit/NSImageCell.m b/AppKit/NSImageCell.m index 3415f36f..f6a3cb54 100755 --- a/AppKit/NSImageCell.m +++ b/AppKit/NSImageCell.m @@ -12,9 +12,37 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #import #import #import +#import @implementation NSImageCell +-(void)encodeWithCoder:(NSCoder *)coder +{ + [super encodeWithCoder:coder]; + [coder encodeBool:_animates forKey:@"NSAnimates"]; + [coder encodeInt:_imageAlignment forKey:@"NSAlign"]; + [coder encodeInt:_imageScaling forKey:@"NSScale"]; + [coder encodeInt:_frameStyle forKey:@"NSStyle"]; + +} + +-(id)initWithCoder:(NSCoder *)coder +{ + [super initWithCoder:coder]; + if([coder isKindOfClass:[NSNibKeyedUnarchiver class]]) + { + NSNibKeyedUnarchiver *keyed=(NSNibKeyedUnarchiver *)coder; + _animates = [keyed decodeBoolForKey:@"NSAnimates"]; + _imageAlignment = [keyed decodeIntForKey:@"NSAlign"]; + _imageScaling = [keyed decodeIntForKey:@"NSScale"]; + _frameStyle = [keyed decodeIntForKey:@"NSStyle"]; + } + else + [NSException raise:NSInvalidArgumentException format:@"%@ can not initWithCoder:%@",isa,[coder class]]; + return self; + +} + -(NSImage *)_imageValue { id result=[self image]; diff --git a/AppKit/NSSystemInfoPanel/NSApplicationIcon.tiff b/AppKit/NSSystemInfoPanel/NSApplicationIcon.tiff new file mode 100644 index 00000000..92b9596f Binary files /dev/null and b/AppKit/NSSystemInfoPanel/NSApplicationIcon.tiff differ diff --git a/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.h b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.h new file mode 100644 index 00000000..884a1217 --- /dev/null +++ b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.h @@ -0,0 +1,27 @@ +/* Copyright (c) 2007 Dr. Rolf Jansen + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#import + +@class NSImageView,NSTextField; + +@interface NSSystemInfoPanel : NSObject +{ + IBOutlet NSImageView *appIconView; + IBOutlet NSTextField *appNameField; + IBOutlet NSScrollView *creditScrollView; + IBOutlet NSTextView *creditView; + IBOutlet NSPanel *infoPanel; + IBOutlet NSTextField *legalTextField; + IBOutlet NSTextField *versionField; +} + ++ (NSSystemInfoPanel *)standardAboutPanel; +- (IBAction)showInfoPanel:(id)sender; + +@end diff --git a/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.m b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.m new file mode 100644 index 00000000..3bbfddde --- /dev/null +++ b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.m @@ -0,0 +1,83 @@ +/* Copyright (c) 2007 Dr. Rolf Jansen + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#import +#import +#import +#import +#import +#import +#import +#import + +@implementation NSSystemInfoPanel + +static NSSystemInfoPanel *_sharedInfoPanel = nil; + ++ (NSSystemInfoPanel *)standardAboutPanel +{ + if(_sharedInfoPanel == nil) + { + _sharedInfoPanel = [NSSystemInfoPanel alloc]; + if(![NSBundle loadNibNamed:@"NSSystemInfoPanel" owner:_sharedInfoPanel]) + NSLog(@"Cannot load NSSystemInfoPanel.nib"); + } + return _sharedInfoPanel; +} + + +- (void)awakeFromNib +{ + NSImage *icon = [NSImage imageNamed:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIconFile"]]; + if (icon != nil) + [appIconView setImage:icon]; + + [appNameField setStringValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]]; + [versionField setStringValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]; + + NSRect frame = [infoPanel frame]; + NSString *resourceFileName = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]; + if (resourceFileName != nil) + { + frame.size.height += 90; + [creditView readRTFDFromFile:resourceFileName]; + } + else + [creditScrollView setFrame:NSMakeRect(0, 0, 0, 0)]; + + resourceFileName = [[NSBundle mainBundle] pathForResource:@"InfoPlist" ofType:@"strings"]; + if (resourceFileName != nil) + { + NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"InfoPlist" ofType:@"strings"]]; + char *p, *q, *r, *s = calloc(1, [data length]+1); + [data getBytes:s]; + if ((p = strstr(s, "NSHumanReadableCopyright")) != NULL) + { + p += 24; + while (*p != '\0' && *p++ != '"'); + q = p; + while (*q != '\0' && *q != '"') + q++; + *q = '\0'; + [legalTextField setStringValue:[[[NSString alloc] initWithUTF8String:p] autorelease]]; + } + free(s); + } + + frame.origin.y = [[NSScreen mainScreen] frame].size.height - 150 - frame.size.height; + frame.origin.x = ([[NSScreen mainScreen] frame].size.width - frame.size.width)/2.0; + [infoPanel setFrame:frame display:NO]; +} + + +- (IBAction)showInfoPanel:(id)sender +{ + [infoPanel makeKeyAndOrderFront:sender]; +} + +@end diff --git a/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.nib/classes.nib b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.nib/classes.nib new file mode 100644 index 00000000..56e3da0a --- /dev/null +++ b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.nib/classes.nib @@ -0,0 +1,27 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {showInfoPanel = id; }; + CLASS = NSSystemInfoPanel; + LANGUAGE = ObjC; + OUTLETS = { + appIconView = NSImageView; + appNameField = NSTextField; + creditScrollView = NSScrollView; + creditView = NSTextView; + infoPanel = NSPanel; + legalTextField = NSTextField; + versionField = NSTextField; + }; + SUPERCLASS = NSObject; + }, + { + CLASS = NSSystemInfoPanelIconView; + LANGUAGE = ObjC; + OUTLETS = {target = id; }; + SUPERCLASS = NSView; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.nib/info.nib b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.nib/info.nib new file mode 100644 index 00000000..2933906d --- /dev/null +++ b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.nib/info.nib @@ -0,0 +1,35 @@ + + + + + IBDocumentLocation + 65 96 356 240 0 0 1024 746 + IBFramework Version + 489.0 + IBOldestOS + 3 + IBOpenObjects + + 195 + + IBSystem Version + 8S165 + IBUserGuides + + InfoPanel + + guideLocations + + guidesLocked + NO + + Window + + guideLocations + + guidesLocked + NO + + + + diff --git a/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.nib/keyedobjects.nib b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.nib/keyedobjects.nib new file mode 100644 index 00000000..362cbaca Binary files /dev/null and b/AppKit/NSSystemInfoPanel/NSSystemInfoPanel.nib/keyedobjects.nib differ diff --git a/AppKit/nib.subproj/NSCustomView.m b/AppKit/nib.subproj/NSCustomView.m index b3c8d09f..8eebcfc8 100644 --- a/AppKit/nib.subproj/NSCustomView.m +++ b/AppKit/nib.subproj/NSCustomView.m @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2007 Rolf Jansen +/* Copyright (c) 2006-2007 Dr. Rolf Jansen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/Foundation/NSCharacterSet/NSCharacterSet.h b/Foundation/NSCharacterSet/NSCharacterSet.h index 0704724b..dcb35420 100755 --- a/Foundation/NSCharacterSet/NSCharacterSet.h +++ b/Foundation/NSCharacterSet/NSCharacterSet.h @@ -12,23 +12,23 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @interface NSCharacterSet : NSObject -+(NSCharacterSet *)characterSetWithBitmapRepresentation:(NSData *)data; -+(NSCharacterSet *)characterSetWithCharactersInString:(NSString *)string; -+(NSCharacterSet *)characterSetWithContentsOfFile:(NSString *)path; -+(NSCharacterSet *)characterSetWithRange:(NSRange)range; ++characterSetWithBitmapRepresentation:(NSData *)data; ++characterSetWithCharactersInString:(NSString *)string; ++characterSetWithContentsOfFile:(NSString *)path; ++characterSetWithRange:(NSRange)range; -+(NSCharacterSet *)alphanumericCharacterSet; -+(NSCharacterSet *)controlCharacterSet; -+(NSCharacterSet *)decimalDigitCharacterSet; -+(NSCharacterSet *)decomposableCharacterSet; -+(NSCharacterSet *)illegalCharacterSet; -+(NSCharacterSet *)letterCharacterSet; -+(NSCharacterSet *)lowercaseLetterCharacterSet; -+(NSCharacterSet *)nonBaseCharacterSet; -+(NSCharacterSet *)punctuationCharacterSet; -+(NSCharacterSet *)uppercaseLetterCharacterSet; -+(NSCharacterSet *)whitespaceAndNewlineCharacterSet; -+(NSCharacterSet *)whitespaceCharacterSet; ++alphanumericCharacterSet; ++controlCharacterSet; ++decimalDigitCharacterSet; ++decomposableCharacterSet; ++illegalCharacterSet; ++letterCharacterSet; ++lowercaseLetterCharacterSet; ++nonBaseCharacterSet; ++punctuationCharacterSet; ++uppercaseLetterCharacterSet; ++whitespaceAndNewlineCharacterSet; ++whitespaceCharacterSet; -(BOOL)characterIsMember:(unichar)character; -(NSCharacterSet *)invertedSet; diff --git a/Foundation/NSCharacterSet/NSCharacterSet.m b/Foundation/NSCharacterSet/NSCharacterSet.m index 19282d30..163d6247 100755 --- a/Foundation/NSCharacterSet/NSCharacterSet.m +++ b/Foundation/NSCharacterSet/NSCharacterSet.m @@ -25,8 +25,7 @@ static NSMapTable *nameToSet=NULL; +(void)initialize { if(self==[NSCharacterSet class]){ - nameToSet=NSCreateMapTable(NSObjectMapKeyCallBacks, - NSObjectMapValueCallBacks,0); + nameToSet=NSCreateMapTable(NSObjectMapKeyCallBacks,NSObjectMapValueCallBacks,0); } } @@ -34,7 +33,6 @@ static NSMapTable *nameToSet=NULL; return [self retain]; } - -mutableCopyWithZone:(NSZone *)zone { return [[NSMutableCharacterSet_bitmap allocWithZone:NULL] initWithCharacterSet:self]; } @@ -53,15 +51,15 @@ static NSMapTable *nameToSet=NULL; NSUnimplementedMethod(); } -+(NSCharacterSet *)characterSetWithBitmapRepresentation:(NSData *)data { ++characterSetWithBitmapRepresentation:(NSData *)data { return NSAutorelease(NSCharacterSet_bitmapNewWithBitmap(NULL,data)); } -+(NSCharacterSet *)characterSetWithCharactersInString:(NSString *)string { ++characterSetWithCharactersInString:(NSString *)string { return NSAutorelease([[NSCharacterSet_string allocWithZone:NULL] initWithString:string inverted:NO]); } -+(NSCharacterSet *)characterSetWithContentsOfFile:(NSString *)path { ++characterSetWithContentsOfFile:(NSString *)path { NSData *data=[NSData dataWithContentsOfFile:path]; if(data==nil) @@ -70,7 +68,7 @@ static NSMapTable *nameToSet=NULL; return [self characterSetWithBitmapRepresentation:data]; } -+(NSCharacterSet *)characterSetWithRange:(NSRange)range { ++characterSetWithRange:(NSRange)range { return NSAutorelease([[NSCharacterSet_range allocWithZone:NULL] initWithRange:range]); } @@ -79,74 +77,74 @@ static NSString *pathForCharacterSet(NSString *name){ NSString *path=[bundle pathForResource:name ofType:@"bitmap"]; if(path==nil) - [NSException raise:@"NSCharacterSetFailedException" - format:@"NSCharacterSet unable to find bitmap for %@",name]; + [NSException raise:@"NSCharacterSetFailedException" format:@"NSCharacterSet unable to find bitmap for %@",name]; return path; } -static NSCharacterSet *sharedSetWithName(NSString *name){ - NSCharacterSet *set; +static NSCharacterSet *sharedSetWithName(Class cls,NSString *name){ + NSCharacterSet *result; - if((set=NSMapGet(nameToSet,name))==nil){ - NSString *path=pathForCharacterSet(name); - - if((set=[NSCharacterSet characterSetWithContentsOfFile:path])!=nil) - NSMapInsert(nameToSet,name,set); + if(cls!=[NSCharacterSet class]) + result=[cls characterSetWithContentsOfFile:pathForCharacterSet(name)]; + else { + if((result=NSMapGet(nameToSet,name))==nil){ + if((result=[NSCharacterSet characterSetWithContentsOfFile:pathForCharacterSet(name)])!=nil) + NSMapInsert(nameToSet,name,result); + } } - - return set; + + return result; } -+(NSCharacterSet *)alphanumericCharacterSet { - return sharedSetWithName(@"alphanumericCharacterSet"); ++alphanumericCharacterSet { + return sharedSetWithName(self,@"alphanumericCharacterSet"); } -+(NSCharacterSet *)controlCharacterSet { - return sharedSetWithName(@"controlCharacterSet"); ++controlCharacterSet { + return sharedSetWithName(self,@"controlCharacterSet"); } -+(NSCharacterSet *)decimalDigitCharacterSet { - return sharedSetWithName(@"decimalDigitCharacterSet"); ++decimalDigitCharacterSet { + return sharedSetWithName(self,@"decimalDigitCharacterSet"); } -+(NSCharacterSet *)decomposableCharacterSet { - return sharedSetWithName(@"decomposableCharacterSet"); ++decomposableCharacterSet { + return sharedSetWithName(self,@"decomposableCharacterSet"); } -+(NSCharacterSet *)illegalCharacterSet { - return sharedSetWithName(@"illegalCharacterSet"); ++illegalCharacterSet { + return sharedSetWithName(self,@"illegalCharacterSet"); } -+(NSCharacterSet *)letterCharacterSet { - return sharedSetWithName(@"letterCharacterSet"); ++letterCharacterSet { + return sharedSetWithName(self,@"letterCharacterSet"); } -+(NSCharacterSet *)lowercaseLetterCharacterSet { - return sharedSetWithName(@"lowercaseLetterCharacterSet"); ++lowercaseLetterCharacterSet { + return sharedSetWithName(self,@"lowercaseLetterCharacterSet"); } -+(NSCharacterSet *)nonBaseCharacterSet { - return sharedSetWithName(@"nonBaseCharacterSet"); ++nonBaseCharacterSet { + return sharedSetWithName(self,@"nonBaseCharacterSet"); } -+(NSCharacterSet *)punctuationCharacterSet { - return sharedSetWithName(@"punctuationCharacterSet"); ++punctuationCharacterSet { + return sharedSetWithName(self,@"punctuationCharacterSet"); } -+(NSCharacterSet *)uppercaseLetterCharacterSet { - return sharedSetWithName(@"uppercaseLetterCharacterSet"); ++uppercaseLetterCharacterSet { + return sharedSetWithName(self,@"uppercaseLetterCharacterSet"); } -+(NSCharacterSet *)whitespaceAndNewlineCharacterSet { - return sharedSetWithName(@"whitespaceAndNewlineCharacterSet"); ++whitespaceAndNewlineCharacterSet { + return sharedSetWithName(self,@"whitespaceAndNewlineCharacterSet"); } -+(NSCharacterSet *)whitespaceCharacterSet { - return sharedSetWithName(@"whitespaceCharacterSet"); ++whitespaceCharacterSet { + return sharedSetWithName(self,@"whitespaceCharacterSet"); } - -(BOOL)characterIsMember:(unichar)character { NSInvalidAbstractInvocation(); return NO; diff --git a/Foundation/NSCharacterSet/NSMutableCharacterSet.m b/Foundation/NSCharacterSet/NSMutableCharacterSet.m index 5e168ac8..a5714ade 100755 --- a/Foundation/NSCharacterSet/NSMutableCharacterSet.m +++ b/Foundation/NSCharacterSet/NSMutableCharacterSet.m @@ -9,6 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI // Original - Christopher Lloyd #import #import +#import "NSMutableCharacterSet_bitmap.h" @implementation NSMutableCharacterSet @@ -19,6 +20,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return NSAllocateObject(self,0,zone); } ++characterSetWithBitmapRepresentation:(NSData *)data { + return [[[NSMutableCharacterSet_bitmap alloc] initWithData:data] autorelease]; +} + ++characterSetWithCharactersInString:(NSString *)string { + return [[[NSMutableCharacterSet_bitmap alloc] initWithString:string] autorelease]; +} + ++characterSetWithRange:(NSRange)range { + return [[[NSMutableCharacterSet_bitmap alloc] initWithRange:range] autorelease]; +} + -(void)addCharactersInString:(NSString *)string { NSInvalidAbstractInvocation(); } diff --git a/Foundation/NSCharacterSet/NSMutableCharacterSet_bitmap.h b/Foundation/NSCharacterSet/NSMutableCharacterSet_bitmap.h index 3a93b08d..7196a6c5 100755 --- a/Foundation/NSCharacterSet/NSMutableCharacterSet_bitmap.h +++ b/Foundation/NSCharacterSet/NSMutableCharacterSet_bitmap.h @@ -15,5 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI -initWithCharacterSet:(NSCharacterSet *)set; -initWithData:(NSData *)data; +-initWithString:(NSString *)string; +-initWithRange:(NSRange)range; @end diff --git a/Foundation/NSCharacterSet/NSMutableCharacterSet_bitmap.m b/Foundation/NSCharacterSet/NSMutableCharacterSet_bitmap.m index 415eec20..2134a56b 100755 --- a/Foundation/NSCharacterSet/NSMutableCharacterSet_bitmap.m +++ b/Foundation/NSCharacterSet/NSMutableCharacterSet_bitmap.m @@ -49,6 +49,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI return self; } +-initWithString:(NSString *)string { + NSUInteger i,length=[string length]; + unichar buffer[length]; + + [string getCharacters:buffer]; + + for(i=0;i