Permalink
Browse files

Plugin submanagers now have a dealloc method and cleaned up access to…

… the _plugins instanve variable.
  • Loading branch information...
1 parent 5c07f03 commit bc9fe5b8f09d95d4d7db4d08ec917c64ab45c680 @Grayson committed Feb 13, 2009
@@ -16,6 +16,8 @@
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)withValue;
@@ -27,6 +27,8 @@ unsigned long ASPluginAppClassCode() {
@implementation ApplescriptPluginManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[PluginManager registerManager:[[self new] autorelease]];
@@ -41,10 +43,16 @@ -(id)init
return self;
}
+- (void)dealloc
+{
+ self.plugins = nil;
+ [super dealloc];
+}
+
-(void)build
{
- if (_plugins) [_plugins release];
- _plugins = [NSMutableDictionary new];
+ NSMutableDictionary *plugins = [NSMutableDictionary dictionary];
+ [self setPlugins:plugins];
NSArray *foundPlugins = [PluginManager pluginFilesForSubmanager:self];
NSAppleEventDescriptor *procDesc = [NSAppleScript processDescriptor];
@@ -59,10 +67,10 @@ -(void)build
if (ret)
{
NSString *property = [ret stringValue];
- NSMutableArray *arr = [_plugins objectForKey:property];
+ NSMutableArray *arr = [plugins objectForKey:property];
if (!arr) arr = [NSMutableArray array];
[arr addObject:as];
- [_plugins setObject:arr forKey:property];
+ [plugins setObject:arr forKey:property];
}
}
}
@@ -71,8 +79,8 @@ -(NSString *)name { return @"Applescript"; }
-(NSArray *)extensions { return [NSArray arrayWithObject:@"scpt"]; }
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)withValue
{
- if (!_plugins) [self build];
- NSArray *arr = [_plugins objectForKey:property];
+ if ([self plugins]) [self build];
+ NSArray *arr = [[self plugins] objectForKey:property];
if (!arr || ![arr count]) return nil;
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
@@ -15,6 +15,8 @@
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)value;
View
@@ -11,6 +11,8 @@
@implementation FScriptPlugInManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
// Assume that the framework exists if strings can respond to `asBlock`.
@@ -30,10 +32,16 @@ - (id)init
return self;
}
+- (void)dealloc
+{
+ [self setPlugins:nil];
+ [super dealloc];
+}
+
- (void)build
{
- if (_plugins) [_plugins release];
- _plugins = [NSMutableDictionary new];
+ NSMutableDictionary *plugins = [NSMutableDictionary dictionary];
+ self.plugins = plugins;
for (NSString *path in [PluginManager pluginFilesForSubmanager:self])
{
FSInterpreter *interpreter = [FSInterpreter interpreter];
@@ -49,18 +57,18 @@ - (void)build
NSString *property = [b value];
if (property && [property isKindOfClass:[NSString class]])
{
- NSMutableArray *arr = [_plugins objectForKey:property];
+ NSMutableArray *arr = [plugins objectForKey:property];
if (!arr) arr = [NSMutableArray array];
[arr addObject:interpreter];
- [_plugins setObject:arr forKey:property];
+ [plugins setObject:arr forKey:property];
}
}
}
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)withValue
{
- if (!_plugins) [self build];
- NSArray *plugins = [_plugins objectForKey:property];
+ if (!self.plugins) [self build];
+ NSArray *plugins = [self.plugins objectForKey:property];
if (!plugins || ![plugins count]) return nil;
NSEnumerator *pluginEnumerator = [plugins objectEnumerator];
@@ -16,6 +16,8 @@
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)value;
@@ -11,6 +11,8 @@
@implementation JavascriptPluginManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[PluginManager registerManager:[[self new] autorelease]];
@@ -28,10 +30,16 @@ - (id)init
return self;
}
+- (void)dealloc
+{
+ self.plugins = nil;
+ [super dealloc];
+}
+
- (void)build
{
- if (_plugins) [_plugins release];
- _plugins = [NSMutableDictionary new];
+ NSMutableDictionary *plugins = [NSMutableDictionary dictionary];
+ self.plugins = plugins;
for (NSString *path in [PluginManager pluginFilesForSubmanager:self])
{
@@ -47,17 +55,17 @@ - (void)build
NSString *property;
if (![JSCocoaFFIArgument unboxJSValueRef:value toObject:&property inContext:[controller ctx]]) continue;
- NSMutableArray *arr = [_plugins objectForKey:property];
+ NSMutableArray *arr = [plugins objectForKey:property];
if (!arr) arr = [NSMutableArray array];
[arr addObject:controller];
- [_plugins setObject:arr forKey:property];
+ [plugins setObject:arr forKey:property];
}
}
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)withValue
{
- if (!_plugins) [self build];
- NSArray *plugins = [_plugins objectForKey:property];
+ if (!self.plugins) [self build];
+ NSArray *plugins = [self.plugins objectForKey:property];
if (!plugins || ![plugins count]) return nil;
NSEnumerator *pluginEnumerator = [plugins objectEnumerator];
View
@@ -15,6 +15,8 @@
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)value;
View
@@ -11,6 +11,8 @@
@implementation LuaPluginManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[PluginManager registerManager:[[self new] autorelease]];
@@ -28,28 +30,34 @@ - (id)init
return self;
}
+- (void)dealloc
+{
+ self.plugins = nil;
+ [super dealloc];
+}
+
- (void)build
{
- if (_plugins) [_plugins release];
- _plugins = [NSMutableDictionary new];
+ NSMutableDictionary *plugins = [NSMutableDictionary dictionary];
+ self.plugins = plugins;
for (NSString *path in [PluginManager pluginFilesForSubmanager:self])
{
LCLua *lua = [LCLua readyLua];
NSString *luaCode = [NSString stringWithContentsOfFile:path];
[lua runFileAtPath:path];
NSString *property = [lua callEmptyFunctionNamed:@"actionProperty" expectReturnValue:YES];
- NSMutableArray *arr = [_plugins objectForKey:property];
+ NSMutableArray *arr = [plugins objectForKey:property];
if (!arr) arr = [NSMutableArray array];
[arr addObject:luaCode];
- [_plugins setObject:arr forKey:property];
+ [plugins setObject:arr forKey:property];
}
}
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)withValue
{
- if (!_plugins) [self build];
- NSArray *plugins = [_plugins objectForKey:property];
+ if (!self.plugins) [self build];
+ NSArray *plugins = [self.plugins objectForKey:property];
if (!plugins || ![plugins count]) return nil;
NSEnumerator *pluginEnumerator = [plugins objectEnumerator];
View
@@ -15,6 +15,8 @@
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)value;
View
@@ -11,6 +11,8 @@
@implementation NuPluginManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
if (NSClassFromString(@"Nu")) [PluginManager registerManager:[[self new] autorelease]];
@@ -28,29 +30,35 @@ - (id)init
return self;
}
+- (void)dealloc
+{
+ self.plugins = nil;
+ [super dealloc];
+}
+
- (void)build
{
- if (_plugins) [_plugins release];
- _plugins = [NSMutableDictionary new];
+ NSMutableDictionary *plugins = [NSMutableDictionary dictionary];
+ self.plugins = plugins;
for (NSString *path in [PluginManager pluginFilesForSubmanager:self])
{
id parser = [Nu parser];
NSString *nuCode = [NSString stringWithContentsOfFile:path];
[parser parseEval:nuCode];
NSString *property = [parser parseEval:@"(actionProperty)"];
- NSMutableArray *arr = [_plugins objectForKey:property];
+ NSMutableArray *arr = [plugins objectForKey:property];
if (!arr) arr = [NSMutableArray array];
[arr addObject:nuCode];
- [_plugins setObject:arr forKey:property];
+ [plugins setObject:arr forKey:property];
[parser close];
}
}
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)withValue
{
- if (!_plugins) [self build];
- NSArray *plugins = [_plugins objectForKey:property];
+ if (!self.plugins) [self build];
+ NSArray *plugins = [self.plugins objectForKey:property];
if (!plugins || ![plugins count]) return nil;
NSEnumerator *pluginEnumerator = [plugins objectEnumerator];
View
@@ -19,6 +19,8 @@ enum {
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)value;
@@ -27,9 +29,6 @@ enum {
-(BOOL)canRunAsScript;
-- (NSMutableDictionary *)plugins;
-- (void)setPlugins:(NSMutableDictionary *)aValue;
-
@end
@protocol ObjCPlugin
View
@@ -11,6 +11,8 @@
@implementation ObjCPluginManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[PluginManager registerManager:[[self new] autorelease]];
@@ -30,7 +32,7 @@ - (id)init
- (void)dealloc
{
- [self setPlugins:nil];
+ self.plugins = nil;
[super dealloc];
}
@@ -135,16 +137,5 @@ -(id)runScriptAtPath:(NSString *)path
-(BOOL)canRunAsScript { return YES; }
-- (NSMutableDictionary *)plugins
-{
- return _plugins;
-}
-
-- (void)setPlugins:(NSMutableDictionary *)aValue
-{
- NSMutableDictionary *oldPlugins = _plugins;
- _plugins = [aValue retain];
- [oldPlugins release];
-}
@end
View
@@ -15,6 +15,8 @@
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)value;
Oops, something went wrong.

0 comments on commit bc9fe5b

Please sign in to comment.