use objc::{msg_send, sel, sel_impl};
use crate::{
object,
objective_c_runtime::{
id,
macros::interface_impl,
traits::{FromId, PNSObject},
},
};
use super::{NSArray, NSDictionary, NSString};
object! {
unsafe pub struct NSBundle;
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
#[repr(usize)]
pub enum MachOArchitecture {
ARM64 = 0x0100000c,
I386 = 0x00000007,
X86_64 = 0x01000007,
PPC = 0x00000012,
PPC64 = 0x01000012,
}
#[interface_impl(NSObject)]
impl NSBundle {
#[property]
pub fn main_bundle() -> NSBundle {
unsafe { NSBundle::from_id(msg_send![Self::m_class(), mainBundle]) }
}
#[property]
pub fn all_frameworks() -> NSArray<NSBundle> {
unsafe { NSArray::from_id(msg_send![Self::m_class(), allFrameworks]) }
}
#[property]
pub fn all_bundles() -> NSArray<NSBundle> {
unsafe { NSArray::from_id(msg_send![Self::m_class(), allBundles]) }
}
#[property]
pub fn resource_path(&self) -> NSString {
unsafe { NSString::from_id(msg_send![self.m_self(), resourcePath]) }
}
#[property]
pub fn executable_path(&self) -> NSString {
unsafe { NSString::from_id(msg_send![self.m_self(), executablePath]) }
}
#[property]
pub fn bundle_path(&self) -> NSString {
unsafe { NSString::from_id(msg_send![self.m_self(), bundlePath]) }
}
#[property]
pub fn bundle_identifier(&self) -> NSString {
unsafe { NSString::from_id(msg_send![self.m_self(), bundleIdentifier]) }
}
#[property]
pub fn info_dictionary(&self) -> NSDictionary<NSString, id> {
unsafe { NSDictionary::from_id(msg_send![self.m_self(), infoDictionary]) }
}
}