File: calls.rst

package info (click to toggle)
squirrel3 3.1-8.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,380 kB
  • sloc: cpp: 12,722; ansic: 917; makefile: 316; python: 40
file content (115 lines) | stat: -rw-r--r-- 3,716 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
.. _api_ref_calls:

=====
Calls
=====

.. _sq_call:

.. c:function:: SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror)

    :param HSQUIRRELVM v: the target VM
    :param SQInteger params: number of parameters of the function
    :param SQBool retval: if true the function will push the return value in the stack
    :param SQBool raiseerror: if true, if a runtime error occurs during the execution of the call, the vm will invoke the error handler.
    :returns: a SQRESULT
    :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.

calls a closure or a native closure.





.. _sq_getcallee:

.. c:function:: SQRESULT sq_getcallee(HSQUIRRELVM v)

    :param HSQUIRRELVM v: the target VM
    :returns: a SQRESULT

push in the stack the currently running closure.





.. _sq_getlasterror:

.. c:function:: SQRESULT sq_getlasterror(HSQUIRRELVM v)

    :param HSQUIRRELVM v: the target VM
    :returns: a SQRESULT
    :remarks: the pushed error descriptor can be any valid squirrel type.

pushes the last error in the stack.





.. _sq_getlocal:

.. c:function:: const SQChar * sq_getlocal(HSQUIRRELVM v, SQUnsignedInteger level, SQUnsignedInteger nseq)

    :param HSQUIRRELVM v: the target VM
    :param SQUnsignedInteger level: the function index in the calls stack, 0 is the current function
    :param SQUnsignedInteger nseq: the index of the local variable in the stack frame (0 is 'this')
    :returns: the name of the local variable if a variable exists at the given level/seq otherwise NULL.

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.





.. _sq_reseterror:

.. c:function:: void sq_reseterror(HSQUIRRELVM v)

    :param HSQUIRRELVM v: the target VM

reset the last error in the virtual machine to null





.. _sq_resume:

.. c:function:: SQRESULT sq_resume(HSQUIRRELVM v, SQBool retval, SQBool raiseerror)

    :param HSQUIRRELVM v: the target VM
    :param SQBool retval: if true the function will push the return value in the stack
    :param SQBool raiseerror: if true, if a runtime error occurs during the execution of the call, the vm will invoke the error handler.
    :returns: a SQRESULT
    :remarks: if retval != 0 the return value of the generator is pushed.

resumes the generator at the top position of the stack.





.. _sq_throwerror:

.. c:function:: SQRESULT sq_throwerror(HSQUIRRELVM v, const SQChar * err)

    :param HSQUIRRELVM v: the target VM
    :param const SQChar * err: the description of the error that has to be thrown
    :returns: the value that has to be returned by a native closure in order to throw an exception in the virtual machine.

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.





.. _sq_throwobject:

.. c:function:: SQRESULT sq_throwobject(HSQUIRRELVM v)

    :param HSQUIRRELVM v: the target VM
    :returns: the value that has to be returned by a native closure in order to throw an exception in the virtual machine.

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).