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


C# Interp.resetResult方法代码示例

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


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

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

示例2: cmdProc

		public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
		{
			if (argv.Length != 2)
			{
				throw new TclNumArgsException(interp, 1, argv, "name");
			}
			
			VwaitTrace trace = new VwaitTrace();
			Var.traceVar(interp, argv[1], TCL.VarFlag.GLOBAL_ONLY | TCL.VarFlag.TRACE_WRITES | TCL.VarFlag.TRACE_UNSETS, trace);
			
			int foundEvent = 1;
			while (!trace.done && (foundEvent != 0))
			{
				foundEvent = interp.getNotifier().doOneEvent(TCL.ALL_EVENTS);
			}
			
			Var.untraceVar(interp, argv[1], TCL.VarFlag.GLOBAL_ONLY | TCL.VarFlag.TRACE_WRITES | TCL.VarFlag.TRACE_UNSETS, trace);
			
			// Clear out the interpreter's result, since it may have been set
			// by event handlers.
			
			interp.resetResult();
			
			if (foundEvent == 0)
			{
				
				throw new TclException(interp, "can't wait for variable \"" + argv[1] + "\":  would wait forever");
			}
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Belxjander,项目名称:Asuna,代码行数:30,代码来源:VwaitCmd.cs

示例3: cmdProc

    /// <summary> Tcl_UpvarObjCmd -> UpvarCmd.cmdProc
    /// 
    /// This procedure is invoked to process the "upvar" Tcl command.
    /// See the user documentation for details on what it does.
    /// </summary>

    public TCL.CompletionCode cmdProc( Interp interp, TclObject[] objv )
    {
      CallFrame frame;
      string frameSpec, otherVarName, myVarName;
      int p;
      int objc = objv.Length, objv_index;
      int result;

      if ( objv.Length < 3 )
      {
        throw new TclNumArgsException( interp, 1, objv, "?level? otherVar localVar ?otherVar localVar ...?" );
      }

      // Find the call frame containing each of the "other variables" to be
      // linked to. 


      frameSpec = objv[1].ToString();
      // Java does not support passing a reference by refernece so use an array
      CallFrame[] frameArr = new CallFrame[1];
      result = CallFrame.getFrame( interp, frameSpec, frameArr );
      frame = frameArr[0];
      objc -= ( result + 1 );
      if ( ( objc & 1 ) != 0 )
      {
        throw new TclNumArgsException( interp, 1, objv, "?level? otherVar localVar ?otherVar localVar ...?" );
      }
      objv_index = result + 1;


      // Iterate over each (other variable, local variable) pair.
      // Divide the other variable name into two parts, then call
      // MakeUpvar to do all the work of linking it to the local variable.

      for ( ; objc > 0; objc -= 2, objv_index += 2 )
      {

        myVarName = objv[objv_index + 1].ToString();

        otherVarName = objv[objv_index].ToString();

        int otherLength = otherVarName.Length;
        p = otherVarName.IndexOf( (System.Char)'(' );
        if ( ( p != -1 ) && ( otherVarName[otherLength - 1] == ')' ) )
        {
          // This is an array variable name
          Var.makeUpvar( interp, frame, otherVarName.Substring( 0, ( p ) - ( 0 ) ), otherVarName.Substring( p + 1, ( otherLength - 1 ) - ( p + 1 ) ), 0, myVarName, 0 );
        }
        else
        {
          // This is a scalar variable name
          Var.makeUpvar( interp, frame, otherVarName, null, 0, myVarName, 0 );
        }
      }
      interp.resetResult();
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:63,代码来源:UpvarCmd.cs

示例4: cmdProc

    /// <summary> This procedure is invoked to process the "while" 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>
    /// <exception cref=""> TclException if script causes error.
    /// </exception>

    public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
    {
      if ( argv.Length != 3 )
      {
        throw new TclNumArgsException( interp, 1, argv, "test command" );
      }

      string test = argv[1].ToString();
      TclObject command = argv[2];

      {
        while ( interp.expr.evalBoolean( interp, test ) )
        {
          try
          {
            interp.eval( command, 0 );
          }
          catch ( TclException e )
          {
            switch ( e.getCompletionCode() )
            {

              case TCL.CompletionCode.BREAK:
                goto loop_brk;


              case TCL.CompletionCode.CONTINUE:
                continue;


              case TCL.CompletionCode.ERROR:
                interp.addErrorInfo( "\n    (\"while\" body line " + interp.errorLine + ")" );
                throw;


              default:
                throw;

            }
          }
        }
      }

loop_brk:
      ;


      interp.resetResult();
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:61,代码来源:WhileCmd.cs

示例5: 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);
				}
			}
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:30,代码来源:TclVarException.cs

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

示例7: cmdProc

        public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
        {
            if ( argv.Length < 3 )
              {
            throw new TclNumArgsException( interp, 1, argv, "list index" );
              }

              int size = TclList.getLength( interp, argv[1] );
              int index = Util.getIntForIndex( interp, argv[2], size - 1 );
              TclObject element = TclList.index( interp, argv[1], index );

              if ( element != null )
              {
            interp.setResult( element );
              }
              else
              {
            interp.resetResult();
              }
              return TCL.CompletionCode.RETURN;
        }
开发者ID:R4P3NET,项目名称:TS3SRV-ASE,代码行数:21,代码来源:LindexCmd.cs

示例8: cmdProc

    public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
    {
      int flags;

      if ( argv.Length == 1 )
      {
        flags = TCL.ALL_EVENTS | TCL.DONT_WAIT;
      }
      else if ( argv.Length == 2 )
      {
        TclIndex.get( interp, argv[1], validOpts, "option", 0 );

        /*
        * Since we just have one valid option, if the above call returns
        * without an exception, we've got "idletasks" (or abreviations).
        */

        flags = TCL.IDLE_EVENTS | TCL.DONT_WAIT;
      }
      else
      {
        throw new TclNumArgsException( interp, 1, argv, "?idletasks?" );
      }

      while ( interp.getNotifier().doOneEvent( flags ) != 0 )
      {
        /* Empty loop body */
      }

      /*
      * Must clear the interpreter's result because event handlers could
      * have executed commands.
      */

      interp.resetResult();
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:37,代码来源:UpdateCmd.cs

示例9: cmdProc

		/// <summary> This procedure is invoked to process the "catch" 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>
		/// <exception cref=""> TclException if wrong number of arguments.
		/// </exception>
		
		public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
		{
			if (argv.Length != 2 && argv.Length != 3)
			{
				throw new TclNumArgsException(interp, 1, argv, "command ?varName?");
			}
			
			TclObject result;
			TCL.CompletionCode code = TCL.CompletionCode.OK;
			
			try
			{
				interp.eval(argv[1], 0);
			}
			catch (TclException e)
			{
				code = e.getCompletionCode();
			}

      result = interp.getResult();

      if ( argv.Length == 3 )
			{
				try
				{
					interp.setVar(argv[2], result, 0);
				}
				catch (TclException e)
				{
					throw new TclException(interp, "couldn't save command result in variable");
				}
			}
			
			interp.resetResult();
			interp.setResult(TclInteger.newInstance((int)code));
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Belxjander,项目名称:Asuna,代码行数:48,代码来源:CatchCmd.cs

示例10: cmdProc


//.........这里部分代码省略.........

              string2 = objv[2].ToString();
            }

            interp.setResult( Util.stringMatch( string1, string2 ) );
            break;
          }


        case STR_RANGE:
          {
            if ( objv.Length != 5 )
            {
              throw new TclNumArgsException( interp, 2, objv, "string first last" );
            }


            string string1 = objv[2].ToString();
            int length1 = string1.Length;

            int first = Util.getIntForIndex( interp, objv[3], length1 - 1 );
            if ( first < 0 )
            {
              first = 0;
            }
            int last = Util.getIntForIndex( interp, objv[4], length1 - 1 );
            if ( last >= length1 )
            {
              last = length1 - 1;
            }

            if ( first > last )
            {
              interp.resetResult();
            }
            else
            {
              interp.setResult( string1.Substring( first, ( last + 1 ) - ( first ) ) );
            }
            break;
          }


        case STR_REPEAT:
          {
            if ( objv.Length != 4 )
            {
              throw new TclNumArgsException( interp, 2, objv, "string count" );
            }

            int count = TclInteger.get( interp, objv[3] );


            string string1 = objv[2].ToString();
            if ( string1.Length > 0 )
            {
              TclObject tstr = TclString.newInstance( "" );
              for ( index = 0; index < count; index++ )
              {
                TclString.append( tstr, string1 );
              }
              interp.setResult( tstr );
            }
            break;
          }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:66,代码来源:StringCmd.cs

示例11: callTraces

    /// <summary> CallTraces -> callTraces
    /// 
    /// This procedure is invoked to find and invoke relevant
    /// trace procedures associated with a particular operation on
    /// a variable.  This procedure invokes traces both on the
    /// variable and on its containing array (where relevant).
    /// 
    /// </summary>
    /// <param name="interp">Interpreter containing variable.
    /// </param>
    /// <param name="array">array variable that contains the variable, or null
    /// if the variable isn't an element of an array.
    /// </param>
    /// <param name="var">Variable whose traces are to be invoked.
    /// </param>
    /// <param name="part1">the first part of a variable name.
    /// </param>
    /// <param name="part2">the second part of a variable name.
    /// </param>
    /// <param name="flags">Flags to pass to trace procedures: indicates
    /// what's happening to variable, plus other stuff like
    /// TCL.VarFlag.GLOBAL_ONLY, TCL.VarFlag.NAMESPACE_ONLY, and TCL.VarFlag.INTERP_DESTROYED.
    /// </param>
    /// <returns> null if no trace procedures were invoked, or
    /// if all the invoked trace procedures returned successfully.
    /// The return value is non-null if a trace procedure returned an
    /// error (in this case no more trace procedures were invoked
    /// after the error was returned). In this case the return value
    /// is a pointer to a string describing the error.
    /// </returns>

    static protected internal string callTraces( Interp interp, Var array, Var var, string part1, string part2, TCL.VarFlag flags )
    {
      TclObject oldResult;
      int i;

      // If there are already similar trace procedures active for the
      // variable, don't call them again.

      if ( ( var.flags & VarFlags.TRACE_ACTIVE ) != 0 )
      {
        return null;
      }
      var.flags |= VarFlags.TRACE_ACTIVE;
      var.refCount++;

      // If the variable name hasn't been parsed into array name and
      // element, do it here.  If there really is an array element,
      // make a copy of the original name so that nulls can be
      // inserted into it to separate the names (can't modify the name
      // string in place, because the string might get used by the
      // callbacks we invoke).

      // FIXME : come up with parsing code to use for all situations!
      if ( (System.Object)part2 == null )
      {
        int len = part1.Length;

        if ( len > 0 )
        {
          if ( part1[len - 1] == ')' )
          {
            for ( i = 0; i < len - 1; i++ )
            {
              if ( part1[i] == '(' )
              {
                break;
              }
            }
            if ( i < len - 1 )
            {
              if ( i < len - 2 )
              {
                part2 = part1.Substring( i + 1, ( len - 1 ) - ( i + 1 ) );
                part1 = part1.Substring( 0, ( i ) - ( 0 ) );
              }
            }
          }
        }
      }

      oldResult = interp.getResult();
      oldResult.preserve();
      interp.resetResult();

      try
      {
        // Invoke traces on the array containing the variable, if relevant.

        if ( array != null )
        {
          array.refCount++;
        }
        if ( ( array != null ) && ( array.traces != null ) )
        {
          for ( i = 0; ( array.traces != null ) && ( i < array.traces.Count ); i++ )
          {
            TraceRecord rec = (TraceRecord)array.traces[i];
            if ( ( rec.flags & flags ) != 0 )
            {
//.........这里部分代码省略.........
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:101,代码来源:Var.cs

示例12: eval2

    public static void eval2( Interp interp, char[] script_array, int script_index, int numBytes, int flags )
    {
      int i;
      int objUsed = 0;
      int nextIndex, tokenIndex;
      int commandLength, bytesLeft;
      bool nested;
      TclObject[] objv;
      TclObject obj;
      TclParse parse = null;
      TclToken token;

      // Saves old copy of interp.varFrame in case TCL.EVAL_GLOBAL was set
      CallFrame savedVarFrame;

      // Take into account the trailing '\0'
      int script_length = script_array.Length - 1;


      // These are modified instead of script_array and script_index
      char[] src_array = script_array;
      int src_index = script_index;

#if DEBUG
				System.Diagnostics.Debug.WriteLine();
				System.Diagnostics.Debug.WriteLine("Entered eval2()");
				System.Diagnostics.Debug.Write("now to eval2 the string \"");
				for (int k = script_index; k < script_array.Length; k++)
				{
					System.Diagnostics.Debug.Write(script_array[k]);
				}
				System.Diagnostics.Debug.WriteLine("\"");
#endif



      if ( numBytes < 0 )
      {
        numBytes = script_length - script_index;
      }
      interp.resetResult();
      savedVarFrame = interp.varFrame;
      if ( ( flags & TCL.EVAL_GLOBAL ) != 0 )
      {
        interp.varFrame = null;
      }

      // Each iteration through the following loop parses the next
      // command from the script and then executes it.

      bytesLeft = numBytes;

      // Init objv with the most commonly used array size
      objv = grabObjv( interp, 3 );

      if ( ( interp.evalFlags & TCL_BRACKET_TERM ) != 0 )
      {
        nested = true;
      }
      else
      {
        nested = false;
      }
      interp.evalFlags &= ~TCL_BRACKET_TERM;

      try
      {

        do
        {
          parse = parseCommand( interp, src_array, src_index, bytesLeft, null, 0, nested );

          if ( parse.result != TCL.CompletionCode.OK )
          {
            throw new TclException( parse.result );
          }

          // The test on noEval is temporary.  As soon as the new expr
          // parser is implemented it should be removed.

          if ( parse.numWords > 0 && interp.noEval == 0 )
          {
            // Generate an array of objects for the words of the command.

            try
            {
              tokenIndex = 0;
              token = parse.getToken( tokenIndex );

              // Test to see if new space needs to be allocated.  If objv
              // is the EXACT size of parse.numWords, then no allocation
              // needs to be performed.

              if ( objv.Length != parse.numWords )
              {
                //System.out.println("need new size " + objv.length);
                releaseObjv( interp, objv ); //let go of resource
                objv = grabObjv( interp, parse.numWords ); //get new resource
              }
              else
//.........这里部分代码省略.........
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:101,代码来源:Parser.cs

示例13: evalObjv

    public static void evalObjv( Interp interp, TclObject[] objv, int length, int flags )
    {
      Command cmd;
      WrappedCommand wCmd = null;
      TclObject[] newObjv;
      int i;
      CallFrame savedVarFrame; //Saves old copy of interp.varFrame
      // in case TCL.EVAL_GLOBAL was set.

      interp.resetResult();
      if ( objv.Length == 0 )
      {
        return;
      }

      // If the interpreter was deleted, return an error.

      if ( interp.deleted )
      {
        interp.setResult( "attempt to call eval in deleted interpreter" );
        interp.setErrorCode( TclString.newInstance( "CORE IDELETE {attempt to call eval in deleted interpreter}" ) );
        throw new TclException( TCL.CompletionCode.ERROR );
      }

      // Check depth of nested calls to eval:  if this gets too large,
      // it's probably because of an infinite loop somewhere.

      if ( interp.nestLevel >= interp.maxNestingDepth )
      {
        throw new TclException( interp, "too many nested calls to eval (infinite loop?)" );
      }
      interp.nestLevel++;

      try
      {
        // Find the procedure to execute this command. If there isn't one,
        // then see if there is a command "unknown".  If so, create a new
        // word array with "unknown" as the first word and the original
        // command words as arguments.  Then call ourselves recursively
        // to execute it.


        cmd = interp.getCommand( objv[0].ToString() );
        if ( cmd == null )
          wCmd = interp.getObjCommand( objv[0].ToString() );
        // See if we are running as a slave interpretor, and this is a windows command        
        if ( cmd == null && wCmd == null && interp.slave != null )
        {
          wCmd = interp.slave.masterInterp.getObjCommand( objv[0].ToString() );
        }
        if ( cmd == null && wCmd == null )
        {
          newObjv = new TclObject[objv.Length + 1];
          for ( i = ( objv.Length - 1 ); i >= 0; i-- )
          {
            newObjv[i + 1] = objv[i];
          }
          newObjv[0] = TclString.newInstance( "unknown" );
          newObjv[0].preserve();
          cmd = interp.getCommand( "unknown" );
          if ( cmd == null )
          {

            Debug.Assert( false, "invalid command name \"" + objv[0].ToString() + "\"" );
            throw new TclException( interp, "invalid command name \"" + objv[0].ToString() + "\"" );
          }
          else
          {
            evalObjv( interp, newObjv, length, 0 );
          }
          newObjv[0].release();
          return;
        }

        // Finally, invoke the Command's cmdProc.

        interp.cmdCount++;
        savedVarFrame = interp.varFrame;
        if ( ( flags & TCL.EVAL_GLOBAL ) != 0 )
        {
          interp.varFrame = null;
        }

        int rc = 0;
        if ( cmd != null )
        {
          if ( cmd.cmdProc( interp, objv ) == TCL.CompletionCode.EXIT )
            throw new TclException( TCL.CompletionCode.EXIT );
        }
        else
        {
          rc = wCmd.objProc( wCmd.objClientData, interp, objv.Length, objv );
          if ( rc != 0 )
          {
            if ( rc == TCL.TCL_RETURN )
              throw new TclException( TCL.CompletionCode.RETURN );
            throw new TclException( TCL.CompletionCode.ERROR );
          }
        }
        interp.varFrame = savedVarFrame;
//.........这里部分代码省略.........
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:101,代码来源:Parser.cs

示例14: 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 != 4 )
      {
        throw new TclNumArgsException( interp, 1, argv, "list first last" );
      }

      int size = TclList.getLength( interp, argv[1] );
      int first;
      int last;

      first = Util.getIntForIndex( interp, argv[2], size - 1 );
      last = Util.getIntForIndex( interp, argv[3], size - 1 );

      if ( last < 0 )
      {
        interp.resetResult();
        return TCL.CompletionCode.RETURN;
      }
      if ( first >= size )
      {
        interp.resetResult();
        return TCL.CompletionCode.RETURN;
      }
      if ( first <= 0 && last >= size )
      {
        interp.setResult( argv[1] );
        return TCL.CompletionCode.RETURN;
      }

      if ( first < 0 )
      {
        first = 0;
      }
      if ( first >= size )
      {
        first = size - 1;
      }
      if ( last < 0 )
      {
        last = 0;
      }
      if ( last >= size )
      {
        last = size - 1;
      }
      if ( first > last )
      {
        interp.resetResult();
        return TCL.CompletionCode.RETURN;
      }

      TclObject list = TclList.newInstance();

      list.preserve();
      try
      {
        for ( int i = first; i <= last; i++ )
        {
          TclList.append( interp, list, TclList.index( interp, argv[1], i ) );
        }
        interp.setResult( list );
      }
      finally
      {
        list.release();
      }
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:73,代码来源:LrangeCmd.cs

示例15: importList

		/*
		*----------------------------------------------------------------------
		*
		* Tcl_Import -> importList
		*
		*	Imports all of the commands matching a pattern into the namespace
		*	specified by namespace (or the current namespace if namespace
		*	is null). This is done by creating a new command (the "imported
		*	command") that points to the real command in its original namespace.
		*
		*      If matching commands are on the autoload path but haven't been
		*	loaded yet, this command forces them to be loaded, then creates
		*	the links to them.
		*
		* Results:
		*  Returns if successful, raises TclException if something goes wrong.
		*
		* Side effects:
		*	Creates new commands in the importing namespace. These indirect
		*	calls back to the real command and are deleted if the real commands
		*	are deleted.
		*
		*----------------------------------------------------------------------
		*/
		
		internal static void  importList(Interp interp, Namespace namespace_Renamed, string pattern, bool allowOverwrite)
		{
			Namespace ns, importNs;
			Namespace currNs = getCurrentNamespace(interp);
			string simplePattern, cmdName;
			IEnumerator search;
			WrappedCommand cmd, realCmd;
			ImportRef ref_Renamed;
			WrappedCommand autoCmd, importedCmd;
			ImportedCmdData data;
			bool wasExported;
			int i, result;
			
			// If the specified namespace is null, use the current namespace.
			
			if (namespace_Renamed == null)
			{
				ns = currNs;
			}
			else
			{
				ns = namespace_Renamed;
			}
			
			// First, invoke the "auto_import" command with the pattern
			// being imported.  This command is part of the Tcl library.
			// It looks for imported commands in autoloaded libraries and
			// loads them in.  That way, they will be found when we try
			// to create links below.
			
			autoCmd = findCommand(interp, "auto_import", null, TCL.VarFlag.GLOBAL_ONLY);
			
			if (autoCmd != null)
			{
				TclObject[] objv = new TclObject[2];
				
				objv[0] = TclString.newInstance("auto_import");
				objv[0].preserve();
				objv[1] = TclString.newInstance(pattern);
				objv[1].preserve();
				
				cmd = autoCmd;
				try
				{
					// Invoke the command with the arguments
					cmd.cmd.cmdProc(interp, objv);
				}
				finally
				{
					objv[0].release();
					objv[1].release();
				}
				
				interp.resetResult();
			}
			
			// From the pattern, find the namespace from which we are importing
			// and get the simple pattern (no namespace qualifiers or ::'s) at
			// the end.
			
			if (pattern.Length == 0)
			{
				throw new TclException(interp, "empty import pattern");
			}
			
			// Java does not support passing an address so we pass
			// an array of size 1 and then assign arr[0] to the value
			Namespace[] importNsArr = new Namespace[1];
			Namespace[] dummyArr = new Namespace[1];
			string[] simplePatternArr = new string[1];
			
			getNamespaceForQualName(interp, pattern, ns, TCL.VarFlag.LEAVE_ERR_MSG, importNsArr, dummyArr, dummyArr, simplePatternArr);
			
			importNs = importNsArr[0];
			simplePattern = simplePatternArr[0];
//.........这里部分代码省略.........
开发者ID:Belxjander,项目名称:Asuna,代码行数:101,代码来源:NamespaceCmd.cs


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