Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Makes some changes to add dynamic app class code generation to the pl…

…ugin manager.
  • Loading branch information...
commit b11739072bd8b0e56a7d047200564c29d130db79 1 parent a5bd805
@Grayson authored
View
2  src/ApplescriptPluginManager.h
@@ -23,3 +23,5 @@
-(id)runScriptAtPath:(NSString *)path;
@end
+
+unsigned long ASPluginAppClassCode();
View
20 src/ApplescriptPluginManager.m
@@ -12,6 +12,18 @@ @interface ApplescriptPluginManager (PrivateMethods)
-(void)build;
@end
+unsigned long ASPluginAppClassCode() {
+ NSDictionary *infoPlist = [[NSBundle mainBundle] infoDictionary];
+ NSString *sig = [infoPlist objectForKey:@"CFBundleSignature"];
+ unsigned long code = 0;
+ code += [sig characterAtIndex:0] << 24;
+ code += [sig characterAtIndex:1] << 16;
+ code += [sig characterAtIndex:2] << 8;
+ code += [sig characterAtIndex:3];
+
+ return code;
+}
+
@implementation ApplescriptPluginManager
+(void)load {
@@ -39,7 +51,7 @@ -(void)build
{
NSAppleScript *as = [NSAppleScript appleScriptWithContentsOfFile:path];
if (!as) continue;
- NSAppleEventDescriptor *desc = [NSAppleEventDescriptor appleEventWithEventClass:ASPluginAppClassCode eventID:ASPluginPropertyEventCode targetDescriptor:procDesc returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID];
+ NSAppleEventDescriptor *desc = [NSAppleEventDescriptor appleEventWithEventClass:ASPluginAppClassCode() eventID:ASPluginPropertyEventCode targetDescriptor:procDesc returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID];
id err = nil;
NSAppleEventDescriptor *ret = [as executeAppleEvent:desc error:&err];
NSLog(@"%s %@", _cmd, err);
@@ -73,10 +85,10 @@ -(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withVa
while (as = [e nextObject])
{
- NSAppleEventDescriptor *enabledDesc = [as executeEvent:ASPluginEnableEventCode eventClass:ASPluginAppClassCode parameters:parameters];
+ NSAppleEventDescriptor *enabledDesc = [as executeEvent:ASPluginEnableEventCode eventClass:ASPluginAppClassCode() parameters:parameters];
if (enabledDesc && [enabledDesc booleanValue])
{
- NSAppleEventDescriptor *desc = [as executeEvent:ASPluginTitleEventCode eventClass:ASPluginAppClassCode parameters:parameters];
+ NSAppleEventDescriptor *desc = [as executeEvent:ASPluginTitleEventCode eventClass:ASPluginAppClassCode() parameters:parameters];
if (desc)
[ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[desc stringValue], @"title",
@@ -92,7 +104,7 @@ -(void)runPlugin:(NSDictionary *)plugin forValue:(id)forValue withValue:(id)with
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
if (forValue) [parameters setObject:forValue forKey:[NSNumber numberWithUnsignedLong:ASPluginForCode]];
if (withValue) [parameters setObject:withValue forKey:[NSNumber numberWithUnsignedLong:ASPluginWithCode]];
- [[plugin objectForKey:@"applescript"] executeEvent:ASPluginPerformEventCode eventClass:ASPluginAppClassCode parameters:parameters];
+ [[plugin objectForKey:@"applescript"] executeEvent:ASPluginPerformEventCode eventClass:ASPluginAppClassCode() parameters:parameters];
}
-(id)runScriptAtPath:(NSString *)path
View
1  src/PluginManager.m
@@ -63,7 +63,6 @@ -(id)runScriptAtPath:(NSString *)path
NSString *ext = [path pathExtension];
while (m = [e nextObject])
{
- NSLog(@"%s %@", _cmd, [m extensions]);
if ([[m extensions] containsObject:ext])
return [m runScriptAtPath:path];
}
View
3  src/PluginManagerApplescriptIncludes.h
@@ -1,5 +1,4 @@
enum PluginAppleEventCodes {
- ASPluginAppClassCode = 'exPM',
ASPluginForCode = 'foR_',
ASPluginWithCode = 'wITh',
@@ -11,4 +10,4 @@ enum PluginAppleEventCodes {
};
-#define ASCodify(x) [NSNumber numberWithUnsignedLong:x]
+#define ASCodify(x) [NSNumber numberWithUnsignedLong:x]
Please sign in to comment.
Something went wrong with that request. Please try again.