Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bindings for `CFBundleGetMainBundle()`, `CFBundleGetInfoDictionary()`, and `CFDictionarySetValue()`. #81

Merged
merged 2 commits into from May 16, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Add bindings for `CFBundleGetMainBundle()` and

`CFBundleGetInfoDictionary()`.
  • Loading branch information
pcwalton committed May 16, 2016
commit 82f7421c137a7a755529f9018c57bdf92cfe6c26
@@ -10,6 +10,7 @@
use libc::c_void;

use base::CFTypeID;
use dictionary::CFDictionaryRef;
use string::CFStringRef;

#[repr(C)]
@@ -23,6 +24,8 @@ extern {
*/
pub fn CFBundleGetBundleWithIdentifier(bundleID: CFStringRef) -> CFBundleRef;
pub fn CFBundleGetFunctionPointerForName(bundle: CFBundleRef, function_name: CFStringRef) -> *const c_void;
pub fn CFBundleGetMainBundle() -> CFBundleRef;
pub fn CFBundleGetInfoDictionary(bundle: CFBundleRef) -> CFDictionaryRef;

pub fn CFBundleGetTypeID() -> CFTypeID;
}
@@ -13,6 +13,7 @@ pub use core_foundation_sys::bundle::*;
use core_foundation_sys::base::CFRelease;

use base::{TCFType};
use dictionary::CFDictionary;

/// A Bundle type.
pub struct CFBundle(CFBundleRef);
@@ -25,4 +26,21 @@ impl Drop for CFBundle {
}
}

impl CFBundle {
pub fn main_bundle() -> CFBundle {
unsafe {
let bundle_ref = CFBundleGetMainBundle();
TCFType::wrap_under_get_rule(bundle_ref)
}
}

pub fn info_dictionary(&self) -> CFDictionary {
unsafe {
let info_dictionary = CFBundleGetInfoDictionary(self.0);
TCFType::wrap_under_get_rule(info_dictionary)
}
}
}

impl_TCFType!(CFBundle, CFBundleRef, CFBundleGetTypeID);

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.