Quirrel4.41.0

Manipulating objects

Reading and writing slots, growing arrays, iterating containers, and freezing them.

Everything here follows the language's own rules: sq_get consults a _get metamethod, sq_set consults _set, and a frozen container refuses a write. The sq_raw* family on Raw object handling skips the metamethods. A frozen container still refuses a raw write.

sq_next is the iteration primitive. Push a null to start. Each step leaves the key and the value on the stack.

void sq_pushroottable(HSQUIRRELVM v)

Pushes the current root table in the stack.

void sq_pushregistrytable(HSQUIRRELVM v)

Pushes the registry table in the stack.

void sq_pushconsttable(HSQUIRRELVM v)

Pushes the current const table in the stack.

SQRESULT sq_setroottable(HSQUIRRELVM v)

Pops a table from the stack and set it as root table.

SQRESULT sq_setconsttable(HSQUIRRELVM v)

Pops a table from the stack and set it as const table.

SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic)

Pops a key and a value and creates that slot on the table or class at idx, as <- does in script.

SQRESULT sq_deleteslot(HSQUIRRELVM v, SQInteger idx, SQBool pushval)

Pops a key and removes that slot from the table at idx. Does nothing when the slot is absent.

SQRESULT sq_set(HSQUIRRELVM v, SQInteger idx)

Pops a key and a value and writes that slot of the value at idx. Consults a _set metamethod.

SQRESULT sq_get(HSQUIRRELVM v, SQInteger idx)

Pops a key and reads that slot of the value at idx, pushing the result. Consults a _get metamethod.

SQRESULT sq_rawget(HSQUIRRELVM v, SQInteger idx)

Pops a key from the stack and performs a get operation on the object at position idx in the stack, without employing delegation or metamethods.

SQRESULT sq_rawset(HSQUIRRELVM v, SQInteger idx)

Pops a key and a value from the stack and performs a set operation on the object at position idx in the stack, without employing delegation or metamethods.

SQRESULT sq_rawdeleteslot(HSQUIRRELVM v, SQInteger idx, SQBool pushval)

Deletes a slot from a table without employing the _delslot metamethod. Pops a key from the stack and delete the slot indexed by it from the table at position idx in the stack; if the slot does not exist nothing happens.

SQRESULT sq_newmember(HSQUIRRELVM v, SQInteger idx, SQBool bstatic)

Pops a key and a value from the stack and performs a new slot operation on the class that is at position idx in the stack; if the slot does not exist, it will be created.

SQRESULT sq_arrayappend(HSQUIRRELVM v, SQInteger idx)

Pops a value from the stack and pushes it in the back of the array at the position idx in the stack.

SQRESULT sq_arraypop(HSQUIRRELVM v, SQInteger idx, SQBool pushval)

Pops a value from the back of the array at the position idx in the stack.

SQRESULT sq_arrayresize(HSQUIRRELVM v, SQInteger idx, SQInteger newsize)

Resizes the array at the position idx in the stack.

SQRESULT sq_arrayreverse(HSQUIRRELVM v, SQInteger idx)

Reverses an array in place.

SQRESULT sq_arrayremove(HSQUIRRELVM v, SQInteger idx, SQInteger itemidx)

Removes an item from an array.

SQRESULT sq_arrayinsert(HSQUIRRELVM v, SQInteger idx, SQInteger destpos)

Pops a value from the stack and inserts it in an array at the specified position.

SQRESULT sq_setdelegate(HSQUIRRELVM v, SQInteger idx)

Pops a table from the stack and sets it as the delegate of the object at the position idx in the stack.

SQRESULT sq_getdelegate(HSQUIRRELVM v, SQInteger idx)

Pushes the current delegate of the object at the position idx in the stack.

SQRESULT sq_clone(HSQUIRRELVM v, SQInteger idx)

Pushes a clone of the table, array, or class instance at the position idx.

SQRESULT sq_setfreevariable(HSQUIRRELVM v, SQInteger idx, SQUnsignedInteger nval)

Pops a value from the stack and sets it as a free variable of the closure at the position idx in the stack.

SQRESULT sq_next(HSQUIRRELVM v, SQInteger idx)

Advances an iteration. Push a null to start; each call replaces it with an iterator and pushes the key and value. Pop those two before the next call, leave the iterator. Fails when the container is exhausted.

SQRESULT sq_getweakrefval(HSQUIRRELVM v, SQInteger idx)

Pushes the object pointed by the weak reference at position idx in the stack.

SQRESULT sq_clear(HSQUIRRELVM v, SQInteger idx, SQBool freemem = SQTrue)

Clears all the elements of the table/array at position idx in the stack.

SQRESULT sq_freeze(HSQUIRRELVM v, SQInteger idx)

Pushes an immutable reference to the value at idx. The original is left alone.

SQRESULT sq_freeze_inplace(HSQUIRRELVM v, SQInteger idx)

Makes the value at idx itself immutable.

SQRESULT sq_mark_pure_inplace(HSQUIRRELVM v, SQInteger idx)

Marks a closure pure, which lets the compiler fold calls to it.

bool sq_is_pure_function(HSQOBJECT *func)

Reports whether a closure is marked pure.