wasCSharpSQLite – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * VwaitCmd.java --
3 *
4 * This file implements the Tcl "vwait" command.
5 *
6 * Copyright (c) 1997 Sun Microsystems, Inc.
7 *
8 * See the file "license.terms" for information on usage and
9 * redistribution of this file, and for a DISCLAIMER OF ALL
10 * WARRANTIES.
11 *
12 * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
13 *
14 * RCS @(#) $Id: VwaitCmd.java,v 1.2 1999/08/03 03:22:47 mo Exp $
15 */
16 using System;
17 namespace tcl.lang
18 {
19  
20 /*
21 * This class implements the built-in "vwait" command in Tcl.
22 */
23  
24 class VwaitCmd : Command
25 {
26  
27 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
28 {
29 if ( argv.Length != 2 )
30 {
31 throw new TclNumArgsException( interp, 1, argv, "name" );
32 }
33  
34 VwaitTrace trace = new VwaitTrace();
35 Var.traceVar( interp, argv[1], TCL.VarFlag.GLOBAL_ONLY | TCL.VarFlag.TRACE_WRITES | TCL.VarFlag.TRACE_UNSETS, trace );
36  
37 int foundEvent = 1;
38 while ( !trace.done && ( foundEvent != 0 ) )
39 {
40 foundEvent = interp.getNotifier().doOneEvent( TCL.ALL_EVENTS );
41 }
42  
43 Var.untraceVar( interp, argv[1], TCL.VarFlag.GLOBAL_ONLY | TCL.VarFlag.TRACE_WRITES | TCL.VarFlag.TRACE_UNSETS, trace );
44  
45 // Clear out the interpreter's result, since it may have been set
46 // by event handlers.
47  
48 interp.resetResult();
49  
50 if ( foundEvent == 0 )
51 {
52  
53 throw new TclException( interp, "can't wait for variable \"" + argv[1] + "\": would wait forever" );
54 }
55 return TCL.CompletionCode.RETURN;
56 }
57 } // end VwaitCmd
58  
59 class VwaitTrace : VarTrace
60 {
61  
62 /*
63 * TraceCmd.cmdProc continuously watches this variable across calls to
64 * doOneEvent(). It returns immediately when done is set to true.
65 */
66  
67 internal bool done = false;
68  
69 public void traceProc( Interp interp, string part1, string part2, TCL.VarFlag flags )
70 // Mode flags: Should only be TCL.VarFlag.TRACE_WRITES.
71 {
72 done = true;
73 }
74 } // end VwaitTrace
75 }