Skip to content

Commit

Permalink
style: Use alias for StyleAppearance.
Browse files Browse the repository at this point in the history
So we could avoid generating it in rust-bindgen and drop transmute.

Differential Revision: https://phabricator.services.mozilla.com/D10304
  • Loading branch information
BorisChiou authored and emilio committed Nov 5, 2018
1 parent b00bbb3 commit 591a478
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -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>

<%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) {
Expand Down Expand Up @@ -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)}
Expand Down

0 comments on commit 591a478

Please sign in to comment.