mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 07:48:02 +08:00
Remove unsafe code and clean up the code base in general (#1263)
* Remove unsafe code * Make node graph test syncronous * Add miri step to ci * Remove unsafe from node graph evaluation * Replace operation pseudo_hash with hash based on discriminant * Fix test * Move memo module to core and make it safe * Fix formatting * Remove unused stuff from gstd * Use safe casting for creating key variants * Fix memo node types * Fix ref node * "fix" ub * Use correct input types for ExtractImageFrame * Fix types for async nodes * Fix missing implementation * Manually override output type for async nodes * Fix types for EditorApi * Fix output type for WasmSurfaceHandle * Remove unused miri.yml * Fix incorrect type for cache node
This commit is contained in:
committed by
Keavon Chambers
parent
259dcdc628
commit
4e1bfddcd8
@@ -1,7 +1,6 @@
|
||||
use crate::Node;
|
||||
|
||||
use core::{
|
||||
borrow::BorrowMut,
|
||||
cell::{Cell, RefCell, RefMut},
|
||||
marker::PhantomData,
|
||||
};
|
||||
@@ -47,10 +46,7 @@ impl<'i, T: 'i> Node<'i, ()> for RefCellMutNode<T> {
|
||||
type Output = RefMut<'i, T>;
|
||||
#[inline(always)]
|
||||
fn eval(&'i self, _input: ()) -> Self::Output {
|
||||
#[cfg(not(target_arch = "spirv"))]
|
||||
let a = self.0.borrow_mut();
|
||||
#[cfg(target_arch = "spirv")]
|
||||
let a = unsafe { self.0.try_borrow_mut().unwrap_unchecked() };
|
||||
a
|
||||
}
|
||||
}
|
||||
@@ -60,24 +56,6 @@ impl<T> RefCellMutNode<T> {
|
||||
RefCellMutNode(RefCell::new(value))
|
||||
}
|
||||
}
|
||||
/// #Safety: Never use this as it is unsound.
|
||||
#[derive(Default, Debug)]
|
||||
pub struct UnsafeMutValueNode<T>(pub T);
|
||||
|
||||
/// #Safety: Never use this as it is unsound.
|
||||
impl<'i, T: 'i> Node<'i, ()> for UnsafeMutValueNode<T> {
|
||||
type Output = &'i mut T;
|
||||
#[inline(always)]
|
||||
fn eval(&'i self, _input: ()) -> Self::Output {
|
||||
unsafe { &mut *(&self.0 as &T as *const T as *mut T) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> UnsafeMutValueNode<T> {
|
||||
pub const fn new(value: T) -> UnsafeMutValueNode<T> {
|
||||
UnsafeMutValueNode(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct OnceCellNode<T>(pub Cell<T>);
|
||||
|
||||
Reference in New Issue
Block a user