mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-03 21:08:18 +00:00
Remove subtyping for () from node graph type system (#2418)
* Remove subtyping for () from node graph type system * Remove special-case in DynAnyNode for downcasting to () * Correct input type for CreateGpuSurfaceNode * Remove unncessary imports --------- Co-authored-by: Dennis Kobert <dennis@kobert.dev> Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: hypercube <0hypercube@gmail.com>
This commit is contained in:
parent
dd27f4653d
commit
92132919d1
3 changed files with 9 additions and 23 deletions
|
@ -1,4 +1,3 @@
|
|||
use crate::transform::Footprint;
|
||||
use crate::{Node, NodeIO, NodeIOTypes, Type, WasmNotSend};
|
||||
use dyn_any::{DynAny, StaticType};
|
||||
use std::collections::HashMap;
|
||||
|
@ -251,21 +250,6 @@ where
|
|||
};
|
||||
match dyn_any::downcast(input) {
|
||||
Ok(input) => Box::pin(output(*input)),
|
||||
// If the input type of the node is `()` and we supply an invalid type, we can still call the
|
||||
// node and just ignore the input and call it with the unit type instead.
|
||||
Err(_) if core::any::TypeId::of::<_I::Static>() == core::any::TypeId::of::<()>() => {
|
||||
assert_eq!(std::mem::size_of::<_I>(), 0);
|
||||
// Rust can't know, that `_I` and `()` are the same size, so we have to use a `transmute_copy()` here
|
||||
Box::pin(output(unsafe { std::mem::transmute_copy(&()) }))
|
||||
}
|
||||
// If the Node expects a footprint but we provide (). In this case construct the default Footprint and pass that
|
||||
// This is pretty hacky pls fix
|
||||
Err(_) if core::any::TypeId::of::<_I::Static>() == core::any::TypeId::of::<Footprint>() => {
|
||||
assert_eq!(std::mem::size_of::<_I>(), std::mem::size_of::<Footprint>());
|
||||
assert_eq!(std::mem::align_of::<_I>(), std::mem::align_of::<Footprint>());
|
||||
// Rust can't know, that `_I` and `Footprint` are the same size, so we have to use a `transmute_copy()` here
|
||||
Box::pin(output(unsafe { std::mem::transmute_copy(&Footprint::default()) }))
|
||||
}
|
||||
Err(e) => panic!("DynAnyNode Input, {0} in:\n{1}", e, node_name),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue