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 tclvarFilter(
            sqlite3_vtab_cursor pVtabCursor,
            int idxNum, string idxStr,
            int argc, sqlite3_value[] argv
            )
        {
            tclvar_cursor pCur   = (tclvar_cursor )pVtabCursor;
            Tcl_Interp    interp = ((tclvar_vtab )(pVtabCursor.pVtab)).interp;

            Tcl_Obj p = TCL.Tcl_NewStringObj("info vars", -1);

            TCL.Tcl_IncrRefCount(p);

            Debug.Assert(argc == 0 || argc == 1);
            if (argc == 1)
            {
                Tcl_Obj pArg = TCL.Tcl_NewStringObj((string)sqlite3_value_text(argv[0]), -1);
                TCL.Tcl_ListObjAppendElement(null, p, pArg);
            }
            TCL.Tcl_EvalObjEx(interp, p, TCL.TCL_EVAL_GLOBAL);
            if (pCur.pList1 != null)
            {
                TCL.Tcl_DecrRefCount(ref pCur.pList1);
            }
            if (pCur.pList2 != null)
            {
                TCL.Tcl_DecrRefCount(ref pCur.pList2);
                pCur.pList2 = null;
            }
            pCur.i1     = 0;
            pCur.i2     = 0;
            pCur.pList1 = TCL.Tcl_GetObjResult(interp);
            TCL.Tcl_IncrRefCount(pCur.pList1);
            Debug.Assert(pCur.i1 == 0 && pCur.i2 == 0 && pCur.pList2 == null);

            TCL.Tcl_DecrRefCount(ref p);
            return(tclvarNext(pVtabCursor));
        }