4.7. Bytecode serialization

SQRESULT sq_readclosure(HSQUIRRELVM v, SQREADFUNC readf, SQUserPointer up)
Parameters:
  • v (HSQUIRRELVM) – the target VM
  • readf (SQREADFUNC) – pointer to a read function that will be invoked by the vm during the serialization.
  • up (SQUserPointer) – pointer that will be passed to each call to the read function
Returns:

a SQRESULT

serialize (read) a closure and pushes it on top of the stack, the source is user defined through a read callback.

SQRESULT sq_writeclosure(HSQUIRRELVM v, SQWRITEFUNC writef, SQUserPointer up)
Parameters:
  • v (HSQUIRRELVM) – the target VM
  • writef (SQWRITEFUNC) – pointer to a write function that will be invoked by the vm during the serialization.
  • up (SQUserPointer) – pointer that will be passed to each call to the write function
Returns:

a SQRESULT

Remarks:

closures with free variables cannot be serialized

serializes(writes) the closure on top of the stack, the destination is user defined through a write callback.