-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.m
26 lines (20 loc) · 909 Bytes
/
script.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#import "script.h"
// fucking shitcode idk apple sdks and objc
NSAppleScript* compileScript(char* script) {
NSString* scriptString = [NSString stringWithUTF8String:script];
NSAppleScript* appleScript = [[NSAppleScript alloc] initWithSource:scriptString];
if (![appleScript compileAndReturnError:nil]) return nil;
return appleScript;
}
NSAppleEventDescriptor* executeScript(NSAppleScript* script) {
return [script executeAndReturnError:nil];
}
const char* getStringFromDescriptor(NSAppleEventDescriptor* descriptor, int index) {
return [[descriptor descriptorAtIndex:index] stringValue].UTF8String;
}
int getIntFromDescriptor(NSAppleEventDescriptor* descriptor, int index) {
return [[descriptor descriptorAtIndex:index] int32Value];
}
float getFloatFromDescriptor(NSAppleEventDescriptor* descriptor, int index) {
return [[descriptor descriptorAtIndex:index] floatValue];
}