wasCSharpSQLite – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * LinsertCmd.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: LinsertCmd.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 "linsert" command in Tcl.</summary>
21  
22 class LinsertCmd : 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, "list index element ?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 {
51 TclList.insert( interp, list, index, argv, 3, argv.Length - 1 );
52 interp.setResult( list );
53 }
54 catch ( TclException e )
55 {
56 if ( isDuplicate )
57 {
58 list.release();
59 }
60 throw;
61 }
62 return TCL.CompletionCode.RETURN;
63 }
64 }
65 }