#![cfg(feature = "WKApplicationMain")]
use core::ffi::{c_char, c_int};
use core::ptr::NonNull;
use objc2::MainThreadMarker;
use objc2_foundation::NSString;
use crate::WKApplication;
extern "C" {
fn _NSGetArgc() -> *mut c_int;
fn _NSGetArgv() -> *mut *mut *mut c_char;
}
impl WKApplication {
#[doc(alias = "WKApplicationMain")]
pub fn main(application_delegate_class_name: Option<&NSString>, mtm: MainThreadMarker) -> ! {
let _ = mtm;
let argc = unsafe { *_NSGetArgc() };
let argv = unsafe { NonNull::new(*_NSGetArgv()).unwrap().cast() };
let _ret = unsafe { Self::__main(argc, argv, application_delegate_class_name) };
#[cfg(feature = "std")]
{
std::process::exit(_ret as i32)
}
#[cfg(not(feature = "std"))]
{
unreachable!("WKApplicationMain should not have returned")
}
}
}