luaur_vm/functions/isobjcleared.rs
1//! Generated skeleton item.
2//! Node: `cxx:Function:Luau.VM:VM/src/lgc.cpp:608:isobjcleared`
3//! Source: `VM/src/lgc.cpp`
4//! Graph edges:
5//! - declared_by: source_file VM/src/lgc.cpp
6//! - source_includes:
7//! - includes -> source_file VM/src/lgc.h
8//! - includes -> source_file VM/src/lobject.h
9//! - includes -> source_file VM/src/lstate.h
10//! - includes -> source_file VM/src/ltable.h
11//! - includes -> source_file VM/src/lfunc.h
12//! - includes -> source_file VM/src/lstring.h
13//! - includes -> source_file VM/src/ldo.h
14//! - includes -> source_file VM/src/lmem.h
15//! - includes -> source_file VM/src/ludata.h
16//! - includes -> source_file VM/src/lbuffer.h
17//! - includes -> source_file VM/src/lclass.h
18//! - incoming:
19//! - declares <- source_file VM/src/lgc.cpp
20//! - outgoing:
21//! - calls -> macro stringmark (VM/src/lgc.cpp)
22//! - calls -> macro iswhite (VM/src/lgc.h)
23//! - translates_to -> rust_item isobjcleared
24
25/// Returns non-zero if the GC object `o` has been cleared (collected).
26///
27/// Strings are treated as values and are never considered cleared: their white
28/// bits are reset so they will not be swept, and 0 is returned immediately.
29/// For all other collectable types the function returns the `iswhite` result —
30/// non-zero means the object's white bits are still set, i.e. it was not
31/// reached during the mark phase and has been (or will be) collected.
32///
33/// C++ original: `static int isobjcleared(GCObject* o)` in VM/src/lgc.cpp:608
34#[inline]
35pub unsafe fn isobjcleared(o: *mut crate::records::gc_object::GCObject) -> i32 {
36 use crate::enums::lua_type::lua_Type;
37
38 if (*o).gch.tt == lua_Type::LUA_TSTRING as u8 {
39 // strings are 'values', so they are never weak — stringmark(&o->ts)
40 crate::stringmark!(
41 core::ptr::addr_of_mut!((*o).ts) as *mut crate::records::t_string::TString
42 );
43 0
44 } else {
45 // iswhite(o): test WHITE0BIT (bit 0) and WHITE1BIT (bit 1)
46 // Using inline bit test because the iswhite! macro has a type-mismatch
47 // (testbits takes i32 but marked is u8, and WHITE0BIT/WHITE1BIT are not
48 // re-exported from crate::macros in this workspace build).
49 ((*o).gch.marked & 0b0000_0011_u8) as i32
50 }
51}