Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

… the _plugins instanve variable.
  • Loading branch information...
commit bc9fe5b8f09d95d4d7db4d08ec917c64ab45c680 1 parent 5c07f03
@Grayson authored
View
2  src/ApplescriptPluginManager.h
@@ -16,6 +16,8 @@
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)withValue;
View
20 src/ApplescriptPluginManager.m
@@ -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];
View
2  src/FScriptPlugInManager.h
@@ -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
20 src/FScriptPlugInManager.m
@@ -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];
View
2  src/JavascriptPluginManager.h
@@ -16,6 +16,8 @@
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)value;
View
20 src/JavascriptPluginManager.m
@@ -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
2  src/LuaPluginManager.h
@@ -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
20 src/LuaPluginManager.m
@@ -11,6 +11,8 @@
@implementation LuaPluginManager
+@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])
{
LCLua *lua = [LCLua readyLua];
@@ -39,17 +47,17 @@ - (void)build
[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
2  src/NuPluginManager.h
@@ -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
20 src/NuPluginManager.m
@@ -11,6 +11,8 @@
@implementation NuPluginManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
if (NSClassFromString(@"Nu")) [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])
{
id parser = [Nu parser];
@@ -39,18 +47,18 @@ - (void)build
[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
5 src/ObjCPluginManager.h
@@ -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
15 src/ObjCPluginManager.m
@@ -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
2  src/PerlPluginManager.h
@@ -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
20 src/PerlPluginManager.m
@@ -11,6 +11,8 @@
@implementation PerlPluginManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
if (NSClassFromString(@"CBPerl")) [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])
{
CBPerl *perl = [CBPerl sharedPerl];
@@ -39,17 +47,17 @@ - (void)build
[perl eval:perlCode];
NSString *property = [perl eval:@"actionProperty();"];
if (!property) continue;
- NSMutableArray *arr = [_plugins objectForKey:property];
+ NSMutableArray *arr = [plugins objectForKey:property];
if (!arr) arr = [NSMutableArray array];
[arr addObject:perlCode];
- [_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
2  src/PythonPluginManager.h
@@ -22,6 +22,8 @@ typedef struct {
NSMutableDictionary *_plugins;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)value;
View
16 src/PythonPluginManager.m
@@ -134,6 +134,8 @@ id depythonify(PyObject *value) {
@implementation PythonPluginManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[PluginManager registerManager:[[self new] autorelease]];
@@ -155,15 +157,15 @@ - (id)init
- (void)dealloc
{
- [_plugins release];
+ self.plugins = nil;
Py_Finalize();
[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]) {
Py_SetProgramName("/usr/bin/python");
FILE *pyFile = fopen([path fileSystemRepresentation], "r");
@@ -177,17 +179,17 @@ - (void)build
PyRun_File(pyFile, [path UTF8String], Py_file_input, globals, globals);
NSString *property = [self callFunction:@"actionProperty" ofModule:mainModule arguments:nil];
- NSMutableArray *arr = [_plugins objectForKey:property];
+ NSMutableArray *arr = [plugins objectForKey:property];
if (!arr) arr = [NSMutableArray array];
[arr addObject:[NSValue valueWithPointer:mainModule]];
- [_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
2  src/RubyPluginManager.h
@@ -16,6 +16,8 @@
Class RBObject;
}
+@property (retain) NSMutableDictionary *plugins;
+
-(NSString *)name;
-(NSArray *)extensions;
-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)withValue;
View
16 src/RubyPluginManager.m
@@ -14,9 +14,11 @@ -(void)build;
@implementation RubyPluginManager
+@synthesize plugins = _plugins;
+
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
- [PluginManager registerManager:[[self new] autorelease]];
+ if (NSClassFromString(@"RBObject")) [PluginManager registerManager:[[self new] autorelease]];
[pool release];
}
@@ -37,8 +39,8 @@ -(id)init
-(void)build
{
- if (_plugins) [_plugins release];
- _plugins = [NSMutableDictionary new];
+ NSMutableDictionary *plugins = [NSMutableDictionary dictionary];
+ self.plugins = plugins;
for (NSString *scriptPath in [PluginManager pluginFilesForSubmanager:self])
{
@@ -52,10 +54,10 @@ -(void)build
// simply by calling the function name as a proxy method. Here, it'll be calling `actionProperty()`
// from the loaded script.
NSString *property = [rb actionProperty];
- NSMutableArray *arr = [_plugins objectForKey:property];
+ NSMutableArray *arr = [plugins objectForKey:property];
if (!arr) arr = [NSMutableArray array];
[arr addObject:rb];
- [_plugins setObject:arr forKey:property];
+ [plugins setObject:arr forKey:property];
}
}
@@ -63,8 +65,8 @@ -(NSString *)name { return @"Ruby"; }
-(NSArray *)extensions { return [NSArray arrayWithObject:@"rb"]; }
-(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;
NSEnumerator *pluginEnumerator = [arr objectEnumerator];
Please sign in to comment.
Something went wrong with that request. Please try again.