From 8329d282d484d4394dc1ffac2eda8cf5436eaef0 Mon Sep 17 00:00:00 2001 From: "Brian J. Burg" Date: Wed, 7 Nov 2012 14:41:19 -0800 Subject: [PATCH] Remove workaround for impl methods not being affected by cfg directives. --- src/servo/gfx/font.rs | 8 ++------ src/servo/gfx/font_context.rs | 10 ++-------- src/servo/gfx/font_list.rs | 6 ++---- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/servo/gfx/font.rs b/src/servo/gfx/font.rs index 7f7c2e4a21f..f1884379687 100644 --- a/src/servo/gfx/font.rs +++ b/src/servo/gfx/font.rs @@ -31,17 +31,13 @@ pub type FontHandle/& = freetype::font::FreeTypeFontHandle; // TODO(Issue #163): this is a workaround for static methods and // 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 { + #[cfg(target_os = "macos")] static pub fn new(fctx: &native::FontContextHandle, buf: @~[u8], pt_size: float) -> Result { quartz::font::QuartzFontHandle::new(fctx, buf, pt_size) } -} -#[cfg(target_os = "linux")] -impl FontHandle { + #[cfg(target_os = "linux")] static pub fn new(fctx: &native::FontContextHandle, buf: @~[u8], pt_size: float) -> Result { freetype::font::FreeTypeFontHandle::new(fctx, buf, pt_size) } diff --git a/src/servo/gfx/font_context.rs b/src/servo/gfx/font_context.rs index bbc59122bd6..9fec4f2eead 100644 --- a/src/servo/gfx/font_context.rs +++ b/src/servo/gfx/font_context.rs @@ -31,25 +31,19 @@ pub fn dummy_style() -> FontStyle { // TODO(Issue #163): this is a workaround for static methods and // 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")] type FontContextHandle/& = quartz::font_context::QuartzFontContextHandle; #[cfg(target_os = "linux")] type FontContextHandle/& = freetype::font_context::FreeTypeFontContextHandle; -#[cfg(target_os = "macos")] pub impl FontContextHandle { + #[cfg(target_os = "macos")] static pub fn new() -> FontContextHandle { quartz::font_context::QuartzFontContextHandle::new() } -} -#[cfg(target_os = "linux")] -pub impl FontContextHandle { + #[cfg(target_os = "linux")] static pub fn new() -> FontContextHandle { freetype::font_context::FreeTypeFontContextHandle::new() } diff --git a/src/servo/gfx/font_list.rs b/src/servo/gfx/font_list.rs index 8ab29fb4338..af4d4a0caa4 100644 --- a/src/servo/gfx/font_list.rs +++ b/src/servo/gfx/font_list.rs @@ -4,15 +4,13 @@ type FontListHandle/& = quartz::font_list::QuartzFontListHandle; #[cfg(target_os = "linux")] type FontListHandle/& = freetype::font_list::FreeTypeFontListHandle; -#[cfg(target_os = "macos")] pub impl FontListHandle { + #[cfg(target_os = "macos")] static pub fn new() -> FontListHandle { quartz::font_list::QuartzFontListHandle::new() } -} -#[cfg(target_os = "linux")] -pub impl FontListHandle { + #[cfg(target_os = "linux")] static pub fn new() -> FontListHandle { freetype::font_list::FreeTypeFontListHandle::new() }