Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 71 lines (45 sloc) 1.682 kb
5f07b80 @ccgus Automator stuff.
authored
1 //
2 // automator.m
3 // automator
4 //
5 // Created by August Mueller on 3/5/09.
6 // Copyright 2009 Flying Meat Inc. All rights reserved.
7 //
8
9 #import "JSTAutomator.h"
10 #import <JSTalk/JSTalk.h>
f8724ec @ccgus Fixing a couple more error.
authored
11 #import <JSTalk/JSCocoa.h>
5f07b80 @ccgus Automator stuff.
authored
12
13 @implementation JSTAutomator
14
2310230 Automator goodness.
August Mueller authored
15 - (void) setupJSTalkEnv:(JSTalk *)jstalk {
16 JSCocoaController *jsController = [jstalk jsController];
17 jsController.delegate = self;
18 jstalk.printController = self;
19
20 }
21
22 - (void) print:(NSString*)s {
23 NSLog(@"%@", s);
24 }
5f07b80 @ccgus Automator stuff.
authored
25
26 - (id)runWithInput:(id)input fromAction:(AMAction *)anAction error:(NSDictionary **)errorInfo {
27 // Add your code here, returning the data to be passed to the next action.
28
29 id result = 0x00;
30
31 NSString *script = [[self parameters] objectForKey:@"script"];
32
2310230 Automator goodness.
August Mueller authored
33 NSLog(@"script: %@", script);
34
5f07b80 @ccgus Automator stuff.
authored
35 if (script) {
2310230 Automator goodness.
August Mueller authored
36 JSTalk *jstalk = [[[JSTalk alloc] init] autorelease];
37 [self setupJSTalkEnv:jstalk];
38
39 [jstalk executeString:script];
40 result = [jstalk callFunctionNamed:@"run" withArguments:[NSArray arrayWithObjects:input, [self parameters], nil]];
41
42 NSLog(@"result: %@", result);
43
5f07b80 @ccgus Automator stuff.
authored
44 }
45
46
2310230 Automator goodness.
August Mueller authored
47 return result;
5f07b80 @ccgus Automator stuff.
authored
48 }
49
2310230 Automator goodness.
August Mueller authored
50
51 - (void) JSCocoa:(JSCocoaController*)controller hadError:(NSString*)error onLineNumber:(NSInteger)lineNumber atSourceURL:(id)url {
52
53 lineNumber -= 1;
54
f8724ec @ccgus Fixing a couple more error.
authored
55 NSLog(@"Error on line %ld, %@", lineNumber, error);
2310230 Automator goodness.
August Mueller authored
56
57 }
58
59
5f07b80 @ccgus Automator stuff.
authored
60 - (void) runScript:(id)sender {
61
62 JSTalk *t = [[[JSTalk alloc] init] autorelease];
2310230 Automator goodness.
August Mueller authored
63 [self setupJSTalkEnv:t];
5f07b80 @ccgus Automator stuff.
authored
64 [t executeString:[[scriptView textStorage] string]];
65 id result = [t callFunctionNamed:@"run" withArguments:[NSArray array]];
66 (void) result;
67
68 }
69
70 @end
Something went wrong with that request. Please try again.