aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2016-08-10 11:58:53 -0700
committerBobby Holley <bobbyholley@gmail.com>2016-08-10 12:07:10 -0700
commit1cd76c291728d772c9791861b5cbc8df50d80ec6 (patch)
tree55bb02b1c756cc82767585a78e346470dd65e26a
parent7afe0376259e7460461410da03523ebec2f86c8f (diff)
downloadservo-1cd76c291728d772c9791861b5cbc8df50d80ec6.tar.gz
servo-1cd76c291728d772c9791861b5cbc8df50d80ec6.zip
Handle enum classes for clonable properties.
-rw-r--r--components/style/properties/data.py3
-rw-r--r--components/style/properties/gecko.mako.rs10
2 files changed, 6 insertions, 7 deletions
diff --git a/components/style/properties/data.py b/components/style/properties/data.py
index 7c63356ca22..400b054ba74 100644
--- a/components/style/properties/data.py
+++ b/components/style/properties/data.py
@@ -58,6 +58,9 @@ class Keyword(object):
def needs_cast(self):
return self.gecko_enum_prefix is None
+ def maybe_cast(self, type_str):
+ return "as " + type_str if self.needs_cast() else ""
+
class Longhand(object):
def __init__(self, style_struct, name, animatable=None, derived_from=None, keyword=None,
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 3037f78cd98..4ebe4a5a12a 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -220,11 +220,7 @@ def set_gecko_property(ffi_name, expr):
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
let result = match v {
% for value in keyword.values_for('gecko'):
- % if keyword.needs_cast():
- Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} as u8,
- % else:
- Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)},
- % endif
+ Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast("u8")},
% endfor
};
${set_gecko_property(gecko_ffi_name, "result")}
@@ -236,11 +232,11 @@ def set_gecko_property(ffi_name, expr):
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use properties::longhands::${ident}::computed_value::T as Keyword;
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
- match ${get_gecko_property(gecko_ffi_name)} as u32 {
+ match ${get_gecko_property(gecko_ffi_name)} ${keyword.maybe_cast("u32")} {
% for value in keyword.values_for('gecko'):
structs::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)},
% endfor
- x => panic!("Found unexpected value in style struct for ${ident} property: {}", x),
+ x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
}
}
</%def>