mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
Add node macro support for injecting nodes into global scope (#4221)
* Macro support * Preprocessor support * Allow Cow str as scope name * Use Passthrough node to work around compiler auto wrapping the producer node and invalidating the node id * Stable NodeIds * Less hacky but with bad performace * Remove Cow from RegistryValueSource::Scope * Connect scope injections to the inner network export --------- Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
@@ -172,7 +172,13 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
quote!(RegistryValueSource::Default(stringify!(#data)))
|
||||
}
|
||||
}
|
||||
ParsedValueSource::Scope(data) => quote!(RegistryValueSource::Scope(#data)),
|
||||
ParsedValueSource::Scope(data) => {
|
||||
if let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(_), .. }) = data {
|
||||
quote!(RegistryValueSource::Scope(#data))
|
||||
} else {
|
||||
quote!(RegistryValueSource::Scope(#data.as_static_str()))
|
||||
}
|
||||
}
|
||||
_ => quote!(RegistryValueSource::None),
|
||||
},
|
||||
_ => quote!(RegistryValueSource::None),
|
||||
@@ -402,6 +408,7 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
|
||||
let properties = &attributes.properties_string.as_ref().map(|value| quote!(Some(#value))).unwrap_or(quote!(None));
|
||||
let memoize_flag = attributes.memoize;
|
||||
let inject_scope_flag = attributes.inject_scope;
|
||||
|
||||
let cfg = crate::shader_nodes::modify_cfg(attributes);
|
||||
let node_input_accessor = generate_node_input_references(parsed, fn_generics, &field_idents, core_types, &identifier, &cfg);
|
||||
@@ -500,6 +507,7 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
properties: #properties,
|
||||
context_features: vec![#(ContextFeature::#context_features,)*],
|
||||
memoize: #memoize_flag,
|
||||
inject_scope: #inject_scope_flag,
|
||||
fields: vec![
|
||||
#(
|
||||
FieldMetadata {
|
||||
|
||||
Reference in New Issue
Block a user