calls.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. .. _api_ref_calls:
  2. =====
  3. Calls
  4. =====
  5. .. _sq_call:
  6. .. c:function:: SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror)
  7. :param HSQUIRRELVM v: the target VM
  8. :param SQInteger params: number of parameters of the function
  9. :param SQBool retval: if true the function will push the return value in the stack
  10. :param SQBool raiseerror: if true, if a runtime error occurs during the execution of the call, the vm will invoke the error handler.
  11. :returns: a SQRESULT
  12. :remarks: the function pops all the parameters and leave the closure in the stack; if retval is true the return value of the closure is pushed. If the execution of the function is suspended through sq_suspendvm(), the closure and the arguments will not be automatically popped from the stack.
  13. calls a closure or a native closure.
  14. .. _sq_getcallee:
  15. .. c:function:: SQRESULT sq_getcallee(HSQUIRRELVM v)
  16. :param HSQUIRRELVM v: the target VM
  17. :returns: a SQRESULT
  18. push in the stack the currently running closure.
  19. .. _sq_getlasterror:
  20. .. c:function:: SQRESULT sq_getlasterror(HSQUIRRELVM v)
  21. :param HSQUIRRELVM v: the target VM
  22. :returns: a SQRESULT
  23. :remarks: the pushed error descriptor can be any valid squirrel type.
  24. pushes the last error in the stack.
  25. .. _sq_getlocal:
  26. .. c:function:: const SQChar * sq_getlocal(HSQUIRRELVM v, SQUnsignedInteger level, SQUnsignedInteger nseq)
  27. :param HSQUIRRELVM v: the target VM
  28. :param SQUnsignedInteger level: the function index in the calls stack, 0 is the current function
  29. :param SQUnsignedInteger nseq: the index of the local variable in the stack frame (0 is 'this')
  30. :returns: the name of the local variable if a variable exists at the given level/seq otherwise NULL.
  31. Returns the name of a local variable given stackframe and sequence in the stack and pushes is current value. Free variables are treated as local variables, by sq_getlocal(), and will be returned as they would be at the base of the stack, just before the real local variables.
  32. .. _sq_reseterror:
  33. .. c:function:: void sq_reseterror(HSQUIRRELVM v)
  34. :param HSQUIRRELVM v: the target VM
  35. reset the last error in the virtual machine to null
  36. .. _sq_resume:
  37. .. c:function:: SQRESULT sq_resume(HSQUIRRELVM v, SQBool retval, SQBool raiseerror)
  38. :param HSQUIRRELVM v: the target VM
  39. :param SQBool retval: if true the function will push the return value in the stack
  40. :param SQBool raiseerror: if true, if a runtime error occurs during the execution of the call, the vm will invoke the error handler.
  41. :returns: a SQRESULT
  42. :remarks: if retval != 0 the return value of the generator is pushed.
  43. resumes the generator at the top position of the stack.
  44. .. _sq_throwerror:
  45. .. c:function:: SQRESULT sq_throwerror(HSQUIRRELVM v, const SQChar * err)
  46. :param HSQUIRRELVM v: the target VM
  47. :param const SQChar * err: the description of the error that has to be thrown
  48. :returns: the value that has to be returned by a native closure in order to throw an exception in the virtual machine.
  49. sets the last error in the virtual machine and returns the value that has to be returned by a native closure in order to trigger an exception in the virtual machine.
  50. .. _sq_throwobject:
  51. .. c:function:: SQRESULT sq_throwobject(HSQUIRRELVM v)
  52. :param HSQUIRRELVM v: the target VM
  53. :returns: the value that has to be returned by a native closure in order to throw an exception in the virtual machine.
  54. pops a value from the stack sets it as the last error in the virtual machine. Returns the value that has to be returned by a native closure in order to trigger an exception in the virtual machine (aka SQ_ERROR).