本文整理汇总了C#中tcl.lang.Interp.setResult方法的典型用法代码示例。如果您正苦于以下问题:C# Interp.setResult方法的具体用法?C# Interp.setResult怎么用?C# Interp.setResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcl.lang.Interp
的用法示例。
在下文中一共展示了Interp.setResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdProc
/// <summary> See Tcl user documentation for details.</summary>
public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
{
if ((argv.Length < 2) || (argv.Length > 3))
{
throw new TclNumArgsException(interp, 1, argv, "script ?count?");
}
int count;
if (argv.Length == 2)
{
count = 1;
}
else
{
count = TclInteger.get(interp, argv[2]);
}
long startTime = System.DateTime.Now.Ticks;
for (int i = 0; i < count; i++)
{
interp.eval(argv[1], 0);
}
long endTime = System.DateTime.Now.Ticks;
long uSecs = (((endTime - startTime) / 10) / count);
if (uSecs == 1)
{
interp.setResult(TclString.newInstance("1 microsecond per iteration"));
}
else
{
interp.setResult(TclString.newInstance(uSecs + " microseconds per iteration"));
}
return TCL.CompletionCode.RETURN;
}
示例2: cmdProc
/// <summary> Evaluates a Tcl expression. See Tcl user documentation for
/// details.
/// </summary>
/// <exception cref=""> TclException If malformed expression.
/// </exception>
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
{
if ( argv.Length < 2 )
{
throw new TclNumArgsException( interp, 1, argv, "arg ?arg ...?" );
}
if ( argv.Length == 2 )
{
interp.setResult( interp.expr.eval( interp, argv[1].ToString() ) );
}
else
{
StringBuilder sbuf = new StringBuilder();
sbuf.Append( argv[1].ToString() );
for ( int i = 2; i < argv.Length; i++ )
{
sbuf.Append( ' ' );
sbuf.Append( argv[i].ToString() );
}
interp.setResult( interp.expr.eval( interp, sbuf.ToString() ) );
}
return TCL.CompletionCode.RETURN;
}
示例3: cmdProc
/// <summary> This procedure is invoked to process the "eof" Tcl command.
/// See the user documentation for details on what it does.
///
/// </summary>
/// <param name="interp">the current interpreter.
/// </param>
/// <param name="argv">command arguments.
/// </param>
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
{
Channel chan; /* The channel being operated on this method */
if ( argv.Length != 2 )
{
throw new TclNumArgsException( interp, 1, argv, "channelId" );
}
chan = TclIO.getChannel( interp, argv[1].ToString() );
if ( chan == null )
{
throw new TclException( interp, "can not find channel named \"" + argv[1].ToString() + "\"" );
}
if ( chan.eof() )
{
interp.setResult( TclInteger.newInstance( 1 ) );
}
else
{
interp.setResult( TclInteger.newInstance( 0 ) );
}
return TCL.CompletionCode.RETURN;
}
示例4: cmdProc
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] objv )
{
TclObject varValue = null;
if ( objv.Length < 2 )
{
throw new TclNumArgsException( interp, 1, objv, "varName ?value value ...?" );
}
else if ( objv.Length == 2 )
{
interp.resetResult();
interp.setResult( interp.getVar( objv[1], 0 ) );
}
else
{
for ( int i = 2; i < objv.Length; i++ )
{
varValue = interp.setVar( objv[1], objv[i], TCL.VarFlag.APPEND_VALUE );
}
if ( varValue != null )
{
interp.resetResult();
interp.setResult( varValue );
}
else
{
interp.resetResult();
}
}
return TCL.CompletionCode.RETURN;
}
示例5: cmdProc
/// <summary> This procedure is invoked to process the "gets" Tcl command.
/// See the user documentation for details on what it does.
///
/// </summary>
/// <param name="interp">the current interpreter.
/// </param>
/// <param name="argv">command arguments.
/// </param>
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
{
bool writeToVar = false; // If true write to var passes as arg
string varName = ""; // The variable to write value to
Channel chan; // The channel being operated on
int lineLen;
TclObject line;
if ( ( argv.Length < 2 ) || ( argv.Length > 3 ) )
{
throw new TclNumArgsException( interp, 1, argv, "channelId ?varName?" );
}
if ( argv.Length == 3 )
{
writeToVar = true;
varName = argv[2].ToString();
}
chan = TclIO.getChannel( interp, argv[1].ToString() );
if ( chan == null )
{
throw new TclException( interp, "can not find channel named \"" + argv[1].ToString() + "\"" );
}
try
{
line = TclString.newInstance( new StringBuilder( 64 ) );
lineLen = chan.read( interp, line, TclIO.READ_LINE, 0 );
if ( lineLen < 0 )
{
// FIXME: Need more specific posix error codes!
if ( !chan.eof() && !chan.isBlocked( interp ) )
{
throw new TclPosixException( interp, TclPosixException.EIO, true, "error reading \"" + argv[1].ToString() + "\"" );
}
lineLen = -1;
}
if ( writeToVar )
{
interp.setVar( varName, line, 0 );
interp.setResult( lineLen );
}
else
{
interp.setResult( line );
}
}
catch ( IOException e )
{
throw new TclRuntimeError( "GetsCmd.cmdProc() Error: IOException when getting " + chan.ChanName + ": " + e.Message );
}
return TCL.CompletionCode.RETURN;
}
示例6: TclVarException
/// <summary> Creates an exception with the appropiate Tcl error message to
/// indicate an error with variable access.
///
/// </summary>
/// <param name="interp">currrent interpreter.
/// </param>
/// <param name="name1">first part of a variable name.
/// </param>
/// <param name="name2">second part of a variable name. May be null.
/// </param>
/// <param name="operation">either "read" or "set".
/// </param>
/// <param name="reason">a string message to explain why the operation fails..
/// </param>
internal TclVarException(Interp interp, string name1, string name2, string operation, string reason):base(TCL.CompletionCode.ERROR)
{
if (interp != null)
{
interp.resetResult();
if ((System.Object) name2 == null)
{
interp.setResult("can't " + operation + " \"" + name1 + "\": " + reason);
}
else
{
interp.setResult("can't " + operation + " \"" + name1 + "(" + name2 + ")\": " + reason);
}
}
}
示例7: TclNumArgsException
/// <summary> Creates a TclException with the appropiate Tcl error
/// message for having the wring number of arguments to a Tcl command.
/// <p>
/// Example: <pre>
///
/// if (argv.length != 3) {
/// throw new TclNumArgsException(interp, 1, argv, "option name");
/// }
/// </pre>
///
/// </summary>
/// <param name="interp">current Interpreter.
/// </param>
/// <param name="argc">the number of arguments to copy from the offending
/// command to put into the error message.
/// </param>
/// <param name="argv">the arguments of the offending command.
/// </param>
/// <param name="message">extra message to appear in the error message that
/// explains the proper usage of the command.
/// </param>
/// <exception cref=""> TclException is always thrown.
/// </exception>
public TclNumArgsException( Interp interp, int argc, TclObject[] argv, string message )
: base(TCL.CompletionCode.ERROR)
{
if ( interp != null )
{
StringBuilder buff = new StringBuilder( 50 );
buff.Append( "wrong # args: should be \"" );
for ( int i = 0; i < argc; i++ )
{
if ( argv[i].InternalRep is TclIndex )
{
buff.Append( argv[i].InternalRep.ToString() );
}
else
{
buff.Append( argv[i].ToString() );
}
if ( i < ( argc - 1 ) )
{
buff.Append( " " );
}
}
if ( ( message != null ) )
{
buff.Append( " " + message );
}
buff.Append( "\"" );
interp.setResult( buff.ToString() );
}
}
示例8: cmdProc
/// <summary> This procedure is invoked to process the "tell" Tcl command.
/// See the user documentation for details on what it does.
///
/// </summary>
/// <param name="interp">the current interpreter.
/// </param>
/// <param name="argv">command arguments.
/// </param>
public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
{
Channel chan; /* The channel being operated on this method */
if (argv.Length != 2)
{
throw new TclNumArgsException(interp, 1, argv, "channelId");
}
chan = TclIO.getChannel(interp, argv[1].ToString());
if (chan == null)
{
throw new TclException(interp, "can not find channel named \"" + argv[1].ToString() + "\"");
}
try
{
interp.setResult(TclInteger.newInstance((int) chan.tell()));
}
catch (System.IO.IOException e)
{
throw new TclException(interp, "Error in TellCmd");
}
return TCL.CompletionCode.RETURN;
}
示例9: cmdProc
public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
{
if (argv.Length < 2 || argv.Length > 4)
{
throw new TclNumArgsException(interp, 1, argv, "message ?errorInfo? ?errorCode?");
}
if (argv.Length >= 3)
{
string errorInfo = argv[2].ToString();
if (!errorInfo.Equals(""))
{
interp.addErrorInfo(errorInfo);
interp.errAlreadyLogged = true;
}
}
if (argv.Length == 4)
{
interp.setErrorCode(argv[3]);
}
interp.setResult(argv[1]);
throw new TclException(TCL.CompletionCode.ERROR);
}
示例10: cmdProc
/// <summary> See Tcl user documentation for details.</summary>
/// <exception cref=""> TclException If incorrect number of arguments.
/// </exception>
public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
{
if (argv.Length != 2)
{
throw new TclNumArgsException(interp, 1, argv, "list");
}
interp.setResult(TclInteger.newInstance(TclList.getLength(interp, argv[1])));
return TCL.CompletionCode.RETURN;
}
示例11: cmdProc
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
{
bool debug;
if ( argv.Length == 2 )
{
System.Diagnostics.Debug.WriteLine( "getting value of \"" + argv[1].ToString() + "\"" );
interp.setResult( interp.getVar( argv[1], 0 ) );
}
else if ( argv.Length == 3 )
{
System.Diagnostics.Debug.WriteLine( "setting value of \"" + argv[1].ToString() + "\" to \"" + argv[2].ToString() + "\"" );
interp.setResult( interp.setVar( argv[1], argv[2], 0 ) );
}
else
{
throw new TclNumArgsException( interp, 1, argv, "varName ?newValue?" );
}
return TCL.CompletionCode.RETURN;
}
示例12: TclException
protected internal TclException(Interp interp, string msg, TCL.CompletionCode ccode, int idx):base(msg)
{
if (ccode == TCL.CompletionCode.OK)
{
throw new TclRuntimeError("The reserved completion code TCL.CompletionCode.OK (0) cannot be used " + "in TclException");
}
compCode = ccode;
errIndex = idx;
if (interp != null && (System.Object) msg != null)
{
interp.setResult(msg);
}
}
示例13: cmdProc
/// <summary> This procedure is invoked to process the "incr" Tcl command.
/// See the user documentation for details on what it does.
/// </summary>
/// <exception cref=""> TclException if wrong # of args or increment is not an
/// integer.
/// </exception>
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] objv )
{
int incrAmount;
TclObject newValue;
if ( ( objv.Length != 2 ) && ( objv.Length != 3 ) )
{
throw new TclNumArgsException( interp, 1, objv, "varName ?increment?" );
}
// Calculate the amount to increment by.
if ( objv.Length == 2 )
{
incrAmount = 1;
}
else
{
try
{
incrAmount = TclInteger.get( interp, objv[2] );
}
catch ( TclException e )
{
interp.addErrorInfo( "\n (reading increment)" );
throw;
}
}
// Increment the variable's value.
newValue = Var.incrVar( interp, objv[1], null, incrAmount, TCL.VarFlag.LEAVE_ERR_MSG );
// FIXME: we need to look at this exception throwing problem again
/*
if (newValue == null) {
return TCL_ERROR;
}
*/
// Set the interpreter's object result to refer to the variable's new
// value object.
interp.setResult( newValue );
return TCL.CompletionCode.RETURN;
}
示例14: cmdProc
/// <summary> See Tcl user documentation for details.</summary>
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
{
TclObject list = TclList.newInstance();
list.preserve();
try
{
for ( int i = 1; i < argv.Length; i++ )
TclList.append( interp, list, argv[i] );
interp.setResult( list );
}
finally
{
list.release();
}
return TCL.CompletionCode.RETURN;
}
示例15: cmdProc
/// <summary> See Tcl user documentation for details.</summary>
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
{
string sep = null;
if ( argv.Length == 2 )
{
sep = null;
}
else if ( argv.Length == 3 )
{
sep = argv[2].ToString();
}
else
{
throw new TclNumArgsException( interp, 1, argv, "list ?joinString?" );
}
TclObject list = argv[1];
int size = TclList.getLength( interp, list );
if ( size == 0 )
{
interp.resetResult();
return TCL.CompletionCode.RETURN;
}
StringBuilder sbuf = new StringBuilder( TclList.index( interp, list, 0 ).ToString() );
for ( int i = 1; i < size; i++ )
{
if ( (System.Object)sep == null )
{
sbuf.Append( ' ' );
}
else
{
sbuf.Append( sep );
}
sbuf.Append( TclList.index( interp, list, i ).ToString() );
}
interp.setResult( sbuf.ToString() );
return TCL.CompletionCode.RETURN;
}