pub extern crate xloop_types as types; #[allow(non_snake_case)] pub mod MTKView; pub mod app; pub mod error; pub mod win; pub mod prelude {} #[derive(Debug)] pub struct Platform; impl types::Platform for Platform { type Error = error::Error; type AppRef<'a> = app::AppRef<'a>; type AppHandle = app::AppHandle; type AppProxy = app::AppProxy; type WinRef<'a> = win::WinRef<'a>; type WinHandle = win::WinHandle; type WinRaw = win::WinRaw; type EvtMouse<'a> = win::WinEvent<'a>; type EvtWheel<'a> = win::WinEvent<'a>; type EvtKey<'a> = win::WinKey<'a>; type EvtTouch<'a> = win::WinTouch<'a>; type EvtCommit<'a> = &'a types::EvtCommit; fn run(delegate: impl types::AppDelegate + 'static) -> Result, Self::Error> { use core::{ffi, ptr}; use objc2::ClassType as _; use objc2_foundation::ns_string; use objc2_foundation::NSString; use std::rc::Rc; app::with_app_vars(Some(Rc::new(delegate)), |_| {}); let _ = app::AppDelegate::class(); extern "C" { pub fn UIApplicationMain( argc: ffi::c_int, argv: *const ffi::c_char, principalClassName: Option<&NSString>, delegateClassName: Option<&NSString>, ) -> ffi::c_int; } unsafe { UIApplicationMain( 0, // ptr::null(), None, Some(ns_string!(app::AppDelegate::NAME)), ) }; unreachable!() } fn win(key: impl AsRef, delegate: impl types::WinDelegate + 'static) -> Result { let window = win::XLoopWindow::new(key, delegate).ok_or(error::Error)?; Ok(win::WinHandle(window)) } fn log(level: log::LevelFilter) { env_logger::builder().filter_level(level).init(); } fn read(path: impl AsRef) -> Option> { use objc2_foundation::NSBundle; let bundle = NSBundle::mainBundle(); let res = unsafe { bundle.resourcePath() }?; let res: std::path::PathBuf = res.to_string().into(); let file = res.join(path); std::fs::read(file).ok() } }