本文整理汇总了C#中tcl.lang.Interp.traceVar方法的典型用法代码示例。如果您正苦于以下问题:C# Interp.traceVar方法的具体用法?C# Interp.traceVar怎么用?C# Interp.traceVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcl.lang.Interp
的用法示例。
在下文中一共展示了Interp.traceVar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: traceProc
public void traceProc( Interp interp, string name1, string name2, TCL.VarFlag flags )
{
// If the variable is unset, then recreate the trace and restore
// the default value of the format string.
if ( ( flags & TCL.VarFlag.TRACE_UNSETS ) != 0 )
{
if ( ( ( flags & TCL.VarFlag.TRACE_DESTROYED ) != 0 ) && ( ( flags & TCL.VarFlag.INTERP_DESTROYED ) == 0 ) )
{
interp.traceVar( name1, name2, new PrecTraceProc(), TCL.VarFlag.GLOBAL_ONLY | TCL.VarFlag.TRACE_WRITES | TCL.VarFlag.TRACE_READS | TCL.VarFlag.TRACE_UNSETS );
Util.precision = Util.DEFAULT_PRECISION;
}
return;
}
// When the variable is read, reset its value from our shared
// value. This is needed in case the variable was modified in
// some other interpreter so that this interpreter's value is
// out of date.
if ( ( flags & TCL.VarFlag.TRACE_READS ) != 0 )
{
interp.setVar( name1, name2, TclInteger.newInstance( Util.precision ), flags & TCL.VarFlag.GLOBAL_ONLY );
return;
}
// The variable is being written. Check the new value and disallow
// it if it isn't reasonable.
//
// (ToDo) Disallow it if this is a safe interpreter (we don't want
// safe interpreters messing up the precision of other
// interpreters).
TclObject tobj = null;
try
{
tobj = interp.getVar( name1, name2, ( flags & TCL.VarFlag.GLOBAL_ONLY ) );
}
catch ( TclException e )
{
// Do nothing when var does not exist.
}
string value;
if ( tobj != null )
{
value = tobj.ToString();
}
else
{
value = "";
}
StrtoulResult r = Util.strtoul( value, 0, 10 );
if ( ( r == null ) || ( r.value <= 0 ) || ( r.value > TCL_MAX_PREC ) || ( r.value > 100 ) || ( r.index == 0 ) || ( r.index != value.Length ) )
{
interp.setVar( name1, name2, TclInteger.newInstance( Util.precision ), TCL.VarFlag.GLOBAL_ONLY );
throw new TclException( interp, "improper value for precision" );
}
Util.precision = (int)r.value;
}
示例2: setupPrecisionTrace
internal static void setupPrecisionTrace( Interp interp )
// Current interpreter.
{
try
{
interp.traceVar( "tcl_precision", new PrecTraceProc(), TCL.VarFlag.GLOBAL_ONLY | TCL.VarFlag.TRACE_WRITES | TCL.VarFlag.TRACE_READS | TCL.VarFlag.TRACE_UNSETS );
}
catch ( TclException e )
{
throw new TclRuntimeError( "unexpected TclException: " + e.Message, e );
}
}