mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +00:00
Use the vtable crate for the ItemVTable
This commit is contained in:
parent
49fc23224e
commit
f74cfe73cd
6 changed files with 99 additions and 113 deletions
|
@ -1,7 +1,7 @@
|
|||
use core::ops::{Deref, DerefMut, Drop};
|
||||
use core::ptr::NonNull;
|
||||
use core::marker::PhantomData;
|
||||
pub use vtable_macro::vtable;
|
||||
pub use vtable_macro::*;
|
||||
|
||||
pub unsafe trait VTableMeta {
|
||||
/// that's the rust trait. (e.g: `Hello`)
|
||||
|
@ -189,6 +189,9 @@ impl<'a, T: ?Sized + VTableMeta> VRefMut<'a, T> {
|
|||
pub fn into_ref(self) -> VRef<'a, T> {
|
||||
unsafe { VRef::from_inner(VRefMut::inner(&self)) }
|
||||
}
|
||||
pub unsafe fn from_raw(vtable: NonNull<T::VTable>, ptr: NonNull<u8>) -> Self {
|
||||
Self {inner : T::from_raw(vtable, ptr), _phantom: PhantomData }
|
||||
}
|
||||
pub fn get_vtable(&self) -> &T::VTable {
|
||||
unsafe { T::get_vtable(&self.inner) }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue