mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 07:18:04 +08:00
Make graphene_core no_std
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
#![no_std]
|
||||
|
||||
pub mod generic;
|
||||
pub mod ops;
|
||||
pub mod structural;
|
||||
pub mod value;
|
||||
|
||||
use dyn_any::{downcast_ref, DynAny, StaticType};
|
||||
use std::any::Any;
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub trait Node< 'n, Input> {
|
||||
type Output : 'n;
|
||||
@@ -23,26 +22,3 @@ impl<'n, T: Node<'n, ()>> Exec<'n> for T {}
|
||||
pub trait Cache {
|
||||
fn clear(&mut self);
|
||||
}
|
||||
|
||||
pub type DynNode<'n, T> = &'n (dyn Node<'n, (), Output = T> + 'n);
|
||||
pub type DynAnyNode<'n> = &'n (dyn Node<'n, (), Output = &'n dyn DynAny<'n>> + 'n);
|
||||
|
||||
pub trait DynamicInput<'n> {
|
||||
fn set_kwarg_by_name(&mut self, name: &str, value: DynAnyNode<'n>);
|
||||
fn set_arg_by_index(&mut self, index: usize, value: DynAnyNode<'n>);
|
||||
}
|
||||
|
||||
pub trait AnyRef<'n, I: StaticType<'n>>: Node<'n, I> {
|
||||
fn any(&'n self, input: &'n dyn DynAny<'n>) -> Self::Output;
|
||||
}
|
||||
|
||||
impl<'n, T: Node<'n, I>, I: StaticType<'n>> AnyRef<'n, I> for T {
|
||||
fn any(&'n self, input: &'n dyn DynAny<'n>) -> Self::Output {
|
||||
self.eval(downcast_ref::<I>(input).unwrap_or_else(|| {
|
||||
panic!(
|
||||
"Node was evaluated with wrong input. The input has to be of type: {}",
|
||||
std::any::type_name::<I>(),
|
||||
)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user