Skip to content
Browse files

More weirdness with RB support, but there's decent work on the start …

…of a Perl plugin manager.
  • Loading branch information...
1 parent afc45ac commit 3acabfd5f3de5b3759cb9875447314daae18af47 @Grayson committed
View
20 ExampleApplication/Example.pl
@@ -0,0 +1,20 @@
+use Foundation;
+
+sub actionProperty {
+ return "label-click";
+}
+
+sub actionEnable {
+ my ($withValue, $forValue) = @_;
+ return 1;
+}
+
+sub actionTitle {
+ my ($withValue, $forValue) = @_;
+ return "Perl example";
+}
+
+sub actionPerform {
+ my ($withValue, $forValue) = @_;
+ print($withValue);
+}
View
5 ExampleApplication/Example.rb
@@ -1,8 +1,3 @@
-# begin
-# require "osx/cocoa"
-# rescue Exception=>e
-# puts "Caught an exception"
-# end
def actionProperty
return "label-click"
end
View
49 ExampleApplication/ExampleApplication.xcodeproj/ghansard.mode1v3
@@ -250,8 +250,6 @@
<key>Layout</key>
<array>
<dict>
- <key>BecomeActive</key>
- <true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXBottomSmartGroupGIDs</key>
@@ -293,16 +291,20 @@
<string>080E96DDFE201D6D7F000001</string>
<string>29B97323FDCFA39411CA2CEA</string>
<string>1C37FBAC04509CD000000102</string>
+ <string>1C37FAAC04509CD000000102</string>
<string>1C37FABC05509CD000000102</string>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
- <integer>36</integer>
+ <integer>5</integer>
+ <integer>2</integer>
+ <integer>1</integer>
+ <integer>0</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
- <string>{{0, 410}, {186, 338}}</string>
+ <string>{{0, 0}, {186, 338}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@@ -366,6 +368,8 @@
<string>0pt</string>
</dict>
<dict>
+ <key>BecomeActive</key>
+ <true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXProjectModuleGUID</key>
@@ -402,9 +406,9 @@
</array>
<key>TableOfContents</key>
<array>
- <string>1DF38D6D0F3DE90700431004</string>
+ <string>1DF38E640F3E2C9100431004</string>
<string>1CE0B1FE06471DED0097A5F4</string>
- <string>1DF38D6E0F3DE90700431004</string>
+ <string>1DF38E650F3E2C9100431004</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
@@ -523,7 +527,7 @@
<key>StatusbarIsVisible</key>
<true/>
<key>TimeStamp</key>
- <real>255718078.155727</real>
+ <real>255739613.264743</real>
<key>ToolbarDisplayMode</key>
<integer>1</integer>
<key>ToolbarIsVisible</key>
@@ -538,10 +542,9 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
- <string>1C530D57069F1CE1000CFCEE</string>
<string>1CD10A99069EF8BA00B06720</string>
- <string>1C78EAAD065D492600B07095</string>
<string>1DC323630F3B75AF0011E197</string>
+ <string>1C78EAAD065D492600B07095</string>
<string>/Users/ghansard/Projects/github/PluginManager/ExampleApplication/ExampleApplication.xcodeproj</string>
</array>
<key>WindowString</key>
@@ -624,7 +627,7 @@
<key>TableOfContents</key>
<array>
<string>1DC323630F3B75AF0011E197</string>
- <string>1DF38D7E0F3DEA1800431004</string>
+ <string>1DF38E620F3E2C8E00431004</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>
@@ -635,7 +638,7 @@
<key>WindowToolGUID</key>
<string>1DC323630F3B75AF0011E197</string>
<key>WindowToolIsVisible</key>
- <true/>
+ <false/>
</dict>
<dict>
<key>FirstTimeWindowDisplayed</key>
@@ -666,8 +669,8 @@
<string>yes</string>
<key>sizes</key>
<array>
- <string>{{0, 0}, {316, 201}}</string>
- <string>{{316, 0}, {378, 201}}</string>
+ <string>{{0, 0}, {316, 202}}</string>
+ <string>{{316, 0}, {378, 202}}</string>
</array>
</dict>
<key>VerticalSplitView</key>
@@ -682,8 +685,8 @@
<string>yes</string>
<key>sizes</key>
<array>
- <string>{{0, 0}, {694, 201}}</string>
- <string>{{0, 201}, {694, 180}}</string>
+ <string>{{0, 0}, {694, 202}}</string>
+ <string>{{0, 202}, {694, 179}}</string>
</array>
</dict>
</dict>
@@ -716,7 +719,7 @@
<real>148</real>
</array>
<key>Frame</key>
- <string>{{316, 0}, {378, 201}}</string>
+ <string>{{316, 0}, {378, 202}}</string>
<key>RubberWindowFrame</key>
<string>373 433 694 422 0 0 1440 878 </string>
</dict>
@@ -744,13 +747,13 @@
<key>TableOfContents</key>
<array>
<string>1CD10A99069EF8BA00B06720</string>
- <string>1DF38D6F0F3DE90700431004</string>
+ <string>1DF38E660F3E2C9100431004</string>
<string>1C162984064C10D400B95A72</string>
- <string>1DF38D700F3DE90700431004</string>
- <string>1DF38D710F3DE90700431004</string>
- <string>1DF38D720F3DE90700431004</string>
- <string>1DF38D730F3DE90700431004</string>
- <string>1DF38D740F3DE90700431004</string>
+ <string>1DF38E670F3E2C9100431004</string>
+ <string>1DF38E680F3E2C9100431004</string>
+ <string>1DF38E690F3E2C9100431004</string>
+ <string>1DF38E6A0F3E2C9100431004</string>
+ <string>1DF38E6B0F3E2C9100431004</string>
</array>
<key>ToolbarConfiguration</key>
<string>xcode.toolbar.config.debugV3</string>
@@ -904,7 +907,7 @@
<key>TableOfContents</key>
<array>
<string>1C78EAAD065D492600B07095</string>
- <string>1DF38D7F0F3DEA1800431004</string>
+ <string>1DF38E630F3E2C8E00431004</string>
<string>1C78EAAC065D492600B07095</string>
</array>
<key>ToolbarConfiguration</key>
View
74 ExampleApplication/ExampleApplication.xcodeproj/ghansard.pbxuser
@@ -141,62 +141,12 @@
speakMessage = 0;
useDebuggerSideImplementation = 0;
};
- 1DF38D830F3DEAC300431004 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 1DC323D10F3B77D80011E197 /* ExamplePlugin.m */;
- name = "ExamplePlugin.m: 21";
- rLen = 5;
- rLoc = 572;
- rType = 0;
- vrLen = 393;
- vrLoc = 220;
- };
- 1DF38D840F3DEAC300431004 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 1DC323EB0F3B795E0011E197 /* ExampleController.m */;
- name = "ExampleController.m: 35";
- rLen = 0;
- rLoc = 1079;
- rType = 0;
- vrLen = 580;
- vrLoc = 840;
- };
- 1DF38D850F3DEAC300431004 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 1DC322F80F3B74FA0011E197 /* ApplescriptPluginManager.m */;
- rLen = 0;
- rLoc = 2410;
- rType = 0;
- };
- 1DF38D860F3DEAC300431004 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 1DC323D10F3B77D80011E197 /* ExamplePlugin.m */;
- name = "ExamplePlugin.m: 21";
- rLen = 5;
- rLoc = 572;
- rType = 0;
- vrLen = 393;
- vrLoc = 220;
- };
- 1DF38D870F3DEAC300431004 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 1DC323EB0F3B795E0011E197 /* ExampleController.m */;
- name = "ExampleController.m: 35";
- rLen = 0;
- rLoc = 1079;
- rType = 0;
- vrLen = 580;
- vrLoc = 840;
- };
- 1DF38D880F3DEAC300431004 /* PBXTextBookmark */ = {
- isa = PBXTextBookmark;
- fRef = 1DC322F80F3B74FA0011E197 /* ApplescriptPluginManager.m */;
- name = "ApplescriptPluginManager.m: 89";
- rLen = 0;
- rLoc = 2914;
- rType = 0;
- vrLen = 542;
- vrLoc = 3099;
+ 1DF38DE40F3E19DF00431004 /* PerlPluginManager.m */ = {
+ uiCtxt = {
+ sepNavIntBoundsRect = "{{0, 0}, {439, 1540}}";
+ sepNavSelRange = "{2785, 0}";
+ sepNavVisRange = "{231, 344}";
+ };
};
29B97313FDCFA39411CA2CEA /* Project object */ = {
activeArchitecture = i386;
@@ -310,16 +260,8 @@
PBXFileDataSource_Warnings_ColumnID,
);
};
- PBXPerProjectTemplateStateSaveDate = 255715561;
- PBXWorkspaceStateSaveDate = 255715561;
- };
- perUserProjectItems = {
- 1DF38D830F3DEAC300431004 /* PBXTextBookmark */ = 1DF38D830F3DEAC300431004 /* PBXTextBookmark */;
- 1DF38D840F3DEAC300431004 /* PBXTextBookmark */ = 1DF38D840F3DEAC300431004 /* PBXTextBookmark */;
- 1DF38D850F3DEAC300431004 /* PBXTextBookmark */ = 1DF38D850F3DEAC300431004 /* PBXTextBookmark */;
- 1DF38D860F3DEAC300431004 /* PBXTextBookmark */ = 1DF38D860F3DEAC300431004 /* PBXTextBookmark */;
- 1DF38D870F3DEAC300431004 /* PBXTextBookmark */ = 1DF38D870F3DEAC300431004 /* PBXTextBookmark */;
- 1DF38D880F3DEAC300431004 /* PBXTextBookmark */ = 1DF38D880F3DEAC300431004 /* PBXTextBookmark */;
+ PBXPerProjectTemplateStateSaveDate = 255732864;
+ PBXWorkspaceStateSaveDate = 255732864;
};
sourceControlManager = 1DC322F40F3B747D0011E197 /* Source Control */;
userBuildSettings = {
View
22 ExampleApplication/ExampleApplication.xcodeproj/project.pbxproj
@@ -18,16 +18,13 @@
1DC323EC0F3B795E0011E197 /* ExampleController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DC323EB0F3B795E0011E197 /* ExampleController.m */; };
1DC3242E0F3B87190011E197 /* Example.scpt in Copy plugins */ = {isa = PBXBuildFile; fileRef = 1DC3242B0F3B870C0011E197 /* Example.scpt */; };
1DC324320F3B89D30011E197 /* ExampleApplication.sdef in Resources */ = {isa = PBXBuildFile; fileRef = 1DC324310F3B89D30011E197 /* ExampleApplication.sdef */; };
- 1DD73B2E0F3CA0DE00552B38 /* Example.rb in Copy plugins */ = {isa = PBXBuildFile; fileRef = 1DD73B270F3CA06500552B38 /* Example.rb */; };
1DD73BBF0F3CD14200552B38 /* PythonPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DC323080F3B74FA0011E197 /* PythonPluginManager.m */; };
1DD73BC20F3CD19700552B38 /* Python.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DC3234F0F3B752B0011E197 /* Python.framework */; };
1DD73BF90F3CD78100552B38 /* FScript.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DC323150F3B751A0011E197 /* FScript.framework */; };
1DD73BFA0F3CD78300552B38 /* JSCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DC323160F3B751A0011E197 /* JSCocoa.framework */; };
1DD73BFB0F3CD78300552B38 /* LuaCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DC323650F3B75C70011E197 /* LuaCore.framework */; };
- 1DD73BFC0F3CD78400552B38 /* Nu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DC323140F3B751A0011E197 /* Nu.framework */; };
1DD73C010F3CD7E200552B38 /* LuaPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DC322FE0F3B74FA0011E197 /* LuaPluginManager.m */; };
1DD73C020F3CD7E400552B38 /* JavascriptPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DC322FC0F3B74FA0011E197 /* JavascriptPluginManager.m */; };
- 1DD73C030F3CD7E600552B38 /* NuPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DC323000F3B74FA0011E197 /* NuPluginManager.m */; };
1DD73C040F3CD7E700552B38 /* ObjCPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DC323020F3B74FA0011E197 /* ObjCPluginManager.m */; };
1DD73C060F3CD7F200552B38 /* Example.js in Sources */ = {isa = PBXBuildFile; fileRef = 1DD73C050F3CD7F200552B38 /* Example.js */; };
1DD73C0F0F3CD85600552B38 /* Example.lua in Copy plugins */ = {isa = PBXBuildFile; fileRef = 1DD73BFF0F3CD7D000552B38 /* Example.lua */; };
@@ -41,6 +38,10 @@
1DD73C610F3CFA9F00552B38 /* NSApplication+Applescript.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DD73C600F3CFA9F00552B38 /* NSApplication+Applescript.m */; };
1DD73C6D0F3CFBDE00552B38 /* ApplescriptPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DC322F80F3B74FA0011E197 /* ApplescriptPluginManager.m */; };
1DF38D770F3DE9AA00431004 /* RubyPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DC3230A0F3B74FA0011E197 /* RubyPluginManager.m */; };
+ 1DF38DD00F3E19CC00431004 /* CamelBones.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF38DCF0F3E19CC00431004 /* CamelBones.framework */; };
+ 1DF38DE60F3E19DF00431004 /* PerlPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DF38DE40F3E19DF00431004 /* PerlPluginManager.m */; };
+ 1DF38DEB0F3E205F00431004 /* Example.pl in Resources */ = {isa = PBXBuildFile; fileRef = 1DF38DEA0F3E205F00431004 /* Example.pl */; };
+ 1DF38DF70F3E20C400431004 /* Example.pl in Copy plugins */ = {isa = PBXBuildFile; fileRef = 1DF38DEA0F3E205F00431004 /* Example.pl */; };
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
@@ -64,8 +65,8 @@
dstPath = "";
dstSubfolderSpec = 13;
files = (
+ 1DF38DF70F3E20C400431004 /* Example.pl in Copy plugins */,
1DD73C5A0F3CF93500552B38 /* Example.py in Copy plugins */,
- 1DD73B2E0F3CA0DE00552B38 /* Example.rb in Copy plugins */,
1DD73C0F0F3CD85600552B38 /* Example.lua in Copy plugins */,
1DD73C100F3CD85600552B38 /* Example.js in Copy plugins */,
1DD73C110F3CD85600552B38 /* Example.fscript in Copy plugins */,
@@ -129,6 +130,10 @@
1DD73C0B0F3CD83E00552B38 /* Example.nu */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Example.nu; sourceTree = "<group>"; };
1DD73C5F0F3CFA9F00552B38 /* NSApplication+Applescript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSApplication+Applescript.h"; sourceTree = "<group>"; };
1DD73C600F3CFA9F00552B38 /* NSApplication+Applescript.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSApplication+Applescript.m"; sourceTree = "<group>"; };
+ 1DF38DCF0F3E19CC00431004 /* CamelBones.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CamelBones.framework; path = /Library/Frameworks/CamelBones.framework; sourceTree = "<absolute>"; };
+ 1DF38DE40F3E19DF00431004 /* PerlPluginManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PerlPluginManager.m; sourceTree = "<group>"; };
+ 1DF38DE50F3E19DF00431004 /* PerlPluginManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerlPluginManager.h; sourceTree = "<group>"; };
+ 1DF38DEA0F3E205F00431004 /* Example.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = Example.pl; sourceTree = "<group>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = "<group>"; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
@@ -159,8 +164,8 @@
1DD73BF90F3CD78100552B38 /* FScript.framework in Frameworks */,
1DD73BFA0F3CD78300552B38 /* JSCocoa.framework in Frameworks */,
1DD73BFB0F3CD78300552B38 /* LuaCore.framework in Frameworks */,
- 1DD73BFC0F3CD78400552B38 /* Nu.framework in Frameworks */,
1DD73C300F3CD9C800552B38 /* Carbon.framework in Frameworks */,
+ 1DF38DD00F3E19CC00431004 /* CamelBones.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -208,6 +213,8 @@
1DC322F60F3B74FA0011E197 /* PluginManager */ = {
isa = PBXGroup;
children = (
+ 1DF38DE40F3E19DF00431004 /* PerlPluginManager.m */,
+ 1DF38DE50F3E19DF00431004 /* PerlPluginManager.h */,
1DC3235F0F3B75910011E197 /* NSApplescript+FCSAdditions.h */,
1DC323600F3B75910011E197 /* NSApplescript+FCSAdditions.m */,
1DC322F70F3B74FA0011E197 /* ApplescriptPluginManager.h */,
@@ -267,6 +274,7 @@
1DD73C050F3CD7F200552B38 /* Example.js */,
1DD73C090F3CD82400552B38 /* Example.fscript */,
1DD73C0B0F3CD83E00552B38 /* Example.nu */,
+ 1DF38DEA0F3E205F00431004 /* Example.pl */,
);
name = PlugIns;
sourceTree = "<group>";
@@ -314,6 +322,7 @@
1DC323140F3B751A0011E197 /* Nu.framework */,
1DC323150F3B751A0011E197 /* FScript.framework */,
1DC323160F3B751A0011E197 /* JSCocoa.framework */,
+ 1DF38DCF0F3E19CC00431004 /* CamelBones.framework */,
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
);
@@ -393,6 +402,7 @@
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */,
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
1DC324320F3B89D30011E197 /* ExampleApplication.sdef in Resources */,
+ 1DF38DEB0F3E205F00431004 /* Example.pl in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -418,7 +428,6 @@
1DD73BBF0F3CD14200552B38 /* PythonPluginManager.m in Sources */,
1DD73C010F3CD7E200552B38 /* LuaPluginManager.m in Sources */,
1DD73C020F3CD7E400552B38 /* JavascriptPluginManager.m in Sources */,
- 1DD73C030F3CD7E600552B38 /* NuPluginManager.m in Sources */,
1DD73C040F3CD7E700552B38 /* ObjCPluginManager.m in Sources */,
1DD73C060F3CD7F200552B38 /* Example.js in Sources */,
1DD73C2B0F3CD9A300552B38 /* FScriptPlugInManager.m in Sources */,
@@ -426,6 +435,7 @@
1DD73C610F3CFA9F00552B38 /* NSApplication+Applescript.m in Sources */,
1DD73C6D0F3CFBDE00552B38 /* ApplescriptPluginManager.m in Sources */,
1DF38D770F3DE9AA00431004 /* RubyPluginManager.m in Sources */,
+ 1DF38DE60F3E19DF00431004 /* PerlPluginManager.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
2 src/NuPluginManager.m
@@ -13,7 +13,7 @@ @implementation NuPluginManager
+(void)load {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
- [PluginManager registerManager:[[self new] autorelease]];
+ if (NSClassFromString(@"Nu")) [PluginManager registerManager:[[self new] autorelease]];
[pool release];
}
View
24 src/PerlPluginManager.h
@@ -0,0 +1,24 @@
+//
+// PerlPluginManager.h
+// PluginManager
+//
+// Created by Grayson Hansard
+// Copyright 2009 From Concentrate Software. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import <CamelBones/CamelBones.h>
+#import "PluginManager.h"
+
+
+@interface PerlPluginManager : NSObject <PluginManagerProtocol> {
+ NSMutableDictionary *_plugins;
+}
+
+-(NSString *)name;
+-(NSArray *)extensions;
+-(NSArray *)pluginsForProperty:(NSString *)property forValue:(id)forValue withValue:(id)value;
+-(void)runPlugin:(NSDictionary *)plugin forValue:(id)forValue withValue:(id)withValue;
+-(id)runScriptAtPath:(NSString *)path;
+
+@end
View
92 src/PerlPluginManager.m
@@ -0,0 +1,92 @@
+//
+// PerlPluginManager.m
+// PluginManager
+//
+// Created by Grayson Hansard
+// Copyright 2009 From Concentrate Software. All rights reserved.
+//
+
+#import "PerlPluginManager.h"
+
+
+@implementation PerlPluginManager
+
++(void)load {
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
+ if (NSClassFromString(@"CBPerl")) [PluginManager registerManager:[[self new] autorelease]];
+ [pool release];
+}
+
+-(NSString *)name { return @"Perl"; }
+-(NSArray *)extensions { return [NSArray arrayWithObjects:@"pl", @"perl", nil]; }
+
+- (id)init
+{
+ self = [super init];
+ if (!self) return nil;
+
+ return self;
+}
+
+- (void)build
+{
+ if (_plugins) [_plugins release];
+ _plugins = [NSMutableDictionary new];
+ for (NSString *path in [PluginManager pluginFilesForSubmanager:self])
+ {
+ CBPerl *perl = [CBPerl sharedPerl];
+ NSString *perlCode = [NSString stringWithContentsOfFile:path];
+ [perl eval:perlCode];
+ NSString *property = [perl eval:@"actionProperty();"];
+ if (!property) continue;
+ NSMutableArray *arr = [_plugins objectForKey:property];
+ if (!arr) arr = [NSMutableArray array];
+ [arr addObject:perlCode];
+ [_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 (!plugins || ![plugins count]) return nil;
+
+ NSEnumerator *pluginEnumerator = [plugins objectEnumerator];
+ NSString *perlCode = nil;
+ NSMutableArray *ret = [NSMutableArray array];
+ CBPerl *perl = [CBPerl sharedPerl];
+ withValue = withValue ? withValue : [NSNull null];
+ forValue = forValue ? forValue : [NSNull null];
+ while (perlCode = [pluginEnumerator nextObject])
+ {
+ [perl eval:perlCode];
+ [perl setValue:forValue forKey:@"_forValue"];
+ [perl setValue:withValue forKey:@"_withValue"];
+ if ([[perl eval:@"actionEnable($_forValue, $_withValue);"] boolValue]) {
+ [ret addObject:[NSDictionary dictionaryWithObjectsAndKeys:
+ [perl eval:@"actionTitle($_forValue, $_withValue);"], @"title",
+ perlCode, @"code", nil]];
+ }
+ }
+
+ return ret;
+}
+
+-(void)runPlugin:(NSDictionary *)plugin forValue:(id)forValue withValue:(id)withValue
+{
+ NSString *perlCode = [plugin objectForKey:@"code"];
+ if (!perlCode) return;
+ CBPerl *perl = [CBPerl sharedPerl];
+ [perl eval:perlCode];
+ [perl setValue:forValue ? forValue : [NSNull null] forKey:@"_forValue"];
+ [perl setValue:withValue ? withValue : [NSNull null] forKey:@"_withValue"];
+ [perl eval:@"actionPerform($_withValue, $_forValue);"];
+}
+
+-(id)runScriptAtPath:(NSString *)path
+{
+ return [[CBPerl sharedPerl] eval:[NSString stringWithContentsOfFile:path]];
+}
+
+@end
View
2 src/RubyPluginManager.m
@@ -94,7 +94,7 @@ -(id)runScriptAtPath:(NSString *)path
{
NSString *rubyCode = [NSString stringWithContentsOfFile:path];
if (!rubyCode) return nil;
- void *v = (void *)rb_eval_string([rubyCode UTF8String]);
+ /*void *v = */(void *)rb_eval_string([rubyCode UTF8String]);
// How do I get a return value from a script? Can I with Ruby?
return nil;
}

0 comments on commit 3acabfd

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