summaryrefslogtreecommitdiffstats
path: root/src/common/apple/osascript.m
blob: f17af03698811ad7ac8e046b2a65c13930f16ccb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "osascript.h"

#import <Foundation/Foundation.h>

bool ffOsascript(const char* input, FFstrbuf* result)
{
    NSAppleScript* script = [NSAppleScript.alloc initWithSource:@(input)];
    NSDictionary* errInfo = nil;
    NSAppleEventDescriptor* descriptor = [script executeAndReturnError:&errInfo];
    if (errInfo)
        return false;

    ffStrbufSetS(result, descriptor.stringValue.UTF8String);
    return true;
}