Auto merge of #263 - pcwalton:add-sublayer, r=jdm

Add a few more bindings to `CALayer` and `CFBundle`

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/263)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo
2018-10-16 18:37:47 -04:00
committed by GitHub
2 changed files with 33 additions and 1 deletions
+14
View File
@@ -299,6 +299,13 @@ impl CALayer {
}
}
#[inline]
pub fn add_sublayer(&self, sublayer: &CALayer) {
unsafe {
msg_send![self.id(), addSublayer:sublayer.id()]
}
}
#[inline]
pub fn insert_sublayer_at_index(&self, sublayer: &CALayer, index: u32) {
unsafe {
@@ -1193,6 +1200,13 @@ impl CALayer {
msg_send![self.id(), reloadValueForKeyPath:key.as_CFTypeRef()]
}
}
#[inline]
pub fn set_contents_opaque(&self, opaque: bool) {
unsafe {
msg_send![self.id(), setContentsOpaque:opaque as BOOL]
}
}
}
#[derive(Clone, Debug, PartialEq)]
+19 -1
View File
@@ -15,9 +15,9 @@ use core_foundation_sys::base::kCFAllocatorDefault;
use base::{CFType, TCFType};
use url::CFURL;
use dictionary::CFDictionary;
use std::os::raw::c_void;
use string::CFString;
declare_TCFType!{
/// A Bundle type.
CFBundle, CFBundleRef
@@ -36,6 +36,24 @@ impl CFBundle {
}
}
pub fn bundle_with_identifier(identifier: CFString) -> Option<CFBundle> {
unsafe {
let bundle_ref = CFBundleGetBundleWithIdentifier(identifier.as_concrete_TypeRef());
if bundle_ref.is_null() {
None
} else {
Some(TCFType::wrap_under_get_rule(bundle_ref))
}
}
}
pub fn function_pointer_for_name(&self, function_name: CFString) -> *const c_void {
unsafe {
CFBundleGetFunctionPointerForName(self.as_concrete_TypeRef(),
function_name.as_concrete_TypeRef())
}
}
pub fn main_bundle() -> CFBundle {
unsafe {
let bundle_ref = CFBundleGetMainBundle();