wasCSharpSQLite – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * LsetCmd.java
3 *
4 * Copyright (c) 1997 Cornell University.
5 * Copyright (c) 1997 Sun Microsystems, Inc.
6 *
7 * See the file "license.terms" for information on usage and
8 * redistribution of this file, and for a DISCLAIMER OF ALL
9 * WARRANTIES.
10 *
11 * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
12 *
13 * RCS @(#) $Id: LsetCmd.java,v 1.3 2003/01/09 02:15:39 mdejong Exp $
14 *
15 */
16 using System;
17 namespace tcl.lang
18 {
19  
20 /// <summary> This class implements the built-in "Lset" command in Tcl.</summary>
21  
22 class LsetCmd : Command
23 {
24 /// <summary> See Tcl user documentation for details.</summary>
25 /// <exception cref=""> TclException If incorrect number of arguments.
26 /// </exception>
27  
28 public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
29 {
30 if ( argv.Length != 4 )
31 {
32 throw new TclNumArgsException( interp, 1, argv, "lset list index element" );
33 }
34  
35 int size = TclList.getLength( interp, argv[1] );
36 int index = Util.getIntForIndex( interp, argv[2], size );
37 TclObject list = argv[1];
38 bool isDuplicate = false;
39  
40 // If the list object is unshared we can modify it directly. Otherwise
41 // we create a copy to modify: this is "copy on write".
42  
43 if ( list.Shared )
44 {
45 list = list.duplicate();
46 isDuplicate = true;
47 }
48  
49 try
50 { TclObject[] replace = new TclObject[1];
51 replace[0]=argv[3];
52 TclList.replace(interp,list,index,1,replace,0,0 );
53 interp.setResult( list );
54 }
55 catch ( TclException e )
56 {
57 if ( isDuplicate )
58 {
59 list.release();
60 }
61 throw;
62 }
63 return TCL.CompletionCode.RETURN;
64 }
65 }
66 }