From e09f87319f1d5464a0258fecf5e3ad9e7b2c6e53 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Wed, 31 Oct 2018 06:20:00 +0000 Subject: [PATCH] Bug 1501116 - Part 2: Use alias for StyleAppearance. r=emilio So we could avoid generating it in rust-bindgen and drop transmute. Differential Revision: https://phabricator.services.mozilla.com/D10304 --HG-- extra : moz-landing-system : lando --- layout/style/ServoBindings.toml | 1 + .../components/style/properties/gecko.mako.rs | 30 +------------------ 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 66ef89df9c3a..190f72b37bfd 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -391,6 +391,7 @@ opaque-types = [ # All cbindgen-types are in mod "structs::root::mozilla". cbindgen-types = [ + { gecko = "mozilla::StyleAppearance", servo = "values::specified::Appearance" }, { gecko = "mozilla::StyleComputedTimingFunction", servo = "values::computed::easing::TimingFunction" }, ] diff --git a/servo/components/style/properties/gecko.mako.rs b/servo/components/style/properties/gecko.mako.rs index 19d5ec8baba1..47143343824d 100644 --- a/servo/components/style/properties/gecko.mako.rs +++ b/servo/components/style/properties/gecko.mako.rs @@ -368,34 +368,6 @@ def set_gecko_property(ffi_name, expr): return "self.gecko.%s = %s;" % (ffi_name, expr) %> -<%def name="impl_cbindgen_keyword(ident, gecko_ffi_name)"> - #[allow(non_snake_case)] - #[inline] - pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { - // unsafe: cbindgen ensures the representations match. - ${set_gecko_property(gecko_ffi_name, "unsafe { transmute(v) }")} - } - - #[allow(non_snake_case)] - #[inline] - pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { - // unsafe: cbindgen ensures the representations match. - unsafe { transmute(${get_gecko_property(gecko_ffi_name)}) } - } - - #[allow(non_snake_case)] - #[inline] - pub fn copy_${ident}_from(&mut self, other: &Self) { - self.gecko.${gecko_ffi_name} = other.gecko.${gecko_ffi_name}; - } - - #[allow(non_snake_case)] - #[inline] - pub fn reset_${ident}(&mut self, other: &Self) { - self.copy_${ident}_from(other) - } - - <%def name="impl_keyword_setter(ident, gecko_ffi_name, keyword, cast_type='u8', on_set=None)"> #[allow(non_snake_case)] pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) { @@ -3091,7 +3063,7 @@ fn static_assert() { unsafe { transmute(self.gecko.mDisplay) } } - ${impl_cbindgen_keyword('_moz_appearance', 'mAppearance')} + ${impl_simple('_moz_appearance', 'mAppearance')} <% float_keyword = Keyword("float", "Left Right None", gecko_enum_prefix="StyleFloat") %> ${impl_keyword('float', 'mFloat', float_keyword)}