1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Take a look at the license at the top of the repository in the LICENSE file.

/// This structure is used to provide the type system with the information
/// required to initialize and destruct (finalize) a type's class and
/// its instances.
///
/// The initialized structure is passed to the `g_type_register_static()` function
/// (or is copied into the provided [`TypeInfo`][crate::TypeInfo] structure in the
/// [`TypePluginExtManual::complete_type_info()`][crate::prelude::TypePluginExtManual::complete_type_info()]). The type system will perform a deep
/// copy of this structure, so its memory does not need to be persistent
/// across invocation of `g_type_register_static()`.
#[derive(Debug, Copy, Clone)]
#[doc(alias = "GTypeInfo")]
#[repr(transparent)]
pub struct TypeInfo(pub(crate) gobject_ffi::GTypeInfo);

impl TypeInfo {
    // rustdoc-stripper-ignore-next
    /// Returns a `GTypeInfo` pointer.
    #[doc(hidden)]
    #[inline]
    pub fn as_ptr(&self) -> *mut gobject_ffi::GTypeInfo {
        &self.0 as *const gobject_ffi::GTypeInfo as *mut _
    }

    // rustdoc-stripper-ignore-next
    /// Borrows the underlying C value mutably.
    #[doc(hidden)]
    #[inline]
    pub unsafe fn from_glib_ptr_borrow_mut<'a>(ptr: *mut gobject_ffi::GTypeInfo) -> &'a mut Self {
        &mut *(ptr as *mut Self)
    }
}

impl Default for TypeInfo {
    // rustdoc-stripper-ignore-next
    /// Creates a new TypeInfo with default value.
    fn default() -> Self {
        Self(gobject_ffi::GTypeInfo {
            class_size: 0u16,
            base_init: None,
            base_finalize: None,
            class_init: None,
            class_finalize: None,
            class_data: ::std::ptr::null(),
            instance_size: 0,
            n_preallocs: 0,
            instance_init: None,
            value_table: ::std::ptr::null(),
        })
    }
}