mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use exhaustive match for cloning keyword value by default for property using enum class
This commit is contained in:
parent
097cea240f
commit
53a786cea6
9 changed files with 11 additions and 21 deletions
|
@ -467,6 +467,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
// as signed type when we have both signed/unsigned integer in order to use them
|
||||
// as match's arms.
|
||||
// Also, to use same implementation here we use casted constant if we have only singed values.
|
||||
% if keyword.gecko_enum_prefix is None:
|
||||
% for value in keyword.values_for('gecko'):
|
||||
const ${keyword.casted_constant_name(value, cast_type)} : ${cast_type} =
|
||||
structs::${keyword.gecko_constant(value)} as ${cast_type};
|
||||
|
@ -480,6 +481,16 @@ def set_gecko_property(ffi_name, expr):
|
|||
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
|
||||
% endif
|
||||
}
|
||||
% else:
|
||||
match ${get_gecko_property(gecko_ffi_name)} {
|
||||
% for value in keyword.values_for('gecko'):
|
||||
structs::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)},
|
||||
% endfor
|
||||
% if keyword.gecko_inexhaustive:
|
||||
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
|
||||
% endif
|
||||
}
|
||||
% endif
|
||||
}
|
||||
</%def>
|
||||
|
||||
|
@ -2818,7 +2829,6 @@ fn static_assert() {
|
|||
"-moz-grid-group -moz-grid-line -moz-stack -moz-inline-stack -moz-deck " +
|
||||
"-moz-popup -moz-groupbox",
|
||||
gecko_enum_prefix="StyleDisplay",
|
||||
gecko_inexhaustive="True",
|
||||
gecko_strip_moz_prefix=False) %>
|
||||
|
||||
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue