Merge branch 'upstream' into fix-non-str-attributes
This commit is contained in:
commit
738f1b3ce0
5 files changed
+2322
-871
No files matched your search
+26
-21
@@ -37,9 +37,6 @@ use syn::{
|
||||
#[derive(Default, Debug)]
|
||||
pub struct CallBody {
|
||||
pub roots: Vec<BodyNode>,
|
||||
|
||||
// set this after
|
||||
pub inline_cx: bool,
|
||||
}
|
||||
|
||||
impl Parse for CallBody {
|
||||
@@ -56,10 +53,7 @@ impl Parse for CallBody {
|
||||
roots.push(node);
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
roots,
|
||||
inline_cx: false,
|
||||
})
|
||||
Ok(Self { roots })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,20 +62,29 @@ impl ToTokens for CallBody {
|
||||
fn to_tokens(&self, out_tokens: &mut TokenStream2) {
|
||||
let body = TemplateRenderer { roots: &self.roots };
|
||||
|
||||
if self.inline_cx {
|
||||
out_tokens.append_all(quote! {
|
||||
Some({
|
||||
let __cx = cx;
|
||||
#body
|
||||
})
|
||||
out_tokens.append_all(quote! {
|
||||
::dioxus::core::LazyNodes::new( move | __cx: &::dioxus::core::ScopeState| -> ::dioxus::core::VNode {
|
||||
#body
|
||||
})
|
||||
} else {
|
||||
out_tokens.append_all(quote! {
|
||||
::dioxus::core::LazyNodes::new( move | __cx: &::dioxus::core::ScopeState| -> ::dioxus::core::VNode {
|
||||
#body
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub struct RenderCallBody(pub CallBody);
|
||||
|
||||
impl ToTokens for RenderCallBody {
|
||||
fn to_tokens(&self, out_tokens: &mut TokenStream2) {
|
||||
let body = TemplateRenderer {
|
||||
roots: &self.0.roots,
|
||||
};
|
||||
|
||||
out_tokens.append_all(quote! {
|
||||
Some({
|
||||
let __cx = cx;
|
||||
#body
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +114,10 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
|
||||
};
|
||||
|
||||
let spndbg = format!("{:?}", self.roots[0].span());
|
||||
let root_col = spndbg[9..].split("..").next().unwrap();
|
||||
let root_col = spndbg
|
||||
.rsplit_once("..")
|
||||
.and_then(|(_, after)| after.split_once(')').map(|(before, _)| before))
|
||||
.unwrap_or_default();
|
||||
|
||||
let root_printer = self.roots.iter().enumerate().map(|(idx, root)| {
|
||||
context.current_path.push(idx as u8);
|
||||
@@ -148,7 +154,6 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
|
||||
key: #key_tokens,
|
||||
template: TEMPLATE,
|
||||
root_ids: std::cell::Cell::from_mut( __cx.bump().alloc([None; #num_roots]) as &mut _).as_slice_of_cells(),
|
||||
// root_ids: std::cell::Cell::from_mut( __cx.bump().alloc([None; #num_roots]) as &mut [::dioxus::core::ElementId]).as_slice_of_cells(),
|
||||
dynamic_nodes: __cx.bump().alloc([ #( #node_printer ),* ]),
|
||||
dynamic_attrs: __cx.bump().alloc([ #( #dyn_attr_printer ),* ]),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user