Skip to content

Commit

Permalink
Move GetRules function into macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
upsuper committed Apr 28, 2017
1 parent 04aac02 commit f19b976
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions ports/geckolib/glue.rs
Expand Up @@ -780,13 +780,30 @@ macro_rules! impl_basic_rule_funcs {
}
}

macro_rules! impl_group_rule_funcs {
{ ($name:ident, $rule_type:ty, $raw_type:ty),
get_rules: $get_rules:ident,
$($basic:tt)+
} => {
impl_basic_rule_funcs! { ($name, $rule_type, $raw_type), $($basic)+ }

#[no_mangle]
pub extern "C" fn $get_rules(rule: &$raw_type) -> ServoCssRulesStrong {
read_locked_arc(rule, |rule: &$rule_type| {
rule.rules.clone().into_strong()
})
}
}
}

impl_basic_rule_funcs! { (Style, StyleRule, RawServoStyleRule),
getter: Servo_CssRules_GetStyleRuleAt,
debug: Servo_StyleRule_Debug,
to_css: Servo_StyleRule_GetCssText,
}

impl_basic_rule_funcs! { (Media, MediaRule, RawServoMediaRule),
impl_group_rule_funcs! { (Media, MediaRule, RawServoMediaRule),
get_rules: Servo_MediaRule_GetRules,
getter: Servo_CssRules_GetMediaRuleAt,
debug: Servo_MediaRule_Debug,
to_css: Servo_MediaRule_GetCssText,
Expand Down Expand Up @@ -847,13 +864,6 @@ pub extern "C" fn Servo_MediaRule_GetMedia(rule: RawServoMediaRuleBorrowed) -> R
})
}

#[no_mangle]
pub extern "C" fn Servo_MediaRule_GetRules(rule: RawServoMediaRuleBorrowed) -> ServoCssRulesStrong {
read_locked_arc(rule, |rule: &MediaRule| {
rule.rules.clone().into_strong()
})
}

#[no_mangle]
pub extern "C" fn Servo_NamespaceRule_GetPrefix(rule: RawServoNamespaceRuleBorrowed) -> *mut nsIAtom {
read_locked_arc(rule, |rule: &NamespaceRule| {
Expand Down

0 comments on commit f19b976

Please sign in to comment.