- NSBitmapImageRep use of CF* for CF types

- NSScroller use of display fixes
- NSMenuView use of display fixes
- NSToolbar fixes for delegate based default items
- NSToolbarItemView selection drawing
- NSControl fixes
- NSGraphicsContext behavior fixes
- NSBundle pathForResourceFile:inDirectory:, pathsForResourcesOfType:inDirectory fixes, localization table caching
- NSAffineTransform decoding
- NSString boolValue, intValuem integerValue, longLongValue fixes
- NSPathUtilities constants, skeletons
- renamed objc_msg_send to objc_msgSendv, objc_msgSendv_stret implementation for Windows (unused)
- NSOldXMLReader fixes when disabling exceptions
- NSCurrentLocaleIsMetric for windows
- Switch Foundation to use -l ws2_32
This commit is contained in:
Christopher Lloyd 2010-03-09 18:14:48 +00:00
parent 2f7e40f5d1
commit 3c0f029d38
32 changed files with 563 additions and 142 deletions

View File

@ -213,18 +213,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_bitmapPlanes[0]=NSZoneCalloc(NULL,_bytesPerRow*_pixelsHigh,1);
CGDataProviderRef provider=CGImageGetDataProvider(cgImage);
// FIXME: inefficient
NSData *bitmapData=(NSData *)CGDataProviderCopyData(provider);
const unsigned char *bytes=[bitmapData bytes];
// FIXME: inefficient but there is no API to get mutable bytes out of an image or image source
CFDataRef bitmapData=CGDataProviderCopyData(provider);
const unsigned char *bytes=CFDataGetBytePtr(bitmapData);
int i,length=_bytesPerRow*_pixelsHigh;
for(i=0;i<length;i++)
_bitmapPlanes[0][i]=bytes[i];
[bitmapData release];
CFRelease(bitmapData);
CFRelease(properties);
CFRelease(imageSource);
CGImageRelease(cgImage);
return self;
}

View File

@ -39,6 +39,7 @@ APPKIT_EXPORT NSString * const NSControlTextDidEndEditingNotification;
-(BOOL)isBezeled;
-(BOOL)isContinuous;
-(BOOL)refusesFirstResponder;
-(id)formatter;
-objectValue;
-(NSString *)stringValue;

View File

@ -133,6 +133,10 @@ static NSMutableDictionary *cellClassDictionary = nil;
return [_cell refusesFirstResponder];
}
-(id)formatter {
return [_cell formatter];
}
-objectValue {
return [[self selectedCell] objectValue];
}
@ -186,6 +190,7 @@ static NSMutableDictionary *cellClassDictionary = nil;
-(void)setImage:(NSImage *)image {
[[self cell] setImage:image];
[self setNeedsDisplay:YES];
}
-(void)setAlignment:(NSTextAlignment)alignment {
@ -232,6 +237,11 @@ static NSMutableDictionary *cellClassDictionary = nil;
[_cell setRefusesFirstResponder:flag];
}
-(void)setFormatter:(NSFormatter *)formatter {
[_cell setFormatter:formatter];
[self setNeedsDisplay:YES];
}
-(void)setObjectValue:(id <NSCopying>)object {
// FIX protocol does not implement isEqual
if(![(id)object isEqual:[[self selectedCell] objectValue]]){
@ -289,8 +299,10 @@ static NSMutableDictionary *cellClassDictionary = nil;
}
-(void)drawCell:(NSCell *)cell {
if (_cell == cell)
if (_cell == cell){
[_cell setControlView:self];
[_cell drawWithFrame:_bounds inView:self];
}
}
-(void)drawCellInside:(NSCell *)cell {
@ -419,6 +431,7 @@ static NSMutableDictionary *cellClassDictionary = nil;
}
-(void)drawRect:(NSRect)rect {
[_cell setControlView:self];
[_cell drawWithFrame:_bounds inView:self];
}
@ -449,8 +462,7 @@ static NSMutableDictionary *cellClassDictionary = nil;
}
[[self window] flushWindow];
event=[[self window] nextEventMatchingMask:NSLeftMouseUpMask|
NSLeftMouseDraggedMask];
event=[[self window] nextEventMatchingMask:NSLeftMouseUpMask|NSLeftMouseDraggedMask];
}while([event type]!=NSLeftMouseUp);
[self unlockFocus];

View File

@ -10,6 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <ApplicationServices/ApplicationServices.h>
#import <AppKit/NSGraphics.h>
@class CIContext;
@class NSWindow,NSBitmapImageRep;
typedef enum {
@ -29,10 +30,11 @@ typedef enum {
@interface NSGraphicsContext : NSObject {
CGContextRef _graphicsPort;
CIContext *_ciContext;
NSMutableArray *_focusStack;
BOOL _isDrawingToScreen;
BOOL _isFlipped;
NSWindow *_window;
NSDictionary *_deviceDescription;
}
+(NSGraphicsContext *)graphicsContextWithWindow:(NSWindow *)window;
@ -58,6 +60,8 @@ typedef enum {
-(void)setColorRenderingIntent:(NSColorRenderingIntent)value;
-(void)setCompositingOperation:(NSCompositingOperation)value;
-(CIContext *)CIContext;
-(void)saveGraphicsState;
-(void)restoreGraphicsState;

View File

@ -9,7 +9,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSWindow-Private.h>
#import <AppKit/NSCachedImageRep.h>
#import <AppKit/NSBitmapImageRep-Private.h>
#import <AppKit/NSRaise.h>
#import <ApplicationServices/ApplicationServices.h>
#import <QuartzCore/CIContext.h>
@class NSColor;
@ -20,7 +22,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_focusStack=[NSMutableArray new];
_isDrawingToScreen=YES;
_isFlipped=NO;
_window=[window retain];
_deviceDescription=[[window deviceDescription] copy];
return self;
}
@ -29,6 +31,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_focusStack=[NSMutableArray new];
_isDrawingToScreen=NO;
_isFlipped=flipped;
_deviceDescription=[[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:NSDeviceIsScreen] copy];
return self;
}
@ -51,14 +54,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_focusStack=[NSMutableArray new];
_isDrawingToScreen=YES;
_isFlipped=NO;
_deviceDescription=[[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSDeviceIsScreen] copy];
return self;
}
-(void)dealloc {
if(_graphicsPort!=NULL)
CGContextRelease(_graphicsPort);
[_ciContext release];
[_focusStack release];
[_window release];
[_deviceDescription release];
[super dealloc];
}
@ -74,7 +79,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return [[[self alloc] initWithBitmapImageRep:imageRep] autorelease];
}
+(NSMutableArray *)_contextStack {
static NSMutableArray *_contextStack() {
NSMutableDictionary *shared=[NSCurrentThread() sharedDictionary];
NSMutableArray *stack=[shared objectForKey:@"NSGraphicsContext.stack"];
@ -87,7 +92,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
static NSGraphicsContext *_currentContext() {
return NSThreadSharedInstanceDoNotCreate(@"NSGraphicsContext");
NSMutableDictionary *shared=[NSCurrentThread() sharedDictionary];
return [shared objectForKey:@"NSGraphicsContext"];
}
CGContextRef NSCurrentGraphicsPort() {
@ -114,22 +120,30 @@ NSMutableArray *NSCurrentFocusStack() {
}
+(void)setCurrentContext:(NSGraphicsContext *)context {
[NSCurrentThread() setSharedObject:context forClassName:@"NSGraphicsContext"];
NSMutableDictionary *shared=[NSCurrentThread() sharedDictionary];
if(context==nil)
[shared removeObjectForKey:@"NSGraphicsContext"];
else
[shared setObject:context forKey:@"NSGraphicsContext"];
}
+(void)saveGraphicsState {
NSGraphicsContext *current=_currentContext();
if(current!=nil)
[[self _contextStack] addObject:current];
if(current!=nil) {
[_contextStack() addObject:current];
[current saveGraphicsState];
}
}
+(void)restoreGraphicsState {
NSGraphicsContext *current=[[self _contextStack] lastObject];
NSGraphicsContext *current=[_contextStack() lastObject];
if(current!=nil){
[self setCurrentContext:current];
[[self _contextStack] removeLastObject];
[_contextStack() removeLastObject];
[current restoreGraphicsState];
}
}
@ -193,12 +207,19 @@ NSMutableArray *NSCurrentFocusStack() {
CGContextSetBlendMode(_graphicsPort,blendMode[value]);
}
-(CIContext *)CIContext {
if(_ciContext==nil)
;//_ciContext=[[CIContext contextWithCGContext:_graphicsPort options:nil] retain];
return _ciContext;
}
-(void)saveGraphicsState {
[isa saveGraphicsState];
CGContextSaveGState(_graphicsPort);
}
-(void)restoreGraphicsState {
[isa restoreGraphicsState];
CGContextRestoreGState(_graphicsPort);
}
-(void)flushGraphics {
@ -206,14 +227,7 @@ NSMutableArray *NSCurrentFocusStack() {
}
-(NSDictionary *)deviceDescription {
if(_window!=nil)
return [_window deviceDescription];
else if([self isDrawingToScreen]){
return [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSDeviceIsScreen];
}
else {
return [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSDeviceIsPrinter];
}
return _deviceDescription;
}
@end

View File

@ -29,8 +29,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-(void)setSelectedItemIndex:(unsigned)itemIndex {
_selectedItemIndex=itemIndex;
[self display];
[[self window] flushWindow];
[self setNeedsDisplay:YES];
}
-(NSArray *)itemArray {
@ -191,8 +190,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_selectedItemIndex=NSNotFound;
[[self window] setAcceptsMouseMovedEvents:oldAcceptsMouseMovedEvents];
[self display];
[[self window] flushWindow];
[self setNeedsDisplay:YES];
return ([item isEnabled] && ![item hasSubmenu])?item:(NSMenuItem *)nil;
}

View File

@ -34,6 +34,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_isVertical=(_bounds.size.width<_bounds.size.height)?YES:NO;
_floatValue=0;
_knobProportion=0;
[self checkSpaceForParts];
}
else {
[NSException raise:NSInvalidArgumentException format:@"-[%@ %s] is not implemented for coder %@",isa,sel_getName(_cmd),coder];
@ -372,9 +373,7 @@ static inline float roundFloat(float value){
NSPoint point;
float delta;
[[self window] flushWindow];
event=[[self window] nextEventMatchingMask:NSLeftMouseUpMask|
NSLeftMouseDraggedMask];
event=[[self window] nextEventMatchingMask:NSLeftMouseUpMask|NSLeftMouseDraggedMask];
point=[self convertPoint:[event locationInWindow] fromView:nil];
@ -420,7 +419,6 @@ static inline float roundFloat(float value){
if (NSMouseInRect(point,rect,[self isFlipped]))
[self sendAction:_action to:_target];
[[self window] flushWindow];
event=[[self window] nextEventMatchingMask:NSPeriodicMask|NSLeftMouseUpMask|NSLeftMouseDraggedMask];
}while([event type]!=NSLeftMouseUp);
@ -465,7 +463,6 @@ static inline float roundFloat(float value){
[self sendAction:_action to:_target];
}
[[self window] flushWindow];
event=[[self window] nextEventMatchingMask:NSLeftMouseUpMask|NSLeftMouseDraggedMask];
}while([event type]!=NSLeftMouseUp);

View File

@ -46,6 +46,7 @@ APPKIT_EXPORT NSString * const NSToolbarDidRemoveItemNotification;
BOOL _visible;
BOOL _allowsUserCustomization;
BOOL _isLoadingConfiguration;
BOOL _loadDefaultItems;
}
-initWithIdentifier:(NSString *)identifier;

View File

@ -67,13 +67,13 @@ NSString * const NSToolbarChangeAppearanceNotification = @"__NSToolbarChangeAppe
}
-initWithIdentifier:(NSString *)identifier {
_identifier=[identifier retain];
_identifier=[identifier copy];
_delegate=nil;
_items=[[NSMutableArray alloc] init];
_selectedItemIdentifier=nil;
_allowedItems=nil;
_defaultItems=nil;
_selectableItems=nil;
_allowedItems=[[NSMutableArray alloc] init];
_defaultItems=[[NSMutableArray alloc] init];
_selectableItems=[[NSMutableArray alloc] init];
_identifiedItems=[[NSMutableDictionary alloc] init];
_window=nil;
_view=[[NSToolbarView alloc] init];
@ -85,6 +85,7 @@ NSString * const NSToolbarChangeAppearanceNotification = @"__NSToolbarChangeAppe
_visible=YES;
_allowsUserCustomization=YES;
_isLoadingConfiguration=NO;
_loadDefaultItems=YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toolbarChangedAppearance:) name:NSToolbarChangeAppearanceNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toolbarWillAddItem:) name:NSToolbarWillAddItemNotification object:nil];
@ -203,15 +204,37 @@ NSString * const NSToolbarChangeAppearanceNotification = @"__NSToolbarChangeAppe
return dictionary;
}
static BOOL isStandardItemIdentifier(NSString *identifier){
if([identifier isEqualToString:NSToolbarCustomizeToolbarItemIdentifier])
return YES;
if([identifier isEqualToString:NSToolbarFlexibleSpaceItemIdentifier])
return YES;
if([identifier isEqualToString:NSToolbarPrintItemIdentifier])
return YES;
if([identifier isEqualToString:NSToolbarSeparatorItemIdentifier])
return YES;
if([identifier isEqualToString:NSToolbarShowColorsItemIdentifier])
return YES;
if([identifier isEqualToString:NSToolbarShowFontsItemIdentifier])
return YES;
if([identifier isEqualToString:NSToolbarSpaceItemIdentifier])
return YES;
return NO;
}
-(NSToolbarItem *)_itemForItemIdentifier:(NSString *)identifier willBeInsertedIntoToolbar:(BOOL)intoToolbar {
NSToolbarItem *item=[_identifiedItems objectForKey:identifier];
if(item==nil){
// The delegate does not get toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar: for the standard items
BOOL standardItem=isStandardItemIdentifier(identifier);
if(_delegate==nil)
if(_delegate==nil || standardItem)
item=[[[NSToolbarItem alloc] initWithItemIdentifier:identifier] autorelease];
else
else {
item=[_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:intoToolbar];
}
if(item!=nil){
[_identifiedItems setObject:item forKey:identifier];
@ -304,6 +327,32 @@ NSString * const NSToolbarChangeAppearanceNotification = @"__NSToolbarChangeAppe
[self saveConfiguration];
}
-(NSArray *)_defaultToolbarItems {
NSArray *result=nil;
if([_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)])
result=[self _itemsWithIdentifiers:[_delegate toolbarDefaultItemIdentifiers:self]];
if(result==nil)
result=_defaultItems;
return result;
}
-(void)loadDefaultItemsIfNeeded {
if(_loadDefaultItems){
_loadDefaultItems=NO;
NSArray *items=[self _defaultToolbarItems];
while([_items count])
[self _removeItemAtIndex:0];
for(NSToolbarItem *item in items)
[self _insertItem:item atIndex:[_items count]];
}
}
-(void)toolbarChangedAppearance:(NSNotification *)note {
NSToolbar *toolbar=[note object];
@ -315,10 +364,12 @@ NSString * const NSToolbarChangeAppearanceNotification = @"__NSToolbarChangeAppe
_sizeMode=[toolbar sizeMode];
_displayMode=[toolbar displayMode];
[_window _toolbarSizeDidChangeFromOldHeight:[self visibleHeight]];
}
-(void)layoutFrameSizeWithWidth:(CGFloat)width {
[self loadDefaultItemsIfNeeded];
[_view layoutViewsWithWidth:width setFrame:YES];
}
@ -405,7 +456,8 @@ NSString * const NSToolbarChangeAppearanceNotification = @"__NSToolbarChangeAppe
-(void)setSelectedItemIdentifier:(NSString *)identifier {
identifier=[identifier copy];
[_selectedItemIdentifier release];
_selectedItemIdentifier=[identifier retain];
_selectedItemIdentifier=identifier;
[_view setNeedsDisplay:YES];
}
-(void)validateVisibleItems {
@ -452,18 +504,6 @@ NSString * const NSToolbarChangeAppearanceNotification = @"__NSToolbarChangeAppe
return result;
}
-(NSArray *)_defaultToolbarItems {
NSArray *result=nil;
if([_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)])
result=[self _itemsWithIdentifiers:[_delegate toolbarDefaultItemIdentifiers:self]];
if(result==nil)
result=_defaultItems;
return result;
}
-initWithCoder:(NSCoder *)coder {
if(![coder allowsKeyedCoding])
NSUnimplementedMethod();
@ -487,7 +527,7 @@ NSString * const NSToolbarChangeAppearanceNotification = @"__NSToolbarChangeAppe
_visible=YES;
_allowsUserCustomization=[coder decodeBoolForKey:@"NSToolbarAllowsUserCustomization"];
_isLoadingConfiguration=NO;
_loadDefaultItems=NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toolbarChangedAppearance:) name:NSToolbarChangeAppearanceNotification object:nil];
/*
NSToolbarPrefersToBeShown = 1;

View File

@ -13,6 +13,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <AppKit/NSStringDrawer.h>
#import <AppKit/NSWindow.h>
#import <AppKit/NSApplication.h>
#import <AppKit/NSColor.h>
#import <AppKit/NSGraphicsContext.h>
@interface NSToolbarItem(private)
-(void)drawInRect:(NSRect)bounds highlighted:(BOOL)highlighted;
@ -47,7 +49,51 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return [[self subviews] lastObject];
}
typedef struct {
CGFloat _C0[4];
CGFloat _C1[4];
} gradientColors;
static void evaluate(void *info,const float *in, float *output) {
float x=in[0];
gradientColors *colors=info;
int i;
for(i=0;i<4;i++)
output[i]=colors->_C0[i]+x*(colors->_C1[i]-colors->_C0[i]);
}
-(void)drawRect:(NSRect)rect {
if([[_toolbarItem itemIdentifier] isEqual:[[_toolbarItem toolbar] selectedItemIdentifier]]){
CGContextRef cgContext=[[NSGraphicsContext currentContext] graphicsPort];
float domain[2]={0,1};
float range[8]={0,1,0,1,0,1,0,1};
CGFunctionCallbacks callbacks={0,evaluate,NULL};
gradientColors colors;
NSColor *startColor=[NSColor blackColor];
NSColor *endColor=[NSColor lightGrayColor];
colors._C0[0]=0.5;
colors._C0[1]=0.5;
colors._C0[2]=0.5;
colors._C0[3]=0.5;
colors._C1[0]=0.8;
colors._C1[1]=0.8;
colors._C1[2]=0.8;
colors._C1[3]=0;
CGFunctionRef function=CGFunctionCreate(&colors,1,domain,4,range,&callbacks);
CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();
CGShadingRef shading;
CGRect bounds=[self bounds];
shading=CGShadingCreateAxial(colorSpace,bounds.origin,CGPointMake(bounds.origin.x,bounds.origin.y+NSHeight(bounds)/2),function,NO,NO);
CGContextDrawShading(cgContext,shading);
CGShadingRelease(shading);
CGFunctionRelease(function);
CGColorSpaceRelease(colorSpace);
}
[_toolbarItem drawInRect:[self bounds] highlighted:_isHighlighted];
}

View File

@ -0,0 +1,86 @@
#import <CoreFoundation/CoreFoundation.h>
#import <CFNetwork/CFNetworkExport.h>
#import <CFNetwork/CFNetServices.h>
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertyShouldCloseNativeSocket;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySocketSecurityLevel;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySOCKSProxy;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySSLPeerCertificates;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySSLPeerTrust;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySSLSettings;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertyProxyLocalByPass;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySocketRemoteHost;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySocketRemoteNetService;
CFNETWORK_EXPORT const CFStringRef kCFStreamSSLLevel;
CFNETWORK_EXPORT const CFStringRef kCFStreamSSLAllowsExpiredCertificates;
CFNETWORK_EXPORT const CFStringRef kCFStreamSSLAllowsExpiredRoots;
CFNETWORK_EXPORT const CFStringRef kCFStreamSSLAllowsAnyRoot;
CFNETWORK_EXPORT const CFStringRef kCFStreamSSLValidatesCertificateChain;
CFNETWORK_EXPORT const CFStringRef kCFStreamSSLPeerName;
CFNETWORK_EXPORT const CFStringRef kCFStreamSSLCertificates;
CFNETWORK_EXPORT const CFStringRef kCFStreamSSLIsServer;
typedef enum {
kCFStreamSocketSecurityNone = 0,
kCFStreamSocketSecuritySSLv2,
kCFStreamSocketSecuritySSLv3,
kCFStreamSocketSecuritySSLv23,
kCFStreamSocketSecurityTLSv1
} CFStreamSocketSecurityProtocol;
CFNETWORK_EXPORT const CFStringRef kCFStreamSocketSecurityLevelNone;
CFNETWORK_EXPORT const CFStringRef kCFStreamSocketSecurityLevelSSLv2;
CFNETWORK_EXPORT const CFStringRef kCFStreamSocketSecurityLevelSSLv3;
CFNETWORK_EXPORT const CFStringRef kCFStreamSocketSecurityLevelTLSv1;
CFNETWORK_EXPORT const CFStringRef kCFStreamSocketSecurityLevelNegotiatedSSL;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySOCKSProxyHost;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySOCKSProxyPort;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySOCKSVersion;
CFNETWORK_EXPORT const CFStringRef kCFStreamSocketSOCKSVersion4;
CFNETWORK_EXPORT const CFStringRef kCFStreamSocketSOCKSVersion5;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySOCKSUser;
CFNETWORK_EXPORT const CFStringRef kCFStreamPropertySOCKSPassword;
CFNETWORK_EXPORT const CFIndex kCFStreamErrorDomainWinSock;
enum {
kCFStreamErrorSOCKSSubDomainNone = 0,
kCFStreamErrorSOCKSSubDomainVersionCode = 1,
kCFStreamErrorSOCKS4SubDomainResponse = 2,
kCFStreamErrorSOCKS5SubDomainUserPass = 3,
kCFStreamErrorSOCKS5SubDomainMethod = 4,
kCFStreamErrorSOCKS5SubDomainResponse = 5
};
/* kCFStreamErrorSOCKSSubDomainNone*/
enum {
kCFStreamErrorSOCKS5BadResponseAddr = 1,
kCFStreamErrorSOCKS5BadState = 2,
kCFStreamErrorSOCKSUnknownClientVersion = 3
};
/* kCFStreamErrorSOCKS4SubDomainResponse*/
enum {
kCFStreamErrorSOCKS4RequestFailed = 91,
kCFStreamErrorSOCKS4IdentdFailed = 92,
kCFStreamErrorSOCKS4IdConflict = 93
};
/* kCFStreamErrorSOCKS5SubDomainMethod*/
enum {
kSOCKS5NoAcceptableMethod = 0xFF
};
CFNETWORK_EXPORT Boolean CFSocketStreamPairSetSecurityProtocol (CFReadStreamRef socketReadStream,CFWriteStreamRef socketWriteStream,CFStreamSocketSecurityProtocol securityProtocol);
CFNETWORK_EXPORT SInt32 CFSocketStreamSOCKSGetError(CFStreamError* error);
CFNETWORK_EXPORT SInt32 CFSocketStreamSOCKSGetErrorSubdomain(CFStreamError* error);
CFNETWORK_EXPORT void CFStreamCreatePairWithSocketToCFHost (CFAllocatorRef alloc,CFHostRef host,SInt32 port,CFReadStreamRef *readStream,CFWriteStreamRef *writeStream);
CFNETWORK_EXPORT void CFStreamCreatePairWithSocketToNetService (CFAllocatorRef alloc,CFNetServiceRef service,CFReadStreamRef *readStream,CFWriteStreamRef *writeStream);

View File

@ -0,0 +1,35 @@
#import <CFNetwork/CFSocketStream.h>
#import <Foundation/NSString.h>
const CFStringRef kCFStreamPropertyShouldCloseNativeSocket=(CFStringRef)@"kCFStreamPropertyShouldCloseNativeSocket";
const CFStringRef kCFStreamPropertySocketSecurityLevel=(CFStringRef)@"kCFStreamPropertySocketSecurityLevel";
const CFStringRef kCFStreamPropertySOCKSProxy=(CFStringRef)@"kCFStreamPropertySOCKSProxy";
const CFStringRef kCFStreamPropertySSLPeerCertificates=(CFStringRef)@"kCFStreamPropertySSLPeerCertificates";
const CFStringRef kCFStreamPropertySSLPeerTrust=(CFStringRef)@"kCFStreamPropertySSLPeerTrust";
const CFStringRef kCFStreamPropertySSLSettings=(CFStringRef)@"kCFStreamPropertySSLSettings";
const CFStringRef kCFStreamPropertyProxyLocalByPass=(CFStringRef)@"kCFStreamPropertyProxyLocalByPass";
const CFStringRef kCFStreamPropertySocketRemoteHost=(CFStringRef)@"kCFStreamPropertySocketRemoteHost";
const CFStringRef kCFStreamPropertySocketRemoteNetService=(CFStringRef)@"kCFStreamPropertySocketRemoteNetService";
const CFStringRef kCFStreamSSLLevel=(CFStringRef)@"kCFStreamSSLLevel";
const CFStringRef kCFStreamSSLAllowsExpiredCertificates=(CFStringRef)@"kCFStreamSSLAllowsExpiredCertificates";
const CFStringRef kCFStreamSSLAllowsExpiredRoots=(CFStringRef)@"kCFStreamSSLAllowsExpiredRoots";
const CFStringRef kCFStreamSSLAllowsAnyRoot=(CFStringRef)@"kCFStreamSSLAllowsAnyRoot";
const CFStringRef kCFStreamSSLValidatesCertificateChain=(CFStringRef)@"kCFStreamSSLValidatesCertificateChain";
const CFStringRef kCFStreamSSLPeerName=(CFStringRef)@"kCFStreamSSLPeerName";
const CFStringRef kCFStreamSSLCertificates=(CFStringRef)@"kCFStreamSSLCertificates";
const CFStringRef kCFStreamSSLIsServer=(CFStringRef)@"kCFStreamSSLIsServer";
const CFStringRef kCFStreamSocketSecurityLevelNone=(CFStringRef)@"kCFStreamSocketSecurityLevelNone";
const CFStringRef kCFStreamSocketSecurityLevelSSLv2=(CFStringRef)@"kCFStreamSocketSecurityLevelSSLv2";
const CFStringRef kCFStreamSocketSecurityLevelSSLv3=(CFStringRef)@"kCFStreamSocketSecurityLevelSSLv3";
const CFStringRef kCFStreamSocketSecurityLevelTLSv1=(CFStringRef)@"kCFStreamSocketSecurityLevelTLSv1";
const CFStringRef kCFStreamSocketSecurityLevelNegotiatedSSL=(CFStringRef)@"kCFStreamSocketSecurityLevelNegotiatedSSL";
const CFStringRef kCFStreamPropertySOCKSProxyHost=(CFStringRef)@"kCFStreamPropertySOCKSProxyHost";
const CFStringRef kCFStreamPropertySOCKSProxyPort=(CFStringRef)@"kCFStreamPropertySOCKSProxyPort";
const CFStringRef kCFStreamPropertySOCKSVersion=(CFStringRef)@"kCFStreamPropertySOCKSVersion";
const CFStringRef kCFStreamSocketSOCKSVersion4=(CFStringRef)@"kCFStreamSocketSOCKSVersion4";
const CFStringRef kCFStreamSocketSOCKSVersion5=(CFStringRef)@"kCFStreamSocketSOCKSVersion5";
const CFStringRef kCFStreamPropertySOCKSUser=(CFStringRef)@"kCFStreamPropertySOCKSUser";
const CFStringRef kCFStreamPropertySOCKSPassword=(CFStringRef)@"kCFStreamPropertySOCKSPassword";

View File

@ -4869,6 +4869,15 @@
FEC1CFE20F7AAB7900619DD5 /* FoundationErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = FEC1CFDF0F7AAB7900619DD5 /* FoundationErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
FEC1CFE30F7AAB7900619DD5 /* FoundationErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = FEC1CFDF0F7AAB7900619DD5 /* FoundationErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
FEC1CFE40F7AAB7900619DD5 /* FoundationErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = FEC1CFDF0F7AAB7900619DD5 /* FoundationErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
FEC79E3C1146C47D0070B596 /* CFByteOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC79E3B1146C47D0070B596 /* CFByteOrder.m */; };
FEC79E3D1146C47D0070B596 /* CFByteOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC79E3B1146C47D0070B596 /* CFByteOrder.m */; };
FEC79E3E1146C47D0070B596 /* CFByteOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC79E3B1146C47D0070B596 /* CFByteOrder.m */; };
FEC79E3F1146C47D0070B596 /* CFByteOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC79E3B1146C47D0070B596 /* CFByteOrder.m */; };
FEC79E401146C47D0070B596 /* CFByteOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC79E3B1146C47D0070B596 /* CFByteOrder.m */; };
FEC79E411146C47D0070B596 /* CFByteOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC79E3B1146C47D0070B596 /* CFByteOrder.m */; };
FEC79E421146C47D0070B596 /* CFByteOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC79E3B1146C47D0070B596 /* CFByteOrder.m */; };
FEC79E431146C47D0070B596 /* CFByteOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC79E3B1146C47D0070B596 /* CFByteOrder.m */; };
FEC79E441146C47D0070B596 /* CFByteOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC79E3B1146C47D0070B596 /* CFByteOrder.m */; };
FEC9F6AE0E2F98EA0034932A /* NSURLProtocol_http.h in Headers */ = {isa = PBXBuildFile; fileRef = FEC9F6AC0E2F98EA0034932A /* NSURLProtocol_http.h */; };
FEC9F6AF0E2F98EA0034932A /* NSURLProtocol_http.m in Sources */ = {isa = PBXBuildFile; fileRef = FEC9F6AD0E2F98EA0034932A /* NSURLProtocol_http.m */; };
FEC9F6B00E2F98EA0034932A /* NSURLProtocol_http.h in Headers */ = {isa = PBXBuildFile; fileRef = FEC9F6AC0E2F98EA0034932A /* NSURLProtocol_http.h */; };
@ -7217,6 +7226,7 @@
FEBF53670F926025005DC684 /* objc_protocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = objc_protocol.h; sourceTree = "<group>"; };
FEBF545A0F93AE8A005DC684 /* objc_property.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = objc_property.m; sourceTree = "<group>"; };
FEC1CFDF0F7AAB7900619DD5 /* FoundationErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FoundationErrors.h; sourceTree = "<group>"; };
FEC79E3B1146C47D0070B596 /* CFByteOrder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CFByteOrder.m; sourceTree = "<group>"; };
FEC9F6AC0E2F98EA0034932A /* NSURLProtocol_http.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSURLProtocol_http.h; sourceTree = "<group>"; };
FEC9F6AD0E2F98EA0034932A /* NSURLProtocol_http.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSURLProtocol_http.m; sourceTree = "<group>"; };
FEC9F6BB0E2F9BEA0034932A /* NSURLConnectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSURLConnectionState.h; sourceTree = "<group>"; };
@ -8330,6 +8340,7 @@
FE4BDD2A0BCD65EB00E19685 /* CoreFoundation */ = {
isa = PBXGroup;
children = (
FEC79E3B1146C47D0070B596 /* CFByteOrder.m */,
1A8A694E1091EF0200DC5A01 /* NSCFTypeID.h */,
FE8693D20FE0108E00F89733 /* CFArray.m */,
FE8693D30FE0108E00F89733 /* CFAttributedString.m */,
@ -12418,6 +12429,7 @@
15D921AD105E918000171406 /* NSString_defaultEncoding_posix.m in Sources */,
151B5CC4105EA25E009092D5 /* objc_msg_sendv-Disabled.m in Sources */,
FE75E2EF10F6442F000419C4 /* bonjour.m in Sources */,
FEC79E431146C47D0070B596 /* CFByteOrder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -12772,6 +12784,7 @@
FE463E71102CD5C700B265D6 /* NSPointerArray.m in Sources */,
FE463E73102CD5C700B265D6 /* NSPointerFunctions.m in Sources */,
FE75E2EE10F6442F000419C4 /* bonjour.m in Sources */,
FEC79E421146C47D0070B596 /* CFByteOrder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -13127,6 +13140,7 @@
FE463E63102CD5C700B265D6 /* NSPointerFunctions.m in Sources */,
FE6014231042FD49008A7357 /* NSString_defaultEncoding_posix.m in Sources */,
FE75E2EA10F6442F000419C4 /* bonjour.m in Sources */,
FEC79E3E1146C47D0070B596 /* CFByteOrder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -13483,6 +13497,7 @@
FE463E5F102CD5C700B265D6 /* NSPointerFunctions.m in Sources */,
FE6014241042FD49008A7357 /* NSString_defaultEncoding_posix.m in Sources */,
FE75E2E910F6442F000419C4 /* bonjour.m in Sources */,
FEC79E3D1146C47D0070B596 /* CFByteOrder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -13843,6 +13858,7 @@
FE463E5B102CD5C700B265D6 /* NSPointerFunctions.m in Sources */,
FE60142A1042FD6B008A7357 /* NSString_defaultEncoding_windows.m in Sources */,
FE75E2E810F6442F000419C4 /* bonjour.m in Sources */,
FEC79E3C1146C47D0070B596 /* CFByteOrder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -14199,6 +14215,7 @@
FE5A86DC10C6EF42005E348A /* NSPlatform_bsd.m in Sources */,
FE5A86DE10C6EF43005E348A /* NSTask_bsd.m in Sources */,
FE75E2F010F6442F000419C4 /* bonjour.m in Sources */,
FEC79E441146C47D0070B596 /* CFByteOrder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -14558,6 +14575,7 @@
1A27C0051090CC0500C44FD7 /* NSNumber_double_const.m in Sources */,
1A27C0631090D1BE00C44FD7 /* NSNumber_BOOL_const.m in Sources */,
FE75E2ED10F6442F000419C4 /* bonjour.m in Sources */,
FEC79E411146C47D0070B596 /* CFByteOrder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -14918,6 +14936,7 @@
1A27C0031090CC0500C44FD7 /* NSNumber_double_const.m in Sources */,
1A27C0611090D1BE00C44FD7 /* NSNumber_BOOL_const.m in Sources */,
FE75E2EB10F6442F000419C4 /* bonjour.m in Sources */,
FEC79E3F1146C47D0070B596 /* CFByteOrder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -15278,6 +15297,7 @@
1A27C0041090CC0500C44FD7 /* NSNumber_double_const.m in Sources */,
1A27C0621090D1BE00C44FD7 /* NSNumber_BOOL_const.m in Sources */,
FE75E2EC10F6442F000419C4 /* bonjour.m in Sources */,
FEC79E401146C47D0070B596 /* CFByteOrder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -15838,7 +15858,7 @@
"-lffi",
"-B,dynamic",
"-shared",
"-lwsock32",
"-lws2_32",
"-Wl,--export-all-symbols",
"-Wl,--image-base=0x10000000",
"-Wl,--out-implib,$TARGET_BUILD_DIR/Foundation.framework/libFoundation.a",

View File

@ -7,10 +7,14 @@ The above copyright notice and this permission notice shall be included in all c
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 <Foundation/NSAffineTransform.h>
#import <Foundation/NSRaise.h>
#import <Foundation/NSKeyedUnarchiver.h>
#import <CoreFoundation/CFByteOrder.h>
#import <math.h>
@implementation NSAffineTransform
static NSAffineTransformStruct identity={1,0,0,1,0,0};
static inline NSAffineTransformStruct multiplyStruct(NSAffineTransformStruct start, NSAffineTransformStruct append){
NSAffineTransformStruct result;
@ -43,12 +47,7 @@ static inline NSAffineTransformStruct invertStruct(NSAffineTransformStruct matri
}
-init {
_matrix.m11=1;
_matrix.m12=0;
_matrix.m21=0;
_matrix.m22=1;
_matrix.tX=0;
_matrix.tY=0;
_matrix=identity;
return self;
}
@ -57,7 +56,25 @@ static inline NSAffineTransformStruct invertStruct(NSAffineTransformStruct matri
}
-initWithCoder:(NSCoder *)coder {
NSUnimplementedMethod();
if([coder allowsKeyedCoding]){
NSKeyedUnarchiver *keyed=(NSKeyedUnarchiver *)coder;
NSUInteger length;
const uint8_t *bytes=[keyed decodeBytesForKey:@"NSTransformStruct" returnedLength:&length];
if(length!=24)
_matrix=identity;
else {
CFSwappedFloat32 *words=(CFSwappedFloat32 *)bytes;
_matrix.m11=CFConvertFloat32SwappedToHost(words[0]);
_matrix.m12=CFConvertFloat32SwappedToHost(words[1]);
_matrix.m21=CFConvertFloat32SwappedToHost(words[2]);
_matrix.m22=CFConvertFloat32SwappedToHost(words[3]);
_matrix.tX=CFConvertFloat32SwappedToHost(words[4]);
_matrix.tY=CFConvertFloat32SwappedToHost(words[5]);
}
}
return self;
}

View File

@ -8,7 +8,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <Foundation/NSObject.h>
@class NSArray,NSDictionary,NSString,NSError;
@class NSArray,NSDictionary,NSString,NSError,NSMutableDictionary;
FOUNDATION_EXPORT NSString * const NSBundleDidLoadNotification;
FOUNDATION_EXPORT NSString * const NSLoadedClasses;
@ -19,6 +19,7 @@ FOUNDATION_EXPORT NSString * const NSLoadedClasses;
NSDictionary *_infoDictionary;
NSString *_executablePath;
NSArray *_lookInDirectories;
NSMutableDictionary *_localizedTables;
BOOL _isLoaded;
}

View File

@ -187,6 +187,7 @@ static NSMapTable *pathToObject=NULL;
[_resourcePath retain];
_infoDictionary=nil;
_localizedTables=nil;
_isLoaded=NO;
NSMapInsert(pathToObject,path,self);
@ -233,10 +234,14 @@ static NSMapTable *pathToObject=NULL;
-(NSDictionary *)infoDictionary {
if(_infoDictionary==nil){
NSString *path=[self pathForResource:@"Info" ofType:@"plist" inDirectory:[_path stringByAppendingPathComponent:@"Contents"]];
NSString *path=[[[_path stringByAppendingPathComponent:@"Contents"] stringByAppendingPathComponent:@"Info"] stringByAppendingPathExtension:@"plist"];
if(![[NSFileManager defaultManager] fileExistsAtPath:path])
path=nil;
if(path==nil)
path=[self pathForResource:@"Info" ofType:@"plist" inDirectory:[_path stringByAppendingPathComponent:@"Resources"]];
path=[self pathForResource:@"Info" ofType:@"plist" inDirectory:@"Resources"];
_infoDictionary=[[NSDictionary allocWithZone:NULL] initWithContentsOfFile:path];
@ -420,13 +425,21 @@ static NSMapTable *pathToObject=NULL;
-(NSString *)pathForResourceFile:(NSString *)file inDirectory:(NSString *)directory {
NSArray *lookIn=[self lookInDirectories];
NSInteger i,count=[lookIn count];
NSInteger i,count=[lookIn count];
for(i=0;i<count;i++){
NSString *path=[[directory stringByAppendingPathComponent:[lookIn objectAtIndex:i]] stringByAppendingPathComponent:file];
NSString *path=[_resourcePath stringByAppendingPathComponent:[lookIn objectAtIndex:i]];
if([[NSFileManager defaultManager] fileExistsAtPath:path])
if(directory!=nil)
path=[path stringByAppendingPathComponent:directory];
path=[path stringByAppendingPathComponent:file];
BOOL value=[[NSFileManager defaultManager] fileExistsAtPath:path];
if(value){
return path;
}
}
return nil;
@ -459,21 +472,29 @@ static NSMapTable *pathToObject=NULL;
}
-(NSString *)pathForResource:(NSString *)name ofType:(NSString *)type {
return [self pathForResource:name ofType:type inDirectory:_resourcePath];
NSString *result=[self pathForResource:name ofType:type inDirectory:nil];
return result;
}
-(NSArray *)pathsForResourcesOfType:(NSString *)type inDirectory:(NSString *)path {
id fullPath=[[self resourcePath] stringByAppendingPathComponent:path];
id allFiles=[[NSFileManager defaultManager] directoryContentsAtPath:fullPath];
int i;
id ret=[NSMutableArray array];
for(i=0; i<[allFiles count]; i++)
{
id filename=[fullPath stringByAppendingPathComponent:[allFiles objectAtIndex:i]];
if(type==nil || [[filename pathExtension] isEqualToString:type])
[ret addObject:filename];
NSMutableArray *result=[NSMutableArray array];
NSString *fullPath=[self resourcePath];
if(path!=nil)
fullPath=[fullPath stringByAppendingPathComponent:path];
NSArray *allFiles=[[NSFileManager defaultManager] directoryContentsAtPath:fullPath];
NSInteger i,count=[allFiles count];
for(i=0;i<count;i++){
NSString *check=[allFiles objectAtIndex:i];
if(type==nil || [[check pathExtension] isEqualToString:type])
[result addObject:[fullPath stringByAppendingPathComponent:check]];
}
return ret;
return result;
}
-(NSArray *)pathsForResourcesOfType:(NSString *)type inDirectory:(NSString *)path forLocalization:(NSString *)localization {
@ -483,25 +504,38 @@ static NSMapTable *pathToObject=NULL;
-(NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)table {
NSString *result;
NSString *path;
NSString *contents=nil;
NSDictionary *dictionary=nil;
NSDictionary *dictionary;
if([table length]==0)
table=@"Localizable";
if((path=[self pathForResource:table ofType:@"strings"])!=nil)
if((contents=[NSString stringWithContentsOfFile:path])!=nil){
NS_DURING
dictionary=[contents propertyListFromStringsFileFormat];
NS_HANDLER
dictionary=nil;
NS_ENDHANDLER
}
dictionary=[_localizedTables objectForKey:table];
if(dictionary==nil){
NSString *path;
NSString *contents=nil;
if(_localizedTables==nil)
_localizedTables=[[NSMutableDictionary alloc] init];
if((path=[self pathForResource:table ofType:@"strings"])!=nil)
if((contents=[NSString stringWithContentsOfFile:path])!=nil){
NS_DURING
dictionary=[contents propertyListFromStringsFileFormat];
NS_HANDLER
dictionary=nil;
NS_ENDHANDLER
}
if(dictionary==nil)
dictionary=[NSDictionary dictionary];
[_localizedTables setObject:dictionary forKey:table];
}
if((result=[dictionary objectForKey:key])==nil)
result=(value!=nil)?value:key;
return result;
}

View File

@ -14,7 +14,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <string.h>
#import <objc/message.h>
id objc_msg_sendv(id self, SEL selector, unsigned arg_size, void *arg_frame);
id objc_msgSendv(id self, SEL selector, unsigned arg_size, void *arg_frame);
@interface NSInvocation (FFICalling)
-(void)_ffiInvokeWithTarget:target;
@ -326,7 +326,7 @@ static void byteCopy(void *src,void *dst,NSUInteger length){
}
const char *returnType=[_signature methodReturnType];
void *msgSendv=objc_msg_sendv;
void *msgSendv=objc_msgSendv;
switch(returnType[0]){
case 'r':

View File

@ -1,11 +1,9 @@
# Original - Christopher Lloyd <cjwl@objc.net>
.globl objc_msg_sendv
.type objc_msg_sendv, @function
objc_msg_sendv:
.globl objc_msgSendv
.type objc_msgSendv, @function
objc_msgSendv:
pushl %ebp
movl %esp, %ebp
pushl %edx
pushl %ecx
pushl 12(%ebp)
pushl 8(%ebp)
call objc_msg_lookup
@ -21,9 +19,7 @@ done:
pushl 12(%ebp) # push _cmd
pushl 8(%ebp) # push self
call *%eax
popl %ecx
popl %edx
leave
ret
.size objc_msg_sendv, .-objc_msg_sendv
.size objc_msgSendv, .-objc_msgSendv
.ident "GCC: (GNU) 3.3.2"

View File

@ -9,7 +9,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <objc/message.h>
// how lame but this is all I need, sparc passes arguments in registers
id objc_msg_sendv(id self, SEL selector, uint32_t arg_size, void *arg_frame) {
id objc_msgSendv(id self, SEL selector, uint32_t arg_size, void *arg_frame) {
uint32_t *argWords=arg_frame;
IMP method=objc_msg_lookup(self,selector);

View File

@ -1,6 +1,6 @@
# Original - Christopher Lloyd <cjwl@objc.net>
.globl _objc_msg_sendv
_objc_msg_sendv:
.globl _objc_msgSendv
_objc_msgSendv:
pushl %ebp
movl %esp, %ebp
pushl 12(%ebp)
@ -20,5 +20,30 @@ done:
call *%eax
leave
ret
.globl _objc_msgSendv_stret
_objc_msgSendv_stret:
pushl %ebp
movl %esp, %ebp
pushl 16(%ebp) # _cmd
pushl 12(%ebp) # self
call _objc_msg_lookup
movl 20(%ebp),%ecx # ecx=argumentFrameByteSize
movl 24(%ebp),%edx # edx=argumentFrame
pushNext_stret:
subl $4,%ecx # argumentFrameByteSize-=sizeof(int)
cmpl $8,%ecx # check if we're at _cmd in argumentFrame
jle done_stret
pushl (%edx,%ecx)
jmp pushNext_stret
done_stret:
pushl 16(%ebp) # push _cmd
pushl 12(%ebp) # push self
pushl 8(%ebp) # push return value ptr
call *%eax
leave
ret
.section .drectve
.ascii " -export:objc_msg_sendv"
.ascii " -export:objc_msgSendv"
.ascii " -export:objc_msgSendv_stret"

View File

@ -31,7 +31,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-initWithData:(NSData *)data;
-initWithContentsOfFile:(NSString *)path;
-(void)tokenize;
-(BOOL)tokenize;
+(NSOldXMLDocument *)documentWithContentsOfFile:(NSString *)path;
+(NSOldXMLDocument *)documentWithData:(NSData *)data;

View File

@ -223,7 +223,7 @@ static inline BOOL codeIsNameContinue(uint8_t code){
[NSException raise:@"" format:@"Unexpected character %c in %@, position=%d",code,state,position];
}
-(void)tokenize {
-(BOOL)tokenize {
while(NSMaxRange(_range)<_length){
uint8_t code=_bytes[NSMaxRange(_range)];
@ -265,6 +265,7 @@ static inline BOOL codeIsNameContinue(uint8_t code){
}
else {
[self unexpectedIn:@"Reference"];
return NO;
}
break;
@ -280,6 +281,7 @@ static inline BOOL codeIsNameContinue(uint8_t code){
}
else {
[self unexpectedIn:@"CharRef"];
return NO;
}
break;
@ -301,8 +303,10 @@ static inline BOOL codeIsNameContinue(uint8_t code){
_state=STATE_content;
rangeAction=advanceLocationToNext;
}
else
else{
[self unexpectedIn:@"hexadecimal CharRef"];
return NO;
}
break;
case STATE_CharRef_decimal:
@ -315,8 +319,10 @@ static inline BOOL codeIsNameContinue(uint8_t code){
_state=STATE_content;
rangeAction=advanceLocationToNext;
}
else
else {
[self unexpectedIn:@"decimal CharRef"];
return NO;
}
break;
case STATE_EntityRef_Name:
@ -327,8 +333,10 @@ static inline BOOL codeIsNameContinue(uint8_t code){
_state=STATE_content;
rangeAction=advanceLocationToNext;
}
else
else {
[self unexpectedIn:@"EntityRef Name"];
return NO;
}
break;
case STATE_Tag:
@ -359,6 +367,7 @@ static inline BOOL codeIsNameContinue(uint8_t code){
}
else {
[self unexpectedIn:@"Tag"];
return NO;
}
break;
@ -408,8 +417,10 @@ static inline BOOL codeIsNameContinue(uint8_t code){
_state=STATE_content;
rangeAction=advanceLocationToNext;
}
else
else {
[self unexpectedIn:@"ETag"];
return NO;
}
break;
case STATE_Attributes:
@ -433,8 +444,10 @@ static inline BOOL codeIsNameContinue(uint8_t code){
_state=STATE_content;
rangeAction=advanceLocationToNext;
}
else
else {
[self unexpectedIn:@"EmptyElementTag"];
return NO;
}
break;
case STATE_Attribute_Name:
@ -472,8 +485,10 @@ static inline BOOL codeIsNameContinue(uint8_t code){
_state=STATE_Attribute_Value_SingleQuote;
rangeAction=advanceLocationToNext;
}
else
else {
[self unexpectedIn:@"Attribute Value"];
return NO;
}
break;
case STATE_Attribute_Value_DoubleQuote:
@ -509,13 +524,15 @@ static inline BOOL codeIsNameContinue(uint8_t code){
break;
}
}
return YES;
}
+(NSOldXMLDocument *)documentWithContentsOfFile:(NSString *)path {
NSOldXMLReader *reader=[[self alloc] initWithContentsOfFile:path];
NSOldXMLDocument *document;
[reader tokenize];
if(![reader tokenize])
return nil;
document=[[[NSOldXMLDocument alloc] init] autorelease];
[document setRootElement:[reader rootElement]];
@ -529,7 +546,8 @@ static inline BOOL codeIsNameContinue(uint8_t code){
NSOldXMLReader *reader=[[self alloc] initWithData:data];
NSOldXMLDocument *document;
[reader tokenize];
if(![reader tokenize])
return nil;
document=[[[NSOldXMLDocument alloc] init] autorelease];
[document setRootElement:[reader rootElement]];

View File

@ -33,6 +33,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-(BOOL)isEqualToPerform:(NSDelayedPerform *)other {
if(_object!=other->_object)
return NO;
if(_selector==NULL || other->_selector==NULL)
return YES;
if(_selector!=other->_selector)
return NO;
if(_argument!=other->_argument)

View File

@ -41,13 +41,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@end
typedef enum {
NSLibraryDirectory,
} NSSearchPathDirectory;
enum {
NSLibraryDirectory=5,
};
typedef enum {
NSSystemDomainMask
} NSSearchPathDomainMask;
typedef NSUInteger NSSearchPathDirectory;
enum {
NSUserDomainMask = 0x0001,
NSLocalDomainMask = 0x0002,
NSNetworkDomainMask= 0x0004,
NSSystemDomainMask = 0x0008,
NSAllDomainsMask = 0xffff,
};
typedef NSUInteger NSSearchPathDomainMask;
FOUNDATION_EXPORT NSArray *NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory d,NSSearchPathDomainMask mask,BOOL expand);

View File

@ -285,6 +285,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@end
NSArray *NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory d,NSSearchPathDomainMask mask,BOOL expand) {
NSUnimplementedFunction();
return nil;
}
NSString *NSHomeDirectory(void) {
return [[NSPlatform currentPlatform] homeDirectory];
}

View File

@ -956,14 +956,61 @@ U+2029 (Unicode paragraph separator), \r\n, in that order (also known as CRLF)
}
-(BOOL)boolValue {
NSUnimplementedMethod();
return 0;
NSUInteger i,length=[self length];
unichar buffer[length];
if(length==0)
return NO;
[self getCharacters:buffer];
NSCharacterSet *set=[NSCharacterSet whitespaceCharacterSet];
for(i=0;i<length;i++)
if(![set characterIsMember:buffer[i]])
break;
if(i==length)
return NO;
if(buffer[i]=='Y' || buffer[i]=='y' || buffer[i]=='T' || buffer[i]=='t')
return YES;
if(buffer[i]=='-' || buffer[i]=='+')
i++;
for(;i<length;i++)
if(buffer[i]!='0')
break;
if(i==length)
return NO;
if(buffer[i]>='1' && buffer[i]<='9')
return YES;
return NO;
}
-(int)intValue {
long long llvalue=[self longLongValue];
if(llvalue>INT_MAX)
llvalue=INT_MAX;
if(llvalue<INT_MIN)
llvalue=INT_MIN;
return llvalue;
}
-(NSInteger)integerValue {
return [self intValue];
}
-(long long)longLongValue {
NSUInteger pos,length=[self length];
unichar unicode[length];
int sign=1,value=0;
unichar unicode[length];
int sign=1;
long long value=0;
[self getCharacters:unicode];
@ -994,16 +1041,6 @@ U+2029 (Unicode paragraph separator), \r\n, in that order (also known as CRLF)
return sign*value;
}
-(NSInteger)integerValue {
NSUnimplementedMethod();
return 0;
}
-(long long)longLongValue {
NSUnimplementedMethod();
return 0;
}
-(float)floatValue {
return (float)[self doubleValue];
}

View File

@ -3,9 +3,9 @@
#import <Foundation/NSString.h>
#import <objc/message.h>
id objc_msg_sendv(id self, SEL selector, unsigned arg_size, void *arg_frame)
id objc_msgSendv(id self, SEL selector, unsigned arg_size, void *arg_frame)
{
[NSException raise:@"OBJCForwardingUnavailableException" format:@"Sorry, but objc_msg_sendv and forwarding including NSInvocation are unavailable on this platform."];
[NSException raise:@"OBJCForwardingUnavailableException" format:@"Sorry, but objc_msgSendv and forwarding including NSInvocation are unavailable on this platform."];
return nil;
}

View File

@ -17,6 +17,7 @@ enum {
void *_handle;
id _delegate;
NSUInteger _currentActivity;
BOOL _isValid;
}
+(NSHandleMonitor_win32 *)handleMonitorWithHandle:(void *)handle;

View File

@ -19,6 +19,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-initWithHandle:(void *)handle {
_handle=handle;
_isValid=YES;
return self;
}
@ -26,6 +27,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return _handle;
}
-(BOOL)isValid {
return _isValid;
}
-(void)invalidate {
_isValid=NO;
}
-(void)setDelegate:delegate {
_delegate=delegate;
}

View File

@ -5,6 +5,16 @@
@implementation NSLocale(windows)
BOOL NSCurrentLocaleIsMetric(){
uint16_t buffer[2];
int size=GetLocaleInfoW(LOCALE_USER_DEFAULT,LOCALE_IMEASURE,buffer,2);
if(buffer[0]=='0')
return YES;
return NO;
}
+(NSString *)_platformCurrentLocaleIdentifier {
switch(GetSystemDefaultLCID() & 0x0000FFFF)
{

View File

@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import <winsock2.h>
@interface NSSocket_windows : NSSocket {
SOCKET _handle;
SOCKET _handle;
}
-initWithSocketHandle:(SOCKET)handle;