mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 04:48:12 +08:00
Rename EdgeHandle to SourceHandle
This commit is contained in:
@@ -7,7 +7,7 @@ use core_types::color::SRGBA8;
|
|||||||
use core_types::context::Context;
|
use core_types::context::Context;
|
||||||
use core_types::gpoll::GPoll;
|
use core_types::gpoll::GPoll;
|
||||||
use core_types::list::List;
|
use core_types::list::List;
|
||||||
use core_types::registry::EdgeHandle;
|
use core_types::registry::SourceHandle;
|
||||||
use core_types::transform::Footprint;
|
use core_types::transform::Footprint;
|
||||||
use core_types::uuid::NodeId;
|
use core_types::uuid::NodeId;
|
||||||
use core_types::value::{leveled_record_value_edge, record_value_edge};
|
use core_types::value::{leveled_record_value_edge, record_value_edge};
|
||||||
@@ -310,7 +310,7 @@ macro_rules! tagged_value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Materializes the value as [`Self::to_dynany`] does, wrapped in a value source typed by [`Self::ty`].
|
/// Materializes the value as [`Self::to_dynany`] does, wrapped in a value source typed by [`Self::ty`].
|
||||||
pub fn to_edge(self) -> Result<EdgeHandle, String> {
|
pub fn to_edge(self) -> Result<SourceHandle, String> {
|
||||||
match self {
|
match self {
|
||||||
// ===============
|
// ===============
|
||||||
// MANUAL VARIANTS
|
// MANUAL VARIANTS
|
||||||
@@ -359,7 +359,7 @@ macro_rules! tagged_value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluates a typed source and converts the landed value into a tagged value, with the coverage of [`Self::try_from_any`].
|
/// Evaluates a typed source and converts the landed value into a tagged value, with the coverage of [`Self::try_from_any`].
|
||||||
pub fn from_edge<'f>(handle: EdgeHandle, ctx: &Context<'f>, frames: &core_types::record::Frames<'f>) -> Result<GPoll<Self>, String> {
|
pub fn from_edge<'f>(handle: SourceHandle, ctx: &Context<'f>, frames: &core_types::record::Frames<'f>) -> Result<GPoll<Self>, String> {
|
||||||
let ty = handle.ty().clone();
|
let ty = handle.ty().clone();
|
||||||
// =======================
|
// =======================
|
||||||
// RECORD WIRES, WHICH LAND AS THEIR ELEMENT
|
// RECORD WIRES, WHICH LAND AS THEIR ELEMENT
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use crate::node_registry;
|
|||||||
use core_types::arena::Arena;
|
use core_types::arena::Arena;
|
||||||
use core_types::context::{ContextImpl, DynSlot, EvalScope, ExtractAnimationTime, ExtractPointerPosition, ExtractRealTime, VarArg, VarArgLink, VarArgSlots};
|
use core_types::context::{ContextImpl, DynSlot, EvalScope, ExtractAnimationTime, ExtractPointerPosition, ExtractRealTime, VarArg, VarArgLink, VarArgSlots};
|
||||||
use core_types::gpoll::GPoll;
|
use core_types::gpoll::GPoll;
|
||||||
use core_types::registry::EdgeHandle;
|
use core_types::registry::SourceHandle;
|
||||||
use core_types::runtime::{DynGraphRuntime, DynSpawner, GraphRuntime, NoopSpawner};
|
use core_types::runtime::{DynGraphRuntime, DynSpawner, GraphRuntime, NoopSpawner};
|
||||||
use graph_craft::Type;
|
use graph_craft::Type;
|
||||||
use graph_craft::document::NodeId;
|
use graph_craft::document::NodeId;
|
||||||
@@ -197,7 +197,7 @@ impl DynamicExecutor {
|
|||||||
let edge = self
|
let edge = self
|
||||||
.tree
|
.tree
|
||||||
.get_by_path(node_path)
|
.get_by_path(node_path)
|
||||||
.and_then(EdgeHandle::record_edge)
|
.and_then(SourceHandle::record_edge)
|
||||||
.ok_or_else(|| IntrospectError::PathNotFound(node_path.to_vec()))?;
|
.ok_or_else(|| IntrospectError::PathNotFound(node_path.to_vec()))?;
|
||||||
let arena = self.arena.lock().unwrap_or_else(PoisonError::into_inner);
|
let arena = self.arena.lock().unwrap_or_else(PoisonError::into_inner);
|
||||||
let persistent = self.persistent.lock().unwrap_or_else(PoisonError::into_inner);
|
let persistent = self.persistent.lock().unwrap_or_else(PoisonError::into_inner);
|
||||||
@@ -363,7 +363,7 @@ impl std::fmt::Display for IntrospectError {
|
|||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
///
|
///
|
||||||
/// * `nodes`: A [`HashMap`] of [`NodeId`]s to tuples of [`EdgeHandle`] and [`Path`].
|
/// * `nodes`: A [`HashMap`] of [`NodeId`]s to tuples of [`SourceHandle`] and [`Path`].
|
||||||
/// This stores the actual node instances and their associated paths.
|
/// This stores the actual node instances and their associated paths.
|
||||||
///
|
///
|
||||||
/// * `source_map`: A [`HashMap`] from [`Path`] to tuples of [`NodeId`] and [`NodeTypes`].
|
/// * `source_map`: A [`HashMap`] from [`Path`] to tuples of [`NodeId`] and [`NodeTypes`].
|
||||||
@@ -373,7 +373,7 @@ impl std::fmt::Display for IntrospectError {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct BorrowTree {
|
pub struct BorrowTree {
|
||||||
/// A hashmap of node IDs and dynamically typed nodes.
|
/// A hashmap of node IDs and dynamically typed nodes.
|
||||||
nodes: HashMap<NodeId, (EdgeHandle, Path)>,
|
nodes: HashMap<NodeId, (SourceHandle, Path)>,
|
||||||
/// A hashmap from the document path to the proto node ID.
|
/// A hashmap from the document path to the proto node ID.
|
||||||
source_map: HashMap<Path, (NodeId, NodeTypes)>,
|
source_map: HashMap<Path, (NodeId, NodeTypes)>,
|
||||||
/// The record-stack reserve, folded from the graph at construction.
|
/// The record-stack reserve, folded from the graph at construction.
|
||||||
@@ -410,11 +410,11 @@ impl BorrowTree {
|
|||||||
Ok((new_nodes, old_nodes))
|
Ok((new_nodes, old_nodes))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_deps(&self, nodes: &[NodeId]) -> Vec<EdgeHandle> {
|
fn node_deps(&self, nodes: &[NodeId]) -> Vec<SourceHandle> {
|
||||||
nodes.iter().map(|node| self.nodes.get(node).unwrap().0.duplicate()).collect()
|
nodes.iter().map(|node| self.nodes.get(node).unwrap().0.duplicate()).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn store_node(&mut self, node: EdgeHandle, id: NodeId, path: Path) {
|
fn store_node(&mut self, node: SourceHandle, id: NodeId, path: Path) {
|
||||||
self.nodes.insert(id, (node, path));
|
self.nodes.insert(id, (node, path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,12 +425,12 @@ impl BorrowTree {
|
|||||||
node.serialize().ok_or(IntrospectError::NoData)
|
node.serialize().ok_or(IntrospectError::NoData)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self, id: NodeId) -> Option<EdgeHandle> {
|
pub fn get(&self, id: NodeId) -> Option<SourceHandle> {
|
||||||
self.nodes.get(&id).map(|(node, _)| node.duplicate())
|
self.nodes.get(&id).map(|(node, _)| node.duplicate())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The edge handle for the node at a document path.
|
/// The edge handle for the node at a document path.
|
||||||
pub fn get_by_path(&self, node_path: &[NodeId]) -> Option<EdgeHandle> {
|
pub fn get_by_path(&self, node_path: &[NodeId]) -> Option<SourceHandle> {
|
||||||
let (id, _) = self.source_map.get(node_path)?;
|
let (id, _) = self.source_map.get(node_path)?;
|
||||||
self.get(*id)
|
self.get(*id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use graphene_std::raster::GPU;
|
|||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
use graphene_std::SourceId;
|
use graphene_std::SourceId;
|
||||||
use graphene_std::raster::{CPU, Raster};
|
use graphene_std::raster::{CPU, Raster};
|
||||||
use graphene_std::registry::{ConstructionError, EdgeHandle, NodeIOTypes, RegistryEntry};
|
use graphene_std::registry::{ConstructionError, SourceHandle, NodeIOTypes, RegistryEntry};
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
use graphene_std::runtime::RuntimeHandle;
|
use graphene_std::runtime::RuntimeHandle;
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ mod node_registry_macros {
|
|||||||
let handle = inputs.next().unwrap();
|
let handle = inputs.next().unwrap();
|
||||||
let layout = handle.layout().clone();
|
let layout = handle.layout().clone();
|
||||||
let node = graphene_std::ops::IntoNode::<$to, _, $from>::new(handle.downcast_record::<$from>()?, &layout);
|
let node = graphene_std::ops::IntoNode::<$to, _, $from>::new(handle.downcast_record::<$from>()?, &layout);
|
||||||
Ok(EdgeHandle::new_record::<$to>(std::sync::Arc::new(node) as std::sync::Arc<core_types::registry::ErasedRecordNode>))
|
Ok(SourceHandle::new_record::<$to>(std::sync::Arc::new(node) as std::sync::Arc<core_types::registry::ErasedRecordNode>))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -314,7 +314,7 @@ mod node_registry_macros {
|
|||||||
&runtime_layout,
|
&runtime_layout,
|
||||||
&source_layout,
|
&source_layout,
|
||||||
);
|
);
|
||||||
Ok(EdgeHandle::new_record::<$to>(std::sync::Arc::new(node) as std::sync::Arc<core_types::registry::ErasedRecordNode>))
|
Ok(SourceHandle::new_record::<$to>(std::sync::Arc::new(node) as std::sync::Arc<core_types::registry::ErasedRecordNode>))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -344,7 +344,7 @@ mod node_registry_macros {
|
|||||||
&value_layout,
|
&value_layout,
|
||||||
&converter_layout,
|
&converter_layout,
|
||||||
);
|
);
|
||||||
Ok(EdgeHandle::new_record::<$to>(std::sync::Arc::new(node) as std::sync::Arc<core_types::registry::ErasedRecordNode>))
|
Ok(SourceHandle::new_record::<$to>(std::sync::Arc::new(node) as std::sync::Arc<core_types::registry::ErasedRecordNode>))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EdgeHandle {
|
pub struct SourceHandle {
|
||||||
node: Box<DynEdge>,
|
node: Box<DynEdge>,
|
||||||
share: fn(&DynEdge) -> Box<DynEdge>,
|
share: fn(&DynEdge) -> Box<DynEdge>,
|
||||||
serialize: fn(&DynEdge) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>>,
|
serialize: fn(&DynEdge) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>>,
|
||||||
@@ -194,20 +194,20 @@ pub struct EdgeHandle {
|
|||||||
ty: Type,
|
ty: Type,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for EdgeHandle {
|
impl std::fmt::Debug for SourceHandle {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("EdgeHandle").field("ty", &self.ty).finish_non_exhaustive()
|
f.debug_struct("SourceHandle").field("ty", &self.ty).finish_non_exhaustive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFETY: wasm is single threaded, so the marker-free payload never actually crosses a thread.
|
// SAFETY: wasm is single threaded, so the marker-free payload never actually crosses a thread.
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
unsafe impl Send for EdgeHandle {}
|
unsafe impl Send for SourceHandle {}
|
||||||
// SAFETY: as in Send.
|
// SAFETY: as in Send.
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
unsafe impl Sync for EdgeHandle {}
|
unsafe impl Sync for SourceHandle {}
|
||||||
|
|
||||||
impl EdgeHandle {
|
impl SourceHandle {
|
||||||
pub fn new_record<T: 'static>(node: std::sync::Arc<ErasedRecordNode>) -> Self {
|
pub fn new_record<T: 'static>(node: std::sync::Arc<ErasedRecordNode>) -> Self {
|
||||||
Self::new_erased(node, record_edge_type::<T>())
|
Self::new_erased(node, record_edge_type::<T>())
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ impl EdgeHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type NodeConstructor = fn(Vec<EdgeHandle>) -> Result<EdgeHandle, ConstructionError>;
|
pub type NodeConstructor = fn(Vec<SourceHandle>) -> Result<SourceHandle, ConstructionError>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct RegistryEntry {
|
pub struct RegistryEntry {
|
||||||
@@ -290,7 +290,7 @@ pub struct RegistryEntry {
|
|||||||
pub layout_meta: Option<crate::record::LayoutMeta>,
|
pub layout_meta: Option<crate::record::LayoutMeta>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn construct(entry: &RegistryEntry, inputs: Vec<EdgeHandle>) -> Result<EdgeHandle, ConstructionError> {
|
pub fn construct(entry: &RegistryEntry, inputs: Vec<SourceHandle>) -> Result<SourceHandle, ConstructionError> {
|
||||||
if inputs.len() != entry.io.inputs.len() {
|
if inputs.len() != entry.io.inputs.len() {
|
||||||
return Err(ConstructionError::Arity {
|
return Err(ConstructionError::Arity {
|
||||||
expected: entry.io.inputs.len(),
|
expected: entry.io.inputs.len(),
|
||||||
@@ -376,7 +376,7 @@ mod tests {
|
|||||||
|
|
||||||
let node = LendNode::new("held");
|
let node = LendNode::new("held");
|
||||||
let layout = Node::<ContextImpl>::layout(&node).clone();
|
let layout = Node::<ContextImpl>::layout(&node).clone();
|
||||||
let handle = EdgeHandle::new_erased(Arc::new(node) as Arc<ErasedRecordNode>, concrete!(String));
|
let handle = SourceHandle::new_erased(Arc::new(node) as Arc<ErasedRecordNode>, concrete!(String));
|
||||||
assert_eq!(*handle.ty(), concrete!(String));
|
assert_eq!(*handle.ty(), concrete!(String));
|
||||||
|
|
||||||
let wired = handle.downcast_erased::<ErasedRecordNode>(concrete!(String)).unwrap();
|
let wired = handle.downcast_erased::<ErasedRecordNode>(concrete!(String)).unwrap();
|
||||||
@@ -551,7 +551,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn construct_checks_arity_and_types() {
|
fn construct_checks_arity_and_types() {
|
||||||
fn construct_strlen(args: Vec<EdgeHandle>) -> Result<EdgeHandle, ConstructionError> {
|
fn construct_strlen(args: Vec<SourceHandle>) -> Result<SourceHandle, ConstructionError> {
|
||||||
let mut args = args.into_iter();
|
let mut args = args.into_iter();
|
||||||
let value = args.next().ok_or(ConstructionError::Arity { expected: 1, got: 0 })?.downcast_record::<String>()?;
|
let value = args.next().ok_or(ConstructionError::Arity { expected: 1, got: 0 })?.downcast_record::<String>()?;
|
||||||
drop(value);
|
drop(value);
|
||||||
@@ -587,7 +587,7 @@ mod tests {
|
|||||||
|
|
||||||
let counting = counting();
|
let counting = counting();
|
||||||
let layout = Node::<ContextImpl>::layout(&counting).clone();
|
let layout = Node::<ContextImpl>::layout(&counting).clone();
|
||||||
let handle = EdgeHandle::new_record::<u32>(Arc::new(counting) as Arc<ErasedRecordNode>);
|
let handle = SourceHandle::new_record::<u32>(Arc::new(counting) as Arc<ErasedRecordNode>);
|
||||||
let duplicate = handle.duplicate();
|
let duplicate = handle.duplicate();
|
||||||
assert_eq!(*duplicate.ty(), record_edge_type::<u32>());
|
assert_eq!(*duplicate.ty(), record_edge_type::<u32>());
|
||||||
let frames = crate::record::test_frames(1 << 12);
|
let frames = crate::record::test_frames(1 << 12);
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The native record edge of a constant.
|
/// The native record edge of a constant.
|
||||||
pub fn record_value_edge<T: Clone + Send + Sync + dyn_any::StaticTypeSized + 'static>(value: T) -> crate::registry::EdgeHandle
|
pub fn record_value_edge<T: Clone + Send + Sync + dyn_any::StaticTypeSized + 'static>(value: T) -> crate::registry::SourceHandle
|
||||||
where
|
where
|
||||||
T::Static: Clone + Send + Sync,
|
T::Static: Clone + Send + Sync,
|
||||||
{
|
{
|
||||||
crate::registry::EdgeHandle::new_record::<T>(std::sync::Arc::new(ValueSource::new(value)) as std::sync::Arc<crate::registry::ErasedRecordNode>)
|
crate::registry::SourceHandle::new_record::<T>(std::sync::Arc::new(ValueSource::new(value)) as std::sync::Arc<crate::registry::ErasedRecordNode>)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The node behind a leveled value source: a constant list served as one level,
|
/// The node behind a leveled value source: a constant list served as one level,
|
||||||
@@ -91,9 +91,9 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The native record edge of a constant level: the edge type is the element's.
|
/// The native record edge of a constant level: the edge type is the element's.
|
||||||
pub fn leveled_record_value_edge<T: Clone + Send + Sync + crate::CacheHash + PartialEq + dyn_any::StaticTypeSized + 'static>(values: Vec<T>) -> crate::registry::EdgeHandle
|
pub fn leveled_record_value_edge<T: Clone + Send + Sync + crate::CacheHash + PartialEq + dyn_any::StaticTypeSized + 'static>(values: Vec<T>) -> crate::registry::SourceHandle
|
||||||
where
|
where
|
||||||
T::Static: Clone + Send + Sync,
|
T::Static: Clone + Send + Sync,
|
||||||
{
|
{
|
||||||
crate::registry::EdgeHandle::new_record::<T>(std::sync::Arc::new(LeveledValueSource::new(values)) as std::sync::Arc<crate::registry::ErasedRecordNode>)
|
crate::registry::SourceHandle::new_record::<T>(std::sync::Arc::new(LeveledValueSource::new(values)) as std::sync::Arc<crate::registry::ErasedRecordNode>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ fn flip_entries_tokens(parsed: &ParsedNodeFn, struct_name: &Ident, regular_field
|
|||||||
let mut inputs = inputs.into_iter();
|
let mut inputs = inputs.into_iter();
|
||||||
#(#downcasts)*
|
#(#downcasts)*
|
||||||
let __node = #struct_name #turbofish::new(#(#names,)* #(#layout_args)*);
|
let __node = #struct_name #turbofish::new(#(#names,)* #(#layout_args)*);
|
||||||
Ok(gcore::registry::EdgeHandle::new_record::<#row_output>(::std::sync::Arc::new(__node) as ::std::sync::Arc<gcore::registry::ErasedRecordNode>))
|
Ok(gcore::registry::SourceHandle::new_record::<#row_output>(::std::sync::Arc::new(__node) as ::std::sync::Arc<gcore::registry::ErasedRecordNode>))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -394,7 +394,7 @@ fn single_row_entries(parsed: &ParsedNodeFn, struct_name: &Ident, regular_fields
|
|||||||
let (io_output, wrap) = match &output_element {
|
let (io_output, wrap) = match &output_element {
|
||||||
Some(element) => (
|
Some(element) => (
|
||||||
quote!(gcore::registry::record_type::<#element>()),
|
quote!(gcore::registry::record_type::<#element>()),
|
||||||
quote!(Ok(gcore::registry::EdgeHandle::new_record::<#element>(::std::sync::Arc::new(__node)))),
|
quote!(Ok(gcore::registry::SourceHandle::new_record::<#element>(::std::sync::Arc::new(__node)))),
|
||||||
),
|
),
|
||||||
None => {
|
None => {
|
||||||
let name = match &node.output.shape.element {
|
let name = match &node.output.shape.element {
|
||||||
@@ -404,7 +404,7 @@ fn single_row_entries(parsed: &ParsedNodeFn, struct_name: &Ident, regular_fields
|
|||||||
let base_ty = format_ident!("__ty_{}", base_indices[0]);
|
let base_ty = format_ident!("__ty_{}", base_indices[0]);
|
||||||
(
|
(
|
||||||
quote!(gcore::Type::Record(Box::new(gcore::Type::Generic(::std::borrow::Cow::Borrowed(#name))))),
|
quote!(gcore::Type::Record(Box::new(gcore::Type::Generic(::std::borrow::Cow::Borrowed(#name))))),
|
||||||
quote!(Ok(gcore::registry::EdgeHandle::new_erased(::std::sync::Arc::new(__node) as ::std::sync::Arc<gcore::registry::ErasedRecordNode>, #base_ty))),
|
quote!(Ok(gcore::registry::SourceHandle::new_erased(::std::sync::Arc::new(__node) as ::std::sync::Arc<gcore::registry::ErasedRecordNode>, #base_ty))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ mod tests {
|
|||||||
use core_types::context::{ContextImpl, EvalScope};
|
use core_types::context::{ContextImpl, EvalScope};
|
||||||
use core_types::node::Node;
|
use core_types::node::Node;
|
||||||
use core_types::record::LiftedSource;
|
use core_types::record::LiftedSource;
|
||||||
use core_types::registry::{EdgeHandle, ErasedRecordNode};
|
use core_types::registry::{SourceHandle, ErasedRecordNode};
|
||||||
use std::sync::atomic::{AtomicU32, Ordering};
|
use std::sync::atomic::{AtomicU32, Ordering};
|
||||||
|
|
||||||
fn lifted<T: Clone + Send + Sync + core_types::StaticTypeSized>(value: T) -> LiftedSource<T, impl for<'c> Fn(&ContextImpl<'c>) -> GPoll<T>>
|
fn lifted<T: Clone + Send + Sync + core_types::StaticTypeSized>(value: T) -> LiftedSource<T, impl for<'c> Fn(&ContextImpl<'c>) -> GPoll<T>>
|
||||||
@@ -303,7 +303,7 @@ mod tests {
|
|||||||
|
|
||||||
let layout = element_layout::<u32>();
|
let layout = element_layout::<u32>();
|
||||||
let monitor = MonitorNode::new(lifted::<u32>(11u32), &layout);
|
let monitor = MonitorNode::new(lifted::<u32>(11u32), &layout);
|
||||||
let handle = EdgeHandle::new_record::<u32>(Arc::new(monitor) as Arc<ErasedRecordNode>);
|
let handle = SourceHandle::new_record::<u32>(Arc::new(monitor) as Arc<ErasedRecordNode>);
|
||||||
assert!(handle.serialize().is_none(), "no snapshot before the first eval");
|
assert!(handle.serialize().is_none(), "no snapshot before the first eval");
|
||||||
|
|
||||||
let edge = handle.duplicate().downcast_record::<u32>().unwrap();
|
let edge = handle.duplicate().downcast_record::<u32>().unwrap();
|
||||||
@@ -331,7 +331,7 @@ mod tests {
|
|||||||
let source = core_types::value::LeveledValueSource::new(vec![10u32, 20, 30]);
|
let source = core_types::value::LeveledValueSource::new(vec![10u32, 20, 30]);
|
||||||
let layout = Node::<ContextImpl>::layout(&source).clone();
|
let layout = Node::<ContextImpl>::layout(&source).clone();
|
||||||
let monitor = MonitorNode::new(source, &layout);
|
let monitor = MonitorNode::new(source, &layout);
|
||||||
let handle = EdgeHandle::new_record::<u32>(Arc::new(monitor) as Arc<ErasedRecordNode>);
|
let handle = SourceHandle::new_record::<u32>(Arc::new(monitor) as Arc<ErasedRecordNode>);
|
||||||
|
|
||||||
let edge = handle.duplicate().downcast_record::<u32>().unwrap();
|
let edge = handle.duplicate().downcast_record::<u32>().unwrap();
|
||||||
let GPoll::Final(_) = core_types::record::serve_input(&edge, &ctx, &frames) else {
|
let GPoll::Final(_) = core_types::record::serve_input(&edge, &ctx, &frames) else {
|
||||||
@@ -475,8 +475,8 @@ mod tests {
|
|||||||
let ctx = ContextImpl::root(&scope);
|
let ctx = ContextImpl::root(&scope);
|
||||||
|
|
||||||
let layout = element_layout::<u32>();
|
let layout = element_layout::<u32>();
|
||||||
let edge = EdgeHandle::new_record::<u32>(Arc::new(counting()) as Arc<ErasedRecordNode>);
|
let edge = SourceHandle::new_record::<u32>(Arc::new(counting()) as Arc<ErasedRecordNode>);
|
||||||
let memoized = EdgeHandle::new_record::<u32>(Arc::new(MemoizeNode::new(edge.downcast_record::<u32>().unwrap(), &layout)) as Arc<ErasedRecordNode>);
|
let memoized = SourceHandle::new_record::<u32>(Arc::new(MemoizeNode::new(edge.downcast_record::<u32>().unwrap(), &layout)) as Arc<ErasedRecordNode>);
|
||||||
let stacked = MemoizeNode::new(memoized.downcast_record::<u32>().unwrap(), &layout);
|
let stacked = MemoizeNode::new(memoized.downcast_record::<u32>().unwrap(), &layout);
|
||||||
let stacked = core_types::record::RecordExtract::<u32, _>::new(stacked, &layout);
|
let stacked = core_types::record::RecordExtract::<u32, _>::new(stacked, &layout);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user