mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Use alias for StyleAppearance.
So we could avoid generating it in rust-bindgen and drop transmute. Differential Revision: https://phabricator.services.mozilla.com/D10304
This commit is contained in:
parent
b00bbb3be7
commit
591a47858b
1 changed files with 1 additions and 29 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue