当前位置: 首页>>代码示例>>C#>>正文


C# Interp.setAssocData方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:R4P3NET,项目名称:TS3SRV-ASE,代码行数:101,代码来源:AfterCmd.cs

示例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;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:71,代码来源:InterpSlaveCmd.cs


注:本文中的tcl.lang.Interp.setAssocData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。