mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
Add meta support to macros.
This commit is contained in:
parent
929bd577f3
commit
61badccf8b
1 changed files with 7 additions and 8 deletions
15
src/lib.rs
15
src/lib.rs
|
@ -174,11 +174,8 @@ macro_rules! check_no_unknown_attributes {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! generate_empty_element {
|
macro_rules! generate_empty_element {
|
||||||
($elem:ident, $name:tt, $ns:expr) => (
|
($(#[$meta:meta])* $elem:ident, $name:tt, $ns:expr) => (
|
||||||
// TODO: Find a better way to concatenate doc.
|
$(#[$meta])*
|
||||||
#[doc="Structure representing a "]
|
|
||||||
#[doc=$name]
|
|
||||||
#[doc=" element."]
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct $elem;
|
pub struct $elem;
|
||||||
|
|
||||||
|
@ -204,13 +201,15 @@ macro_rules! generate_empty_element {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! generate_element_with_only_attributes {
|
macro_rules! generate_element_with_only_attributes {
|
||||||
($elem:ident, $name:tt, $ns:expr, [$($attr:ident: $attr_type:ty = $attr_name:tt => $attr_action:tt),+,]) => (
|
($(#[$meta:meta])* $elem:ident, $name:tt, $ns:expr, [$($(#[$attr_meta:meta])* $attr:ident: $attr_type:ty = $attr_name:tt => $attr_action:tt),+,]) => (
|
||||||
generate_element_with_only_attributes!($elem, $name, $ns, [$($attr: $attr_type = $attr_name => $attr_action),*]);
|
generate_element_with_only_attributes!($(#[$meta])* $elem, $name, $ns, [$($(#[$attr_meta])* $attr: $attr_type = $attr_name => $attr_action),*]);
|
||||||
);
|
);
|
||||||
($elem:ident, $name:tt, $ns:expr, [$($attr:ident: $attr_type:ty = $attr_name:tt => $attr_action:tt),+]) => (
|
($(#[$meta:meta])* $elem:ident, $name:tt, $ns:expr, [$($(#[$attr_meta:meta])* $attr:ident: $attr_type:ty = $attr_name:tt => $attr_action:tt),+]) => (
|
||||||
|
$(#[$meta])*
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct $elem {
|
pub struct $elem {
|
||||||
$(
|
$(
|
||||||
|
$(#[$attr_meta])*
|
||||||
pub $attr: $attr_type
|
pub $attr: $attr_type
|
||||||
),*
|
),*
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue