mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
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
This commit is contained in:
parent
7e0bfa77d7
commit
e09f87319f
@ -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" },
|
||||
]
|
||||
|
||||
|
@ -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) {
|
||||
@ -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)}
|
||||
|
Loading…
Reference in New Issue
Block a user