use lief_ffi as ffi;
use super::{DeclOpt, Method, Property, Protocol};
use crate::common::FromFFI;
use crate::declare_fwd_iterator;
use std::marker::PhantomData;
pub struct Category<'a> {
ptr: cxx::UniquePtr<ffi::ObjC_Category>,
_owner: PhantomData<&'a ()>,
}
impl FromFFI<ffi::ObjC_Category> for Category<'_> {
fn from_ffi(info: cxx::UniquePtr<ffi::ObjC_Category>) -> Self {
Self {
ptr: info,
_owner: PhantomData,
}
}
}
impl Category<'_> {
pub fn name(&self) -> String {
self.ptr.name().to_string()
}
pub fn class_name(&self) -> String {
self.ptr.class_name().to_string()
}
pub fn methods(&self) -> Methods<'_> {
Methods::new(self.ptr.methods())
}
pub fn protocols(&self) -> Protocols<'_> {
Protocols::new(self.ptr.protocols())
}
pub fn properties(&self) -> Properties<'_> {
Properties::new(self.ptr.properties())
}
pub fn to_decl(&self) -> String {
self.ptr.to_decl().to_string()
}
pub fn to_decl_with_opt(&self, opt: &DeclOpt) -> String {
self.ptr.to_decl_with_opt(&opt.to_ffi()).to_string()
}
}
declare_fwd_iterator!(
Methods,
Method<'a>,
ffi::ObjC_Method,
ffi::ObjC_Category,
ffi::ObjC_Category_it_methods
);
declare_fwd_iterator!(
Protocols,
Protocol<'a>,
ffi::ObjC_Protocol,
ffi::ObjC_Category,
ffi::ObjC_Category_it_protocols
);
declare_fwd_iterator!(
Properties,
Property<'a>,
ffi::ObjC_Property,
ffi::ObjC_Category,
ffi::ObjC_Category_it_properties
);