API Reference | developer.brewmp.com API Reference | developer.brewmp.com


API Reference


Brew Release
Brew MP 1.0.2
See Also
Pops a key from the stack and pushes the "next" key-value pair of the table at the given index. Used primarily for table traversal. When the end of the table is reached nothing is pushed on the stack and this function returns AEE_ENOMORE.
A typical traversal looks like this:
     // table is in the stack at index 't'
     ILua_PushNil(piLua);  // first key
     while (AEE_SUCCESS == ILua_Next(piLua)) {
       // uses 'key' (at index -2) and 'value' (at index -1) 
       key   = ILua_TypeName(piLua, -2);
       value = ILua_TypeName(piLua, -1);
       // ...
       // removes 'value'; keeps 'key' for next iteration
       ILua_Pop(piLua, 1);
a pointer to the ILua object
the stack index of the table object
  •    AEEResult ILua_Next(ILua *pif, int nIndex)
  • If there are no errors and there are more elements to traverse, pushes the next key-value pair on the stack and returns AEE_SUCCESS. Otherwise if there are no more elements left to traverse, pops the last key from the stack and returns AEE_ENOMORE. For other errors, an error code.
Side Effect
  • The key should not be modified during a traversal, as this confuses the call to ILua_Next. In particular, be cautious of calling ILua_ToString() directly on a key, unless the key is known to actually be a string, as ILua_ToString() may convert the value to a string.