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


C# lang.Interp类代码示例

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


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

示例1: cmdProc

    /// <summary> This procedure is invoked to process the "eval" 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 < 2 )
      {
        throw new TclNumArgsException( interp, 1, argv, "arg ?arg ...?" );
      }

      try
      {
        if ( argv.Length == 2 )
        {
          interp.eval( argv[1], 0 );
        }
        else
        {
          string s = Util.concat( 1, argv.Length - 1, argv );
          interp.eval( s, 0 );
        }
      }
      catch ( TclException e )
      {
        if ( e.getCompletionCode() == TCL.CompletionCode.ERROR )
        {
          interp.addErrorInfo( "\n    (\"eval\" body line " + interp.errorLine + ")" );
        }
        throw;
      }
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:40,代码来源:EvalCmd.cs

示例2: sqlite3BtreeSharedCacheReport

    /*
    ** 2007 May 05
    **
    ** The author disclaims copyright to this source code.  In place of
    ** a legal notice, here is a blessing:
    **
    **    May you do good and not evil.
    **    May you find forgiveness for yourself and forgive others.
    **    May you share freely, never taking more than you give.
    **
    *************************************************************************
    ** Code for testing the btree.c module in SQLite.  This code
    ** is not included in the SQLite library.  It is used for automated
    ** testing of the SQLite library.
    *************************************************************************
    **  Included in SQLite3 port to C#-SQLite;  2008 Noah B Hart
    **  C#-SQLite is an independent reimplementation of the SQLite software library
    **
    **  SQLITE_SOURCE_ID: 2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c
    **
    **  $Header$
    *************************************************************************
    */
    //#include "btreeInt.h"
    //#include <tcl.h>

    /*
    ** Usage: sqlite3_shared_cache_report
    **
    ** Return a list of file that are shared and the number of
    ** references to each file.
    */
    static int sqlite3BtreeSharedCacheReport(
    object clientData,
    Tcl_Interp interp,
    int objc,
    Tcl_Obj[] objv
    )
    {
开发者ID:Belxjander,项目名称:Asuna,代码行数:39,代码来源:test_btree_c.cs

示例3: cmdProc

		/// <summary> This procedure is invoked to process the "seek" Tcl command.
		/// See the user documentation for details on what it does.
		/// </summary>
		
		public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
		{
			
			Channel chan; /* The channel being operated on this method */
			int mode; /* Stores the search mode, either beg, cur or end
			* of file.  See the TclIO class for more info */
			
			if (argv.Length != 3 && argv.Length != 4)
			{
				throw new TclNumArgsException(interp, 1, argv, "channelId offset ?origin?");
			}
			
			// default is the beginning of the file
			
			mode = TclIO.SEEK_SET;
			if (argv.Length == 4)
			{
				int index = TclIndex.get(interp, argv[3], validOrigins, "origin", 0);
				
				switch (index)
				{
					
					case OPT_START:  {
							mode = TclIO.SEEK_SET;
							break;
						}
					
					case OPT_CURRENT:  {
							mode = TclIO.SEEK_CUR;
							break;
						}
					
					case OPT_END:  {
							mode = TclIO.SEEK_END;
							break;
						}
					}
			}
			
			
			chan = TclIO.getChannel(interp, argv[1].ToString());
			if (chan == null)
			{
				
				throw new TclException(interp, "can not find channel named \"" + argv[1].ToString() + "\"");
			}
			long offset = TclInteger.get(interp, argv[2]);
			
			try
			{
				chan.seek(interp, offset, mode);
			}
			catch (System.IO.IOException e)
			{
				// FIXME: Need to figure out Tcl specific error conditions.
				// Should we also wrap an IOException in a ReflectException?
				throw new TclRuntimeError("SeekCmd.cmdProc() Error: IOException when seeking " + chan.ChanName + ":" + e.Message);
			}
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Belxjander,项目名称:Asuna,代码行数:64,代码来源:SeekCmd.cs

示例4: cmdProc

    /// <summary> Evaluates a Tcl expression. See Tcl user documentation for
    /// details.
    /// </summary>
    /// <exception cref=""> TclException If malformed expression.
    /// </exception>

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

      if ( argv.Length == 2 )
      {

        interp.setResult( interp.expr.eval( interp, argv[1].ToString() ) );
      }
      else
      {
        StringBuilder sbuf = new StringBuilder();

        sbuf.Append( argv[1].ToString() );
        for ( int i = 2; i < argv.Length; i++ )
        {
          sbuf.Append( ' ' );

          sbuf.Append( argv[i].ToString() );
        }
        interp.setResult( interp.expr.eval( interp, sbuf.ToString() ) );
      }
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:33,代码来源:ExprCmd.cs

示例5: cmdProc

    /// <summary> This procedure is invoked to process the "tell" 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>

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

      Channel chan; /* The channel being operated on this method */

      if ( argv.Length != 2 )
      {
        throw new TclNumArgsException( interp, 1, argv, "channelId" );
      }


      chan = TclIO.getChannel( interp, argv[1].ToString() );
      if ( chan == null )
      {

        throw new TclException( interp, "can not find channel named \"" + argv[1].ToString() + "\"" );
      }

      try
      {
        interp.setResult( TclInteger.newInstance( (int)chan.tell() ) );
      }
      catch ( IOException e )
      {
        throw new TclException( interp, "Error in TellCmd" );
      }
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:37,代码来源:TellCmd.cs

示例6: Procedure

    internal Procedure( Interp interp, NamespaceCmd.Namespace ns, string name, TclObject args, TclObject b, string sFileName, int sLineNumber )
    {
      this.ns = ns;
      srcFileName = sFileName;
      srcLineNumber = sLineNumber;

      // Break up the argument list into argument specifiers, then process
      // each argument specifier.

      int numArgs = TclList.getLength( interp, args );
      argList = new TclObject[numArgs][];
      for ( int i = 0; i < numArgs; i++ )
      {
        argList[i] = new TclObject[2];
      }

      for ( int i = 0; i < numArgs; i++ )
      {
        // Now divide the specifier up into name and default.

        TclObject argSpec = TclList.index( interp, args, i );
        int specLen = TclList.getLength( interp, argSpec );

        if ( specLen == 0 )
        {
          throw new TclException( interp, "procedure \"" + name + "\" has argument with no name" );
        }
        if ( specLen > 2 )
        {

          throw new TclException( interp, "too many fields in argument " + "specifier \"" + argSpec + "\"" );
        }

        argList[i][0] = TclList.index( interp, argSpec, 0 );
        argList[i][0].preserve();
        if ( specLen == 2 )
        {
          argList[i][1] = TclList.index( interp, argSpec, 1 );
          argList[i][1].preserve();
        }
        else
        {
          argList[i][1] = null;
        }
      }


      if ( numArgs > 0 && ( argList[numArgs - 1][0].ToString().Equals( "args" ) ) )
      {
        isVarArgs = true;
      }
      else
      {
        isVarArgs = false;
      }


      body = new CharPointer( b.ToString() );
      body_length = body.length();
    }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:60,代码来源:Procedure.cs

示例7: 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

示例8: cmdProc

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

      if ( argv.Length > 2 )
      {
        throw new TclNumArgsException( interp, 1, argv, "?dirName?" );
      }

      if ( argv.Length == 1 )
      {
        dirName = "~";
      }
      else
      {

        dirName = argv[1].ToString();
      }
      if ( ( JACL.PLATFORM == JACL.PLATFORM_WINDOWS ) && ( dirName.Length == 2 ) && ( dirName[1] == ':' ) )
      {
        dirName = dirName + "/";
      }

      // Set the interp's working dir.

      interp.setWorkingDir( dirName );
      return TCL.CompletionCode.RETURN;
    }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:28,代码来源:CdCmd.cs

示例9: cmdProc

		public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
		{
			if (argv.Length < 2 || argv.Length > 4)
			{
				throw new TclNumArgsException(interp, 1, argv, "message ?errorInfo? ?errorCode?");
			}
			
			if (argv.Length >= 3)
			{
				
				string errorInfo = argv[2].ToString();
				
				if (!errorInfo.Equals(""))
				{
					interp.addErrorInfo(errorInfo);
					interp.errAlreadyLogged = true;
				}
			}
			
			if (argv.Length == 4)
			{
				interp.setErrorCode(argv[3]);
			}
			
			interp.setResult(argv[1]);
			throw new TclException(TCL.CompletionCode.ERROR);
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:27,代码来源:ErrorCmd.cs

示例10: cmdProc

        /// <summary> This procedure is invoked to process the "flush" 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>
        public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
        {
            Channel chan; /* The channel being operated on this method */

              if ( argv.Length != 2 )
              {
            throw new TclNumArgsException( interp, 1, argv, "channelId" );
              }

              chan = TclIO.getChannel( interp, argv[1].ToString() );
              if ( chan == null )
              {

            throw new TclException( interp, "can not find channel named \"" + argv[1].ToString() + "\"" );
              }

              try
              {
            chan.flush( interp );
              }
              catch ( IOException e )
              {
            throw new TclRuntimeError( "FlushCmd.cmdProc() Error: IOException when flushing " + chan.ChanName );
              }
              return TCL.CompletionCode.RETURN;
        }
开发者ID:R4P3NET,项目名称:TS3SRV-ASE,代码行数:34,代码来源:FlushCmd.cs

示例11: cmdProc

		/// <summary> See Tcl user documentation for details.</summary>
		
		public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
		{
			if ((argv.Length < 2) || (argv.Length > 3))
			{
				throw new TclNumArgsException(interp, 1, argv, "script ?count?");
			}
			
			int count;
			if (argv.Length == 2)
			{
				count = 1;
			}
			else
			{
				count = TclInteger.get(interp, argv[2]);
			}
			
			long startTime = System.DateTime.Now.Ticks;
			for (int i = 0; i < count; i++)
			{
				interp.eval(argv[1], 0);
			}
			long endTime = System.DateTime.Now.Ticks;
			long uSecs = (((endTime - startTime) / 10) / count);
			if (uSecs == 1)
			{
				interp.setResult(TclString.newInstance("1 microsecond per iteration"));
			}
			else
			{
				interp.setResult(TclString.newInstance(uSecs + " microseconds per iteration"));
			}
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Belxjander,项目名称:Asuna,代码行数:36,代码来源:TimeCmd.cs

示例12: 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

示例13: TclNumArgsException

        /// <summary> Creates a TclException with the appropiate Tcl error
        /// message for having the wring number of arguments to a Tcl command.
        /// <p>
        /// Example: <pre>
        /// 
        /// if (argv.length != 3) {
        /// throw new TclNumArgsException(interp, 1, argv, "option name");
        /// }
        /// </pre>
        /// 
        /// </summary>
        /// <param name="interp">current Interpreter.
        /// </param>
        /// <param name="argc">the number of arguments to copy from the offending
        /// command to put into the error message.
        /// </param>
        /// <param name="argv">the arguments of the offending command.
        /// </param>
        /// <param name="message">extra message to appear in the error message that
        /// explains the proper usage of the command.
        /// </param>
        /// <exception cref=""> TclException is always thrown.
        /// </exception>
        public TclNumArgsException( Interp interp, int argc, TclObject[] argv, string message )
            : base(TCL.CompletionCode.ERROR)
        {
            if ( interp != null )
              {
            StringBuilder buff = new StringBuilder( 50 );
            buff.Append( "wrong # args: should be \"" );

            for ( int i = 0; i < argc; i++ )
            {
              if ( argv[i].InternalRep is TclIndex )
              {
            buff.Append( argv[i].InternalRep.ToString() );
              }
              else
              {
            buff.Append( argv[i].ToString() );
              }
              if ( i < ( argc - 1 ) )
              {
            buff.Append( " " );
              }
            }
            if ( ( message != null ) )
            {
              buff.Append( " " + message );
            }
            buff.Append( "\"" );
            interp.setResult( buff.ToString() );
              }
        }
开发者ID:R4P3NET,项目名称:TS3SRV-ASE,代码行数:54,代码来源:TclNumArgsException.cs

示例14: cmdProc

    /// <summary> This procedure is invoked to process the "gets" 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>

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

      bool writeToVar = false; // If true write to var passes as arg
      string varName = ""; // The variable to write value to
      Channel chan; // The channel being operated on
      int lineLen;
      TclObject line;

      if ( ( argv.Length < 2 ) || ( argv.Length > 3 ) )
      {
        throw new TclNumArgsException( interp, 1, argv, "channelId ?varName?" );
      }

      if ( argv.Length == 3 )
      {
        writeToVar = true;

        varName = argv[2].ToString();
      }


      chan = TclIO.getChannel( interp, argv[1].ToString() );
      if ( chan == null )
      {

        throw new TclException( interp, "can not find channel named \"" + argv[1].ToString() + "\"" );
      }

      try
      {
        line = TclString.newInstance( new StringBuilder( 64 ) );
        lineLen = chan.read( interp, line, TclIO.READ_LINE, 0 );
        if ( lineLen < 0 )
        {
          // FIXME: Need more specific posix error codes!
          if ( !chan.eof() && !chan.isBlocked( interp ) )
          {

            throw new TclPosixException( interp, TclPosixException.EIO, true, "error reading \"" + argv[1].ToString() + "\"" );
          }
          lineLen = -1;
        }
        if ( writeToVar )
        {
          interp.setVar( varName, line, 0 );
          interp.setResult( lineLen );
        }
        else
        {
          interp.setResult( line );
        }
      }
      catch ( IOException e )
      {
        throw new TclRuntimeError( "GetsCmd.cmdProc() Error: IOException when getting " + chan.ChanName + ": " + e.Message );
      }
      return TCL.CompletionCode.RETURN;
    }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:68,代码来源:GetsCmd.cs

示例15: cmdProc

		/// <summary> This procedure is invoked to process the "break" Tcl command.
		/// See the user documentation for details on what it does.
		/// </summary>
		/// <exception cref=""> TclException is always thrown.
		/// </exception>
		
		public TCL.CompletionCode cmdProc(Interp interp, TclObject[] argv)
		{
			if (argv.Length != 1)
			{
				throw new TclNumArgsException(interp, 1, argv, null);
			}
			throw new TclException(interp, null, TCL.CompletionCode.BREAK);
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:14,代码来源:BreakCmd.cs


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