mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Rename record_edge_type to record_source_type
This commit is contained in:
@@ -364,19 +364,19 @@ macro_rules! tagged_value {
|
||||
// =======================
|
||||
// RECORD WIRES, WHICH LAND AS THEIR ELEMENT
|
||||
// =======================
|
||||
if ty == core_types::registry::record_edge_type::<()>() {
|
||||
if ty == core_types::registry::record_source_type::<()>() {
|
||||
let edge = handle.downcast_record::<()>().map_err(|e| format!("{e:?}"))?;
|
||||
return Ok(core_types::record::serve_input(&edge, ctx, frames).map(|_| TaggedValue::None));
|
||||
}
|
||||
$(
|
||||
if ty == core_types::registry::record_edge_type::<$ty>() {
|
||||
if ty == core_types::registry::record_source_type::<$ty>() {
|
||||
let layout = handle.layout().clone();
|
||||
let edge = handle.downcast_record::<$ty>().map_err(|e| format!("{e:?}"))?;
|
||||
return Ok(core_types::record::serve_input(&edge, ctx, frames)
|
||||
.map(|value| TaggedValue::$identifier(unsafe { core_types::record::read_element::<$ty>(layout.rec(&value)) })));
|
||||
}
|
||||
)*
|
||||
if ty == core_types::registry::record_edge_type::<RenderOutput>() {
|
||||
if ty == core_types::registry::record_source_type::<RenderOutput>() {
|
||||
let layout = handle.layout().clone();
|
||||
let edge = handle.downcast_record::<RenderOutput>().map_err(|e| format!("{e:?}"))?;
|
||||
return Ok(core_types::record::serve_input(&edge, ctx, frames)
|
||||
@@ -919,27 +919,27 @@ mod typedefault_dispatch {
|
||||
mod leveled_edges {
|
||||
use super::*;
|
||||
use core_types::descriptor;
|
||||
use core_types::registry::record_edge_type;
|
||||
use core_types::registry::record_source_type;
|
||||
|
||||
#[test]
|
||||
fn list_variants_produce_leveled_edges_typed_by_element() {
|
||||
let edge = TaggedValue::F64Array(vec![1., 2., 3.]).to_edge().unwrap();
|
||||
assert_eq!(edge.ty(), &record_edge_type::<f64>());
|
||||
assert_eq!(edge.ty(), &record_source_type::<f64>());
|
||||
assert_eq!(edge.layout().depth, 1);
|
||||
|
||||
let edge = TaggedValue::Color(Some(Color::default())).to_edge().unwrap();
|
||||
assert_eq!(edge.ty(), &record_edge_type::<Color>());
|
||||
assert_eq!(edge.ty(), &record_source_type::<Color>());
|
||||
assert_eq!(edge.layout().depth, 1);
|
||||
|
||||
let edge = TaggedValue::TypeDefault(descriptor!(List<Graphic>)).to_edge().unwrap();
|
||||
assert_eq!(edge.ty(), &record_edge_type::<Graphic>());
|
||||
assert_eq!(edge.ty(), &record_source_type::<Graphic>());
|
||||
assert_eq!(edge.layout().depth, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scalar_variants_keep_their_rank_zero_edges() {
|
||||
let edge = TaggedValue::Bool(true).to_edge().unwrap();
|
||||
assert_eq!(edge.ty(), &record_edge_type::<bool>());
|
||||
assert_eq!(edge.ty(), &record_source_type::<bool>());
|
||||
assert_eq!(edge.layout().depth, 0);
|
||||
}
|
||||
|
||||
@@ -961,7 +961,7 @@ mod leveled_edges {
|
||||
#[cfg(test)]
|
||||
mod record_defaults {
|
||||
use super::*;
|
||||
use core_types::registry::record_edge_type;
|
||||
use core_types::registry::record_source_type;
|
||||
|
||||
// The registry can present a record row first (wasm registration order),
|
||||
// so primitive defaults must parse through the record wrapping.
|
||||
@@ -969,7 +969,7 @@ mod record_defaults {
|
||||
fn primitive_defaults_parse_through_record_wires() {
|
||||
let leveled = core_types::registry::record_type::<f64>();
|
||||
assert_eq!(TaggedValue::from_primitive_string("2.", &leveled), Some(TaggedValue::F64(2.)));
|
||||
assert_eq!(TaggedValue::from_primitive_string("5", &record_edge_type::<u32>()), Some(TaggedValue::U32(5)));
|
||||
assert_eq!(TaggedValue::from_primitive_string("true", &record_edge_type::<bool>()), Some(TaggedValue::Bool(true)));
|
||||
assert_eq!(TaggedValue::from_primitive_string("5", &record_source_type::<u32>()), Some(TaggedValue::U32(5)));
|
||||
assert_eq!(TaggedValue::from_primitive_string("true", &record_source_type::<bool>()), Some(TaggedValue::Bool(true)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -788,7 +788,7 @@ mod test {
|
||||
|
||||
let executor = build_executor(network);
|
||||
let value = executor.tree().get(NodeId(0)).unwrap();
|
||||
assert_eq!(value.ty(), &core_types::registry::record_edge_type::<f64>());
|
||||
assert_eq!(value.ty(), &core_types::registry::record_source_type::<f64>());
|
||||
assert_eq!(value.layout().depth, 0);
|
||||
assert_eq!((&executor).execute(()).unwrap(), GPoll::Final(TaggedValue::F64(7.)));
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ mod node_registry_macros {
|
||||
io: NodeIOTypes::new(
|
||||
concrete!(Context),
|
||||
core_types::registry::record_type::<$to>(),
|
||||
vec![core_types::registry::record_edge_type::<$from>()],
|
||||
vec![core_types::registry::record_source_type::<$from>()],
|
||||
),
|
||||
constructor: |inputs| {
|
||||
if inputs.len() != 1 {
|
||||
@@ -284,10 +284,10 @@ mod node_registry_macros {
|
||||
concrete!(Context),
|
||||
core_types::registry::record_type::<$to>(),
|
||||
vec![
|
||||
core_types::registry::record_edge_type::<$from>(),
|
||||
core_types::registry::record_edge_type::<$convert>(),
|
||||
core_types::registry::record_edge_type::<RuntimeHandle>(),
|
||||
core_types::registry::record_edge_type::<SourceId>(),
|
||||
core_types::registry::record_source_type::<$from>(),
|
||||
core_types::registry::record_source_type::<$convert>(),
|
||||
core_types::registry::record_source_type::<RuntimeHandle>(),
|
||||
core_types::registry::record_source_type::<SourceId>(),
|
||||
],
|
||||
),
|
||||
constructor: |inputs| {
|
||||
@@ -327,7 +327,7 @@ mod node_registry_macros {
|
||||
io: NodeIOTypes::new(
|
||||
concrete!(Context),
|
||||
core_types::registry::record_type::<$to>(),
|
||||
vec![core_types::registry::record_edge_type::<$from>(), core_types::registry::record_edge_type::<$convert>()],
|
||||
vec![core_types::registry::record_source_type::<$from>(), core_types::registry::record_source_type::<$convert>()],
|
||||
),
|
||||
constructor: |inputs| {
|
||||
if inputs.len() != 2 {
|
||||
|
||||
@@ -87,7 +87,7 @@ pub fn record_type<T: 'static>() -> Type {
|
||||
Type::Record(Box::new(concrete!(T)))
|
||||
}
|
||||
|
||||
pub fn record_edge_type<T: 'static>() -> Type {
|
||||
pub fn record_source_type<T: 'static>() -> Type {
|
||||
Type::Fn(Box::new(concrete!(Context)), Box::new(record_type::<T>()))
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ unsafe impl Sync for SourceHandle {}
|
||||
|
||||
impl SourceHandle {
|
||||
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_source_type::<T>())
|
||||
}
|
||||
|
||||
pub fn new_erased<N>(node: std::sync::Arc<N>, ty: Type) -> Self
|
||||
@@ -260,7 +260,7 @@ impl SourceHandle {
|
||||
}
|
||||
|
||||
pub fn downcast_record<T: 'static>(self) -> Result<SharedSource<ErasedRecordNode>, ConstructionError> {
|
||||
self.downcast_erased(record_edge_type::<T>())
|
||||
self.downcast_erased(record_source_type::<T>())
|
||||
}
|
||||
|
||||
/// The erased record source, for callers that dispatch on the layout rather
|
||||
@@ -559,7 +559,7 @@ mod tests {
|
||||
}
|
||||
let entry = RegistryEntry {
|
||||
layout_meta: None,
|
||||
io: NodeIOTypes::new(concrete!(Context), record_type::<u32>(), vec![record_edge_type::<String>()]),
|
||||
io: NodeIOTypes::new(concrete!(Context), record_type::<u32>(), vec![record_source_type::<String>()]),
|
||||
constructor: construct_strlen,
|
||||
};
|
||||
|
||||
@@ -572,8 +572,8 @@ mod tests {
|
||||
assert_eq!(
|
||||
construct(&entry, vec![mistyped]).unwrap_err(),
|
||||
ConstructionError::Type {
|
||||
expected: Box::new(record_edge_type::<String>()),
|
||||
found: Box::new(record_edge_type::<f64>()),
|
||||
expected: Box::new(record_source_type::<String>()),
|
||||
found: Box::new(record_source_type::<f64>()),
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -589,7 +589,7 @@ mod tests {
|
||||
let layout = Node::<ContextImpl>::layout(&counting).clone();
|
||||
let handle = SourceHandle::new_record::<u32>(Arc::new(counting) as Arc<ErasedRecordNode>);
|
||||
let duplicate = handle.duplicate();
|
||||
assert_eq!(*duplicate.ty(), record_edge_type::<u32>());
|
||||
assert_eq!(*duplicate.ty(), record_source_type::<u32>());
|
||||
let frames = crate::record::test_frames(1 << 12);
|
||||
|
||||
let first = handle.downcast_record::<u32>().unwrap();
|
||||
|
||||
@@ -130,7 +130,7 @@ fn flip_entries_tokens(parsed: &ParsedNodeFn, struct_name: &Ident, regular_field
|
||||
};
|
||||
let assignment_types = assignment_types.iter();
|
||||
let turbofish = quote!(::<#(#node_underscores,)* #(#assignment_types,)*>);
|
||||
let input_types = row.iter().map(|ty| quote!(gcore::registry::record_edge_type::<#ty>()));
|
||||
let input_types = row.iter().map(|ty| quote!(gcore::registry::record_source_type::<#ty>()));
|
||||
let downcasts = names.iter().zip(row.iter()).enumerate().map(|(index, (name, ty))| {
|
||||
let handle = format_ident!("__handle_{index}");
|
||||
let layout = format_ident!("__layout_{index}");
|
||||
@@ -340,7 +340,7 @@ fn single_row_entries(parsed: &ParsedNodeFn, struct_name: &Ident, regular_fields
|
||||
|
||||
let input_types = slots.iter().map(|slot| match slot {
|
||||
SlotKind::BaseGeneric(name) => quote!(gcore::registry::generic_record_edge_type(#name)),
|
||||
SlotKind::BaseConcrete(ty) | SlotKind::Value(ty) | SlotKind::Extracted(ty) | SlotKind::Ranked(ty) => quote!(gcore::registry::record_edge_type::<#ty>()),
|
||||
SlotKind::BaseConcrete(ty) | SlotKind::Value(ty) | SlotKind::Extracted(ty) | SlotKind::Ranked(ty) => quote!(gcore::registry::record_source_type::<#ty>()),
|
||||
});
|
||||
|
||||
let downcasts = names.iter().zip(&slots).enumerate().map(|(index, (name, slot))| {
|
||||
|
||||
@@ -551,9 +551,9 @@ mod tests {
|
||||
let entries = _flat_map_mod::flat_map_entries();
|
||||
assert_eq!(entries.len(), 6, "one registry row per content implementation");
|
||||
let content_types: Vec<core_types::Type> = entries.iter().map(|entry| entry.io.inputs[0].clone()).collect();
|
||||
assert_eq!(content_types[0], core_types::registry::record_edge_type::<Graphic>());
|
||||
assert_eq!(content_types[1], core_types::registry::record_edge_type::<Vector>());
|
||||
assert_eq!(content_types[5], core_types::registry::record_edge_type::<String>());
|
||||
assert_eq!(content_types[0], core_types::registry::record_source_type::<Graphic>());
|
||||
assert_eq!(content_types[1], core_types::registry::record_source_type::<Vector>());
|
||||
assert_eq!(content_types[5], core_types::registry::record_source_type::<String>());
|
||||
// The subject and the output stay erased across rows.
|
||||
assert_eq!(entries[0].io.inputs[1], entries[5].io.inputs[1]);
|
||||
assert_eq!(entries[0].io.return_value, entries[5].io.return_value);
|
||||
|
||||
@@ -1148,12 +1148,12 @@ mod graphene_test {
|
||||
assert_eq!(entries.len(), 6);
|
||||
assert_eq!(
|
||||
entries[0].io.inputs,
|
||||
vec![core_types::registry::record_edge_type::<f64>(), core_types::registry::record_edge_type::<f64>()]
|
||||
vec![core_types::registry::record_source_type::<f64>(), core_types::registry::record_source_type::<f64>()]
|
||||
);
|
||||
assert_eq!(entries[0].io.return_value, core_types::registry::record_type::<f64>());
|
||||
assert_eq!(
|
||||
entries[3].io.inputs,
|
||||
vec![core_types::registry::record_edge_type::<DVec2>(), core_types::registry::record_edge_type::<DVec2>()]
|
||||
vec![core_types::registry::record_source_type::<DVec2>(), core_types::registry::record_source_type::<DVec2>()]
|
||||
);
|
||||
assert_eq!(entries[3].io.return_value, core_types::registry::record_type::<DVec2>());
|
||||
|
||||
@@ -1179,7 +1179,7 @@ mod graphene_test {
|
||||
// Routing forwards the whole record, so the branch types need no rows.
|
||||
let entries = super::_switch_mod::switch_entries();
|
||||
assert_eq!(entries.len(), 1);
|
||||
assert_eq!(entries[0].io.inputs[0], core_types::registry::record_edge_type::<bool>());
|
||||
assert_eq!(entries[0].io.inputs[0], core_types::registry::record_source_type::<bool>());
|
||||
assert!(matches!(&entries[0].io.return_value, core_types::Type::Record(element) if matches!(**element, core_types::Type::Generic(_))));
|
||||
assert_eq!(entries[0].io.inputs.len(), 3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user