pub struct GcRef<T>(pub Gc<T>)
where
T: Trace + 'static;Expand description
A GC-managed pointer to a Lua collectable object. Newtype over
lua_gc::Gc<T> so callers preserve gc.0-shape access while the
backend swaps under them.
Tuple Fields§
§0: Gc<T>Implementations§
Source§impl<T> GcRef<T>where
T: Trace + 'static,
impl<T> GcRef<T>where
T: Trace + 'static,
Sourcepub fn new(value: T) -> GcRef<T>
pub fn new(value: T) -> GcRef<T>
Allocate a new GC-tracked value. If a HeapGuard is active (set by
state.run() / pcall_k), the new allocation joins that heap’s
allgc chain. Otherwise it allocates “uncollected” — leaks until
process exit, same as the old Rc::new behavior.
Sourcepub fn trace_obj(&self, m: &mut Marker)
pub fn trace_obj(&self, m: &mut Marker)
Cycle-aware trace dispatch.
During D-0/D-1 (before a real Color::Gray flag is reachable from
inside Trace impls), Marker::try_visit records the underlying
allocation’s identity and short-circuits a second recursion. Once
D-2 ships the in-header color flag, this helper collapses to
m.mark(self.0).
Source§impl<T> GcRef<T>where
T: Trace + 'static,
impl<T> GcRef<T>where
T: Trace + 'static,
Sourcepub fn ptr_eq(a: &GcRef<T>, b: &GcRef<T>) -> bool
pub fn ptr_eq(a: &GcRef<T>, b: &GcRef<T>) -> bool
Two GcRefs are identity-equal iff they point at the same box.
Sourcepub fn identity(&self) -> usize
pub fn identity(&self) -> usize
Identity as a usize — used as a HashMap key for “same object” tests.
Sourcepub fn strong_count(&self) -> usize
pub fn strong_count(&self) -> usize
Number of strong references. Phase D-1: always returns 1 (no refcount semantics). Real value once weak refs land in D-2.
Sourcepub fn weak_count(&self) -> usize
pub fn weak_count(&self) -> usize
Number of weak references. Phase D-1: always returns 0.
Trait Implementations§
Source§impl LuaLClosureRefExt for GcRef<LuaLClosure>
impl LuaLClosureRefExt for GcRef<LuaLClosure>
Source§impl LuaStringRefExt for GcRef<LuaString>
impl LuaStringRefExt for GcRef<LuaString>
Source§impl LuaTableRefExt for GcRef<LuaTable>
impl LuaTableRefExt for GcRef<LuaTable>
Source§fn raw_set(
&self,
_state: &mut LuaState,
k: LuaValue,
v: LuaValue,
) -> Result<(), LuaError>
fn raw_set( &self, _state: &mut LuaState, k: LuaValue, v: LuaValue, ) -> Result<(), LuaError>
Forwards to LuaTable::try_raw_set, which performs the nil/NaN
key validation internally as part of its integer-fast-path match.
fn metatable(&self) -> Option<GcRef<LuaTable>>
fn as_ptr(&self) -> *const ()
fn get(&self, k: &LuaValue) -> LuaValue
fn get_int(&self, k: i64) -> LuaValue
fn get_short_str(&self, k: &GcRef<LuaString>) -> LuaValue
fn raw_set_int( &self, _state: &mut LuaState, k: i64, v: LuaValue, ) -> Result<(), LuaError>
fn invalidate_tm_cache(&self)
fn resize( &self, _state: &mut LuaState, na: usize, nh: usize, ) -> Result<(), LuaError>
fn next(&self, k: LuaValue) -> Result<Option<(LuaValue, LuaValue)>, LuaError>
Source§impl LuaUserDataRefExt for GcRef<LuaUserData>
impl LuaUserDataRefExt for GcRef<LuaUserData>
Source§impl<T> Trace for GcRef<T>where
T: Trace + 'static,
Forwarder for GcRef<T>. Now that GcRef wraps a real lua_gc::Gc<T>
(D-1e), tracing must enqueue the box onto the gray queue via
Marker::mark — that is what flips its header color from White to Gray
and ultimately to Black during gray-queue drainage. The previous
try_visit short-circuit was a Phase A-D-0 workaround for the
Rc-backed handle (no header, no color), and produced a silent bug
post-D-1e: every GC-tracked allocation stayed White and was freed in
the sweep on the first collectgarbage(). Cycles are now handled
natively by the heap’s gray-queue (Color::Gray check in mark makes
re-visits idempotent).
impl<T> Trace for GcRef<T>where
T: Trace + 'static,
Forwarder for GcRef<T>. Now that GcRef wraps a real lua_gc::Gc<T>
(D-1e), tracing must enqueue the box onto the gray queue via
Marker::mark — that is what flips its header color from White to Gray
and ultimately to Black during gray-queue drainage. The previous
try_visit short-circuit was a Phase A-D-0 workaround for the
Rc-backed handle (no header, no color), and produced a silent bug
post-D-1e: every GC-tracked allocation stayed White and was freed in
the sweep on the first collectgarbage(). Cycles are now handled
natively by the heap’s gray-queue (Color::Gray check in mark makes
re-visits idempotent).