1use std::ptr;
2use std::sync::atomic::AtomicBool;
3
4use glib::wrapper::Wrapper;
5use gobject_subclass::object::*;
6
7#[repr(C)]
8pub struct ElementInstanceStruct<T: ObjectType> {
9 _parent: <T::ParentType as Wrapper>::GlibType,
10 _imp: ptr::NonNull<T::ImplType>,
11
12 _panicked: AtomicBool,
13}
14
15pub trait PanicPoison {
16 fn panicked(&self) -> &AtomicBool;
17}
18
19unsafe impl<T: ObjectType> Instance<T> for ElementInstanceStruct<T> {
20 fn parent(&self) -> &<T::ParentType as Wrapper>::GlibType {
21 &self._parent
22 }
23
24 fn get_impl(&self) -> &T::ImplType {
25 unsafe { self._imp.as_ref() }
26 }
27
28 unsafe fn set_impl(&mut self, imp: ptr::NonNull<T::ImplType>) {
29 self._imp = imp;
30 }
31
32 unsafe fn get_class(&self) -> *const ClassStruct<T> {
33 *(self as *const _ as *const *const ClassStruct<T>)
34 }
35}
36
37impl<T: ObjectType> PanicPoison for ElementInstanceStruct<T> {
38 fn panicked(&self) -> &AtomicBool {
39 &self._panicked
40 }
41}