Skip to main content

luaur_vm/records/
lua_t_value.rs

1#[allow(non_camel_case_types)]
2#[derive(Clone, Copy)]
3#[repr(C)]
4pub struct lua_TValue {
5    pub value: crate::type_aliases::value::Value,
6    pub extra: [core::ffi::c_int; 1],
7    pub tt: core::ffi::c_int,
8}
9
10#[allow(non_camel_case_types)]
11pub type TValue = lua_TValue;
12
13impl Default for lua_TValue {
14    fn default() -> Self {
15        Self {
16            value: crate::type_aliases::value::Value::default(),
17            extra: [0; 1],
18            tt: 0,
19        }
20    }
21}
22
23impl core::fmt::Debug for lua_TValue {
24    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
25        f.debug_struct("lua_TValue")
26            .field("extra", &self.extra)
27            .field("tt", &self.tt)
28            .finish_non_exhaustive()
29    }
30}
31
32impl lua_TValue {
33    /// Tag accessor mirroring `TKey::tt()` so the C++ duck-typed tag macros
34    /// (`ttype!`, `setttype!`, `iscollectable!`) work on values AND keys.
35    #[inline]
36    pub fn tt(&self) -> core::ffi::c_int {
37        self.tt
38    }
39
40    #[inline]
41    pub fn set_tt(&mut self, tt: core::ffi::c_int) {
42        self.tt = tt;
43    }
44}