Skip to content

Commit 6f371d7

Browse files
TrueDoctorKeavon
andauthored
Add type checking to the node graph (#1025)
* Implement type inference Add type hints to node trait Add type annotation infrastructure Refactor type ascription infrastructure Run cargo fix Insert infer types stub Remove types from node identifier * Implement covariance * Disable rejection of generic inputs + parameters * Fix lints * Extend type checking to cover Network inputs * Implement generic specialization * Relax covariance rules * Fix type annotations for TypErasedComposeNode * Fix type checking errors * Keep connection information during node resolution * Fix TypeDescriptor PartialEq implementation * Apply review suggestions * Add documentation to type inference * Add Imaginate node to document node types * Fix whitespace in macros * Add types to imaginate node * Fix type declaration for imaginate node + add console logging * Use fully qualified type names as fallback during comparison --------- Co-authored-by: Keavon Chambers <[email protected]>
1 parent 76be1f8 commit 6f371d7

File tree

25 files changed

+1355
-998
lines changed

25 files changed

+1355
-998
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ use document_legacy::layers::nodegraph_layer::NodeGraphFrameLayer;
1010
use document_legacy::LayerId;
1111
use graph_craft::document::value::TaggedValue;
1212
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeInput, NodeNetwork, NodeOutput};
13+
use graphene_core::*;
1314
mod document_node_types;
1415
mod node_properties;
1516

1617
use glam::IVec2;
1718

18-
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
19+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
1920
pub enum FrontendGraphDataType {
2021
#[default]
2122
#[serde(rename = "general")]
@@ -310,7 +311,7 @@ impl NodeGraphMessageHandler {
310311
exposed_inputs: node
311312
.inputs
312313
.iter()
313-
.zip(node_type.inputs)
314+
.zip(node_type.inputs.iter())
314315
.skip(1)
315316
.filter(|(input, _)| input.is_exposed())
316317
.map(|(_, input_type)| NodeGraphInput {
@@ -769,7 +770,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
769770
if let Some(node) = network.nodes.get_mut(node_id) {
770771
// Extend number of inputs if not already large enough
771772
if input_index >= node.inputs.len() {
772-
node.inputs.extend(((node.inputs.len() - 1)..input_index).map(|_| NodeInput::Network));
773+
node.inputs.extend(((node.inputs.len() - 1)..input_index).map(|_| NodeInput::Network(generic!(T))));
773774
}
774775
node.inputs[input_index] = NodeInput::Value { tagged_value: value, exposed: false };
775776
if network.connected_to_output(*node_id) {

0 commit comments

Comments
 (0)