Skip to content
Browse files

Cleans up a few dumb mistakes in ObjCPluginManager.

  • Loading branch information...
1 parent da78bc0 commit 8f27ece4a8c98102ac4ae061b37c3567a3dd4abe @Grayson committed Feb 5, 2009
Showing with 8 additions and 9 deletions.
  1. +1 −3 src/ObjCPluginManager.h
  2. +7 −6 src/ObjCPluginManager.m
View
4 src/ObjCPluginManager.h
@@ -13,7 +13,7 @@
enum {
ObjCPMBundleLoadError = 1,
ObjCPMClassLoadError = 2
-}
+};
@interface ObjCPluginManager : NSObject <PluginManagerProtocol> {
NSMutableDictionary *_plugins;
@@ -33,11 +33,9 @@ enum {
@end
@protocol ObjCPlugin
-
-(NSString *)actionProperty;
-(BOOL)actionEnableForValue:(id)forValue withValue:(id)withValue;
-(NSString *)actionTitleForValue:(id)forValue withValue:(id)withValue;
-(void)actionPerformForValue:(id)forValue withValue:(id)withValue;
-(id)run;
-
@end
View
13 src/ObjCPluginManager.m
@@ -31,6 +31,7 @@ - (id)init
- (void)dealloc
{
[self setPlugins:nil];
+ [super dealloc];
}
- (void)build
@@ -47,17 +48,17 @@ - (void)build
if (![fm fileExistsAtPath:pluginsPath isDirectory:&isFolder] || !isFolder) return;
// Add all of the plugins available in either the plugins folder in Application Support or in the bundle resources
- NSArray *plugins = [fm directoryContentsAtPath:pluginsPath];
- plugins = [plugins arrayByAddingObjectsFromArray:[fm directoryContentsAtPath:[[NSBundle mainBundle] pathForResource:@"Plug-Ins" ofType:nil]]];
- NSEnumerator *pluginEnumerator = [plugins objectEnumerator];
+ NSArray *foundPlugins = [fm directoryContentsAtPath:pluginsPath];
+ foundPlugins = [foundPlugins arrayByAddingObjectsFromArray:[fm directoryContentsAtPath:[[NSBundle mainBundle] pathForResource:@"Plug-Ins" ofType:nil]]];
+ NSEnumerator *pluginEnumerator = [foundPlugins objectEnumerator];
NSString *path;
NSArray *extensions = [self extensions];
while (path = [pluginEnumerator nextObject])
{
if (![extensions containsObject:[path pathExtension]]) continue;
NSBundle *b = [NSBundle bundleWithPath:path];
- if (!b) goto next;
+ if (!b) continue;
Class c = [b principalClass];
if (![c conformsToProtocol:@protocol(ObjCPlugin)]) continue;
@@ -105,7 +106,7 @@ -(id)runScriptAtPath:(NSString *)path
if (!path) return nil;
NSMutableDictionary *plugins = [self plugins];
if (!plugins) plugins = [NSMutableDictionary dictionary];
- id plugin = [plugins objectForKey:path];
+ id<ObjCPlugin> plugin = [plugins objectForKey:path];
unsigned int errorCode = 0;
NSString *errorString = nil;
if (!plugin) {
@@ -121,7 +122,7 @@ -(id)runScriptAtPath:(NSString *)path
errorCode = ObjCPMClassLoadError;
goto error;
}
- if (![plugin respondsToSelector:@selector(run)]) {
+ if (![(id)plugin respondsToSelector:@selector(run)]) {
errorString = [NSString stringWithFormat:NSLocalizedString(@"Loaded bundle at path '%@' does not respond to -(id)run.", @"error message"), path];
errorCode = 3;
goto error;

0 comments on commit 8f27ece

Please sign in to comment.
Something went wrong with that request. Please try again.