mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Delete the Ref wire type and its lend edge surface
This commit is contained in:
@@ -74,10 +74,6 @@ pub use crate::NodeIOTypes;
|
||||
pub type ErasedNode<T> = dyn for<'c> Node<ContextImpl<'c>, Output = T> + Send + Sync;
|
||||
#[cfg(target_family = "wasm")]
|
||||
pub type ErasedNode<T> = dyn for<'c> Node<ContextImpl<'c>, Output = T>;
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
pub type ErasedLendNode<T> = dyn for<'c> Node<ContextImpl<'c>, Output = &'c T> + Send + Sync;
|
||||
#[cfg(target_family = "wasm")]
|
||||
pub type ErasedLendNode<T> = dyn for<'c> Node<ContextImpl<'c>, Output = &'c T>;
|
||||
|
||||
/// Element-independent by erasure; the wire's `Type::Record(El)` keeps element reads proven at wiring.
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
@@ -94,14 +90,6 @@ pub fn edge_type<T: 'static>() -> Type {
|
||||
Type::Fn(Box::new(concrete!(Context)), Box::new(concrete!(T)))
|
||||
}
|
||||
|
||||
pub fn ref_type<T: 'static>() -> Type {
|
||||
Type::Ref(Box::new(concrete!(T)))
|
||||
}
|
||||
|
||||
pub fn lend_edge_type<T: 'static>() -> Type {
|
||||
Type::Fn(Box::new(concrete!(Context)), Box::new(ref_type::<T>()))
|
||||
}
|
||||
|
||||
pub fn record_type<T: 'static>() -> Type {
|
||||
Type::Record(Box::new(concrete!(T)))
|
||||
}
|
||||
@@ -112,10 +100,7 @@ pub fn record_edge_type<T: 'static>() -> Type {
|
||||
|
||||
/// The record edge type of a token row, generic over the element.
|
||||
pub fn generic_record_edge_type(name: &'static str) -> Type {
|
||||
Type::Fn(
|
||||
Box::new(concrete!(Context)),
|
||||
Box::new(Type::Record(Box::new(Type::Generic(std::borrow::Cow::Borrowed(name))))),
|
||||
)
|
||||
Type::Fn(Box::new(concrete!(Context)), Box::new(Type::Record(Box::new(Type::Generic(std::borrow::Cow::Borrowed(name))))))
|
||||
}
|
||||
|
||||
pub fn cache_key<C: CacheHash + ?Sized>(ctx: &C) -> u64 {
|
||||
@@ -217,10 +202,6 @@ impl EdgeHandle {
|
||||
Self::new_erased(node, edge_type::<T>())
|
||||
}
|
||||
|
||||
pub fn new_ref<T: 'static>(node: std::sync::Arc<ErasedLendNode<T>>) -> Self {
|
||||
Self::new_erased(node, lend_edge_type::<T>())
|
||||
}
|
||||
|
||||
pub fn new_record<T: 'static>(node: std::sync::Arc<ErasedRecordNode>) -> Self {
|
||||
Self::new_erased(node, record_edge_type::<T>())
|
||||
}
|
||||
@@ -265,10 +246,6 @@ impl EdgeHandle {
|
||||
self.downcast_erased(edge_type::<T>())
|
||||
}
|
||||
|
||||
pub fn downcast_lend<T: 'static>(self) -> Result<SharedEdge<ErasedLendNode<T>>, ConstructionError> {
|
||||
self.downcast_erased(lend_edge_type::<T>())
|
||||
}
|
||||
|
||||
pub fn downcast_record<T: 'static>(self) -> Result<SharedEdge<ErasedRecordNode>, ConstructionError> {
|
||||
self.downcast_erased(record_edge_type::<T>())
|
||||
}
|
||||
@@ -430,9 +407,9 @@ mod tests {
|
||||
let scope = scope_fixture(&generations, &arena);
|
||||
let ctx = ContextImpl::root(&scope);
|
||||
|
||||
let lending = EdgeHandle::new_ref(Arc::new(LendNode("held".to_string())) as Arc<ErasedLendNode<String>>);
|
||||
let upstream = lending.downcast_lend::<String>().unwrap();
|
||||
let node: Arc<ErasedSplitEdge> = Arc::new(SplitNode { content: upstream });
|
||||
let node: Arc<ErasedSplitEdge> = Arc::new(SplitNode {
|
||||
content: LendNode("held".to_string()),
|
||||
});
|
||||
let handle = EdgeHandle::new_erased(node, concrete!(SplitBorrow<'static>));
|
||||
assert_eq!(*handle.ty(), concrete!(SplitBorrow<'static>));
|
||||
|
||||
@@ -572,15 +549,6 @@ mod tests {
|
||||
found: Box::new(edge_type::<f64>()),
|
||||
}
|
||||
);
|
||||
|
||||
let lent = EdgeHandle::new_ref(Arc::new(LendNode("typed".to_string())) as Arc<ErasedLendNode<String>>);
|
||||
assert_eq!(
|
||||
construct(&entry, vec![lent]).unwrap_err(),
|
||||
ConstructionError::Type {
|
||||
expected: Box::new(edge_type::<String>()),
|
||||
found: Box::new(lend_edge_type::<String>()),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -235,7 +235,6 @@ pub enum Type {
|
||||
Fn(Box<Type>, Box<Type>),
|
||||
/// Represents a future which promises to return the inner type.
|
||||
Future(Box<Type>),
|
||||
Ref(Box<Type>),
|
||||
/// A packed record wire over the element type; the layout stays node-resident metadata.
|
||||
Record(Box<Type>),
|
||||
}
|
||||
@@ -311,7 +310,6 @@ impl Type {
|
||||
Self::Concrete(ty) => Some(ty.size),
|
||||
Self::Fn(_, _) => None,
|
||||
Self::Future(_) => None,
|
||||
Self::Ref(_) => None,
|
||||
Self::Record(_) => None,
|
||||
}
|
||||
}
|
||||
@@ -322,7 +320,6 @@ impl Type {
|
||||
Self::Concrete(ty) => Some(ty.align),
|
||||
Self::Fn(_, _) => None,
|
||||
Self::Future(_) => None,
|
||||
Self::Ref(_) => None,
|
||||
Self::Record(_) => None,
|
||||
}
|
||||
}
|
||||
@@ -333,7 +330,6 @@ impl Type {
|
||||
Self::Concrete(_) => self,
|
||||
Self::Fn(_, output) => output.nested_type(),
|
||||
Self::Future(output) => output.nested_type(),
|
||||
Self::Ref(inner) => inner.nested_type(),
|
||||
Self::Record(inner) => inner.nested_type(),
|
||||
}
|
||||
}
|
||||
@@ -347,7 +343,6 @@ impl Type {
|
||||
Self::Concrete(_) => None,
|
||||
Self::Fn(_, output) => output.replace_nested(f),
|
||||
Self::Future(output) => output.replace_nested(f),
|
||||
Self::Ref(inner) => inner.replace_nested(f),
|
||||
Self::Record(inner) => inner.replace_nested(f),
|
||||
}
|
||||
}
|
||||
@@ -358,7 +353,6 @@ impl Type {
|
||||
Type::Concrete(ty) => simplify_identifier_name(&ty.name),
|
||||
Type::Fn(call_arg, return_value) => format!("{} called with {}", return_value.identifier_name(), call_arg.identifier_name()),
|
||||
Type::Future(ty) => ty.identifier_name(),
|
||||
Type::Ref(ty) => ty.identifier_name(),
|
||||
Type::Record(ty) => ty.identifier_name(),
|
||||
}
|
||||
}
|
||||
@@ -454,7 +448,6 @@ impl std::fmt::Display for Type {
|
||||
Type::Concrete(ty) => write!(f, "{ty}"),
|
||||
Type::Fn(_, return_value) => write!(f, "{return_value}"),
|
||||
Type::Future(ty) => write!(f, "{ty}"),
|
||||
Type::Ref(ty) => write!(f, "{ty}"),
|
||||
Type::Record(ty) => write!(f, "{ty}"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user