use crate::common::*;
use crate::Foundation::*;
ns_enum!(
#[underlying(NSInteger)]
pub enum NSTaskTerminationReason {
NSTaskTerminationReasonExit = 1,
NSTaskTerminationReasonUncaughtSignal = 2,
}
);
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSTask;
unsafe impl ClassType for NSTask {
type Super = NSObject;
}
);
extern_methods!(
unsafe impl NSTask {
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Option<Allocated<Self>>) -> Id<Self, Shared>;
#[method_id(@__retain_semantics Other executableURL)]
pub unsafe fn executableURL(&self) -> Option<Id<NSURL, Shared>>;
#[method(setExecutableURL:)]
pub unsafe fn setExecutableURL(&self, executableURL: Option<&NSURL>);
#[method_id(@__retain_semantics Other arguments)]
pub unsafe fn arguments(&self) -> Option<Id<NSArray<NSString>, Shared>>;
#[method(setArguments:)]
pub unsafe fn setArguments(&self, arguments: Option<&NSArray<NSString>>);
#[method_id(@__retain_semantics Other environment)]
pub unsafe fn environment(&self) -> Option<Id<NSDictionary<NSString, NSString>, Shared>>;
#[method(setEnvironment:)]
pub unsafe fn setEnvironment(&self, environment: Option<&NSDictionary<NSString, NSString>>);
#[method_id(@__retain_semantics Other currentDirectoryURL)]
pub unsafe fn currentDirectoryURL(&self) -> Option<Id<NSURL, Shared>>;
#[method(setCurrentDirectoryURL:)]
pub unsafe fn setCurrentDirectoryURL(&self, currentDirectoryURL: Option<&NSURL>);
#[method_id(@__retain_semantics Other standardInput)]
pub unsafe fn standardInput(&self) -> Option<Id<Object, Shared>>;
#[method(setStandardInput:)]
pub unsafe fn setStandardInput(&self, standardInput: Option<&Object>);
#[method_id(@__retain_semantics Other standardOutput)]
pub unsafe fn standardOutput(&self) -> Option<Id<Object, Shared>>;
#[method(setStandardOutput:)]
pub unsafe fn setStandardOutput(&self, standardOutput: Option<&Object>);
#[method_id(@__retain_semantics Other standardError)]
pub unsafe fn standardError(&self) -> Option<Id<Object, Shared>>;
#[method(setStandardError:)]
pub unsafe fn setStandardError(&self, standardError: Option<&Object>);
#[method(launchAndReturnError:)]
pub unsafe fn launchAndReturnError(&self) -> Result<(), Id<NSError, Shared>>;
#[method(interrupt)]
pub unsafe fn interrupt(&self);
#[method(terminate)]
pub unsafe fn terminate(&self);
#[method(suspend)]
pub unsafe fn suspend(&self) -> bool;
#[method(resume)]
pub unsafe fn resume(&self) -> bool;
#[method(processIdentifier)]
pub unsafe fn processIdentifier(&self) -> c_int;
#[method(isRunning)]
pub unsafe fn isRunning(&self) -> bool;
#[method(terminationStatus)]
pub unsafe fn terminationStatus(&self) -> c_int;
#[method(terminationReason)]
pub unsafe fn terminationReason(&self) -> NSTaskTerminationReason;
#[method(terminationHandler)]
pub unsafe fn terminationHandler(&self) -> *mut Block<(NonNull<NSTask>,), ()>;
#[method(setTerminationHandler:)]
pub unsafe fn setTerminationHandler(
&self,
terminationHandler: Option<&Block<(NonNull<NSTask>,), ()>>,
);
#[method(qualityOfService)]
pub unsafe fn qualityOfService(&self) -> NSQualityOfService;
#[method(setQualityOfService:)]
pub unsafe fn setQualityOfService(&self, qualityOfService: NSQualityOfService);
}
);
extern_methods!(
unsafe impl NSTask {
#[method_id(@__retain_semantics Other launchedTaskWithExecutableURL:arguments:error:terminationHandler:)]
pub unsafe fn launchedTaskWithExecutableURL_arguments_error_terminationHandler(
url: &NSURL,
arguments: &NSArray<NSString>,
error: *mut *mut NSError,
terminationHandler: Option<&Block<(NonNull<NSTask>,), ()>>,
) -> Option<Id<NSTask, Shared>>;
#[method(waitUntilExit)]
pub unsafe fn waitUntilExit(&self);
}
);
extern_methods!(
unsafe impl NSTask {
#[method_id(@__retain_semantics Other launchPath)]
pub unsafe fn launchPath(&self) -> Option<Id<NSString, Shared>>;
#[method(setLaunchPath:)]
pub unsafe fn setLaunchPath(&self, launchPath: Option<&NSString>);
#[method_id(@__retain_semantics Other currentDirectoryPath)]
pub unsafe fn currentDirectoryPath(&self) -> Id<NSString, Shared>;
#[method(setCurrentDirectoryPath:)]
pub unsafe fn setCurrentDirectoryPath(&self, currentDirectoryPath: &NSString);
#[method(launch)]
pub unsafe fn launch(&self);
#[method_id(@__retain_semantics Other launchedTaskWithLaunchPath:arguments:)]
pub unsafe fn launchedTaskWithLaunchPath_arguments(
path: &NSString,
arguments: &NSArray<NSString>,
) -> Id<NSTask, Shared>;
}
);
extern_static!(NSTaskDidTerminateNotification: &'static NSNotificationName);