本文整理汇总了C#中tcl.lang.TclObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TclObject.ToString方法的具体用法?C# TclObject.ToString怎么用?C# TclObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcl.lang.TclObject
的用法示例。
在下文中一共展示了TclObject.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Tcl_GetIndexFromObjStruct
static int Tcl_GetIndexFromObjStruct( Interp interp, TclObject to, BackupSubCommand[] table, int len, string msg, int flags, ref int index )
{
string zCmd = to.ToString();
for ( index = 0 ; index < len ; index++ )
{
if ( zCmd == table[index].zCmd ) return 0;
}
return 1;
}
示例2: compile
public static Regexp compile(Interp interp, TclObject exp, bool nocase)
{
try
{
return new Regexp(exp.ToString(), nocase);
}
catch (System.ArgumentException e)
{
string msg = e.Message;
if (msg.Equals("missing )"))
{
msg = "unmatched ()";
}
else if (msg.Equals("missing ]"))
{
msg = "unmatched []";
}
msg = "couldn't compile regular expression pattern: " + msg;
throw new TclException(interp, msg);
}
}
示例3: setNsNameFromAny
/*
*----------------------------------------------------------------------
*
* SetNsNameFromAny -> setNsNameFromAny
*
* Attempt to generate a nsName internal representation for a
* TclObject.
*
* Results:
* Returns if the value could be converted to a proper
* namespace reference. Otherwise, raises TclException.
*
* Side effects:
* If successful, the object is made a nsName object. Its internal rep
* is set to point to a ResolvedNsName, which contains a cached pointer
* to the Namespace. Reference counts are kept on both the
* ResolvedNsName and the Namespace, so we can keep track of their
* usage and free them when appropriate.
*
*----------------------------------------------------------------------
*/
private static void setNsNameFromAny(Interp interp, TclObject tobj)
{
string name;
Namespace ns;
ResolvedNsName resName;
// Java does not support passing an address so we pass
// an array of size 1 and then assign arr[0] to the value
Namespace[] nsArr = new Namespace[1];
Namespace[] dummy1Arr = new Namespace[1];
string[] dummy2Arr = new string[1];
// Get the string representation.
name = tobj.ToString();
// Look for the namespace "name" in the current namespace. If there is
// an error parsing the (possibly qualified) name, return an error.
// If the namespace isn't found, we convert the object to an nsName
// object with a null ResolvedNsName internal rep.
getNamespaceForQualName(interp, name, null, TCL.VarFlag.FIND_ONLY_NS, nsArr, dummy1Arr, dummy1Arr, dummy2Arr);
// Get the values out of the arrays!
ns = nsArr[0];
// If we found a namespace, then create a new ResolvedNsName structure
// that holds a reference to it.
if (ns != null)
{
Namespace currNs = getCurrentNamespace(interp);
ns.refCount++;
resName = new ResolvedNsName();
resName.ns = ns;
resName.nsId = ns.nsId;
resName.refNs = currNs;
resName.refCount = 1;
}
else
{
resName = null;
}
// By setting the new internal rep we free up the old one.
// FIXME : should a NamespaceCmd wrap a ResolvedNsName?
// this is confusing because it seems like the C code uses
// a ResolvedNsName like it is the InternalRep.
NamespaceCmd wrap = new NamespaceCmd();
wrap.otherValue = resName;
tobj.InternalRep = wrap;
return ;
}
示例4: setBooleanFromAny
/// <summary> Called to convert the other object's internal rep to boolean.
///
/// </summary>
/// <param name="interp">current interpreter.
/// </param>
/// <param name="tobj">the TclObject to convert to use the
/// representation provided by this class.
/// </param>
private static void setBooleanFromAny( Interp interp, TclObject tobj )
{
InternalRep rep = tobj.InternalRep;
if ( rep is TclBoolean )
{
/*
* Do nothing.
*/
}
else if ( rep is TclInteger )
{
int i = TclInteger.get( interp, tobj );
tobj.InternalRep = new TclBoolean( i != 0 );
}
else
{
/*
* (ToDo) other short-cuts
*/
tobj.InternalRep = new TclBoolean( interp, tobj.ToString() );
}
}
示例5: objCommandComplete
internal static bool objCommandComplete( TclObject obj )
// Points to object holding script
// to check.
{
string inString = obj.ToString();
return commandComplete( inString, inString.Length );
}
示例6: delete
internal static void delete( Interp interp, Interp slaveInterp, TclObject name )
{
// If the alias has been renamed in the slave, the master can still use
// the original name (with which it was created) to find the alias to
// delete it.
string inString = name.ToString();
if ( !slaveInterp.aliasTable.ContainsKey( inString ) )
{
throw new TclException( interp, "alias \"" + inString + "\" not found" );
}
InterpAliasCmd alias = (InterpAliasCmd)slaveInterp.aliasTable[inString];
slaveInterp.deleteCommandFromToken( alias.slaveCmd );
}
示例7: get
/// <summary> Tcl_GetIndexFromObj -> get
///
/// Gets the index into the table of the object. Generate an error
/// it it doesn't occur. This also converts the object to an index
/// which should catch the lookup for speed improvement.
///
/// </summary>
/// <param name="interp">the interperter or null
/// </param>
/// <param name="tobj">the object to operate on.
/// @paran table the list of commands
/// @paran msg used as part of any error messages
/// @paran flags may be TCL.EXACT.
/// </param>
public static int get( Interp interp, TclObject tobj, string[] table, string msg, int flags )
{
InternalRep rep = tobj.InternalRep;
if ( rep is TclIndex )
{
if ( ( (TclIndex)rep ).table == table )
{
return ( (TclIndex)rep ).index;
}
}
string str = tobj.ToString();
int strLen = str.Length;
int tableLen = table.Length;
int index = -1;
int numAbbrev = 0;
{
if ( strLen > 0 )
{
for ( int i = 0; i < tableLen; i++ )
{
string option = table[i];
if ( ( ( flags & TCL.EXACT ) == TCL.EXACT ) && ( option.Length != strLen ) )
{
continue;
}
if ( option.Equals( str ) )
{
// Found an exact match already. Return it.
index = i;
goto checking_brk;
}
if ( option.StartsWith( str ) )
{
numAbbrev++;
index = i;
}
}
}
if ( numAbbrev != 1 )
{
StringBuilder sbuf = new StringBuilder();
if ( numAbbrev > 1 )
{
sbuf.Append( "ambiguous " );
}
else
{
sbuf.Append( "bad " );
}
sbuf.Append( msg );
sbuf.Append( " \"" );
sbuf.Append( str );
sbuf.Append( "\"" );
sbuf.Append( ": must be " );
sbuf.Append( table[0] );
for ( int i = 1; i < tableLen; i++ )
{
if ( i == ( tableLen - 1 ) )
{
sbuf.Append( ( i > 1 ) ? ", or " : " or " );
}
else
{
sbuf.Append( ", " );
}
sbuf.Append( table[i] );
}
throw new TclException( interp, sbuf.ToString() );
}
}
checking_brk:
;
// Create a new index object.
tobj.InternalRep = new TclIndex( index, table );
return index;
}
示例8: setDoubleFromAny
private static void setDoubleFromAny(Interp interp, TclObject tobj)
{
InternalRep rep = tobj.InternalRep;
if (rep is TclDouble)
{
/*
* Do nothing.
*/
}
else if (rep is TclBoolean)
{
/*
* Short-cut.
*/
bool b = TclBoolean.get(interp, tobj);
if (b)
{
tobj.InternalRep = new TclDouble(1.0);
}
else
{
tobj.InternalRep = new TclDouble(0.0);
}
}
else if (rep is TclInteger)
{
/*
* Short-cut.
*/
int i = TclInteger.get(interp, tobj);
tobj.InternalRep = new TclDouble(i);
}
else
{
tobj.InternalRep = new TclDouble(interp, tobj.ToString());
}
}
示例9: Procedure
internal Procedure( Interp interp, NamespaceCmd.Namespace ns, string name, TclObject args, TclObject b, string sFileName, int sLineNumber )
{
this.ns = ns;
srcFileName = sFileName;
srcLineNumber = sLineNumber;
// Break up the argument list into argument specifiers, then process
// each argument specifier.
int numArgs = TclList.getLength( interp, args );
argList = new TclObject[numArgs][];
for ( int i = 0; i < numArgs; i++ )
{
argList[i] = new TclObject[2];
}
for ( int i = 0; i < numArgs; i++ )
{
// Now divide the specifier up into name and default.
TclObject argSpec = TclList.index( interp, args, i );
int specLen = TclList.getLength( interp, argSpec );
if ( specLen == 0 )
{
throw new TclException( interp, "procedure \"" + name + "\" has argument with no name" );
}
if ( specLen > 2 )
{
throw new TclException( interp, "too many fields in argument " + "specifier \"" + argSpec + "\"" );
}
argList[i][0] = TclList.index( interp, argSpec, 0 );
argList[i][0].preserve();
if ( specLen == 2 )
{
argList[i][1] = TclList.index( interp, argSpec, 1 );
argList[i][1].preserve();
}
else
{
argList[i][1] = null;
}
}
if ( numArgs > 0 && ( argList[numArgs - 1][0].ToString().Equals( "args" ) ) )
{
isVarArgs = true;
}
else
{
isVarArgs = false;
}
body = new CharPointer( b.ToString() );
body_length = body.length();
}
示例10: compare
/// <summary> Compares the order of two items in the array.
///
/// </summary>
/// <param name="obj1">first item.
/// </param>
/// <param name="obj2">second item.
/// </param>
/// <returns> 0 if they are equal, 1 if obj1 > obj2, -1 otherwise.
///
/// </returns>
/// <exception cref=""> TclException if an error occurs during sorting.
/// </exception>
private int compare( TclObject obj1, TclObject obj2 )
{
int index;
int code = 0;
if ( sortIndex != -1 )
{
// The "-index" option was specified. Treat each object as a
// list, extract the requested element from each list, and
// compare the elements, not the lists. The special index "end"
// is signaled here with a negative index (other than -1).
TclObject obj;
if ( sortIndex < -1 )
{
index = TclList.getLength( sortInterp, obj1 ) - 1;
}
else
{
index = sortIndex;
}
obj = TclList.index( sortInterp, obj1, index );
if ( obj == null )
{
throw new TclException( sortInterp, "element " + index + " missing from sublist \"" + obj1 + "\"" );
}
obj1 = obj;
if ( sortIndex < -1 )
{
index = TclList.getLength( sortInterp, obj2 ) - 1;
}
else
{
index = sortIndex;
}
obj = TclList.index( sortInterp, obj2, index );
if ( obj == null )
{
throw new TclException( sortInterp, "element " + index + " missing from sublist \"" + obj2 + "\"" );
}
obj2 = obj;
}
switch ( sortMode )
{
case ASCII:
// ATK C# CompareTo use option
// similar to -dictionary but a > A
code = System.Globalization.CultureInfo.InvariantCulture.CompareInfo.Compare( obj1.ToString(), obj2.ToString(), System.Globalization.CompareOptions.Ordinal );
// code = obj1.ToString().CompareTo(obj2.ToString());
break;
case DICTIONARY:
code = doDictionary( obj1.ToString(), obj2.ToString() );
break;
case INTEGER:
try
{
int int1 = TclInteger.get( sortInterp, obj1 );
int int2 = TclInteger.get( sortInterp, obj2 );
if ( int1 > int2 )
{
code = 1;
}
else if ( int2 > int1 )
{
code = -1;
}
}
catch ( TclException e1 )
{
sortInterp.addErrorInfo( "\n (converting list element from string to integer)" );
throw e1;
}
break;
case REAL:
try
//.........这里部分代码省略.........
示例11: writeObj
/// <summary> Tcl_WriteObj -> writeObj
///
/// Takes the Tcl object and queues its contents for output. If the
/// encoding of the channel is NULL, takes the byte-array representation
/// of the object and queues those bytes for output. Otherwise, takes
/// the characters in the UTF-8 (string) representation of the object
/// and converts them for output using the channel's current encoding.
/// May flush internal buffers to output if one becomes full or is ready
/// for some other reason, e.g. if it contains a newline and the channel
/// is in line buffering mode.
///
/// The number of bytes written or -1 in case of error. If -1,
/// Tcl_GetErrno will return the error code.
///
/// May buffer up output and may cause output to be produced on the
/// channel.
///
/// </summary>
/// <param name="obj"> The object to write.
/// </param>
internal int writeObj( TclObject obj )
{
// Always use the topmost channel of the stack
//char *src;
int srcLen;
//statePtr = ((Channel *) chan)->state;
//chanPtr = statePtr->topChanPtr;
//if (CheckChannelErrors(statePtr, TCL_WRITABLE) != 0) {
// return -1;
//}
if ( (System.Object)encoding == null )
{
srcLen = TclByteArray.getLength( null, obj );
byte[] bytes = TclByteArray.getBytes( null, obj );
return writeBytes( bytes, 0, srcLen );
}
else
{
char[] chars = obj.ToString().ToCharArray();
return writeChars( chars, 0, chars.Length );
}
}
示例12: eval
public void eval( TclObject tobj, int flags )
{
eval( tobj.ToString(), flags );
}
示例13: append
/// <summary> Appends a TclObject to a TclObject. This method is equivalent to
/// Tcl_AppendToObj() in Tcl 8.0.
///
/// The type of the TclObject will be a TclString that contains the
/// string value:
/// tobj.toString() + tobj2.toString();
/// </summary>
internal static void append(TclObject tobj, TclObject tobj2)
{
append(tobj, tobj2.ToString());
}
示例14: getInterp
internal static Interp getInterp(Interp interp, TclObject path)
{
TclObject[] objv = TclList.getElements(interp, path);
Interp searchInterp = interp; //Interim storage for interp. to find.
for (int i = 0; i < objv.Length; i++)
{
string name = objv[i].ToString();
if (!searchInterp.slaveTable.ContainsKey(name))
{
searchInterp = null;
break;
}
InterpSlaveCmd slave = (InterpSlaveCmd) searchInterp.slaveTable[name];
searchInterp = slave.slaveInterp;
if (searchInterp == null)
{
break;
}
}
if (searchInterp == null)
{
throw new TclException(interp, "could not find interpreter \"" + path.ToString() + "\"");
}
return searchInterp;
}
示例15: setListFromAny
/// <summary> Called to convert the other object's internal rep to list.
///
/// </summary>
/// <param name="interp">current interpreter.
/// </param>
/// <param name="tobj">the TclObject to convert to use the List internal rep.
/// </param>
/// <exception cref=""> TclException if the object doesn't contain a valid list.
/// </exception>
internal static void setListFromAny( Interp interp, TclObject tobj )
{
InternalRep rep = tobj.InternalRep;
if ( !( rep is TclList ) )
{
TclList tlist = new TclList();
splitList( interp, tlist.vector, tobj.ToString() );
tobj.InternalRep = tlist;
}
}