Ejemplo n.º 1
0
/*
** Returns 1 if data is ready, or 0 if not.
*/
        static int next2(Tcl_Interp interp, tclvar_cursor pCur, Tcl_Obj pObj)
        {
            Tcl_Obj p;

            if (pObj != null)
            {
                if (null == pCur.pList2)
                {
                    p = TCL.Tcl_NewStringObj("array names", -1);
                    TCL.Tcl_IncrRefCount(p);
                    TCL.Tcl_ListObjAppendElement(null, p, pObj);
                    TCL.Tcl_EvalObjEx(interp, p, TCL.TCL_EVAL_GLOBAL);
                    TCL.Tcl_DecrRefCount(ref p);
                    pCur.pList2 = TCL.Tcl_GetObjResult(interp);
                    TCL.Tcl_IncrRefCount(pCur.pList2);
                    Debug.Assert(pCur.i2 == 0);
                }
                else
                {
                    int n = 0;
                    pCur.i2++;
                    TCL.Tcl_ListObjLength(null, pCur.pList2, out n);
                    if (pCur.i2 >= n)
                    {
                        TCL.Tcl_DecrRefCount(ref pCur.pList2);
                        pCur.pList2 = null;
                        pCur.i2     = 0;
                        return(0);
                    }
                }
            }

            return(1);
        }
Ejemplo n.º 2
0
        static int tclvarNext(sqlite3_vtab_cursor cur)
        {
            Tcl_Obj pObj = null;
            int     n    = 0;
            int     ok   = 0;

            tclvar_cursor pCur   = (tclvar_cursor )cur;
            Tcl_Interp    interp = ((tclvar_vtab )(cur.pVtab)).interp;

            TCL.Tcl_ListObjLength(null, pCur.pList1, out n);
            while (0 == ok && pCur.i1 < n)
            {
                TCL.Tcl_ListObjIndex(null, pCur.pList1, pCur.i1, out pObj);
                ok = next2(interp, pCur, pObj);
                if (0 == ok)
                {
                    pCur.i1++;
                }
            }

            return(0);
        }