+1
-1
@@ -9,7 +9,7 @@ RUST_SRC=$(shell find $(VPATH)/. -type f -name '*.rs')
|
||||
all: libcore_foundation.dummy
|
||||
|
||||
libcore_foundation.dummy: lib.rs $(RUST_SRC)
|
||||
$(RUSTC) $(RUSTFLAGS) $< --lib --out-dir .
|
||||
$(RUSTC) $(RUSTFLAGS) $< --crate-type=lib --out-dir .
|
||||
touch $@
|
||||
|
||||
core_foundation-test: lib.rs $(RUST_SRC)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
use std::cast;
|
||||
use std::libc::{c_long, c_ulong};
|
||||
use std::num::Bounded;
|
||||
|
||||
pub type Boolean = u8;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#[crate_id = "github.com/mozilla-servo/rust-core-foundation#core_foundation:0.1"];
|
||||
|
||||
extern mod std;
|
||||
extern crate std;
|
||||
|
||||
pub mod array;
|
||||
pub mod base;
|
||||
|
||||
@@ -15,6 +15,7 @@ use base::{Boolean, CFAllocatorRef, CFIndex, CFIndexConvertible, CFOptionFlags,
|
||||
use base::{CFRelease, CFTypeID, TCFType, kCFAllocatorDefault, kCFAllocatorNull};
|
||||
|
||||
use std::cast;
|
||||
use std::fmt;
|
||||
use std::libc;
|
||||
use std::ptr;
|
||||
use std::vec;
|
||||
@@ -259,8 +260,8 @@ impl FromStr for CFString {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToStr for CFString {
|
||||
fn to_str(&self) -> ~str {
|
||||
impl fmt::Show for CFString {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
unsafe {
|
||||
let char_len = self.char_len();
|
||||
let range = CFRange::init(0, char_len);
|
||||
@@ -294,11 +295,14 @@ impl ToStr for CFString {
|
||||
assert!(bytes_used == buffer.len().to_CFIndex());
|
||||
|
||||
// Then, reinterpret it as as string. You have been warned!
|
||||
cast::transmute(buffer)
|
||||
let s: ~str = cast::transmute(buffer);
|
||||
|
||||
write!(f.buf, "{}", s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl CFString {
|
||||
/// Like `CFString::from_string`, but references a string that can be used as a backing store
|
||||
/// by virtue of being statically allocated.
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#[allow(non_uppercase_statics)];
|
||||
|
||||
use base::{CFOptionFlags, CFRelease, CFTypeID, TCFType};
|
||||
use std::fmt;
|
||||
use string::{CFString, CFStringRef};
|
||||
|
||||
struct __CFURL;
|
||||
@@ -49,12 +50,13 @@ impl TCFType<CFURLRef> for CFURL {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToStr for CFURL {
|
||||
impl fmt::Show for CFURL {
|
||||
#[inline]
|
||||
fn to_str(&self) -> ~str {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
unsafe {
|
||||
let string: CFString = TCFType::wrap_under_get_rule(CFURLGetString(self.obj));
|
||||
string.to_str()
|
||||
let s: ~str = string.to_str();
|
||||
write!(f.buf, "{}", s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user