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


C# Interp.unsetVar方法代码示例

本文整理汇总了C#中tcl.lang.Interp.unsetVar方法的典型用法代码示例。如果您正苦于以下问题:C# Interp.unsetVar方法的具体用法?C# Interp.unsetVar怎么用?C# Interp.unsetVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tcl.lang.Interp的用法示例。


在下文中一共展示了Interp.unsetVar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: cmdProc

    /// <summary> Tcl_UnsetObjCmd -> UnsetCmd.cmdProc
    /// 
    /// Unsets Tcl variable (s). See Tcl user documentation * for
    /// details.
    /// </summary>
    /// <exception cref=""> TclException If tries to unset a variable that does
    /// not exist.
    /// </exception>

    public TCL.CompletionCode cmdProc( Interp interp, TclObject[] objv )
    {
      switch ( objv.Length )
      {
        case 2:
          interp.unsetVar( objv[1], 0 );
          break;
        case 3:
          for ( int i = ( objv[1].ToString() != "-nocomplain" ) ? 1 : 2; i < objv.Length; i++ )
          {
            Var.unsetVar( interp, objv[i].ToString(), 0 );
          }
          break;
        default:
          if ( objv.Length < 2 )
          {
            throw new TclNumArgsException( interp, 1, objv, "varName ?varName ...?" );
          }
          break;
      }

      return TCL.CompletionCode.RETURN;
    }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:32,代码来源:UnsetCmd.cs

示例2: makeSafe

    private static void makeSafe( Interp interp )
    {
      Channel chan; // Channel to remove from safe interpreter.

      interp.hideUnsafeCommands();

      interp.isSafe = true;

      //  Unsetting variables : (which should not have been set 
      //  in the first place, but...)

      // No env array in a safe slave.

      try
      {
        interp.unsetVar( "env", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }

      // Remove unsafe parts of tcl_platform

      try
      {
        interp.unsetVar( "tcl_platform", "os", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_platform", "osVersion", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_platform", "machine", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_platform", "user", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }

      // Unset path informations variables
      // (the only one remaining is [info nameofexecutable])

      try
      {
        interp.unsetVar( "tclDefaultLibrary", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_library", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_pkgPath", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }

      // Remove the standard channels from the interpreter; safe interpreters
      // do not ordinarily have access to stdin, stdout and stderr.
      //
      // NOTE: These channels are not added to the interpreter by the
      // Tcl_CreateInterp call, but may be added later, by another I/O
      // operation. We want to ensure that the interpreter does not have
      // these channels even if it is being made safe after being used for
      // some time..

      chan = TclIO.getStdChannel( StdChannel.STDIN );
      if ( chan != null )
      {
        TclIO.unregisterChannel( interp, chan );
      }
      chan = TclIO.getStdChannel( StdChannel.STDOUT );
      if ( chan != null )
      {
        TclIO.unregisterChannel( interp, chan );
      }
      chan = TclIO.getStdChannel( StdChannel.STDERR );
      if ( chan != null )
      {
        TclIO.unregisterChannel( interp, chan );
//.........这里部分代码省略.........
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:101,代码来源:InterpSlaveCmd.cs

示例3: cmdProc


//.........这里部分代码省略.........
                Var elem = (Var)e.Value;
                if ( ( elem.flags & VarFlags.UNDEFINED ) == 0 )
                {
                  size++;
                }
              }
              interp.setResult( size );
            }
            break;
          }

        case OPT_STARTSEARCH:
          {

            if ( objv.Length != 3 )
            {
              throw new TclNumArgsException( interp, 2, objv, "arrayName" );
            }
            if ( notArray )
            {

              errorNotArray( interp, objv[2].ToString() );
            }

            if ( var.sidVec == null )
            {
              var.sidVec = new ArrayList( 10 );
            }

            // Create a SearchId Object:
            // To create a new SearchId object, a unique string
            // identifier needs to be composed and we need to
            // create an Enumeration of the array keys.  The
            // unique string identifier is created from three
            // strings:
            //
            //     "s-"   is the default prefix
            //     "i"    is a unique number that is 1+ the greatest
            //	      SearchId index currently on the ArrayVar.
            //     "name" is the name of the array
            //
            // Once the SearchId string is created we construct a
            // new SearchId object using the string and the
            // Enumeration.  From now on the string is used to
            // uniquely identify the SearchId object.

            int i = var.NextIndex;

            string s = "s-" + i + "-" + objv[2].ToString();
            IDictionaryEnumerator e = ( (Hashtable)var.value ).GetEnumerator();
            var.sidVec.Add( new SearchId( e, s, i ) );
            interp.setResult( s );
            break;
          }

        case OPT_UNSET:
          {
            string pattern;
            string name;

            if ( ( objv.Length != 3 ) && ( objv.Length != 4 ) )
            {
              throw new TclNumArgsException( interp, 2, objv, "arrayName ?pattern?" );
            }
            if ( notArray )
            {

              //Ignot this error -- errorNotArray(interp, objv[2].ToString());
              break;
            }
            if ( objv.Length == 3 )
            {
              // When no pattern is given, just unset the whole array

              interp.unsetVar( objv[2], 0 );
            }
            else
            {

              pattern = objv[3].ToString();
              Hashtable table = (Hashtable)( ( (Hashtable)var.value ).Clone() );
              for ( IDictionaryEnumerator e = table.GetEnumerator(); e.MoveNext(); )
              {
                name = (string)e.Key;
                Var elem = (Var)e.Value;
                if ( var.isVarUndefined() )
                {
                  continue;
                }
                if ( Util.stringMatch( name, pattern ) )
                {
                  interp.unsetVar( varName, name, 0 );
                }
              }
            }
            break;
          }
      }
      return TCL.CompletionCode.RETURN;
    }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:101,代码来源:ArrayCmd.cs


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