Class LuauUserData
- Namespace
- LuauInterop.Objects
- Assembly
- LuauInterop.dll
public sealed class LuauUserData : LuauBase, IDisposable
- Inheritance
-
LuauUserData
- Implements
- Inherited Members
Constructors
LuauUserData(Luau, LuaState, int)
public LuauUserData(Luau owner, LuaState state, int reference)
Parameters
Properties
Pointer
public nint Pointer { get; }
Property Value
Size
Gets the number of bytes actually allocated for this userdata's payload,
as reported by the Lua runtime (lua_objlen).
public int Size { get; }
Property Value
Remarks
This is the authoritative size of the native block backing this userdata. Read<T>() validates against this value before reading.
Tag
public int Tag { get; }
Property Value
Methods
Read<T>()
Reads this userdata's payload as a value of type T.
public T Read<T>() where T : unmanaged
Returns
- T
Type Parameters
T
Exceptions
- InvalidOperationException
Thrown if the userdata's pointer is null, or if the userdata's actual allocated size (Size) is smaller than
sizeof(T). This guards against out-of-bounds reads.
TryRead<T>(out T)
Attempts to read this userdata's payload as a value of type
T, returning false instead of
throwing if the userdata is too small or its pointer is null.
public bool TryRead<T>(out T value) where T : unmanaged
Parameters
valueT
Returns
Type Parameters
T