Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ exclude = [
exception = ["objc_exception"]
verify_message = []

[dependencies]
malloc_buf = "0.0"
[dependencies.mbox]
version = "0.5"
default_features = false

[dependencies.objc_exception]
version = "0.1"
Expand Down
6 changes: 3 additions & 3 deletions src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::ffi::CStr;
use std::fmt;
use std::os::raw::{c_char, c_void};
use std::str;
use malloc_buf::MallocBuffer;
use mbox::MBox;

use runtime::{Class, Object, Sel};

Expand All @@ -26,7 +26,7 @@ enum Code {
Slice(&'static str),
Owned(String),
Inline(u8, [u8; CODE_INLINE_CAP]),
Malloc(MallocBuffer<u8>)
Malloc(MBox<[u8]>)
}

/// An Objective-C type encoding.
Expand Down Expand Up @@ -104,7 +104,7 @@ pub unsafe fn from_malloc_str(ptr: *mut c_char) -> Encoding {
let s = CStr::from_ptr(ptr);
let bytes = s.to_bytes_with_nul();
assert!(str::from_utf8(bytes).is_ok());
let buf = MallocBuffer::new(ptr as *mut u8, bytes.len()).unwrap();
let buf = MBox::from_raw_parts(ptr as *mut u8, bytes.len());
Encoding { code: Code::Malloc(buf) }
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The bindings can be used on Linux or *BSD utilizing the

#![warn(missing_docs)]

extern crate malloc_buf;
extern crate mbox;
#[cfg(feature = "exception")]
extern crate objc_exception;

Expand Down
26 changes: 13 additions & 13 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::fmt;
use std::os::raw::{c_char, c_int, c_uint, c_void};
use std::ptr;
use std::str;
use malloc_buf::MallocBuffer;
use mbox::MBox;

use encode;
use {Encode, Encoding};
Expand Down Expand Up @@ -284,11 +284,11 @@ impl Class {
}

/// Obtains the list of registered class definitions.
pub fn classes() -> MallocBuffer<&'static Class> {
pub fn classes() -> MBox<[&'static Class]> {
unsafe {
let mut count: c_uint = 0;
let classes = objc_copyClassList(&mut count);
MallocBuffer::new(classes as *mut _, count as usize).unwrap()
MBox::from_raw_parts(classes as *mut _, count as usize)
}
}

Expand Down Expand Up @@ -351,11 +351,11 @@ impl Class {
}

/// Describes the instance methods implemented by self.
pub fn instance_methods(&self) -> MallocBuffer<&Method> {
pub fn instance_methods(&self) -> MBox<[&Method]> {
unsafe {
let mut count: c_uint = 0;
let methods = class_copyMethodList(self, &mut count);
MallocBuffer::new(methods as *mut _, count as usize).unwrap()
MBox::from_raw_parts(methods as *mut _, count as usize)
}

}
Expand All @@ -366,20 +366,20 @@ impl Class {
}

/// Get a list of the protocols to which this class conforms.
pub fn adopted_protocols(&self) -> MallocBuffer<&Protocol> {
pub fn adopted_protocols(&self) -> MBox<[&Protocol]> {
unsafe {
let mut count: c_uint = 0;
let protos = class_copyProtocolList(self, &mut count);
MallocBuffer::new(protos as *mut _, count as usize).unwrap()
MBox::from_raw_parts(protos as *mut _, count as usize)
}
}

/// Describes the instance variables declared by self.
pub fn instance_variables(&self) -> MallocBuffer<&Ivar> {
pub fn instance_variables(&self) -> MBox<[&Ivar]> {
unsafe {
let mut count: c_uint = 0;
let ivars = class_copyIvarList(self, &mut count);
MallocBuffer::new(ivars as *mut _, count as usize).unwrap()
MBox::from_raw_parts(ivars as *mut _, count as usize)
}
}
}
Expand Down Expand Up @@ -412,20 +412,20 @@ impl Protocol {
}

/// Obtains the list of registered protocol definitions.
pub fn protocols() -> MallocBuffer<&'static Protocol> {
pub fn protocols() -> MBox<[&'static Protocol]> {
unsafe {
let mut count: c_uint = 0;
let protocols = objc_copyProtocolList(&mut count);
MallocBuffer::new(protocols as *mut _, count as usize).unwrap()
MBox::from_raw_parts(protocols as *mut _, count as usize)
}
}

/// Get a list of the protocols to which this protocol conforms.
pub fn adopted_protocols(&self) -> MallocBuffer<&Protocol> {
pub fn adopted_protocols(&self) -> MBox<[&Protocol]> {
unsafe {
let mut count: c_uint = 0;
let protocols = protocol_copyProtocolList(self, &mut count);
MallocBuffer::new(protocols as *mut _, count as usize).unwrap()
MBox::from_raw_parts(protocols as *mut _, count as usize)
}
}

Expand Down