Remove workaround for impl methods not being affected by cfg directives.

This commit is contained in:
Brian J. Burg 2012-11-07 14:41:19 -08:00
parent a2589dbfec
commit 8329d282d4
3 changed files with 6 additions and 18 deletions

View file

@ -31,17 +31,13 @@ pub type FontHandle/& = freetype::font::FreeTypeFontHandle;
// TODO(Issue #163): this is a workaround for static methods and // TODO(Issue #163): this is a workaround for static methods and
// typedefs not working well together. It should be removed. // typedefs not working well together. It should be removed.
// TODO(Rust #1723): #cfg doesn't work for impl methods, so we have
// to conditionally define the entire impl.
#[cfg(target_os = "macos")]
impl FontHandle { impl FontHandle {
#[cfg(target_os = "macos")]
static pub fn new(fctx: &native::FontContextHandle, buf: @~[u8], pt_size: float) -> Result<FontHandle, ()> { static pub fn new(fctx: &native::FontContextHandle, buf: @~[u8], pt_size: float) -> Result<FontHandle, ()> {
quartz::font::QuartzFontHandle::new(fctx, buf, pt_size) quartz::font::QuartzFontHandle::new(fctx, buf, pt_size)
} }
}
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
impl FontHandle {
static pub fn new(fctx: &native::FontContextHandle, buf: @~[u8], pt_size: float) -> Result<FontHandle, ()> { static pub fn new(fctx: &native::FontContextHandle, buf: @~[u8], pt_size: float) -> Result<FontHandle, ()> {
freetype::font::FreeTypeFontHandle::new(fctx, buf, pt_size) freetype::font::FreeTypeFontHandle::new(fctx, buf, pt_size)
} }

View file

@ -31,25 +31,19 @@ pub fn dummy_style() -> FontStyle {
// TODO(Issue #163): this is a workaround for static methods and // TODO(Issue #163): this is a workaround for static methods and
// typedefs not working well together. It should be removed. // typedefs not working well together. It should be removed.
// TODO(Rust #1723): #cfg doesn't work for impl methods, so we have
// to conditionally define the entire impl.
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
type FontContextHandle/& = quartz::font_context::QuartzFontContextHandle; type FontContextHandle/& = quartz::font_context::QuartzFontContextHandle;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
type FontContextHandle/& = freetype::font_context::FreeTypeFontContextHandle; type FontContextHandle/& = freetype::font_context::FreeTypeFontContextHandle;
#[cfg(target_os = "macos")]
pub impl FontContextHandle { pub impl FontContextHandle {
#[cfg(target_os = "macos")]
static pub fn new() -> FontContextHandle { static pub fn new() -> FontContextHandle {
quartz::font_context::QuartzFontContextHandle::new() quartz::font_context::QuartzFontContextHandle::new()
} }
}
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub impl FontContextHandle {
static pub fn new() -> FontContextHandle { static pub fn new() -> FontContextHandle {
freetype::font_context::FreeTypeFontContextHandle::new() freetype::font_context::FreeTypeFontContextHandle::new()
} }

View file

@ -4,15 +4,13 @@ type FontListHandle/& = quartz::font_list::QuartzFontListHandle;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
type FontListHandle/& = freetype::font_list::FreeTypeFontListHandle; type FontListHandle/& = freetype::font_list::FreeTypeFontListHandle;
#[cfg(target_os = "macos")]
pub impl FontListHandle { pub impl FontListHandle {
#[cfg(target_os = "macos")]
static pub fn new() -> FontListHandle { static pub fn new() -> FontListHandle {
quartz::font_list::QuartzFontListHandle::new() quartz::font_list::QuartzFontListHandle::new()
} }
}
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub impl FontListHandle {
static pub fn new() -> FontListHandle { static pub fn new() -> FontListHandle {
freetype::font_list::FreeTypeFontListHandle::new() freetype::font_list::FreeTypeFontListHandle::new()
} }