mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Makes int_getter macro, and uses -1 as default maxlength instead of maxint
This commit is contained in:
parent
d26c555e2a
commit
eecdfdf6c1
4 changed files with 51 additions and 11 deletions
|
@ -26,6 +26,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) => (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue