01: /*
02: * ReRepCmd.java --
03: *
04: * This file tests modification of an internal rep.
05: *
06: * Copyright (c) 2002 by Mo DeJong
07: *
08: * See the file "license.terms" for information on usage and redistribution
09: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10: *
11: * RCS: @(#) $Id: ReRepCmd.java,v 1.1 2002/12/21 04:05:19 mdejong Exp $
12: */
13:
14: package tests;
15:
16: import tcl.lang.*;
17:
18: public class ReRepCmd implements Command {
19: public void cmdProc(Interp interp, TclObject[] objv)
20: throws TclException {
21: if (objv.length != 2) {
22: throw new TclNumArgsException(interp, 1, objv, "obj");
23: }
24: TclObject obj = objv[1];
25: TclObject str = TclString.newInstance(obj.toString());
26: // preserve so that a CObject's ref count gets incremented
27: obj.preserve();
28: // CObject.dispose() will drop any native refrences
29: // before switching to the new internal rep
30: obj.setInternalRep(str.getInternalRep());
31: // Does not effect CObject because it is now a TclString
32: obj.release();
33: return;
34: }
35: }
|