Rename several node graph structs/fields

This commit is contained in:
Keavon Chambers 2023-12-08 15:27:32 -08:00
parent d082b15abb
commit c5ed54cbd2
18 changed files with 379 additions and 380 deletions

View File

@ -9,7 +9,7 @@ use crate::{DocumentError, DocumentResponse, Operation};
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeNetwork, NodeOutput}; use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeNetwork, NodeOutput};
use graphene_core::renderer::ClickTarget; use graphene_core::renderer::ClickTarget;
use graphene_core::transform::Footprint; use graphene_core::transform::Footprint;
use graphene_core::{concrete, generic, NodeIdentifier}; use graphene_core::{concrete, generic, ProtoNodeIdentifier};
use graphene_std::wasm_application_io::WasmEditorApi; use graphene_std::wasm_application_io::WasmEditorApi;
use glam::{DAffine2, DVec2}; use glam::{DAffine2, DVec2};
@ -64,13 +64,13 @@ impl Default for Document {
DocumentNode { DocumentNode {
name: "EditorApi".to_string(), name: "EditorApi".to_string(),
inputs: vec![NodeInput::Network(concrete!(WasmEditorApi))], inputs: vec![NodeInput::Network(concrete!(WasmEditorApi))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default() ..Default::default()
}, },
DocumentNode { DocumentNode {
name: "Create Canvas".to_string(), name: "Create Canvas".to_string(),
inputs: vec![NodeInput::node(0, 0)], inputs: vec![NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_std::wasm_application_io::CreateSurfaceNode")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_std::wasm_application_io::CreateSurfaceNode")),
skip_deduplication: true, skip_deduplication: true,
..Default::default() ..Default::default()
}, },
@ -78,7 +78,7 @@ impl Default for Document {
name: "Cache".to_string(), name: "Cache".to_string(),
manual_composition: Some(concrete!(())), manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::node(1, 0)], inputs: vec![NodeInput::node(1, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode<_, _>")),
..Default::default() ..Default::default()
}, },
DocumentNode { DocumentNode {
@ -88,7 +88,7 @@ impl Default for Document {
NodeInput::Network(graphene_core::Type::Fn(Box::new(concrete!(Footprint)), Box::new(generic!(T)))), NodeInput::Network(graphene_core::Type::Fn(Box::new(concrete!(Footprint)), Box::new(generic!(T)))),
NodeInput::node(2, 0), NodeInput::node(2, 0),
], ],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_std::wasm_application_io::RenderNode<_, _, _>")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_std::wasm_application_io::RenderNode<_, _, _>")),
..Default::default() ..Default::default()
}, },
] ]

View File

@ -473,7 +473,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
// Set a random seed input // Set a random seed input
responses.add(NodeGraphMessage::SetInputValue { responses.add(NodeGraphMessage::SetInputValue {
node_id: *imaginate_node.last().unwrap(), node_id: *imaginate_node.last().unwrap(),
// Needs to match the index of the seed parameter in `pub const IMAGINATE_NODE: DocumentNodeBlueprint` in `document_node_type.rs` // Needs to match the index of the seed parameter in `pub const IMAGINATE_NODE: DocumentNodeDefinition` in `document_node_type.rs`
input_index: 3, input_index: 3,
value: graph_craft::document::value::TaggedValue::F64(random_value), value: graph_craft::document::value::TaggedValue::F64(random_value),
}); });

View File

@ -76,8 +76,8 @@ pub struct FrontendNode {
#[serde(rename = "isLayer")] #[serde(rename = "isLayer")]
pub is_layer: bool, pub is_layer: bool,
pub id: graph_craft::document::NodeId, pub id: graph_craft::document::NodeId,
pub alias: String,
pub name: String, pub name: String,
pub identifier: String,
#[serde(rename = "primaryInput")] #[serde(rename = "primaryInput")]
pub primary_input: Option<FrontendGraphInput>, pub primary_input: Option<FrontendGraphInput>,
#[serde(rename = "exposedInputs")] #[serde(rename = "exposedInputs")]
@ -297,8 +297,8 @@ impl NodeGraphMessageHandler {
nodes.push(FrontendNode { nodes.push(FrontendNode {
is_layer: node.is_layer(), is_layer: node.is_layer(),
id: *id, id: *id,
name: node.alias.clone(), alias: node.alias.clone(),
identifier: node.name.clone(), name: node.name.clone(),
primary_input, primary_input,
exposed_inputs, exposed_inputs,
primary_output, primary_output,

View File

@ -741,7 +741,7 @@
</div> </div>
<div class="details"> <div class="details">
<!-- TODO: Allow the user to edit the name, just like in the Layers panel --> <!-- TODO: Allow the user to edit the name, just like in the Layers panel -->
<TextLabel tooltip={editor.instance.inDevelopmentMode() ? `Node ID: ${node.id}` : undefined} italic={!node.name}>{node.name || "Layer"}</TextLabel> <TextLabel tooltip={editor.instance.inDevelopmentMode() ? `Node ID: ${node.id}` : undefined} italic={!node.alias}>{node.alias || "Layer"}</TextLabel>
</div> </div>
<svg class="border-mask" width="0" height="0"> <svg class="border-mask" width="0" height="0">
@ -771,9 +771,9 @@
> >
<!-- Primary row --> <!-- Primary row -->
<div class="primary" class:no-parameter-section={exposedInputsOutputs.length === 0}> <div class="primary" class:no-parameter-section={exposedInputsOutputs.length === 0}>
<IconLabel icon={nodeIcon(node.identifier)} /> <IconLabel icon={nodeIcon(node.name)} />
<!-- TODO: Allow the user to edit the name, just like in the Layers panel --> <!-- TODO: Allow the user to edit the name, just like in the Layers panel -->
<TextLabel tooltip={editor.instance.inDevelopmentMode() ? `Node ID: ${node.id}` : undefined} italic={!node.name}>{node.name || node.identifier}</TextLabel> <TextLabel tooltip={editor.instance.inDevelopmentMode() ? `Node ID: ${node.id}` : undefined} italic={!node.alias}>{node.alias || node.name}</TextLabel>
</div> </div>
<!-- Parameter rows --> <!-- Parameter rows -->
{#if exposedInputsOutputs.length > 0} {#if exposedInputsOutputs.length > 0}

View File

@ -87,7 +87,6 @@
</script> </script>
<!-- TODO: Refactor this component to use `<svelte:component this={attributesObject} />` to avoid all the separate conditional components --> <!-- TODO: Refactor this component to use `<svelte:component this={attributesObject} />` to avoid all the separate conditional components -->
<!-- TODO: Also rename this component, and probably move the `widget-${direction}` wrapper to be part of `WidgetLayout.svelte` as part of its refactor -->
<div class={`widget-span ${className} ${extraClasses}`.trim()} class:row={direction === "row"} class:column={direction === "column"}> <div class={`widget-span ${className} ${extraClasses}`.trim()} class:row={direction === "row"} class:column={direction === "column"}>
{#each widgetsAndNextSiblingIsSuffix as [component, nextIsSuffix], index} {#each widgetsAndNextSiblingIsSuffix as [component, nextIsSuffix], index}

View File

@ -101,9 +101,9 @@ export class FrontendNode {
readonly id!: bigint; readonly id!: bigint;
readonly name!: string; readonly alias!: string;
readonly identifier!: string; readonly name!: string;
readonly primaryInput!: FrontendGraphInput | undefined; readonly primaryInput!: FrontendGraphInput | undefined;

View File

@ -26,10 +26,10 @@ pub struct DocumentNode {
Each `DocumentNode` is of a particular type, for example the "Opacity" node type. You can define your own type of document node in `editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/document_node_types.rs`. A sample document node type definition for the opacity node is shown: Each `DocumentNode` is of a particular type, for example the "Opacity" node type. You can define your own type of document node in `editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/document_node_types.rs`. A sample document node type definition for the opacity node is shown:
```rs ```rs
DocumentNodeBlueprint { DocumentNodeDefinition {
name: "Opacity", name: "Opacity",
category: "Image Adjustments", category: "Image Adjustments",
identifier: NodeImplementation::proto("graphene_core::raster::OpacityNode<_>"), implementation: NodeImplementation::proto("graphene_core::raster::OpacityNode<_>"),
inputs: vec![ inputs: vec![
DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true), DocumentInputType::value("Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
DocumentInputType::value("Factor", TaggedValue::F32(100.), false), DocumentInputType::value("Factor", TaggedValue::F32(100.), false),
@ -136,7 +136,7 @@ The definition for the constructor of a node that applies the opacity transforma
```rs ```rs
( (
// Matches against the string defined in the document node. // Matches against the string defined in the document node.
NodeIdentifier::new("graphene_core::raster::OpacityNode<_>"), ProtoNodeIdentifier::new("graphene_core::raster::OpacityNode<_>"),
// This function is run when converting the `ProtoNode` struct into the desired struct. // This function is run when converting the `ProtoNode` struct into the desired struct.
|args| { |args| {
Box::pin(async move { Box::pin(async move {

View File

@ -66,7 +66,7 @@ macro_rules! fn_type {
#[derive(Clone, Debug, PartialEq, Eq, Hash, specta::Type)] #[derive(Clone, Debug, PartialEq, Eq, Hash, specta::Type)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct NodeIdentifier { pub struct ProtoNodeIdentifier {
pub name: Cow<'static, str>, pub name: Cow<'static, str>,
} }
@ -218,14 +218,14 @@ impl std::fmt::Display for Type {
} }
} }
impl From<&'static str> for NodeIdentifier { impl From<&'static str> for ProtoNodeIdentifier {
fn from(s: &'static str) -> Self { fn from(s: &'static str) -> Self {
NodeIdentifier { name: Cow::Borrowed(s) } ProtoNodeIdentifier { name: Cow::Borrowed(s) }
} }
} }
impl NodeIdentifier { impl ProtoNodeIdentifier {
pub const fn new(name: &'static str) -> Self { pub const fn new(name: &'static str) -> Self {
NodeIdentifier { name: Cow::Borrowed(name) } ProtoNodeIdentifier { name: Cow::Borrowed(name) }
} }
} }

View File

@ -1,6 +1,6 @@
use crate::document::value::TaggedValue; use crate::document::value::TaggedValue;
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput}; use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
use graphene_core::{GraphicGroup, NodeIdentifier, Type}; use graphene_core::{GraphicGroup, ProtoNodeIdentifier, Type};
use dyn_any::{DynAny, StaticType}; use dyn_any::{DynAny, StaticType};
use glam::IVec2; use glam::IVec2;
@ -40,15 +40,17 @@ fn return_true() -> bool {
true true
} }
/// An instance of a [`DocumentNodeDefinition`] that has been instantiated in a [`NodeNetwork`].
/// Currently, when an instance is made, it lives all on its own without any lasting connection to the definition.
/// But we will want to change it in the future so it merely references its definition.
#[derive(Clone, Debug, PartialEq, Hash, DynAny)] #[derive(Clone, Debug, PartialEq, Hash, DynAny)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DocumentNode { pub struct DocumentNode {
// TODO: Rename to "name" (also rename the TODOs in the `DocumentNodeBlueprint` struct) /// A name chosen by the user for this instance of the node. Empty indicates no given name, in which case the node definition's name is displayed to the user in italics.
/// A name chosen by the user for this node. Empty indicates no given name, in which case the node's identifier is displayed to the user in italics.
#[serde(default)] #[serde(default)]
pub alias: String, pub alias: String,
// TODO: Rename to "identifier" (also rename the TODOs in the `DocumentNodeBlueprint` struct) // TODO: Replace this name with a reference to the [`DocumentNodeDefinition`] node definition to use the name from there instead.
/// An identifier used to display in the UI and to display the appropriate properties. /// The name of the node definition, as originally set by [`DocumentNodeDefinition`], used to display in the UI and to display the appropriate properties.
pub name: String, pub name: String,
/// The inputs to a node, which are either: /// The inputs to a node, which are either:
/// - From other nodes within this graph [`NodeInput::Node`], /// - From other nodes within this graph [`NodeInput::Node`],
@ -360,12 +362,12 @@ impl NodeInput {
#[derive(Clone, Debug, PartialEq, Hash, DynAny)] #[derive(Clone, Debug, PartialEq, Hash, DynAny)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
/// Represents the implementation of a node, which can be a nested [`NodeNetwork`], a proto [`NodeIdentifier`], or extract. /// Represents the implementation of a node, which can be a nested [`NodeNetwork`], a proto [`ProtoNodeIdentifier`], or extract.
pub enum DocumentNodeImplementation { pub enum DocumentNodeImplementation {
/// A nested [`NodeNetwork`] that is flattened by the [`NodeNetwork::flatten`] function. /// A nested [`NodeNetwork`] that is flattened by the [`NodeNetwork::flatten`] function.
Network(NodeNetwork), Network(NodeNetwork),
/// A protonode identifier which can be found in `node_registry.rs`. /// A protonode identifier which can be found in `node_registry.rs`.
Unresolved(NodeIdentifier), Unresolved(ProtoNodeIdentifier),
/// `DocumentNode`s with a `DocumentNodeImplementation::Extract` are converted into a `ClonedNode` that returns the `DocumentNode` specified by the single `NodeInput::Node`. /// `DocumentNode`s with a `DocumentNodeImplementation::Extract` are converted into a `ClonedNode` that returns the `DocumentNode` specified by the single `NodeInput::Node`.
/// The referenced node (specified by the single `NodeInput::Node`) is removed from the network, and any `NodeInput::Node`s used by the referenced node are replaced with a generically typed network input. /// The referenced node (specified by the single `NodeInput::Node`) is removed from the network, and any `NodeInput::Node`s used by the referenced node are replaced with a generically typed network input.
Extract, Extract,
@ -373,7 +375,7 @@ pub enum DocumentNodeImplementation {
impl Default for DocumentNodeImplementation { impl Default for DocumentNodeImplementation {
fn default() -> Self { fn default() -> Self {
Self::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")) Self::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode"))
} }
} }
@ -393,7 +395,7 @@ impl DocumentNodeImplementation {
} }
pub const fn proto(name: &'static str) -> Self { pub const fn proto(name: &'static str) -> Self {
Self::Unresolved(NodeIdentifier::new(name)) Self::Unresolved(ProtoNodeIdentifier::new(name))
} }
} }
@ -527,7 +529,7 @@ impl NodeNetwork {
name: "MemoNode".to_string(), name: "MemoNode".to_string(),
manual_composition: Some(concrete!(())), manual_composition: Some(concrete!(())),
inputs: vec![NodeInput::Network(ty)], inputs: vec![NodeInput::Network(ty)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::memo::MemoNode")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode")),
..Default::default() ..Default::default()
}, },
), ),
@ -536,7 +538,7 @@ impl NodeNetwork {
DocumentNode { DocumentNode {
name: "CloneNode".to_string(), name: "CloneNode".to_string(),
inputs: vec![NodeInput::node(0, 0)], inputs: vec![NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::CloneNode<_>")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::CloneNode<_>")),
..Default::default() ..Default::default()
}, },
), ),
@ -983,7 +985,7 @@ impl NodeNetwork {
.nodes .nodes
.iter() .iter()
.filter(|(_, node)| { .filter(|(_, node)| {
matches!(&node.implementation, DocumentNodeImplementation::Unresolved(ident) if ident == &NodeIdentifier::new("graphene_core::ops::IdentityNode")) matches!(&node.implementation, DocumentNodeImplementation::Unresolved(ident) if ident == &ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode"))
&& node.inputs.len() == 1 && node.inputs.len() == 1
&& matches!(node.inputs[0], NodeInput::Node { .. }) && matches!(node.inputs[0], NodeInput::Node { .. })
}) })
@ -1115,7 +1117,7 @@ mod test {
use super::*; use super::*;
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput}; use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
use graphene_core::NodeIdentifier; use graphene_core::ProtoNodeIdentifier;
fn gen_node_id() -> NodeId { fn gen_node_id() -> NodeId {
static NODE_ID: AtomicU64 = AtomicU64::new(4); static NODE_ID: AtomicU64 = AtomicU64::new(4);
@ -1366,7 +1368,7 @@ mod test {
DocumentNode { DocumentNode {
name: "Identity 1".into(), name: "Identity 1".into(),
inputs: vec![NodeInput::Network(concrete!(u32))], inputs: vec![NodeInput::Network(concrete!(u32))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default() ..Default::default()
}, },
), ),
@ -1375,7 +1377,7 @@ mod test {
DocumentNode { DocumentNode {
name: "Identity 2".into(), name: "Identity 2".into(),
inputs: vec![NodeInput::Network(concrete!(u32))], inputs: vec![NodeInput::Network(concrete!(u32))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default() ..Default::default()
}, },
), ),
@ -1405,7 +1407,7 @@ mod test {
DocumentNode { DocumentNode {
name: "Result".into(), name: "Result".into(),
inputs: vec![result_node_input], inputs: vec![result_node_input],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default() ..Default::default()
}, },
), ),

View File

@ -3,7 +3,7 @@ extern crate log;
#[macro_use] #[macro_use]
extern crate graphene_core; extern crate graphene_core;
pub use graphene_core::{concrete, generic, NodeIdentifier, Type, TypeDescriptor}; pub use graphene_core::{concrete, generic, ProtoNodeIdentifier, Type, TypeDescriptor};
pub mod document; pub mod document;
pub mod proto; pub mod proto;

View File

@ -204,7 +204,7 @@ impl ConstructionArgs {
pub struct ProtoNode { pub struct ProtoNode {
pub construction_args: ConstructionArgs, pub construction_args: ConstructionArgs,
pub input: ProtoNodeInput, pub input: ProtoNodeInput,
pub identifier: NodeIdentifier, pub identifier: ProtoNodeIdentifier,
pub document_node_path: Vec<NodeId>, pub document_node_path: Vec<NodeId>,
pub skip_deduplication: bool, pub skip_deduplication: bool,
/// Represents a global state on which the node depends. This is a hack, TODO: figure out a proper solution /// Represents a global state on which the node depends. This is a hack, TODO: figure out a proper solution
@ -214,7 +214,7 @@ pub struct ProtoNode {
impl Default for ProtoNode { impl Default for ProtoNode {
fn default() -> Self { fn default() -> Self {
Self { Self {
identifier: NodeIdentifier::new("graphene_core::ops::IdentityNode"), identifier: ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode"),
construction_args: ConstructionArgs::Value(value::TaggedValue::U32(0)), construction_args: ConstructionArgs::Value(value::TaggedValue::U32(0)),
input: ProtoNodeInput::None, input: ProtoNodeInput::None,
document_node_path: vec![], document_node_path: vec![],
@ -282,7 +282,7 @@ impl ProtoNode {
/// Construct a new [`ProtoNode`] with the specified construction args and a `ClonedNode` implementation. /// Construct a new [`ProtoNode`] with the specified construction args and a `ClonedNode` implementation.
pub fn value(value: ConstructionArgs, path: Vec<NodeId>) -> Self { pub fn value(value: ConstructionArgs, path: Vec<NodeId>) -> Self {
Self { Self {
identifier: NodeIdentifier::new("graphene_core::value::ClonedNode"), identifier: ProtoNodeIdentifier::new("graphene_core::value::ClonedNode"),
construction_args: value, construction_args: value,
input: ProtoNodeInput::None, input: ProtoNodeInput::None,
document_node_path: path, document_node_path: path,
@ -395,7 +395,7 @@ impl ProtoNetwork {
self.nodes.push(( self.nodes.push((
compose_node_id, compose_node_id,
ProtoNode { ProtoNode {
identifier: NodeIdentifier::new("graphene_core::structural::ComposeNode<_, _, _>"), identifier: ProtoNodeIdentifier::new("graphene_core::structural::ComposeNode<_, _, _>"),
construction_args: ConstructionArgs::Nodes(vec![(input_node_id, false), (node_id, true)]), construction_args: ConstructionArgs::Nodes(vec![(input_node_id, false), (node_id, true)]),
input, input,
document_node_path: path, document_node_path: path,
@ -541,14 +541,14 @@ impl ProtoNetwork {
/// The `TypingContext` is used to store the types of the nodes indexed by their stable node id. /// The `TypingContext` is used to store the types of the nodes indexed by their stable node id.
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub struct TypingContext { pub struct TypingContext {
lookup: Cow<'static, HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>>>, lookup: Cow<'static, HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>>>,
inferred: HashMap<NodeId, NodeIOTypes>, inferred: HashMap<NodeId, NodeIOTypes>,
constructor: HashMap<NodeId, NodeConstructor>, constructor: HashMap<NodeId, NodeConstructor>,
} }
impl TypingContext { impl TypingContext {
/// Creates a new `TypingContext` with the given lookup table. /// Creates a new `TypingContext` with the given lookup table.
pub fn new(lookup: &'static HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>>) -> Self { pub fn new(lookup: &'static HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>>) -> Self {
Self { Self {
lookup: Cow::Borrowed(lookup), lookup: Cow::Borrowed(lookup),
..Default::default() ..Default::default()

View File

@ -8,7 +8,7 @@ use graph_craft::{
document::*, document::*,
graphene_compiler::{Compiler, Executor}, graphene_compiler::{Compiler, Executor},
imaginate_input::ImaginatePreferences, imaginate_input::ImaginatePreferences,
NodeIdentifier, ProtoNodeIdentifier,
}; };
use graphene_core::{ use graphene_core::{
application_io::{ApplicationIo, NodeGraphUpdateSender}, application_io::{ApplicationIo, NodeGraphUpdateSender},
@ -164,20 +164,20 @@ fn begin_scope() -> DocumentNode {
DocumentNode { DocumentNode {
name: "SetNode".to_string(), name: "SetNode".to_string(),
manual_composition: Some(concrete!(WasmEditorApi)), manual_composition: Some(concrete!(WasmEditorApi)),
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::SomeNode")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::SomeNode")),
..Default::default() ..Default::default()
}, },
DocumentNode { DocumentNode {
name: "LetNode".to_string(), name: "LetNode".to_string(),
inputs: vec![NodeInput::node(0, 0)], inputs: vec![NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::memo::LetNode<_>")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::LetNode<_>")),
..Default::default() ..Default::default()
}, },
DocumentNode { DocumentNode {
name: "RefNode".to_string(), name: "RefNode".to_string(),
manual_composition: Some(concrete!(WasmEditorApi)), manual_composition: Some(concrete!(WasmEditorApi)),
inputs: vec![NodeInput::lambda(1, 0)], inputs: vec![NodeInput::lambda(1, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::memo::RefNode<_, _>")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::memo::RefNode<_, _>")),
..Default::default() ..Default::default()
}, },
] ]

View File

@ -381,9 +381,9 @@ pub struct MapGpuSingleImageNode<N> {
#[node_macro::node_fn(MapGpuSingleImageNode)] #[node_macro::node_fn(MapGpuSingleImageNode)]
fn map_gpu_single_image(input: Image<Color>, node: String) -> Image<Color> { fn map_gpu_single_image(input: Image<Color>, node: String) -> Image<Color> {
use graph_craft::document::*; use graph_craft::document::*;
use graph_craft::NodeIdentifier; use graph_craft::ProtoNodeIdentifier;
let identifier = NodeIdentifier { name: std::borrow::Cow::Owned(node) }; let identifier = ProtoNodeIdentifier { name: std::borrow::Cow::Owned(node) };
let network = NodeNetwork { let network = NodeNetwork {
inputs: vec![0], inputs: vec![0],

View File

@ -24,7 +24,7 @@ mod tests {
DocumentNode { DocumentNode {
name: "Cons".into(), name: "Cons".into(),
inputs: vec![NodeInput::Network(concrete!(u32)), NodeInput::Network(concrete!(&u32))], inputs: vec![NodeInput::Network(concrete!(u32)), NodeInput::Network(concrete!(&u32))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::structural::ConsNode<_, _>")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::structural::ConsNode<_, _>")),
..Default::default() ..Default::default()
}, },
), ),
@ -33,7 +33,7 @@ mod tests {
DocumentNode { DocumentNode {
name: "Add".into(), name: "Add".into(),
inputs: vec![NodeInput::node(0, 0)], inputs: vec![NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::AddPairNode")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::AddPairNode")),
..Default::default() ..Default::default()
}, },
), ),
@ -95,7 +95,7 @@ mod tests {
DocumentNode { DocumentNode {
name: "id".into(), name: "id".into(),
inputs: vec![NodeInput::Network(concrete!(u32))], inputs: vec![NodeInput::Network(concrete!(u32))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdentityNode")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode")),
..Default::default() ..Default::default()
}, },
), ),
@ -105,7 +105,7 @@ mod tests {
DocumentNode { DocumentNode {
name: "Add".into(), name: "Add".into(),
inputs: vec![NodeInput::node(0, 0), NodeInput::node(0, 0)], inputs: vec![NodeInput::node(0, 0), NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::AddNode<_>")), implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("graphene_core::ops::AddNode<_>")),
..Default::default() ..Default::default()
}, },
), ),

View File

@ -13,7 +13,7 @@ use graphene_core::vector::VectorData;
use graphene_core::{application_io::SurfaceHandle, SurfaceFrame, WasmSurfaceHandleFrame}; use graphene_core::{application_io::SurfaceHandle, SurfaceFrame, WasmSurfaceHandleFrame};
use graphene_core::{concrete, generic, Artboard, GraphicGroup}; use graphene_core::{concrete, generic, Artboard, GraphicGroup};
use graphene_core::{fn_type, raster::*}; use graphene_core::{fn_type, raster::*};
use graphene_core::{Cow, NodeIdentifier, Type}; use graphene_core::{Cow, ProtoNodeIdentifier, Type};
use graphene_core::{Node, NodeIO, NodeIOTypes}; use graphene_core::{Node, NodeIO, NodeIOTypes};
use graphene_std::any::{ComposeTypeErased, DowncastBothNode, DynAnyNode, FutureWrapperNode, IntoTypeErasedNode}; use graphene_std::any::{ComposeTypeErased, DowncastBothNode, DynAnyNode, FutureWrapperNode, IntoTypeErasedNode};
use graphene_std::wasm_application_io::*; use graphene_std::wasm_application_io::*;
@ -55,7 +55,7 @@ macro_rules! register_node {
($path:ty, input: $input:ty, fn_params: [ $($arg:ty => $type:ty),*]) => { ($path:ty, input: $input:ty, fn_params: [ $($arg:ty => $type:ty),*]) => {
vec![ vec![
( (
NodeIdentifier::new(stringify!($path)), ProtoNodeIdentifier::new(stringify!($path)),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let node = construct_node!(args, $path, [$($arg => $type),*]).await; let node = construct_node!(args, $path, [$($arg => $type),*]).await;
@ -86,7 +86,7 @@ macro_rules! async_node {
($path:ty, input: $input:ty, output: $output:ty, fn_params: [ $($arg:ty => $type:ty),*]) => { ($path:ty, input: $input:ty, output: $output:ty, fn_params: [ $($arg:ty => $type:ty),*]) => {
vec![ vec![
( (
NodeIdentifier::new(stringify!($path)), ProtoNodeIdentifier::new(stringify!($path)),
|mut args| { |mut args| {
Box::pin(async move { Box::pin(async move {
args.reverse(); args.reverse();
@ -122,10 +122,10 @@ macro_rules! raster_node {
// optimization purposes. // optimization purposes.
#[cfg_attr(debug_assertions, inline(never))] #[cfg_attr(debug_assertions, inline(never))]
#[cfg_attr(not(debug_assertions), inline)] #[cfg_attr(not(debug_assertions), inline)]
fn generate_triples() -> Vec<(NodeIdentifier, NodeConstructor, NodeIOTypes)> { fn generate_triples() -> Vec<(ProtoNodeIdentifier, NodeConstructor, NodeIOTypes)> {
vec![ vec![
( (
NodeIdentifier::new(stringify!($path)), ProtoNodeIdentifier::new(stringify!($path)),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let node = construct_node!(args, $path, [$(() => $type),*]).await; let node = construct_node!(args, $path, [$(() => $type),*]).await;
@ -140,7 +140,7 @@ macro_rules! raster_node {
}, },
), ),
( (
NodeIdentifier::new(stringify!($path)), ProtoNodeIdentifier::new(stringify!($path)),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let node = construct_node!(args, $path, [$(() => $type),*]).await; let node = construct_node!(args, $path, [$(() => $type),*]).await;
@ -156,7 +156,7 @@ macro_rules! raster_node {
}, },
), ),
( (
NodeIdentifier::new(stringify!($path)), ProtoNodeIdentifier::new(stringify!($path)),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let node = construct_node!(args, $path, [$(() => $type),*]).await; let node = construct_node!(args, $path, [$(() => $type),*]).await;
@ -178,11 +178,11 @@ macro_rules! raster_node {
} }
//TODO: turn into hashmap //TODO: turn into hashmap
fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>> { fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>> {
let node_types: Vec<Vec<(NodeIdentifier, NodeConstructor, NodeIOTypes)>> = vec![ let node_types: Vec<Vec<(ProtoNodeIdentifier, NodeConstructor, NodeIOTypes)>> = vec![
//register_node!(graphene_core::ops::IdentityNode, input: Any<'_>, params: []), //register_node!(graphene_core::ops::IdentityNode, input: Any<'_>, params: []),
vec![( vec![(
NodeIdentifier::new("graphene_core::ops::IdentityNode"), ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode"),
|_| Box::pin(async move { FutureWrapperNode::new(IdentityNode::new()).into_type_erased() }), |_| Box::pin(async move { FutureWrapperNode::new(IdentityNode::new()).into_type_erased() }),
NodeIOTypes::new(generic!(I), generic!(I), vec![]), NodeIOTypes::new(generic!(I), generic!(I), vec![]),
)], )],
@ -284,7 +284,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
register_node!(graphene_std::raster::InsertChannelNode<_, _, _, _>, input: ImageFrame<Color>, params: [ImageFrame<Color>, RedGreenBlue]), register_node!(graphene_std::raster::InsertChannelNode<_, _, _, _>, input: ImageFrame<Color>, params: [ImageFrame<Color>, RedGreenBlue]),
register_node!(graphene_std::raster::InsertChannelNode<_, _, _, _>, input: ImageFrame<Color>, params: [ImageFrame<Luma>, RedGreenBlue]), register_node!(graphene_std::raster::InsertChannelNode<_, _, _, _>, input: ImageFrame<Color>, params: [ImageFrame<Luma>, RedGreenBlue]),
vec![( vec![(
NodeIdentifier::new("graphene_std::raster::CombineChannelsNode"), ProtoNodeIdentifier::new("graphene_std::raster::CombineChannelsNode"),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
use graphene_core::raster::*; use graphene_core::raster::*;
@ -380,7 +380,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
), ),
#[cfg(feature = "gpu")] #[cfg(feature = "gpu")]
vec![( vec![(
NodeIdentifier::new("graphene_std::executor::MapGpuSingleImageNode<_>"), ProtoNodeIdentifier::new("graphene_std::executor::MapGpuSingleImageNode<_>"),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let document_node: DowncastBothNode<(), graph_craft::document::DocumentNode> = DowncastBothNode::new(args[0].clone()); let document_node: DowncastBothNode<(), graph_craft::document::DocumentNode> = DowncastBothNode::new(args[0].clone());
@ -399,7 +399,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
)], )],
#[cfg(feature = "gpu")] #[cfg(feature = "gpu")]
vec![( vec![(
NodeIdentifier::new("graphene_std::executor::BlendGpuImageNode<_, _, _>"), ProtoNodeIdentifier::new("graphene_std::executor::BlendGpuImageNode<_, _, _>"),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let background: DowncastBothNode<(), ImageFrame<Color>> = DowncastBothNode::new(args[0].clone()); let background: DowncastBothNode<(), ImageFrame<Color>> = DowncastBothNode::new(args[0].clone());
@ -418,7 +418,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
), ),
)], )],
vec![( vec![(
NodeIdentifier::new("graphene_core::structural::ComposeNode<_, _, _>"), ProtoNodeIdentifier::new("graphene_core::structural::ComposeNode<_, _, _>"),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let node = ComposeTypeErased::new(args[0].clone(), args[1].clone()); let node = ComposeTypeErased::new(args[0].clone(), args[1].clone());
@ -446,7 +446,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
register_node!(graphene_core::raster::adjustments::ColorFillNode<_>, input: ImageFrame<Color>, params: [Color]), register_node!(graphene_core::raster::adjustments::ColorFillNode<_>, input: ImageFrame<Color>, params: [Color]),
register_node!(graphene_core::raster::adjustments::ColorOverlayNode<_, _, _>, input: ImageFrame<Color>, params: [Color, BlendMode, f32]), register_node!(graphene_core::raster::adjustments::ColorOverlayNode<_, _, _>, input: ImageFrame<Color>, params: [Color, BlendMode, f32]),
vec![( vec![(
NodeIdentifier::new("graphene_core::raster::BlendNode<_, _, _, _>"), ProtoNodeIdentifier::new("graphene_core::raster::BlendNode<_, _, _, _>"),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let image: DowncastBothNode<(), ImageFrame<Color>> = DowncastBothNode::new(args[0].clone()); let image: DowncastBothNode<(), ImageFrame<Color>> = DowncastBothNode::new(args[0].clone());
@ -478,7 +478,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
params: [RelativeAbsolute, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32] params: [RelativeAbsolute, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32]
), ),
vec![( vec![(
NodeIdentifier::new("graphene_core::raster::BrightnessContrastNode<_, _, _>"), ProtoNodeIdentifier::new("graphene_core::raster::BrightnessContrastNode<_, _, _>"),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
use graphene_core::raster::brightness_contrast::*; use graphene_core::raster::brightness_contrast::*;
@ -508,7 +508,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
)], )],
vec![ vec![
( (
NodeIdentifier::new("graphene_core::raster::CurvesNode<_>"), ProtoNodeIdentifier::new("graphene_core::raster::CurvesNode<_>"),
|args| { |args| {
use graphene_core::raster::{curve::Curve, GenerateCurvesNode}; use graphene_core::raster::{curve::Curve, GenerateCurvesNode};
let curve: DowncastBothNode<(), Curve> = DowncastBothNode::new(args[0].clone()); let curve: DowncastBothNode<(), Curve> = DowncastBothNode::new(args[0].clone());
@ -526,7 +526,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
), ),
// TODO: Use channel split and merge for this instead of using LuminanceMut for the whole color. // TODO: Use channel split and merge for this instead of using LuminanceMut for the whole color.
( (
NodeIdentifier::new("graphene_core::raster::CurvesNode<_>"), ProtoNodeIdentifier::new("graphene_core::raster::CurvesNode<_>"),
|args| { |args| {
use graphene_core::raster::{curve::Curve, GenerateCurvesNode}; use graphene_core::raster::{curve::Curve, GenerateCurvesNode};
let curve: DowncastBothNode<(), Curve> = DowncastBothNode::new(args[0].clone()); let curve: DowncastBothNode<(), Curve> = DowncastBothNode::new(args[0].clone());
@ -584,7 +584,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
async_node!(graphene_core::memo::EndLetNode<_, _>, input: WasmEditorApi, output: SurfaceFrame, params: [SurfaceFrame]), async_node!(graphene_core::memo::EndLetNode<_, _>, input: WasmEditorApi, output: SurfaceFrame, params: [SurfaceFrame]),
vec![ vec![
( (
NodeIdentifier::new("graphene_core::memo::RefNode<_, _>"), ProtoNodeIdentifier::new("graphene_core::memo::RefNode<_, _>"),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let node: DowncastBothNode<Option<WasmEditorApi>, WasmEditorApi> = graphene_std::any::DowncastBothNode::new(args[0].clone()); let node: DowncastBothNode<Option<WasmEditorApi>, WasmEditorApi> = graphene_std::any::DowncastBothNode::new(args[0].clone());
@ -597,7 +597,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
NodeIOTypes::new(concrete!(()), concrete!(WasmEditorApi), vec![fn_type!(Option<WasmEditorApi>, WasmEditorApi)]), NodeIOTypes::new(concrete!(()), concrete!(WasmEditorApi), vec![fn_type!(Option<WasmEditorApi>, WasmEditorApi)]),
), ),
( (
NodeIdentifier::new("graphene_std::raster::ImaginateNode<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _>"), ProtoNodeIdentifier::new("graphene_std::raster::ImaginateNode<_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _>"),
|args: Vec<graph_craft::proto::SharedNodeContainer>| { |args: Vec<graph_craft::proto::SharedNodeContainer>| {
Box::pin(async move { Box::pin(async move {
use graphene_std::raster::ImaginateNode; use graphene_std::raster::ImaginateNode;
@ -669,7 +669,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
//register_node!(graphene_core::transform::TranformNode<_, _, _, _, _, _>, input: , output: RenderOutput, fn_params: [Footprint => GraphicGroup, () => Arc<WasmSurfaceHandle>]), //register_node!(graphene_core::transform::TranformNode<_, _, _, _, _, _>, input: , output: RenderOutput, fn_params: [Footprint => GraphicGroup, () => Arc<WasmSurfaceHandle>]),
vec![ vec![
( (
NodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"), ProtoNodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"),
|mut args| { |mut args| {
Box::pin(async move { Box::pin(async move {
args.reverse(); args.reverse();
@ -691,7 +691,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
}, },
), ),
( (
NodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"), ProtoNodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"),
|mut args| { |mut args| {
Box::pin(async move { Box::pin(async move {
args.reverse(); args.reverse();
@ -720,7 +720,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
}, },
), ),
( (
NodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"), ProtoNodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"),
|mut args| { |mut args| {
Box::pin(async move { Box::pin(async move {
args.reverse(); args.reverse();
@ -749,7 +749,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
}, },
), ),
( (
NodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"), ProtoNodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"),
|mut args| { |mut args| {
Box::pin(async move { Box::pin(async move {
const EXPECT_MESSAGE: &str = "Not enough arguments provided to construct node"; const EXPECT_MESSAGE: &str = "Not enough arguments provided to construct node";
@ -785,7 +785,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
register_node!(graphene_core::vector::BoundingBoxNode, input: VectorData, params: []), register_node!(graphene_core::vector::BoundingBoxNode, input: VectorData, params: []),
register_node!(graphene_core::vector::CircularRepeatNode<_, _, _>, input: VectorData, params: [f32, f32, u32]), register_node!(graphene_core::vector::CircularRepeatNode<_, _, _>, input: VectorData, params: [f32, f32, u32]),
vec![( vec![(
NodeIdentifier::new("graphene_core::transform::CullNode<_>"), ProtoNodeIdentifier::new("graphene_core::transform::CullNode<_>"),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let mut args = args.clone(); let mut args = args.clone();
@ -806,7 +806,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
register_node!(graphene_core::transform::CullNode<_>, input: Footprint, params: [Artboard]), register_node!(graphene_core::transform::CullNode<_>, input: Footprint, params: [Artboard]),
register_node!(graphene_core::transform::CullNode<_>, input: Footprint, params: [ImageFrame<Color>]), register_node!(graphene_core::transform::CullNode<_>, input: Footprint, params: [ImageFrame<Color>]),
vec![( vec![(
NodeIdentifier::new("graphene_core::transform::CullNode<_>"), ProtoNodeIdentifier::new("graphene_core::transform::CullNode<_>"),
|args| { |args| {
Box::pin(async move { Box::pin(async move {
let mut args = args.clone(); let mut args = args.clone();
@ -850,19 +850,19 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
register_node!(graphene_core::ToGraphicElementData, input: Artboard, params: []), register_node!(graphene_core::ToGraphicElementData, input: Artboard, params: []),
async_node!(graphene_core::ConstructArtboardNode<_, _, _, _, _>, input: Footprint, output: Artboard, fn_params: [Footprint => GraphicGroup, () => glam::IVec2, () => glam::IVec2, () => Color, () => bool]), async_node!(graphene_core::ConstructArtboardNode<_, _, _, _, _>, input: Footprint, output: Artboard, fn_params: [Footprint => GraphicGroup, () => glam::IVec2, () => glam::IVec2, () => Color, () => bool]),
]; ];
let mut map: HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>> = HashMap::new(); let mut map: HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>> = HashMap::new();
for (id, c, types) in node_types.into_iter().flatten() { for (id, c, types) in node_types.into_iter().flatten() {
// TODO: this is a hack to remove the newline from the node new_name // TODO: this is a hack to remove the newline from the node new_name
// This occurs for the ChannelMixerNode presumably because of the long name. // This occurs for the ChannelMixerNode presumably because of the long name.
// This might be caused by the stringify! macro // This might be caused by the stringify! macro
let new_name = id.name.replace('\n', " "); let new_name = id.name.replace('\n', " ");
let nid = NodeIdentifier { name: Cow::Owned(new_name) }; let nid = ProtoNodeIdentifier { name: Cow::Owned(new_name) };
map.entry(nid).or_default().insert(types.clone(), c); map.entry(nid).or_default().insert(types.clone(), c);
} }
map map
} }
pub static NODE_REGISTRY: Lazy<HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>>> = Lazy::new(|| node_registry()); pub static NODE_REGISTRY: Lazy<HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>>> = Lazy::new(|| node_registry());
#[cfg(test)] #[cfg(test)]
mod protograph_testing { mod protograph_testing {

View File

@ -116,7 +116,7 @@ fn create_buffer<T: Pod + Send + Sync>(data: Vec<T>, alloc: &StandardMemoryAlloc
// TODO: Fix this test // TODO: Fix this test
// #[cfg(test)] // #[cfg(test)]
// mod test { // mod test {
// use graph_craft::proto::{ConstructionArgs, NodeIdentifier, ProtoNetwork, ProtoNode, ProtoNodeInput, Type}; // use graph_craft::proto::{ConstructionArgs, ProtoNodeIdentifier, ProtoNetwork, ProtoNode, ProtoNodeInput, Type};
// use graph_craft::{concrete, generic}; // use graph_craft::{concrete, generic};
// fn inc_network() -> ProtoNetwork { // fn inc_network() -> ProtoNetwork {
@ -127,7 +127,7 @@ fn create_buffer<T: Pod + Send + Sync>(data: Vec<T>, alloc: &StandardMemoryAlloc
// ( // (
// 1, // 1,
// ProtoNode { // ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::ops::IdentityNode", &[generic!("u32")]), // identifier: ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode", &[generic!("u32")]),
// input: ProtoNodeInput::Node(11), // input: ProtoNodeInput::Node(11),
// construction_args: ConstructionArgs::Nodes(vec![]), // construction_args: ConstructionArgs::Nodes(vec![]),
// }, // },
@ -135,7 +135,7 @@ fn create_buffer<T: Pod + Send + Sync>(data: Vec<T>, alloc: &StandardMemoryAlloc
// ( // (
// 10, // 10,
// ProtoNode { // ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::structural::ConsNode", &[generic!("&ValueNode<u32>"), generic!("()")]), // identifier: ProtoNodeIdentifier::new("graphene_core::structural::ConsNode", &[generic!("&ValueNode<u32>"), generic!("()")]),
// input: ProtoNodeInput::Network, // input: ProtoNodeInput::Network,
// construction_args: ConstructionArgs::Nodes(vec![14]), // construction_args: ConstructionArgs::Nodes(vec![14]),
// }, // },
@ -143,7 +143,7 @@ fn create_buffer<T: Pod + Send + Sync>(data: Vec<T>, alloc: &StandardMemoryAlloc
// ( // (
// 11, // 11,
// ProtoNode { // ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::ops::AddPairNode", &[generic!("u32"), generic!("u32")]), // identifier: ProtoNodeIdentifier::new("graphene_core::ops::AddPairNode", &[generic!("u32"), generic!("u32")]),
// input: ProtoNodeInput::Node(10), // input: ProtoNodeInput::Node(10),
// construction_args: ConstructionArgs::Nodes(vec![]), // construction_args: ConstructionArgs::Nodes(vec![]),
// }, // },
@ -151,7 +151,7 @@ fn create_buffer<T: Pod + Send + Sync>(data: Vec<T>, alloc: &StandardMemoryAlloc
// ( // (
// 14, // 14,
// ProtoNode { // ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::value::ValueNode", &[concrete!("u32")]), // identifier: ProtoNodeIdentifier::new("graphene_core::value::ValueNode", &[concrete!("u32")]),
// input: ProtoNodeInput::None, // input: ProtoNodeInput::None,
// construction_args: ConstructionArgs::Value(Box::new(3_u32)), // construction_args: ConstructionArgs::Value(Box::new(3_u32)),
// }, // },

View File

@ -209,7 +209,7 @@ async fn execute_shader<I: Pod + Send + Sync, O: Pod + Send + Sync>(device: Arc<
// ( // (
// 1, // 1,
// ProtoNode { // ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::ops::IdentityNode", &[generic!("u32")]), // identifier: ProtoNodeIdentifier::new("graphene_core::ops::IdentityNode", &[generic!("u32")]),
// input: ProtoNodeInput::Node(11), // input: ProtoNodeInput::Node(11),
// construction_args: ConstructionArgs::Nodes(vec![]), // construction_args: ConstructionArgs::Nodes(vec![]),
// }, // },
@ -217,7 +217,7 @@ async fn execute_shader<I: Pod + Send + Sync, O: Pod + Send + Sync>(device: Arc<
// ( // (
// 10, // 10,
// ProtoNode { // ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::structural::ConsNode", &[generic!("&ValueNode<u32>"), generic!("()")]), // identifier: ProtoNodeIdentifier::new("graphene_core::structural::ConsNode", &[generic!("&ValueNode<u32>"), generic!("()")]),
// input: ProtoNodeInput::Network, // input: ProtoNodeInput::Network,
// construction_args: ConstructionArgs::Nodes(vec![14]), // construction_args: ConstructionArgs::Nodes(vec![14]),
// }, // },
@ -225,7 +225,7 @@ async fn execute_shader<I: Pod + Send + Sync, O: Pod + Send + Sync>(device: Arc<
// ( // (
// 11, // 11,
// ProtoNode { // ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::ops::AddPairNode", &[generic!("u32"), generic!("u32")]), // identifier: ProtoNodeIdentifier::new("graphene_core::ops::AddPairNode", &[generic!("u32"), generic!("u32")]),
// input: ProtoNodeInput::Node(10), // input: ProtoNodeInput::Node(10),
// construction_args: ConstructionArgs::Nodes(vec![]), // construction_args: ConstructionArgs::Nodes(vec![]),
// }, // },
@ -233,7 +233,7 @@ async fn execute_shader<I: Pod + Send + Sync, O: Pod + Send + Sync>(device: Arc<
// ( // (
// 14, // 14,
// ProtoNode { // ProtoNode {
// identifier: NodeIdentifier::new("graphene_core::value::ValueNode", &[concrete!("u32")]), // identifier: ProtoNodeIdentifier::new("graphene_core::value::ValueNode", &[concrete!("u32")]),
// input: ProtoNodeInput::None, // input: ProtoNodeInput::None,
// construction_args: ConstructionArgs::Value(Box::new(3_u32)), // construction_args: ConstructionArgs::Value(Box::new(3_u32)),
// }, // },