make html hot reloding context work

This commit is contained in:
= committed 2022-12-14 21:38:50 -06:00
1 parent 6d2e510200
commit ab743e01b7
1 file changed
+55 -62
+55 -62
View File
@@ -43,24 +43,35 @@ macro_rules! impl_attribute {
macro_rules! impl_attribute_match { macro_rules! impl_attribute_match {
( (
$(#[$attr_method:meta])* $attr:ident $fil:ident: $vil:ident (DEFAULT),
$fil:ident: $vil:ident (DEFAULT),
) => { ) => {
stringify!($fil) => Some((stringify!($fil), None)) if $attr == stringify!($fil) {
return Some((stringify!($fil), None));
}
}; };
( (
$(#[$attr_method:meta])* $attr:ident $fil:ident: $vil:ident (volatile),
$fil:ident: $vil:ident ($name:literal),
) => { ) => {
stringify!($fil) => Some(($name, None)) if $attr == stringify!($fil) {
return Some((stringify!($fil), None));
}
}; };
( (
$(#[$attr_method:meta])* $attr:ident $fil:ident: $vil:ident ($name:literal),
$fil:ident: $vil:ident (in $ns:ident),
) => { ) => {
stringify!($fil) => Some((stringify!(fil), Some(stringify!(ns)))) if $attr == stringify!($fil) {
return Some(($name, None));
}
};
(
$attr:ident $fil:ident: $vil:ident (in $ns:ident),
) => {
if $attr == stringify!($fil) {
return Some((stringify!(fil), Some(stringify!(ns))));
}
}; };
} }
@@ -124,29 +135,25 @@ macro_rules! impl_element {
macro_rules! impl_element_match { macro_rules! impl_element_match {
( (
$(#[$attr:meta])* $el:ident $name:ident None {
$name:ident None {
$( $(
$(#[$attr_method:meta])*
$fil:ident: $vil:ident $extra:tt, $fil:ident: $vil:ident $extra:tt,
)* )*
} }
) => { ) => {
if element == stringify!($name) { if $el == stringify!($name) {
return Some((stringify!($name), None)); return Some((stringify!($name), None));
} }
}; };
( (
$(#[$attr:meta])* $el:ident $name:ident $namespace:tt {
$name:ident $namespace:ident {
$( $(
$(#[$attr_method:meta])*
$fil:ident: $vil:ident $extra:tt, $fil:ident: $vil:ident $extra:tt,
)* )*
} }
) => { ) => {
if element == stringify!($name) { if $el == stringify!($name) {
return Some((stringify!($name), Some(stringify!($namespace)))); return Some((stringify!($name), Some(stringify!($namespace))));
} }
}; };
@@ -154,42 +161,34 @@ macro_rules! impl_element_match {
macro_rules! impl_element_match_attributes { macro_rules! impl_element_match_attributes {
( (
$(#[$attr:meta])* $el:ident $attr:ident $name:ident None {
$name:ident None {
$( $(
$(#[$attr_method:meta])*
$fil:ident: $vil:ident $extra:tt, $fil:ident: $vil:ident $extra:tt,
)* )*
} }
) => { ) => {
stringify!($name) => match attr{ if $el == stringify!($name) {
$( $(
impl_attribute_match!( impl_attribute_match!(
$(#[$attr_method])* $attr $fil: $vil ($extra),
$fil: $vil ($extra), );
),
)* )*
_ => None,
} }
}; };
( (
$(#[$attr:meta])* $el:ident $attr:ident $name:ident $namespace:tt {
$name:ident $namespace:tt {
$( $(
$(#[$attr_method:meta])*
$fil:ident: $vil:ident $extra:tt, $fil:ident: $vil:ident $extra:tt,
)* )*
} }
) => { ) => {
stringify!($name) => match attr{ if $el == stringify!($name) {
$( $(
impl_attribute_match!( impl_attribute_match!(
$(#[$attr_method])* $attr $fil: $vil in $namespace $extra
$fil: $vil in $namespace $extra );
),
)* )*
_ => None,
} }
} }
} }
@@ -209,26 +208,35 @@ macro_rules! builder_constructors {
pub struct Html; pub struct Html;
impl HotReloadingContext for Html { impl HotReloadingContext for Html {
fn map_attribute(element: &str, attr: &str) -> Option<(&'static str, Option<&'static str>)> { fn map_attribute(element: &str, attribute: &str) -> Option<(&'static str, Option<&'static str>)> {
match element { $(
// $( impl_element_match_attributes!(
// impl_element_match_attributes!( element attribute $name $namespace {
// $(#[$attr])* $(
// $name $namespace { $fil: $vil $extra,
// $( )*
// $(#[$attr_method])*
// $fil: $vil $extra,
// )*
// }
// )
// )*
_ => None
} }
);
)*
None
} }
fn map_element(element: &str) -> Option<(&'static str, Option<&'static str>)> { fn map_element(element: &str) -> Option<(&'static str, Option<&'static str>)> {
$( $(
impl_element_match!( impl_element_match!(
element $name $namespace {
$(
$fil: $vil $extra,
)*
}
);
)*
None
}
}
$(
impl_element!(
$(#[$attr])* $(#[$attr])*
$name $namespace { $name $namespace {
$( $(
@@ -238,21 +246,6 @@ macro_rules! builder_constructors {
} }
); );
)* )*
unreachable!()
}
}
// $(
// impl_element!(
// $(#[$attr])*
// $name $namespace {
// $(
// $(#[$attr_method])*
// $fil: $vil $extra,
// )*
// }
// );
// )*
}; };
} }