glib/gobject/
type_value_table.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::gobject_ffi;
4
5/// - `'i'`: Integers, passed as `collect_values[].v_int`
6///  - `'l'`: Longs, passed as `collect_values[].v_long`
7///  - `'d'`: Doubles, passed as `collect_values[].v_double`
8///  - `'p'`: Pointers, passed as `collect_values[].v_pointer`
9///
10///  It should be noted that for variable argument list construction,
11///  ANSI C promotes every type smaller than an integer to an int, and
12///  floats to doubles. So for collection of short int or char, `'i'`
13///  needs to be used, and for collection of floats `'d'`.
14/// The [`TypeValueTable`][crate::TypeValueTable] provides the functions required by the [`Value`][crate::Value]
15/// implementation, to serve as a container for values of a type.
16#[derive(Debug, Copy, Clone)]
17#[doc(alias = "GTypeValueTable")]
18#[repr(transparent)]
19pub struct TypeValueTable(pub(crate) gobject_ffi::GTypeValueTable);
20
21impl TypeValueTable {
22    // rustdoc-stripper-ignore-next
23    /// Returns a `GTypeValueTable` pointer.
24    #[doc(hidden)]
25    #[inline]
26    pub fn as_ptr(&self) -> *mut gobject_ffi::GTypeValueTable {
27        &self.0 as *const gobject_ffi::GTypeValueTable as *mut _
28    }
29
30    // rustdoc-stripper-ignore-next
31    /// Borrows the underlying C value mutably.
32    #[doc(hidden)]
33    #[inline]
34    pub unsafe fn from_glib_ptr_borrow_mut<'a>(
35        ptr: *mut gobject_ffi::GTypeValueTable,
36    ) -> &'a mut Self {
37        &mut *(ptr as *mut Self)
38    }
39}
40
41impl Default for TypeValueTable {
42    // rustdoc-stripper-ignore-next
43    /// Creates a new TypeValueTable with default value.
44    fn default() -> Self {
45        Self(gobject_ffi::GTypeValueTable {
46            value_init: None,
47            value_free: None,
48            value_copy: None,
49            value_peek_pointer: None,
50            collect_format: ::std::ptr::null(),
51            collect_value: None,
52            lcopy_format: ::std::ptr::null(),
53            lcopy_value: None,
54        })
55    }
56}