Merge branch 'upstream' into simplify-native-core

This commit is contained in:
Evan Almloff committed 2023-01-08 14:03:44 -06:00
commit ecf4ee275a
142 files changed
+2951 -1853

No files matched your search

+1 -2
View File
@@ -18,10 +18,9 @@ proc-macro = true
syn = { version = "1.0.11", features = ["extra-traits"] }
quote = "1.0"
dioxus-native-core = { path = "../native-core", version = "^0.2.0" }
[dev-dependencies]
dioxus = { path = "../dioxus" }
[dev-dependencies]
smallvec = "1.6"
rustc-hash = "1.1.0"
anymap = "0.12.1"
+27
View File
@@ -23,6 +23,33 @@ pub fn state_macro_derive(input: TokenStream) -> TokenStream {
}
fn impl_derive_macro(ast: &syn::DeriveInput) -> TokenStream {
let custom_type = ast
.attrs
.iter()
.find(|a| a.path.is_ident("state"))
.and_then(|attr| {
// parse custom_type = "MyType"
let assignment = attr.parse_args::<syn::Expr>().unwrap();
if let syn::Expr::Assign(assign) = assignment {
let (left, right) = (&*assign.left, &*assign.right);
if let syn::Expr::Path(e) = left {
let path = &e.path;
if let Some(ident) = path.get_ident() {
if ident == "custom_value" {
return match right {
syn::Expr::Path(e) => {
let path = &e.path;
Some(quote! {#path})
}
_ => None,
};
}
}
}
}
None
})
.unwrap_or(quote! {()});
let type_name = &ast.ident;
let fields: Vec<_> = match &ast.data {
syn::Data::Struct(data) => match &data.fields {
@@ -43,7 +43,6 @@ impl ParentDepState for ParentDepCallCounter {
const NODE_MASK: NodeMask = NodeMask::ALL;
fn reduce(&mut self, _node: NodeView, _parent: Option<(&Self,)>, _ctx: &Self::Ctx) -> bool {
self.0 += 1;
println!("ParentDepCallCounter::reduce on {:?}\n{}", _node, self.0);
true
}
}