Raw object handling
Working with an HSQOBJECT handle instead of a stack slot, and reference counting.
Two different things live here. The header groups them together because both work outside the stack.
Handles. sq_getstackobj takes a handle to a value, and sq_addref / sq_release control its lifetime. This is how a host keeps a script value across frames. See Holding references from C for the sequence and its common mistakes.
Handle-direct access. The sq_obj_* family reads and writes through a handle without the stack. This saves the push and pop around a hot read.
Takes a handle to the value at position idx, which can then outlive the stack slot.
Pushes an object handle onto the stack.
Pushes the value an object handle names back onto the stack.
Pushes the value an object handle names back onto the stack.
Adds a reference, assuming the object is of a reference-counted type. sq_addref checks that first.
Removes a reference, assuming the object is of a reference-counted type.
Returns the number of references of a given object.
Initializes an object handle. Required before the handle is used for anything else.
Returns the string value of a raw object reference.
Returns the bool value of a raw object reference.
Reports whether an object is true by the language's rules.
Returns the integer value of a raw object reference.
Returns the float value of a raw object reference.
Returns the userpointer value of a raw object reference.
Gets the typetag of a raw object reference(userdata or class).
Returns the reference count of a VM.
Returns the type name of an object as a string.
Reads a slot from an object handle without using the stack.
Orders two objects, as the relational operators do.
Compares two objects for equality, as == does.
Compares two values by content rather than by identity, following containers.
Returns the payload pointer of a userdata held as an object handle.
Returns the element count of a container held as an object handle.
Returns the user pointer of an instance held as an object handle.
Writes a slot of an object handle without using the stack.
Creates a slot on an object handle without using the stack.
Returns a handle to the registry table without going through the stack.
Records the current write to a container field, for the variable trace.
Runs the mark and sweep pass and returns how many reference cycles it freed. Nothing calls it on its own.
Runs the garbage collector and pushes an array in the stack containing all unreachable object found. If no unreachable object is found, null is pushed instead. This function is meant to help debug reference cycles.
Binds the VM to the calling OS thread, so a stray access from another one is caught.
Reports whether the calling OS thread is allowed to touch this VM.
Returns the allocation context the VM was created with.
Adds a reference to the value an object handle names, so it survives leaving the stack.
Removes a reference added with sq_addref.