本文整理汇总了C#中tcl.lang.Interp.setAssocData方法的典型用法代码示例。如果您正苦于以下问题:C# Interp.setAssocData方法的具体用法?C# Interp.setAssocData怎么用?C# Interp.setAssocData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcl.lang.Interp
的用法示例。
在下文中一共展示了Interp.setAssocData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdProc
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
{
int i;
Notifier notifier = (Notifier)interp.getNotifier();
Object info;
if ( assocData == null )
{
/*
* Create the "after" information associated for this
* interpreter, if it doesn't already exist.
*/
assocData = (AfterAssocData)interp.getAssocData( "tclAfter" );
if ( assocData == null )
{
assocData = new AfterAssocData( this );
interp.setAssocData( "tclAfter", assocData );
}
}
if ( argv.Length < 2 )
{
throw new TclNumArgsException( interp, 1, argv, "option ?arg arg ...?" );
}
/*
* First lets see if the command was passed a number as the first argument.
*/
bool isNumber = false;
int ms = 0;
if ( argv[1].InternalRep is TclInteger )
{
ms = TclInteger.get( interp, argv[1] );
isNumber = true;
}
else
{
string s = argv[1].ToString();
if ( ( s.Length > 0 ) && ( System.Char.IsDigit( s[0] ) ) )
{
ms = TclInteger.get( interp, argv[1] );
isNumber = true;
}
}
if ( isNumber )
{
if ( ms < 0 )
{
ms = 0;
}
if ( argv.Length == 2 )
{
/*
* Sleep for at least the given milliseconds and return.
*/
long endTime = System.DateTime.Now.Ticks / 10000 + ms;
while ( true )
{
try
{
System.Threading.Thread.Sleep( ms );
return TCL.CompletionCode.RETURN;
}
catch ( System.Threading.ThreadInterruptedException e )
{
/*
* We got interrupted. Sleep again if we havn't slept
* long enough yet.
*/
long sysTime = System.DateTime.Now.Ticks / 10000;
if ( sysTime >= endTime )
{
return TCL.CompletionCode.RETURN;
}
ms = (int)( endTime - sysTime );
continue;
}
}
}
TclObject cmd = getCmdObject( argv );
cmd.preserve();
assocData.lastAfterId++;
TimerInfo timerInfo = new TimerInfo( this, notifier, ms );
timerInfo.interp = interp;
timerInfo.command = cmd;
timerInfo.id = assocData.lastAfterId;
assocData.handlers.Add( timerInfo );
interp.setResult( "after#" + timerInfo.id );
return TCL.CompletionCode.RETURN;
//.........这里部分代码省略.........
示例2: create
internal static Interp create( Interp interp, TclObject path, bool safe )
{
Interp masterInterp;
string pathString;
TclObject[] objv = TclList.getElements( interp, path );
if ( objv.Length < 2 )
{
masterInterp = interp;
pathString = path.ToString();
}
else
{
TclObject obj = TclList.newInstance();
TclList.insert( interp, obj, 0, objv, 0, objv.Length - 2 );
masterInterp = InterpCmd.getInterp( interp, obj );
pathString = objv[objv.Length - 1].ToString();
}
if ( !safe )
{
safe = masterInterp.isSafe;
}
if ( masterInterp.slaveTable.ContainsKey( pathString ) )
{
throw new TclException( interp, "interpreter named \"" + pathString + "\" already exists, cannot create" );
}
Interp slaveInterp = new Interp();
InterpSlaveCmd slave = new InterpSlaveCmd();
slaveInterp.slave = slave;
slaveInterp.setAssocData( "InterpSlaveCmd", slave );
slave.masterInterp = masterInterp;
slave.path = pathString;
slave.slaveInterp = slaveInterp;
masterInterp.createCommand( pathString, slaveInterp.slave );
slaveInterp.slave.interpCmd = NamespaceCmd.findCommand( masterInterp, pathString, null, 0 );
SupportClass.PutElement( masterInterp.slaveTable, pathString, slaveInterp.slave );
slaveInterp.setVar( "tcl_interactive", "0", TCL.VarFlag.GLOBAL_ONLY );
// Inherit the recursion limit.
slaveInterp.maxNestingDepth = masterInterp.maxNestingDepth;
if ( safe )
{
try
{
makeSafe( slaveInterp );
}
catch ( TclException e )
{
SupportClass.WriteStackTrace( e, Console.Error );
}
}
else
{
//Tcl_Init(slaveInterp);
}
return slaveInterp;
}