stack_operations.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. .. _api_ref_stack_operations:
  2. ================
  3. Stack Operations
  4. ================
  5. .. _sq_cmp:
  6. .. c:function:: SQInteger sq_cmp(HSQUIRRELVM v)
  7. :param HSQUIRRELVM v: the target VM
  8. :returns: > 0 if obj1>obj2
  9. :returns: == 0 if obj1==obj2
  10. :returns: < 0 if obj1<obj2
  11. compares 2 object from the top of the stack. obj2 should be pushed before obj1.
  12. .. _sq_gettop:
  13. .. c:function:: SQInteger sq_gettop(HSQUIRRELVM v)
  14. :param HSQUIRRELVM v: the target VM
  15. :returns: an integer representing the index of the top of the stack
  16. returns the index of the top of the stack
  17. .. _sq_pop:
  18. .. c:function:: void sq_pop(HSQUIRRELVM v, SQInteger nelementstopop)
  19. :param HSQUIRRELVM v: the target VM
  20. :param SQInteger nelementstopop: the number of elements to pop
  21. pops n elements from the stack
  22. .. _sq_poptop:
  23. .. c:function:: void sq_poptop(HSQUIRRELVM v)
  24. :param HSQUIRRELVM v: the target VM
  25. pops 1 object from the stack
  26. .. _sq_push:
  27. .. c:function:: void sq_push(HSQUIRRELVM v, SQInteger idx)
  28. :param HSQUIRRELVM v: the target VM
  29. :param SQInteger idx: the index in the stack of the value that has to be pushed
  30. pushes in the stack the value at the index idx
  31. .. _sq_remove:
  32. .. c:function:: void sq_remove(HSQUIRRELVM v, SQInteger idx)
  33. :param HSQUIRRELVM v: the target VM
  34. :param SQInteger idx: index of the element that has to be removed
  35. removes an element from an arbitrary position in the stack
  36. .. _sq_reservestack:
  37. .. c:function:: SQRESULT sq_reservestack(HSQUIRRELVM v, SQInteger nsize)
  38. :param HSQUIRRELVM v: the target VM
  39. :param SQInteger nsize: required stack size
  40. :returns: a SQRESULT
  41. ensure that the stack space left is at least of a specified size.If the stack is smaller it will automatically grow. If there's a metamethod currently running the function will fail and the stack will not be resized, this situation has to be considered a "stack overflow".
  42. .. _sq_settop:
  43. .. c:function:: void sq_settop(HSQUIRRELVM v, SQInteger x)
  44. :param HSQUIRRELVM v: the target VM
  45. :param SQInteger x: the new top index
  46. resize the stack. If new top is bigger then the current top the function will push nulls.