aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/macros.rs
diff options
context:
space:
mode:
authorSam Gibson <sam@ifdown.net>2015-09-01 11:14:29 +1200
committerSam Gibson <sam@ifdown.net>2015-12-03 14:00:52 +1100
commiteecdfdf6c17b71b03a9d6404d83de482880aa26c (patch)
tree678602a59cecf6b601ef4b8b740450140463a449 /components/script/dom/macros.rs
parentd26c555e2a2fe0e10b9237e1ccf48d96665828c7 (diff)
downloadservo-eecdfdf6c17b71b03a9d6404d83de482880aa26c.tar.gz
servo-eecdfdf6c17b71b03a9d6404d83de482880aa26c.zip
Makes int_getter macro, and uses -1 as default maxlength instead of maxint
Diffstat (limited to 'components/script/dom/macros.rs')
-rw-r--r--components/script/dom/macros.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index 166b52d82d5..a292737ac47 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -27,6 +27,25 @@ macro_rules! make_bool_getter(
);
#[macro_export]
+macro_rules! make_int_getter(
+ ($attr:ident, $htmlname:expr, $default:expr) => (
+ fn $attr(&self) -> i32 {
+ use dom::bindings::codegen::InheritTypes::ElementCast;
+ use string_cache::Atom;
+ let element = ElementCast::from_ref(self);
+ // FIXME(pcwalton): Do this at compile time, not runtime.
+ element.get_int_attribute(&Atom::from_slice($htmlname), $default)
+ }
+ );
+ ($attr:ident, $htmlname:expr) => {
+ make_int_getter!($attr, $htmlname, 0);
+ };
+ ($attr:ident) => {
+ make_int_getter!($attr, to_lower!(stringify!($attr)));
+ }
+);
+
+#[macro_export]
macro_rules! make_uint_getter(
($attr:ident, $htmlname:tt, $default:expr) => (
fn $attr(&self) -> u32 {