Low-Level runtime fixes

- void* in NSGetSizeAndAlignment
- removed implementation of NSProxy +respondsToSelector
- some objc_ methods
- NSBundle executablePath and NSTask launchedTask
This commit is contained in:
Johannes Fortmann 2008-04-16 11:12:40 +00:00
parent 8c40b0c046
commit 6f0008345b
11 changed files with 61 additions and 14 deletions

View File

@ -125,9 +125,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
_accessoryView=view;
}
@end
@implementation NSSavePanel (PanelSheet)
#pragma mark -
#pragma mark Sheet methods
- (void)beginSheetForDirectory:(NSString *)path
file:(NSString *)name
modalForWindow:(NSWindow *)docWindow

View File

@ -265,10 +265,7 @@ static NSMapTable *pathToObject=NULL;
NSUnimplementedMethod();
return 0;
}
-(NSString *)executablePath {
NSUnimplementedMethod();
return 0;
}
-(NSArray *)localizations {
NSUnimplementedMethod();
return 0;
@ -361,17 +358,20 @@ static NSMapTable *pathToObject=NULL;
return [[_path stringByAppendingPathComponent:name] stringByAppendingPathExtension:loadableObjectFileExtension];
}
-(NSString *)executablePath {
return [_path stringByAppendingPathComponent:[self _findExecutable]];
}
-(BOOL)load {
if(!_isLoaded){
NSString *load=[self _findExecutable];
_isLoaded=YES;
if(NSLoadModule([load fileSystemRepresentation]) == NULL){
NSLog(@"load of %@ FAILED",load);
return NO;
}
}
_isLoaded=YES;
return YES;
}

View File

@ -150,7 +150,11 @@ void NSSetUncaughtExceptionHandler(NSUncaughtExceptionHandler *proc) {
@end
void __gnu_objc_personality_sj0()
{
printf("shouldn't get here");
abort();
}
void objc_exception_try_enter(void* exceptionFrame)
{

View File

@ -41,6 +41,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
}
-initWithMethodSignature:(NSMethodSignature *)signature {
if(!signature)
{
[NSException raise:NSInvalidArgumentException
format:@"nil signature in NSInvocation creation"];
}
_signature=[signature retain];
[self buildFrame];
@ -211,7 +217,9 @@ static void byteCopy(void *src,void *dst,unsigned length){
}
else
{
[NSException raise:NSInvalidArgumentException format:@"Unable to convert naturalSize=%d to promotedSize=%d",naturalSize,promotedSize];
}
}
@ -232,7 +240,10 @@ static void byteCopy(void *src,void *dst,unsigned length){
byteCopy(promoted,_argumentFrame+_argumentOffsets[index],promotedSize);
}
else
{
*(char*)0=0;
[NSException raise:NSInvalidArgumentException format:@"Unable to convert naturalSize=%d to promotedSize=%d",naturalSize,promotedSize];
}
}
-(void)retainArguments {

View File

@ -72,7 +72,7 @@ static NSMapTable *_cache=NULL;
first=NO;
while((*next>='0' && *next<='9') || *next=='+' || *next=='-')
while((*next>='0' && *next<='9') || *next=='+' || *next=='-' || *next=='?')
next++;
if(*next=='\0')

View File

@ -164,6 +164,10 @@ const char *NSGetSizeAndAlignment(const char *type,unsigned *size,
*size=sizeof(SEL);
quit=YES;
break;
case '?':
*size=0;
quit=YES;
case '[':
{
@ -217,6 +221,7 @@ const char *NSGetSizeAndAlignment(const char *type,unsigned *size,
type++;
type=NSGetSizeAndAlignment(type,&subsize,&subalignment);
type--;
*size=sizeof(void*);
quit=YES;
break;

View File

@ -25,10 +25,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return self;
}
/*
FIXME: should we implement this? The Apple implementation does _not_ throw an exception, so we may not, either
+(BOOL)respondsToSelector:(SEL)selector {
NSUnimplementedMethod();
return NO;
}
*/
+allocWithZone:(NSZone *)zone {
return NSAllocateObject(self,0,zone);

View File

@ -24,8 +24,11 @@ NSString *NSTaskDidTerminateNotification=@"NSTaskDidTerminateNotification";
}
+(NSTask *)launchedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments {
NSUnimplementedMethod();
return nil;
NSTask *task=[[NSTask new] autorelease];
[task setLaunchPath:path];
[task setArguments:arguments];
[task launch];
return task;
}
-init {

View File

@ -50,6 +50,23 @@ void objc_addClass(Class class) {
OBJCRegisterClass(class);
}
Method class_getClassMethod(Class class, SEL selector)
{
return OBJCLookupUniqueIdInClass(class, selector);
}
int objc_getClassList(Class *buffer, int bufferLen)
{
OBJCHashEnumerator classes=OBJCEnumerateHashTable(OBJCClassTable());
int i;
for(i=0; i<bufferLen; i++)
buffer[i]=(Class)OBJCNextHashEnumeratorValue(&classes);
for(;OBJCNextHashEnumeratorValue(&classes)!=0; i++)
;
i--;
return i;
}
// I think this is generated by the compiler
// to get the class pre-posing, since we don't support posing
// just use the normal thing
@ -209,7 +226,7 @@ void OBJCInitializeClass(Class class) {
if(!(class->info&CLASS_INFO_INITIALIZED)) {
SEL selector=@selector(initialize);
struct objc_method *method=OBJCLookupUniqueIdInOnlyThisClass(class->isa,OBJCSelectorUniqueId(selector));
struct objc_method *method=OBJCLookupUniqueIdInClass(class->isa,OBJCSelectorUniqueId(selector));
class->info|=CLASS_INFO_INITIALIZED;

View File

@ -34,4 +34,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#endif
#ifndef typeof
#define typeof __typeof
#endif
#import <objc/objc.h>

View File

@ -28,6 +28,7 @@ enum {
_C_UINT='I',
_C_FLT='f',
_C_DBL='d',
_C_VOID='v'
};
typedef struct objc_ivar {