Esempio n. 1
0
        /// <summary> Sorts the list according to the sort mode and (optional) sort command.
        /// The resulting list will contain no duplicates, if argument unique is
        /// specifed as true.
        /// If tobj is not a list object, an attempt will be made to
        /// convert it to a list.
        ///
        /// </summary>
        /// <param name="interp">the current interpreter.
        /// </param>
        /// <param name="tobj">the list to sort.
        /// </param>
        /// <param name="sortMode">the sorting mode.
        /// </param>
        /// <param name="sortIncreasing">true if to sort the elements in increasing order.
        /// </param>
        /// <param name="command">the command to compute the order of two elements.
        /// </param>
        /// <param name="unique">true if the result should contain no duplicates.
        /// </param>
        /// <exception cref=""> TclException if tobj is not a valid list.
        /// </exception>

        internal static void sort(Interp interp, TclObject tobj, int sortMode, int sortIndex, bool sortIncreasing, string command, bool unique)
        {
            setListFromAny(interp, tobj);
            tobj.invalidateStringRep();
            TclList tlist = (TclList)tobj.InternalRep;

            int size = tlist.vector.Count;

            if (size <= 1)
            {
                return;
            }

            TclObject[] objArray = new TclObject[size];
            for (int i = 0; i < size; i++)
            {
                objArray[i] = (TclObject)tlist.vector[i];
            }

            QSort s       = new QSort();
            int   newsize = s.sort(interp, objArray, sortMode, sortIndex, sortIncreasing, command, unique);

            for (int i = 0; i < size; i++)
            {
                if (i < newsize)
                {
                    tlist.vector[i] = objArray[i];
                    objArray[i]     = null;
                }
                else
                {
                    tlist.vector.RemoveAt(newsize);
                }
            }
        }
Esempio n. 2
0
        /// <summary> Appends a string to a TclObject object. This method is equivalent to
        /// Tcl_AppendToObj() in Tcl 8.0.
        ///
        /// </summary>
        /// <param name="tobj">the TclObject to append a string to.
        /// </param>
        /// <param name="string">the string to append to the object.
        /// </param>
        public static void  append(TclObject tobj, string toAppend)
        {
            StringFromAny = tobj;

            TclString tstr = (TclString)tobj.InternalRep;

            if (tstr.sbuf == null)
            {
                tstr.sbuf = new System.Text.StringBuilder(tobj.ToString());
            }
            tobj.invalidateStringRep();
            tstr.sbuf.Append(toAppend);
        }
Esempio n. 3
0
        /// <summary> Appends an array of characters to a TclObject Object.
        /// Tcl_AppendUnicodeToObj() in Tcl 8.0.
        ///
        /// </summary>
        /// <param name="tobj">the TclObject to append a string to.
        /// </param>
        /// <param name="charArr">array of characters.
        /// </param>
        /// <param name="offset">index of first character to append.
        /// </param>
        /// <param name="length">number of characters to append.
        /// </param>
        public static void  append(TclObject tobj, char[] charArr, int offset, int length)
        {
            StringFromAny = tobj;

            TclString tstr = (TclString)tobj.InternalRep;

            if (tstr.sbuf == null)
            {
                tstr.sbuf = new System.Text.StringBuilder(tobj.ToString());
            }
            tobj.invalidateStringRep();
            tstr.sbuf.Append(charArr, offset, length);
        }
Esempio n. 4
0
        /// <summary> Tcl_ListObjAppendElement -> TclList.append()
        ///
        /// Appends a TclObject element to a list object.
        ///
        /// </summary>
        /// <param name="interp">current interpreter.
        /// </param>
        /// <param name="tobj">the TclObject to append an element to.
        /// </param>
        /// <param name="elemObj">the element to append to the object.
        /// </param>
        /// <exception cref=""> TclException if tobj cannot be converted into a list.
        /// </exception>
        public static void append(Interp interp, TclObject tobj, TclObject elemObj)
        {
            if (tobj.Shared)
            {
                throw new TclRuntimeError("TclList.append() called with shared object");
            }
            setListFromAny(interp, tobj);
            tobj.invalidateStringRep();

            TclList tlist = (TclList)tobj.InternalRep;

            elemObj.preserve();
            tlist.vector.Add(elemObj);
        }
Esempio n. 5
0
        // The new value for the object.
        public static void set( TclObject tobj, double d )
        {
            tobj.invalidateStringRep();
              InternalRep rep = tobj.InternalRep;

              if ( rep is TclDouble )
              {
            TclDouble tdouble = (TclDouble)rep;
            tdouble.value = d;
              }
              else
              {
            tobj.InternalRep = new TclDouble( d );
              }
        }
Esempio n. 6
0
        /// <summary> Changes the object value of the object.
        ///
        /// </summary>
        /// <param name="interp">current interpreter.
        /// </param>
        /// <param name="tobj">the object to operate on.
        /// @paran i the new object value.
        /// </param>
        public static void set(TclObject tobj, object o)
        {
            tobj.invalidateStringRep();
            InternalRep rep = tobj.InternalRep;
            TclObj      tint;

            if (rep is TclObj)
            {
                tint       = (TclObj)rep;
                tint.value = o;
            }
            else
            {
                tobj.InternalRep = new TclObj(o);
            }
        }
Esempio n. 7
0
        /// <summary> Changes the long value of the object.
        ///
        /// </summary>
        /// <param name="interp">current interpreter.
        /// </param>
        /// <param name="tobj">the object to operate on.
        /// @paran i the new long value.
        /// </param>
        public static void set(TclObject tobj, long i)
        {
            tobj.invalidateStringRep();
            InternalRep rep = tobj.InternalRep;
            TclLong     tlong;

            if (rep is TclLong)
            {
                tlong       = (TclLong)rep;
                tlong.value = i;
            }
            else
            {
                tobj.InternalRep = new TclLong(i);
            }
        }
Esempio n. 8
0
        /// <summary> Changes the integer value of the object.
        ///
        /// </summary>
        /// <param name="interp">current interpreter.
        /// </param>
        /// <param name="tobj">the object to operate on.
        /// @paran i the new integer value.
        /// </param>
        public static void  set(TclObject tobj, int i)
        {
            tobj.invalidateStringRep();
            InternalRep rep = tobj.InternalRep;
            TclInteger  tint;

            if (rep is TclInteger)
            {
                tint       = (TclInteger)rep;
                tint.value = i;
            }
            else
            {
                tobj.InternalRep = new TclInteger(i);
            }
        }
Esempio n. 9
0
    /// <summary> Changes the object value of the object.
    /// 
    /// </summary>
    /// <param name="interp">current interpreter.
    /// </param>
    /// <param name="tobj">the object to operate on.
    /// @paran i the new object value.
    /// </param>
    public static void set( TclObject tobj, object o )
    {
      tobj.invalidateStringRep();
      InternalRep rep = tobj.InternalRep;
      TclObj tint;

      if ( rep is TclObj )
      {
        tint = (TclObj)rep;
        tint.value = o;
      }
      else
      {
        tobj.InternalRep = new TclObj( o );
      }
    }
Esempio n. 10
0
        public static void  set(TclObject tobj, double d)
        // The new value for the object.
        {
            tobj.invalidateStringRep();
            InternalRep rep = tobj.InternalRep;

            if (rep is TclDouble)
            {
                TclDouble tdouble = (TclDouble)rep;
                tdouble.value = d;
            }
            else
            {
                tobj.InternalRep = new TclDouble(d);
            }
        }
Esempio n. 11
0
        /// <summary> This procedure clears out an existing TclObject so
        /// that it has a string representation of "".
        /// </summary>

        public static void  empty(TclObject tobj)
        {
            StringFromAny = tobj;

            TclString tstr = (TclString)tobj.InternalRep;

            if (tstr.sbuf == null)
            {
                tstr.sbuf = new System.Text.StringBuilder();
            }
            else
            {
                tstr.sbuf.Length = 0;
            }
            tobj.invalidateStringRep();
        }
Esempio n. 12
0
        /// <summary> Tcl_ListObjAppendElement -> TclList.append()
        ///
        /// Appends a TclObject element to a list object.
        ///
        /// </summary>
        /// <param name="interp">current interpreter.
        /// </param>
        /// <param name="tobj">the TclObject to append an element to.
        /// </param>
        /// <param name="elemObj">the element to append to the object.
        /// </param>
        /// <exception cref=""> TclException if tobj cannot be converted into a list.
        /// </exception>
        public static void append(Interp interp, TclObject tobj, TclObject elemObj)
        {
            if (tobj.Shared)
            {
                throw new TclRuntimeError("TclList.append() called with shared object");
            }
            setListFromAny(interp, tobj);
            tobj.invalidateStringRep();

            TclList tlist = (TclList)tobj.InternalRep;

            if (!String.IsNullOrEmpty(elemObj.stringRep) && elemObj.stringRep[0] == '{')
            {
                elemObj = TclString.newInstance(elemObj.stringRep.Substring(1, elemObj.stringRep.Length - 2));
            }
            elemObj.preserve();
            tlist.vector.Add(elemObj);
        }
Esempio n. 13
0
        /// <summary>
        /// This method changes the length of the byte array for this
        /// object.  Once the caller has set the length of the array, it
        /// is acceptable to directly modify the bytes in the array up until
        /// Tcl_GetStringFromObj() has been called on this object.
        ///
        /// Results:
        /// The new byte array of the specified length.
        ///
        /// Side effects:
        /// Allocates enough memory for an array of bytes of the requested
        /// size.  When growing the array, the old array is copied to the
        /// new array; new bytes are undefined.  When shrinking, the
        /// old array is truncated to the specified length.
        /// </summary>

        public static byte[] setLength(Interp interp, TclObject tobj, int length)
        {
            if (tobj.Shared)
            {
                throw new TclRuntimeError("TclByteArray.setLength() called with shared object");
            }
            setByteArrayFromAny(interp, tobj);
            TclByteArray tbyteArray = (TclByteArray)tobj.InternalRep;

            if (length > tbyteArray.bytes.Length)
            {
                byte[] newBytes = new byte[length];
                Array.Copy(tbyteArray.bytes, 0, newBytes, 0, tbyteArray.used);
                tbyteArray.bytes = newBytes;
            }
            tobj.invalidateStringRep();
            tbyteArray.used = length;
            return(tbyteArray.bytes);
        }
Esempio n. 14
0
        /// <summary> This procedure replaces zero or more elements of the list
        /// referenced by tobj with the objects from an TclObject array.
        /// If tobj is not a list object, an attempt will be made to
        /// convert it to a list.
        ///
        /// </summary>
        /// <param name="interp">current interpreter.
        /// </param>
        /// <param name="tobj">the TclObject to use as a list.
        /// </param>
        /// <param name="index">the starting index of the replace operation. <=0 means
        /// the beginning of the list. >= TclList.getLength(tobj) means
        /// the end of the list.
        /// </param>
        /// <param name="count">the number of elements to delete from the list. <=0 means
        /// no elements should be deleted and the operation is equivalent to
        /// an insertion operation.
        /// </param>
        /// <param name="elements">the element(s) to insert.
        /// </param>
        /// <param name="from">insert elements starting from elements[from] (inclusive)
        /// </param>
        /// <param name="to">insert elements up to elements[to] (inclusive)
        /// </param>
        /// <exception cref=""> TclException if tobj is not a valid list.
        /// </exception>
        public static void replace(Interp interp, TclObject tobj, int index, int count, TclObject[] elements, int from, int to)
        {
            if (tobj.Shared)
            {
                throw new TclRuntimeError("TclList.replace() called with shared object");
            }
            setListFromAny(interp, tobj);
            tobj.invalidateStringRep();
            TclList tlist = (TclList)tobj.InternalRep;

            int size = tlist.vector.Count;
            int i;

            if (index >= size)
            {
                // Append to the end of the list. There is no need for deleting
                // elements.
                index = size;
            }
            else
            {
                if (index < 0)
                {
                    index = 0;
                }
                if (count > size - index)
                {
                    count = size - index;
                }
                for (i = 0; i < count; i++)
                {
                    TclObject obj = (TclObject)tlist.vector[index];
                    obj.release();
                    tlist.vector.RemoveAt(index);
                }
            }
            for (i = from; i <= to; i++)
            {
                elements[i].preserve();
                tlist.vector.Insert(index++, elements[i]);
            }
        }
    /// <summary> Changes the long value of the object.
    /// 
    /// </summary>
    /// <param name="interp">current interpreter.
    /// </param>
    /// <param name="tobj">the object to operate on.
    /// @paran i the new long value.
    /// </param>
    public static void set( TclObject tobj, long i )
    {
      tobj.invalidateStringRep();
      InternalRep rep = tobj.InternalRep;
      TclLong tlong;

      if ( rep is TclLong )
      {
        tlong = (TclLong)rep;
        tlong.value = i;
      }
      else
      {
        tobj.InternalRep = new TclLong( i );
      }
    }
		/// <summary> 
		/// This method changes the length of the byte array for this
		/// object.  Once the caller has set the length of the array, it
		/// is acceptable to directly modify the bytes in the array up until
		/// Tcl_GetStringFromObj() has been called on this object.
		/// 
		/// Results:
		/// The new byte array of the specified length.
		/// 
		/// Side effects:
		/// Allocates enough memory for an array of bytes of the requested
		/// size.  When growing the array, the old array is copied to the
		/// new array; new bytes are undefined.  When shrinking, the
		/// old array is truncated to the specified length.
		/// </summary>
		
		public static byte[] setLength(Interp interp, TclObject tobj, int length)
		{
			if (tobj.Shared)
			{
				throw new TclRuntimeError("TclByteArray.setLength() called with shared object");
			}
			setByteArrayFromAny(interp, tobj);
			TclByteArray tbyteArray = (TclByteArray) tobj.InternalRep;
			
			if (length > tbyteArray.bytes.Length)
			{
				byte[] newBytes = new byte[length];
				Array.Copy(tbyteArray.bytes, 0, newBytes, 0, tbyteArray.used);
				tbyteArray.bytes = newBytes;
			}
			tobj.invalidateStringRep();
			tbyteArray.used = length;
			return tbyteArray.bytes;
		}
Esempio n. 17
0
    /// <summary> Sorts the list according to the sort mode and (optional) sort command.
    /// The resulting list will contain no duplicates, if argument unique is
    /// specifed as true.
    /// If tobj is not a list object, an attempt will be made to
    /// convert it to a list.
    /// 
    /// </summary>
    /// <param name="interp">the current interpreter.
    /// </param>
    /// <param name="tobj">the list to sort.
    /// </param>
    /// <param name="sortMode">the sorting mode.
    /// </param>
    /// <param name="sortIncreasing">true if to sort the elements in increasing order.
    /// </param>
    /// <param name="command">the command to compute the order of two elements.
    /// </param>
    /// <param name="unique">true if the result should contain no duplicates.
    /// </param>
    /// <exception cref=""> TclException if tobj is not a valid list.
    /// </exception>

    internal static void sort( Interp interp, TclObject tobj, int sortMode, int sortIndex, bool sortIncreasing, string command, bool unique )
    {
      setListFromAny( interp, tobj );
      tobj.invalidateStringRep();
      TclList tlist = (TclList)tobj.InternalRep;

      int size = tlist.vector.Count;

      if ( size <= 1 )
      {
        return;
      }

      TclObject[] objArray = new TclObject[size];
      for ( int i = 0 ; i < size ; i++ )
      {
        objArray[i] = (TclObject)tlist.vector[i];
      }

      QSort s = new QSort();
      int newsize = s.sort( interp, objArray, sortMode, sortIndex, sortIncreasing, command, unique );

      for ( int i = 0 ; i < size   ; i++ )
      {
        if ( i < newsize )
        {
          tlist.vector[i] = objArray[i];
          objArray[i] = null;
        }
        else tlist.vector.RemoveAt( newsize  );
      }
    }
Esempio n. 18
0
    /// <summary> This procedure replaces zero or more elements of the list
    /// referenced by tobj with the objects from an TclObject array.
    /// If tobj is not a list object, an attempt will be made to
    /// convert it to a list.
    /// 
    /// </summary>
    /// <param name="interp">current interpreter.
    /// </param>
    /// <param name="tobj">the TclObject to use as a list.
    /// </param>
    /// <param name="index">the starting index of the replace operation. <=0 means
    /// the beginning of the list. >= TclList.getLength(tobj) means
    /// the end of the list.
    /// </param>
    /// <param name="count">the number of elements to delete from the list. <=0 means
    /// no elements should be deleted and the operation is equivalent to
    /// an insertion operation.
    /// </param>
    /// <param name="elements">the element(s) to insert.
    /// </param>
    /// <param name="from">insert elements starting from elements[from] (inclusive)
    /// </param>
    /// <param name="to">insert elements up to elements[to] (inclusive)
    /// </param>
    /// <exception cref=""> TclException if tobj is not a valid list.
    /// </exception>
    public static void replace( Interp interp, TclObject tobj, int index, int count, TclObject[] elements, int from, int to )
    {
      if ( tobj.Shared )
      {
        throw new TclRuntimeError( "TclList.replace() called with shared object" );
      }
      setListFromAny( interp, tobj );
      tobj.invalidateStringRep();
      TclList tlist = (TclList)tobj.InternalRep;

      int size = tlist.vector.Count;
      int i;

      if ( index >= size )
      {
        // Append to the end of the list. There is no need for deleting
        // elements.
        index = size;
      }
      else
      {
        if ( index < 0 )
        {
          index = 0;
        }
        if ( count > size - index )
        {
          count = size - index;
        }
        for ( i = 0 ; i < count ; i++ )
        {
          TclObject obj = (TclObject)tlist.vector[index];
          obj.release();
          tlist.vector.RemoveAt( index );
        }
      }
      for ( i = from ; i <= to ; i++ )
      {
        elements[i].preserve();
        tlist.vector.Insert( index++, elements[i] );
      }
    }
Esempio n. 19
0
    /// <summary> Tcl_ListObjAppendElement -> TclList.append()
    /// 
    /// Appends a TclObject element to a list object.
    /// 
    /// </summary>
    /// <param name="interp">current interpreter.
    /// </param>
    /// <param name="tobj">the TclObject to append an element to.
    /// </param>
    /// <param name="elemObj">the element to append to the object.
    /// </param>
    /// <exception cref=""> TclException if tobj cannot be converted into a list.
    /// </exception>
    public static void append( Interp interp, TclObject tobj, TclObject elemObj )
    {
      if ( tobj.Shared )
      {
        throw new TclRuntimeError( "TclList.append() called with shared object" );
      }
      setListFromAny( interp, tobj );
      tobj.invalidateStringRep();

      TclList tlist = (TclList)tobj.InternalRep;

      if ( !String.IsNullOrEmpty( elemObj.stringRep ) && elemObj.stringRep[0] == '{' ) elemObj = TclString.newInstance( elemObj.stringRep.Substring( 1, elemObj.stringRep.Length - 2 ) );
      elemObj.preserve();
      tlist.vector.Add( elemObj );
    }
Esempio n. 20
0
		/// <summary> Appends an array of characters to a TclObject Object.
		/// Tcl_AppendUnicodeToObj() in Tcl 8.0.
		/// 
		/// </summary>
		/// <param name="tobj">the TclObject to append a string to.
		/// </param>
		/// <param name="charArr">array of characters.
		/// </param>
		/// <param name="offset">index of first character to append.
		/// </param>
		/// <param name="length">number of characters to append.
		/// </param>
		public static void  append(TclObject tobj, char[] charArr, int offset, int length)
		{
			StringFromAny = tobj;
			
			TclString tstr = (TclString) tobj.InternalRep;
			if (tstr.sbuf == null)
			{
				tstr.sbuf = new System.Text.StringBuilder(tobj.ToString());
			}
			tobj.invalidateStringRep();
			tstr.sbuf.Append(charArr, offset, length);
		}
Esempio n. 21
0
		/// <summary> Appends a string to a TclObject object. This method is equivalent to
		/// Tcl_AppendToObj() in Tcl 8.0.
		/// 
		/// </summary>
		/// <param name="tobj">the TclObject to append a string to.
		/// </param>
		/// <param name="string">the string to append to the object.
		/// </param>
		public static void  append(TclObject tobj, string toAppend)
		{
			StringFromAny = tobj;
			
			TclString tstr = (TclString) tobj.InternalRep;
			if (tstr.sbuf == null)
			{
				tstr.sbuf = new System.Text.StringBuilder(tobj.ToString());
			}
			tobj.invalidateStringRep();
      tstr.sbuf.Append( toAppend );
		}
Esempio n. 22
0
    /// <summary> Changes the integer value of the object.
    /// 
    /// </summary>
    /// <param name="interp">current interpreter.
    /// </param>
    /// <param name="tobj">the object to operate on.
    /// @paran i the new integer value.
    /// </param>
    public static void set( TclObject tobj, int i )
    {
      tobj.invalidateStringRep();
      InternalRep rep = tobj.InternalRep;
      TclInteger tint;

      if ( rep is TclInteger )
      {
        tint = (TclInteger)rep;
        tint.value = i;
      }
      else
      {
        tobj.InternalRep = new TclInteger( i );
      }
    }
    /// <summary> DoReadChars -> doReadChars
    /// 
    /// Reads from the channel until the requested number of characters
    /// have been seen, EOF is seen, or the channel would block.  EOL
    /// and EOF translation is done.  If reading binary data, the raw
    /// bytes are wrapped in a Tcl byte array object.  Otherwise, the raw
    /// bytes are converted to characters using the channel's current
    /// encoding and stored in a Tcl string object.
    /// 
    /// </summary>
    /// <param name="obj">Input data is stored in this object.
    /// </param>
    /// <param name="toRead">Maximum number of characters to store,
    /// or -1 to read all available data (up to EOF
    /// or when channel blocks).
    /// </param>

    internal int doReadChars( TclObject obj, int toRead )
    {
      ChannelBuffer buf;
      int copied, copiedNow, result;
      IntPtr offset = new IntPtr( this );

      if ( (System.Object)encoding == null )
      {
        TclByteArray.setLength( null, obj, 0 );
      }
      else
      {
        TclString.empty( obj );
      }
      offset.i = 0;

      // if toRead is negative, read until EOF
      if ( toRead < 0 )
      {
        toRead = System.Int32.MaxValue;
      }

      {
        for ( copied = 0; toRead > 0; )
        {
          copiedNow = -1;
          if ( inQueueHead != null )
          {
            if ( (System.Object)encoding == null )
            {
              System.Diagnostics.Debug.WriteLine( "calling readBytes " + toRead );
              copiedNow = readBytes( obj, toRead, offset );
            }
            else
            {
              System.Diagnostics.Debug.WriteLine( "calling readChars " + toRead );
              copiedNow = readChars( obj, toRead );
            }

            // If the current buffer is empty recycle it.

            buf = inQueueHead;
            System.Diagnostics.Debug.WriteLine( "after read* buf.nextRemoved is " + buf.nextRemoved );
            System.Diagnostics.Debug.WriteLine( "after read* buf.nextAdded is " + buf.nextAdded );

            if ( buf.nextRemoved == buf.nextAdded )
            {
              System.Diagnostics.Debug.WriteLine( "recycling empty buffer" );
              ChannelBuffer next;

              next = buf.next;
              recycleBuffer( buf, false );
              inQueueHead = next;
              if ( next == null )
              {
                System.Diagnostics.Debug.WriteLine( "inQueueTail set to null" );
                inQueueTail = null;
              }
              else
              {
                System.Diagnostics.Debug.WriteLine( "inQueueTail is not null" );
              }
            }
          }
          if ( copiedNow < 0 )
          {
            System.Diagnostics.Debug.WriteLine( "copiedNow < 0" );
            if ( eofCond )
            {
              System.Diagnostics.Debug.WriteLine( "eofCond" );
              break;
            }
            if ( blocked )
            {
              System.Diagnostics.Debug.WriteLine( "blocked" );
              if ( !blocking )
              {
                break;
              }
              blocked = false;
            }
            result = Input;
            if ( result != 0 )
            {
              System.Diagnostics.Debug.WriteLine( "non-zero result" );
              if ( result == TclPosixException.EAGAIN )
              {
                break;
              }
              copied = -1;
              goto done_brk; //goto done
            }
          }
          else
          {
            copied += copiedNow;
            System.Diagnostics.Debug.WriteLine( "copied incremented to " + copied );
            toRead -= copiedNow;
            System.Diagnostics.Debug.WriteLine( "toRead decremented to " + toRead );
          }
        }

        blocked = false;

        if ( (System.Object)encoding == null )
        {
          TclByteArray.setLength( null, obj, offset.i );
          System.Diagnostics.Debug.WriteLine( "set byte array length to " + offset.i );
        }
      }

done_brk:
      ;
      // end done: block

      //done:
      updateInterest();

#if DEBUG
				System.Diagnostics.Debug.WriteLine("returning copied = " + copied);
				
				System.Diagnostics.Debug.WriteLine("returning string \"" + obj + "\"");
				obj.invalidateStringRep();
				
				System.Diagnostics.Debug.WriteLine("returning string \"" + obj + "\"");
#endif

      return copied;
    }
    /// <summary> Tcl_ListObjAppendElement -> TclList.append()
    /// 
    /// Appends a TclObject element to a list object.
    /// 
    /// </summary>
    /// <param name="interp">current interpreter.
    /// </param>
    /// <param name="tobj">the TclObject to append an element to.
    /// </param>
    /// <param name="elemObj">the element to append to the object.
    /// </param>
    /// <exception cref=""> TclException if tobj cannot be converted into a list.
    /// </exception>
    public static void append( Interp interp, TclObject tobj, TclObject elemObj )
    {
      if ( tobj.Shared )
      {
        throw new TclRuntimeError( "TclList.append() called with shared object" );
      }
      setListFromAny( interp, tobj );
      tobj.invalidateStringRep();

      TclList tlist = (TclList)tobj.InternalRep;
      elemObj.preserve();
      tlist.vector.Add( elemObj );
    }
Esempio n. 25
0
		/// <summary> This procedure clears out an existing TclObject so
		/// that it has a string representation of "".
		/// </summary>
		
		public static void  empty(TclObject tobj)
		{
			StringFromAny = tobj;
			
			TclString tstr = (TclString) tobj.InternalRep;
			if (tstr.sbuf == null)
			{
				tstr.sbuf = new System.Text.StringBuilder();
			}
			else
			{
				tstr.sbuf.Length = 0;
			}
			tobj.invalidateStringRep();
		}