Add automatic type conversion and the node graph preprocessor (#2478)

* Prototype document network level into node insertion

* Implement Convert trait / node for places we can't use Into

* Add isize/usize and i128/u128 implementations for Convert trait

* Factor out substitutions into preprocessor crate

* Simplify layer node further

* Code review

* Mark preprocessed networks as generated

* Revert changes to layer node definition

* Skip generated flag for serialization

* Don't expand for tests

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert 2025-06-27 01:10:14 +02:00 committed by GitHub
parent 86da69e33f
commit a40a760f27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 484 additions and 128 deletions

View file

@ -683,6 +683,8 @@ pub struct NodeNetwork {
#[serde(default)]
#[serde(serialize_with = "graphene_core::vector::serialize_hashmap", deserialize_with = "graphene_core::vector::deserialize_hashmap")]
pub scope_injections: FxHashMap<String, (NodeId, Type)>,
#[serde(skip)]
pub generated: bool,
}
impl Hash for NodeNetwork {
@ -797,7 +799,9 @@ impl NodeNetwork {
pub fn generate_node_paths(&mut self, prefix: &[NodeId]) {
for (node_id, node) in &mut self.nodes {
let mut new_path = prefix.to_vec();
new_path.push(*node_id);
if !self.generated {
new_path.push(*node_id);
}
if let DocumentNodeImplementation::Network(network) = &mut node.implementation {
network.generate_node_paths(new_path.as_slice());
}