Closed Lenheart357 closed 1 year ago
by calling your table traverser recursively? this is a programming textbook homework question.
I did use recursion, but it seems like I won't be able to retrieve the table on the stack the next time I call it
case OT_TABLE:
{
sq_get(v, -1);
Jso += EncodeTABLE(v, Jso);
}
break;
SQInteger Top = sq_gettop(v);
SQObject obj;
sq_getstackobj(v, -1, &obj);
sq_pushobject(v, obj);
Jso += EncodeTABLE(v, Jso);
sq_settop(v, Top);
I solved it
Do not use sq_get
use sq_getstackobj
If I want to traverse the table
sq_pushnull(v) while(SQ_SUCCEEDED(sq_next(v,-2))) { //-1 value -2key }
But how should I traverse value when it is another table