Creating objects
Pushing C values into the VM, making containers and classes, and reading values back out.
This is the largest section of the header. It holds three related jobs: the sq_push* family puts a C value on the stack, the sq_new* family creates a Quirrel object, and the sq_get* family converts a value on the stack back to C.
A sq_get* returns SQRESULT because the conversion can fail. A read of a string from a slot that holds an integer is an error, not a coercion. A string pointer obtained this way is owned by the VM. It stays valid only while the value is reachable from the stack or from a handle you hold a reference to. See Holding references from C.
Use sq_new_closure_slot_from_decl_string to register a native function, not sq_newclosure plus a type mask. The declaration string gives the function parameter names and types. Every signature on this site is built from one.
Creates a new userdata and pushes it in the stack.
Creates a new table and pushes it in the stack.
Creates a new table and pushes it in the stack. This function allows you to specify the initial capacity of the table to prevent unnecessary rehashing when the number of slots required is known at creation-time.
Creates a new array and pushes it in the stack.
Creates a native closure from a readable declaration string and stores it as a slot, which is how a binding gets real parameter names and types.
Creates a native closure from a C function, taking n values off the stack as its free variables, and pushes it.
Sets the parameter validation scheme for the native closure at the top position in the stack. Allows you to validate the number of parameters accepted by the function and optionally their types. If the function call does not comply with the parameter schema set by sq_setparamscheck, an exception is thrown.
Pops an object from the stack (must be a table, instance, or class); clones the closure at position idx in the stack and sets the popped object as environment of the cloned closure. Then pushes the new cloned closure on top of the stack.
Pushes a string in the stack.
Pushes a float into the stack.
Pushes an integer into the stack.
Pushes a bool into the stack.
Pushes a userpointer into the stack.
Pushes a null value into the stack.
Pushes a thread (a VM handle) onto the stack of another VM.
Returns the type of the value at the position idx in the stack.
Pushes the type name of the value at the position idx in the stack. It also invokes the _typeof metamethod for tables and class instances that implement it; in that case the pushed object could be something other than a string (is up to the _typeof implementation).
Returns the element count of the value at idx. For a class or instance this is the size of its userdata buffer, not a member count.
Returns the hash key of a value at the idx position in the stack.
Pushes the base class of the 'class' at stored position idx in the stack.
Determines if an object is an instance of a certain class. Expects an instance and a class in the stack.
Converts the object at position idx in the stack to string and pushes the resulting string in the stack.
Gets the value at position idx in the stack as bool.
Gets a pointer to the string at the idx position in the stack; additionally retrieves its size.
Gets a pointer to the string at the idx position in the stack.
Gets the value of the integer at the idx position in the stack.
Gets the value of the float at the idx position in the stack.
Gets the value of the bool at the idx position in the stack.
Gets a pointer to the thread at the idx position in the stack.
Gets the value of the userpointer at the idx position in the stack.
Gets a pointer to the value of the userdata at the idx position in the stack.
Sets the typetag of the object (userdata or class) at position idx in the stack.
Gets the typetag of the object (userdata or class) at position idx in the stack.
Sets the release hook of the userdata, class instance, or class at position idx in the stack.
Gets the release hook of the userdata, class instance or class at position idx in the stack.
Returns a pointer to a memory buffer that is at least as big as minsize.
Fills a function info struct for the closure at position idx.
Retrieves number of parameters and number of freevariables from a Quirrel closure.
Pushes the name of the closure at position idx in the stack. Note that the name can be a string or null if the closure is anonymous or a native closure with no name assigned to it.
Sets the name of the native closure at the position idx in the stack. The name of a native closure is purely for debug purposes. The name is retrieved through the function sq_stackinfos() while the closure is in the call stack.
Attaches a documentation string to a native closure.
Attaches a documentation string to an object.
Sets the userpointer of the class instance at position idx in the stack.
Gets the userpointer of the class instance at position idx in the stack. if the parameter 'typetag' is different than 0, the function checks that the class or a base class of the instance is tagged with the specified tag; if not the function fails. If 'typetag' is 0 the function will ignore the tag check.
Sets the user data size of a class. If a class 'user data size' is greater than 0. When an instance of the class is created additional space will be reserved at the end of the memory chunk where the instance is stored. The userpointer of the instance will also be automatically set to this memory area. This allows you to minimize allocations in applications that have to carry data along with the class instance.
Creates a new class object. If the parameter 'hasbase' is different than 0, the function pops a class from the stack and inherits the new created class from it. The new class is pushed in the stack.
Creates an instance of the class at 'idx' position in the stack. The new class instance is pushed on top of the stack.
Pushes the class of the 'class instance' at stored position idx in the stack.
Pushes a weak reference to the object at position idx in the stack.
Pops a value from the stack and uses it as index to fetch the handle of a class member. The handle can be later used to set or get the member value using sq_getbyhandle(), sq_setbyhandle().
Pushes the value of a class or instance member using a member handle (see sq_getmemberhandle).
Pops a value from the stack and sets it to a class or instance member using a member handle (see sq_getmemberhandle).
Native fields
A class whose instances carry a C++ struct can expose the fields of that struct directly, without a getter closure per field.
Exposes a field of a C++ struct held in inline userdata as a slot on the class.