wasCSharpSQLite – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * TclObj.java
3 *
4 * Copyright (c) 1997 Sun Microsystems, Inc.
5 *
6 * See the file "license.terms" for information on usage and
7 * redistribution of this file, and for a DISCLAIMER OF ALL
8 * WARRANTIES.
9 *
10 * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart
11 *
12 * RCS @(#) $Id: TclObj.java,v 1.5 2000/10/29 06:00:42 mdejong Exp $
13 *
14 */
15 using System;
16 namespace tcl.lang
17 {
18  
19 /// <summary> This class implements the object type in Tcl.</summary>
20  
21 public class TclObj : InternalRep
22 {
23 /// <summary> Internal representation of a object value.</summary>
24 private object value;
25  
26 /// <summary> Construct a TclObj representation with the given object value.</summary>
27 private TclObj( object o )
28 {
29 value = o;
30 }
31  
32 /// <summary> Returns a dupilcate of the current object.</summary>
33 /// <param name="obj">the TclObject that contains this internalRep.
34 /// </param>
35 public InternalRep duplicate()
36 {
37 return new TclObj( value );
38 }
39  
40 /// <summary> Implement this no-op for the InternalRep interface.</summary>
41  
42 public void dispose()
43 {
44 value = null;
45 }
46  
47 /// <summary> Called to query the string representation of the Tcl object. This
48 /// method is called only by TclObject.toString() when
49 /// TclObject.stringRep is null.
50 ///
51 /// </summary>
52 /// <returns> the string representation of the Tcl object.
53 /// </returns>
54 public override string ToString()
55 {
56 return value.ToString();
57 }
58  
59 /// <summary> Tcl_NewIntObj -> TclObj.newInstance
60 ///
61 /// Creates a new instance of a TclObject with a TclObj internal
62 /// representation.
63 ///
64 /// </summary>
65 /// <param name="b">initial value of the object object.
66 /// </param>
67 /// <returns> the TclObject with the given object value.
68 /// </returns>
69  
70 public static TclObject newInstance( object o )
71 {
72 return new TclObject( new TclObj( o ) );
73 }
74  
75  
76 /// <summary> Changes the object value of the object.
77 ///
78 /// </summary>
79 /// <param name="interp">current interpreter.
80 /// </param>
81 /// <param name="tobj">the object to operate on.
82 /// @paran i the new object value.
83 /// </param>
84 public static void set( TclObject tobj, object o )
85 {
86 tobj.invalidateStringRep();
87 InternalRep rep = tobj.InternalRep;
88 TclObj tint;
89  
90 if ( rep is TclObj )
91 {
92 tint = (TclObj)rep;
93 tint.value = o;
94 }
95 else
96 {
97 tobj.InternalRep = new TclObj( o );
98 }
99 }
100 }
101 }