diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-09 00:23:37 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-09 00:23:37 +0000 |
| commit | 391932ec56e8da5372e14726ef0aa2fb881654f2 (patch) | |
| tree | 6e57a884e06b900f8b9328b18c967891cae94789 /macosx/PcsxrPlugin.m | |
| parent | 14d7a28b25e9231965941d30471cdd32fcb5fcdd (diff) | |
| download | pcsxr-391932ec56e8da5372e14726ef0aa2fb881654f2.tar.gz | |
Since when did PcsxrPlugin.m in Xcode get marked to use spaces instead of tabs?
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85922 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/PcsxrPlugin.m')
| -rwxr-xr-x | macosx/PcsxrPlugin.m | 358 |
1 files changed, 179 insertions, 179 deletions
diff --git a/macosx/PcsxrPlugin.m b/macosx/PcsxrPlugin.m index 41909fb5..de11f378 100755 --- a/macosx/PcsxrPlugin.m +++ b/macosx/PcsxrPlugin.m @@ -85,9 +85,9 @@ + (NSArray *)pluginsPaths { - static NSArray *returnArray = nil; - if (returnArray == nil) - { + static NSArray *returnArray = nil; + if (returnArray == nil) + { NSURL *supportURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; NSURL *libraryURL = [[NSFileManager defaultManager] URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; NSURL *localSupportURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSLocalDomainMask appropriateForURL:nil create:YES error:NULL]; @@ -109,31 +109,31 @@ if ([url checkResourceIsReachableAndReturnError:NULL]) [mutArray addObject:[url path]]; returnArray = [[NSArray alloc] initWithArray:mutArray]; - } - return returnArray; + } + return returnArray; } - (id)initWithPath:(NSString *)aPath { - if (!(self = [super init])) { - return nil; - } - - PSEgetLibType PSE_getLibType = NULL; - PSEgetLibVersion PSE_getLibVersion = NULL; - PSEgetLibName PSE_getLibName = NULL; - - NSFileManager *fm = [NSFileManager defaultManager]; - - pluginRef = NULL; - name = nil; - self.path = aPath; - NSString *goodPath = nil; - if ([aPath isAbsolutePath]) { - goodPath = aPath; - } else { - long tempVers = 0; - for (NSString *plugDir in [PcsxrPlugin pluginsPaths]) + if (!(self = [super init])) { + return nil; + } + + PSEgetLibType PSE_getLibType = NULL; + PSEgetLibVersion PSE_getLibVersion = NULL; + PSEgetLibName PSE_getLibName = NULL; + + NSFileManager *fm = [NSFileManager defaultManager]; + + pluginRef = NULL; + name = nil; + self.path = aPath; + NSString *goodPath = nil; + if ([aPath isAbsolutePath]) { + goodPath = aPath; + } else { + long tempVers = 0; + for (NSString *plugDir in [PcsxrPlugin pluginsPaths]) { NSString *fullPath = [plugDir stringByAppendingPathComponent:path]; if ([fm fileExistsAtPath:fullPath]) { @@ -158,21 +158,21 @@ } } } - } - - if (goodPath == nil) { - AUTORELEASEOBJNORETURN(self); - return nil; - } - - pluginRef = SysLoadLibrary([goodPath fileSystemRepresentation]); - if (pluginRef == NULL) { - SysLibError(); - AUTORELEASEOBJNORETURN(self); - return nil; - } - - // TODO: add support for plugins with multiple functionalities??? + } + + if (goodPath == nil) { + AUTORELEASEOBJNORETURN(self); + return nil; + } + + pluginRef = SysLoadLibrary([goodPath fileSystemRepresentation]); + if (pluginRef == NULL) { + SysLibError(); + AUTORELEASEOBJNORETURN(self); + return nil; + } + + // TODO: add support for plugins with multiple functionalities??? PSE_getLibType = (PSEgetLibType) SysLoadSym(pluginRef, kPCSXRGetLibType); if (SysLibError() != nil) { if (([path rangeOfString: @"gpu" options:NSCaseInsensitiveSearch]).length != 0) @@ -198,49 +198,49 @@ return nil; } } - - PSE_getLibName = (PSEgetLibName) SysLoadSym(pluginRef, kPCSXRGetLibName); - if (SysLibError() == nil) { - self.name = @(PSE_getLibName()); - } - - PSE_getLibVersion = (PSEgetLibVersion) SysLoadSym(pluginRef, kPCSXRGetLibVersion); - if (SysLibError() == nil) { - version = PSE_getLibVersion(); - } else { - version = -1; - } - - // save the current modification date - NSDictionary *fattrs = [fm attributesOfItemAtPath:[goodPath stringByResolvingSymlinksInPath] error:NULL]; - self.modDate = [fattrs fileModificationDate]; - self.fullPlugPath = goodPath; - - active = 0; - - return self; + + PSE_getLibName = (PSEgetLibName) SysLoadSym(pluginRef, kPCSXRGetLibName); + if (SysLibError() == nil) { + self.name = @(PSE_getLibName()); + } + + PSE_getLibVersion = (PSEgetLibVersion) SysLoadSym(pluginRef, kPCSXRGetLibVersion); + if (SysLibError() == nil) { + version = PSE_getLibVersion(); + } else { + version = -1; + } + + // save the current modification date + NSDictionary *fattrs = [fm attributesOfItemAtPath:[goodPath stringByResolvingSymlinksInPath] error:NULL]; + self.modDate = [fattrs fileModificationDate]; + self.fullPlugPath = goodPath; + + active = 0; + + return self; } - (void)dealloc { - int i; - - // shutdown if we had previously been inited - for (i=0; i<32; i++) { - if (active & (1 << i)) { - [self shutdownAs:(1 << i)]; - } - } - - if (pluginRef) SysCloseLibrary(pluginRef); - + int i; + + // shutdown if we had previously been inited + for (i=0; i<32; i++) { + if (active & (1 << i)) { + [self shutdownAs:(1 << i)]; + } + } + + if (pluginRef) SysCloseLibrary(pluginRef); + #if !__has_feature(objc_arc) - self.modDate = nil; - self.path = nil; - self.name = nil; - self.fullPlugPath = nil; - - [super dealloc]; + self.modDate = nil; + self.path = nil; + self.name = nil; + self.fullPlugPath = nil; + + [super dealloc]; #endif } @@ -248,65 +248,65 @@ - (void)runCommand:(id)arg { - @autoreleasepool { - NSString *funcName = [arg objectAtIndex:0]; - long (*func)(void); - - func = SysLoadSym(pluginRef, [funcName cStringUsingEncoding:NSASCIIStringEncoding]); - if (SysLibError() == nil) { - func(); - } else { - NSBeep(); - } - - RELEASEOBJ(arg); - return; - } + @autoreleasepool { + NSString *funcName = [arg objectAtIndex:0]; + long (*func)(void); + + func = SysLoadSym(pluginRef, [funcName cStringUsingEncoding:NSASCIIStringEncoding]); + if (SysLibError() == nil) { + func(); + } else { + NSBeep(); + } + + RELEASEOBJ(arg); + return; + } } - (long)runAs:(int)aType { - long (*init)(); - long (*initArg)(long arg); - long res = PSE_ERR_FATAL; - - if ((active & aType) == aType) { - return 0; - } - - init = initArg = SysLoadSym(pluginRef, [PluginSymbolName(aType, @"init") - cStringUsingEncoding:NSASCIIStringEncoding]); - if (SysLibError() == nil) { - if (aType != PSE_LT_PAD) { - res = init(); - } else { - res = initArg(1|2); - } - } - - if (0 == res) { - active |= aType; - } else { - NSRunCriticalAlertPanel(NSLocalizedString(@"Plugin Initialization Failed!", nil), - NSLocalizedString(@"Pcsxr failed to initialize the selected %@ plugin (error=%i).\nThe plugin might not work with your system.", nil), - nil, nil, nil, [PcsxrPlugin prefixForType:aType], res); - } - - return res; + long (*init)(); + long (*initArg)(long arg); + long res = PSE_ERR_FATAL; + + if ((active & aType) == aType) { + return 0; + } + + init = initArg = SysLoadSym(pluginRef, [PluginSymbolName(aType, @"init") + cStringUsingEncoding:NSASCIIStringEncoding]); + if (SysLibError() == nil) { + if (aType != PSE_LT_PAD) { + res = init(); + } else { + res = initArg(1|2); + } + } + + if (0 == res) { + active |= aType; + } else { + NSRunCriticalAlertPanel(NSLocalizedString(@"Plugin Initialization Failed!", nil), + NSLocalizedString(@"Pcsxr failed to initialize the selected %@ plugin (error=%i).\nThe plugin might not work with your system.", nil), + nil, nil, nil, [PcsxrPlugin prefixForType:aType], res); + } + + return res; } - (long)shutdownAs:(int)aType { - long (*shutdown)(void); - - shutdown = SysLoadSym(pluginRef, [PluginSymbolName(aType, @"shutdown") - cStringUsingEncoding:NSASCIIStringEncoding]); - if (SysLibError() == nil) { - active &= ~aType; - return shutdown(); - } - - return PSE_ERR_FATAL; + long (*shutdown)(void); + + shutdown = SysLoadSym(pluginRef, [PluginSymbolName(aType, @"shutdown") + cStringUsingEncoding:NSASCIIStringEncoding]); + if (SysLibError() == nil) { + active &= ~aType; + return shutdown(); + } + + return PSE_ERR_FATAL; } #define PluginSymbolNameConfigure(type) PluginSymbolName(type, @"configure") @@ -314,94 +314,94 @@ - (BOOL)hasAboutAs:(int)aType { - SysLoadSym(pluginRef, [PluginSymbolNameAbout(aType) - cStringUsingEncoding:NSASCIIStringEncoding]); - - return (SysLibError() == nil); + SysLoadSym(pluginRef, [PluginSymbolNameAbout(aType) + cStringUsingEncoding:NSASCIIStringEncoding]); + + return (SysLibError() == nil); } - (BOOL)hasConfigureAs:(int)aType { - SysLoadSym(pluginRef, [PluginSymbolNameConfigure(aType) - cStringUsingEncoding:NSASCIIStringEncoding]); - - return (SysLibError() == nil); + SysLoadSym(pluginRef, [PluginSymbolNameConfigure(aType) + cStringUsingEncoding:NSASCIIStringEncoding]); + + return (SysLibError() == nil); } - (void)aboutAs:(int)aType { - NSArray *arg; - - NSString *aboutSym = PluginSymbolNameAbout(aType); - arg = @[aboutSym, @0]; - RETAINOBJNORETURN(arg); - - // detach a new thread - [NSThread detachNewThreadSelector:@selector(runCommand:) toTarget:self - withObject:arg]; - //NOTE: the runCommand releases the arg command. Probably not the best way to do it... - //This is not an issue with ARC (64-bit) code + NSArray *arg; + + NSString *aboutSym = PluginSymbolNameAbout(aType); + arg = @[aboutSym, @0]; + RETAINOBJNORETURN(arg); + + // detach a new thread + [NSThread detachNewThreadSelector:@selector(runCommand:) toTarget:self + withObject:arg]; + //NOTE: the runCommand releases the arg command. Probably not the best way to do it... + //This is not an issue with ARC (64-bit) code } - (void)configureAs:(int)aType { - NSArray *arg; - - NSString *configSym = PluginSymbolNameConfigure(aType); - arg = @[configSym, @1]; - RETAINOBJNORETURN(arg); - - // detach a new thread - [NSThread detachNewThreadSelector:@selector(runCommand:) toTarget:self - withObject:arg]; - //NOTE: the runCommand releases the arg command. Probably not the best way to do it... - //This is not an issue with ARC (64-bit) code + NSArray *arg; + + NSString *configSym = PluginSymbolNameConfigure(aType); + arg = @[configSym, @1]; + RETAINOBJNORETURN(arg); + + // detach a new thread + [NSThread detachNewThreadSelector:@selector(runCommand:) toTarget:self + withObject:arg]; + //NOTE: the runCommand releases the arg command. Probably not the best way to do it... + //This is not an issue with ARC (64-bit) code } - (NSString *)displayVersion { - if (version == -1) - return @""; - - return [NSString stringWithFormat:@"v%ld.%ld.%ld", version>>16,(version>>8)&0xff,version&0xff]; + if (version == -1) + return @""; + + return [NSString stringWithFormat:@"v%ld.%ld.%ld", version>>16,(version>>8)&0xff,version&0xff]; } - (int)type { - return type; + return type; } - (NSUInteger)hash { - return [path hash]; + return [path hash]; } - (NSString *)description { - if (name == nil) - return [path lastPathComponent]; - - return [NSString stringWithFormat:@"%@ %@ [%@]", name, [self displayVersion], [path lastPathComponent]]; + if (name == nil) + return [path lastPathComponent]; + + return [NSString stringWithFormat:@"%@ %@ [%@]", name, [self displayVersion], [path lastPathComponent]]; } - (NSString*)debugDescription { - if (name == nil) { - return fullPlugPath; - } - return [NSString stringWithFormat:@"%@, %@ [%@]", name, [self displayVersion], fullPlugPath]; + if (name == nil) { + return fullPlugPath; + } + return [NSString stringWithFormat:@"%@, %@ [%@]", name, [self displayVersion], fullPlugPath]; } // the plugin will check if it's still valid and return the status - (BOOL)verifyOK { - // check that the file is still there with the same modification date - NSFileManager *dfm = [NSFileManager defaultManager]; - if (![dfm fileExistsAtPath:fullPlugPath]) - return NO; - - NSDictionary *fattrs = [dfm attributesOfItemAtPath:[fullPlugPath stringByResolvingSymlinksInPath] error:NULL]; - return [[fattrs fileModificationDate] isEqualToDate:modDate]; + // check that the file is still there with the same modification date + NSFileManager *dfm = [NSFileManager defaultManager]; + if (![dfm fileExistsAtPath:fullPlugPath]) + return NO; + + NSDictionary *fattrs = [dfm attributesOfItemAtPath:[fullPlugPath stringByResolvingSymlinksInPath] error:NULL]; + return [[fattrs fileModificationDate] isEqualToDate:modDate]; } @end |
