01: /*
02: * HoldRefCmd.java --
03: *
04: * This file tests incrementing and decrementing a
05: * the ref count of a native object.
06: *
07: * Copyright (c) 2002 by Mo DeJong
08: *
09: * See the file "license.terms" for information on usage and redistribution
10: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11: *
12: * RCS: @(#) $Id: HoldRefCmd.java,v 1.1 2002/12/21 04:05:08 mdejong Exp $
13: */
14:
15: package tests;
16:
17: import tcl.lang.*;
18: import java.util.Vector;
19: import java.util.Enumeration;
20:
21: public class HoldRefCmd implements CommandWithDispose {
22: Vector holding = new Vector();
23:
24: public void cmdProc(Interp interp, TclObject[] objv)
25: throws TclException {
26: if (objv.length != 2) {
27: throw new TclNumArgsException(interp, 1, objv, "obj");
28: }
29: TclObject hold = objv[1];
30: hold.preserve();
31: holding.addElement(hold);
32: }
33:
34: // Called when the command is deleted
35:
36: public void disposeCmd() {
37: TclObject hold;
38: Enumeration search;
39: for (search = holding.elements(); search.hasMoreElements();) {
40: hold = (TclObject) search.nextElement();
41: hold.release();
42: }
43: }
44: }
|