use base::{CFRelease, CFRetain, CFTypeID, CFTypeRef, TCFType};
use std::mem;
use string::CFStringRef;
use libc::c_void;
#[repr(C)]
struct __CFBundle;
pub type CFBundleRef = *const __CFBundle;
pub struct CFBundle {
obj: CFBundleRef,
}
impl Drop for CFBundle {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
}
impl TCFType<CFBundleRef> for CFBundle {
#[inline]
fn as_concrete_TypeRef(&self) -> CFBundleRef {
self.obj
}
#[inline]
unsafe fn wrap_under_get_rule(reference: CFBundleRef) -> CFBundle {
let reference: CFBundleRef = mem::transmute(CFRetain(mem::transmute(reference)));
TCFType::wrap_under_create_rule(reference)
}
#[inline]
fn as_CFTypeRef(&self) -> CFTypeRef {
unsafe {
mem::transmute(self.as_concrete_TypeRef())
}
}
unsafe fn wrap_under_create_rule(obj: CFBundleRef) -> CFBundle {
CFBundle {
obj: obj,
}
}
#[inline]
fn type_id() -> CFTypeID {
unsafe {
CFBundleGetTypeID()
}
}
}
#[link(name = "CoreFoundation", kind = "framework")]
extern {
pub fn CFBundleGetBundleWithIdentifier(bundleID: CFStringRef) -> CFBundleRef;
pub fn CFBundleGetFunctionPointerForName(bundle: CFBundleRef, function_name: CFStringRef) -> *const c_void;
fn CFBundleGetTypeID() -> CFTypeID;
}