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


C# Tcl_Interp类代码示例

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


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

示例1: sqlite3TestTextToPtr

 static object sqlite3TestTextToPtr( Tcl_Interp interp, string z )
 {
   //object p ;
   //u64[] v = new u64[1];
   //u32 v2;
   //int zIndex = 0;
   //if ( z[0] == '0' && z[1] == 'x' )
   //{
   //  zIndex += 2;
   //}
   //v[0] = 0;
   //while ( zIndex < z.Length )* z )
   //{
   //  v[0] = ( v[0] << 4 ) + (ulong)testHexToInt( z[zIndex] );
   //  zIndex++;
   //}
   //if ( sizeof( object ) == sizeof( u64 ) )
   //{
   //  Marshal.Copy( v, 0, (IntPtr)p, 1 );// memcpy( &p, v, sizeof( p ) );
   //}
   //else
   //{
   //  Debug.Assert( sizeof( p ) == sizeof( v2 ) );
   //  v2 = (u32)v;
   //  memcpy( &p, v2, sizeof( p ) );
   //}
   WrappedCommand cmdInfo = new WrappedCommand();
   if ( TCL.Tcl_GetCommandInfo( interp, z, ref cmdInfo ) || cmdInfo == null )
   { return null; }
   else
   {
     return cmdInfo.objClientData;
   }
 }
开发者ID:plainprogrammer,项目名称:csharp-sqlite,代码行数:34,代码来源:test1_c.cs

示例2: btree_open

 /*
 ** Usage:   btree_open FILENAME NCACHE FLAGS
 **
 ** Open a new database
 */
 static int btree_open(
 object NotUsed,
 Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
 int argc,              /* Number of arguments */
 TclObject[] argv      /* Text of each argument */
 )
 {
   Btree pBt = null;
   int rc; int nCache = 0; int flags = 0;
   string zBuf = "";
   if ( argc != 4 )
   {
     TCL.Tcl_AppendResult( interp, "wrong # args: should be \"", argv[0].ToString(),
     " FILENAME NCACHE FLAGS\"", "" );
     return TCL.TCL_ERROR;
   }
   if ( TCL.Tcl_GetInt( interp, argv[2], ref nCache ) ) return TCL.TCL_ERROR;
   if ( TCL.Tcl_GetInt( interp, argv[3], ref flags ) ) return TCL.TCL_ERROR;
   nRefSqlite3++;
   if ( nRefSqlite3 == 1 )
   {
     sDb.pVfs = sqlite3_vfs_find( null );
     sDb.mutex = sqlite3MutexAlloc( SQLITE_MUTEX_RECURSIVE );
     sqlite3_mutex_enter( sDb.mutex );
   }
   rc = sqlite3BtreeOpen( argv[1].ToString(), sDb, ref pBt, flags,
   SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAIN_DB );
   if ( rc != SQLITE_OK )
   {
     TCL.Tcl_AppendResult( interp, errorName( rc ), null );
     return TCL.TCL_ERROR;
   }
   sqlite3BtreeSetCacheSize( pBt, nCache );
   sqlite3_snprintf( 100, ref zBuf, "->%p", pBt );
   if ( TCL.Tcl_CreateCommandPointer( interp, zBuf, pBt ) )
   {
     return TCL.TCL_ERROR;
   }
   else
     TCL.Tcl_AppendResult( interp, zBuf, null );
   return TCL.TCL_OK;
 }
开发者ID:Belxjander,项目名称:Asuna,代码行数:47,代码来源:test3_c.cs

示例3: c_collation_test

    /*
    ** 2007 March 29
    **
    ** 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.
    **
    *************************************************************************
    **
    ** This file contains obscure tests of the C-interface required
    ** for completeness. Test code is written in C for these cases
    ** as there is not much point in binding to Tcl.
    *************************************************************************
    **  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: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3
    **
    *************************************************************************
    */
    //#include "sqliteInt.h"
    //#include "tcl.h"
    //#include <stdlib.h>
    //#include <string.h>

    /*
    ** c_collation_test
    */
    static int c_collation_test(
    object clientdata, /* Pointer to sqlite3_enable_XXX function */
    Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
    int objc,              /* Number of arguments */
    Tcl_Obj[] objv  /* Command arguments */
    )
    {
      string zErrFunction = "N/A";
      sqlite3 db = null;

      int rc;
      if ( objc != 1 )
      {
        TCL.Tcl_WrongNumArgs( interp, 1, objv, "" );
        return TCL.TCL_ERROR;
      }

      /* Open a database. */
      rc = sqlite3_open( ":memory:", out db );
      if ( rc != SQLITE_OK )
      {
        zErrFunction = "sqlite3_open";
        goto error_out;
      }

      rc = sqlite3_create_collation( db, "collate", 456, null, null );
      if ( rc != SQLITE_MISUSE )
      {
        sqlite3_close( db );
        zErrFunction = "sqlite3_create_collation";
        goto error_out;
      }

      sqlite3_close( db );
      return TCL.TCL_OK;

error_out:
      TCL.Tcl_ResetResult( interp );
      TCL.Tcl_AppendResult( interp, "Error testing function: ", zErrFunction, null );
      return TCL.TCL_ERROR;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:72,代码来源:test9_c.cs

示例4: btree_begin_transaction

 /*
 ** Usage:   btree_begin_transaction ID
 **
 ** Start a new transaction
 */
 static int btree_begin_transaction(
 object NotUsed,
 Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
 int argc,              /* Number of arguments */
 TclObject[] argv      /* Text of each argument */
 )
 {
   Btree pBt;
   int rc;
   if ( argc != 2 )
   {
     TCL.Tcl_AppendResult( interp, "wrong # args: should be \"", argv[0].ToString(),
     " ID\"", null );
     return TCL.TCL_ERROR;
   }
   pBt = (Btree)sqlite3TestTextToPtr( interp, argv[1].ToString() );
   sqlite3BtreeEnter( pBt );
   rc = sqlite3BtreeBeginTrans( pBt, 1 );
   sqlite3BtreeLeave( pBt );
   if ( rc != SQLITE_OK )
   {
     TCL.Tcl_AppendResult( interp, errorName( rc ), null );
     ;
     return TCL.TCL_ERROR;
   }
   return TCL.TCL_OK;
 }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:32,代码来源:test3_c.cs

示例5: btree_pager_stats

    /*
    ** Usage:   btree_pager_stats ID
    **
    ** Returns pager statistics
    */
    static int btree_pager_stats(
    object NotUsed,
    Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
    int argc,              /* Number of arguments */
    TclObject[] argv      /* Text of each argument */
    )
    {
      Btree pBt;
      int i;
      int[] a;

      if ( argc != 2 )
      {
        TCL.Tcl_AppendResult( interp, "wrong # args: should be \"", argv[0].ToString(),
        " ID\"" );
        return TCL.TCL_ERROR;
      }
      pBt = (Btree)sqlite3TestTextToPtr( interp, argv[1].ToString() );

      /* Normally in this file, with a b-tree handle opened using the
      ** [btree_open] command it is safe to call sqlite3BtreeEnter() directly.
      ** But this function is sometimes called with a btree handle obtained
      ** from an open SQLite connection (using [btree_from_db]). In this case
      ** we need to obtain the mutex for the controlling SQLite handle before
      ** it is safe to call sqlite3BtreeEnter().
      */
      sqlite3_mutex_enter( pBt.db.mutex );

      sqlite3BtreeEnter( pBt );
      a = sqlite3PagerStats( sqlite3BtreePager( pBt ) );
      for ( i = 0; i < 11; i++ )
      {
        string[] zName = new string[]{
"ref", "page", "max", "size", "state", "err",
"hit", "miss", "ovfl", "read", "write"
};
        StringBuilder zBuf = new StringBuilder( 100 );
        TCL.Tcl_AppendElement( interp, zName[i] );
        sqlite3_snprintf( 100, zBuf, "%d", a[i] );
        TCL.Tcl_AppendElement( interp, zBuf );
      }
      sqlite3BtreeLeave( pBt );
      /* Release the mutex on the SQLite handle that controls this b-tree */
      sqlite3_mutex_leave( pBt.db.mutex );
      return TCL.TCL_OK;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:51,代码来源:test3_c.cs

示例6: Sqlitetest8_Init

    /*
** Register commands with the TCL interpreter.
*/
    static public int Sqlitetest8_Init( Tcl_Interp interp )
    {
#if !SQLITE_OMIT_VIRTUALTABLE
      //static struct {
      //   string zName;
      //   Tcl_ObjCmdProc *xProc;
      //   void *clientData;
      //} 
      _aObjCmd[] aObjCmd = new _aObjCmd[]{
     new _aObjCmd( "register_echo_module",   register_echo_module, 0 ),
     new _aObjCmd(  "sqlite3_declare_vtab",   declare_vtab, 0 ),
  };
      int i;
      for ( i = 0; i < aObjCmd.Length; i++ )//sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++)
      {
        TCL.Tcl_CreateObjCommand( interp, aObjCmd[i].zName,
            aObjCmd[i].xProc, aObjCmd[i].clientData, null );
      }
#endif
      return TCL.TCL_OK;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:24,代码来源:test8_c.cs

示例7: md5_cmd

    /*
    ** A TCL command for md5.  The argument is the text to be hashed.  The
    ** Result is the hash in base64.
    */
    static int md5_cmd( object cd, Tcl_Interp interp, int argc, Tcl_Obj[] argv )
    {
      MD5Context ctx = new MD5Context();
      byte[] digest = new byte[16];
      byte[] zBuf = new byte[32];


      if ( argc != 2 )
      {
        TCL.Tcl_AppendResult( interp, "wrong # args: should be \"", argv[0],
        " TEXT\"" );
        return TCL.TCL_ERROR;
      }
      MD5Init( ctx );
      MD5Update( ctx, Encoding.UTF8.GetBytes( argv[1].ToString() ), Encoding.UTF8.GetByteCount( argv[1].ToString() ) );
      MD5Final( digest, ctx );
      DigestToBase16( digest, zBuf );
      TCL.Tcl_AppendResult( interp, Encoding.UTF8.GetString( zBuf ) );
      return TCL.TCL_OK;
    }
开发者ID:mbahar94,项目名称:fracture,代码行数:24,代码来源:test_md5_c.cs

示例8: btree_ismemdb

    /*
    ** Usage:   btree_ismemdb ID
    **
    ** Return true if the B-Tree is in-memory.
    */
    static int btree_ismemdb(
    object NotUsed,
    Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
    int argc,              /* Number of arguments */
    TclObject[] argv      /* Text of each argument */
    )
    {
      Btree pBt;
      int res;

      if ( argc != 2 )
      {
        TCL.Tcl_AppendResult( interp, "wrong # args: should be \"", argv[0],
        " ID\"" );
        return TCL.TCL_ERROR;
      }
      pBt = (Btree)sqlite3TestTextToPtr( interp, argv[1].ToString() );
      sqlite3_mutex_enter( pBt.db.mutex );
      sqlite3BtreeEnter( pBt );
      res = sqlite3PagerIsMemdb( sqlite3BtreePager( pBt ) ) ? 1 : 0;
      sqlite3BtreeLeave( pBt );
      sqlite3_mutex_leave( pBt.db.mutex );
      TCL.Tcl_SetObjResult( interp, TCL.Tcl_NewBooleanObj( res ) );
      return TCL.TCL_OK;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:30,代码来源:test3_c.cs

示例9: register_echo_module

 /*
 ** Register the echo virtual table module.
 */
 static int register_echo_module(
   ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
   Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
   int objc,              /* Number of arguments */
   Tcl_Obj[] objv  /* Command arguments */
 )
 {
   sqlite3 db = null;
   ;
   ;
   EchoModule pMod;
   if ( objc != 2 )
   {
     TCL.Tcl_WrongNumArgs( interp, 1, objv, "DB" );
     return TCL.TCL_ERROR;
   }
   if ( getDbPointer( interp, TCL.Tcl_GetString( objv[1] ), out db ) != 0 )
     return TCL.TCL_ERROR;
   pMod = new EchoModule();//sqlite3_malloc(sizeof(EchoModule));
   pMod.interp = interp;
   sqlite3_create_module_v2( db, "echo", echoModule, pMod, moduleDestroy );
   return TCL.TCL_OK;
 }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:26,代码来源:test8_c.cs

示例10: btree_first

    /*
    ** Usage:   btree_first ID
    **
    ** Move the cursor to the first entry in the table.  Return 0 if the
    ** cursor was left point to something and 1 if the table is empty.
    */
    static int btree_first(
    object NotUsed,
    Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
    int argc,              /* Number of arguments */
    TclObject[] argv      /* Text of each argument */
    )
    {
      BtCursor pCur;
      int rc;
      int res = 0;
      StringBuilder zBuf = new StringBuilder( 100 );

      if ( argc != 2 )
      {
        TCL.Tcl_AppendResult( interp, "wrong # args: should be \"", argv[0].ToString(),
        " ID\"" );
        return TCL.TCL_ERROR;
      }
      pCur = (BtCursor)sqlite3TestTextToPtr( interp, argv[1].ToString() );
#if SQLITE_TEST
      sqlite3BtreeEnter( pCur.pBtree );
#endif
      rc = sqlite3BtreeFirst( pCur, ref res );
#if SQLITE_TEST
      sqlite3BtreeLeave( pCur.pBtree );
#endif
      if ( rc != 0 )
      {
        TCL.Tcl_AppendResult( interp, errorName( rc ), null );
        ;
        return TCL.TCL_ERROR;
      }
      sqlite3_snprintf( 100, zBuf, "%d", res );
      TCL.Tcl_AppendResult( interp, zBuf );
      return SQLITE_OK;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:42,代码来源:test3_c.cs

示例11: Md5_Init

 /*
 ** Register the two TCL commands above with the TCL interpreter.
 */
 static public int Md5_Init( Tcl_Interp interp )
 {
   TCL.Tcl_CreateCommand( interp, "md5", md5_cmd, null, null );
   TCL.Tcl_CreateCommand( interp, "md5file", md5file_cmd, null, null );
   return TCL.TCL_OK;
 }
开发者ID:mbahar94,项目名称:fracture,代码行数:9,代码来源:test_md5_c.cs

示例12: c_misuse_test

    /*
    ** c_misuse_test
    */
    static int c_misuse_test(
    object clientdata, /* Pointer to sqlite3_enable_XXX function */
    Tcl_Interp interp,    /* The TCL interpreter that invoked this command */
    int objc,              /* Number of arguments */
    Tcl_Obj[] objv /* Command arguments */
    )
    {
      string zErrFunction = "N/A";
      sqlite3 db = null;
      sqlite3_stmt pStmt;
      int rc;

      if ( objc != 1 )
      {
        TCL.Tcl_WrongNumArgs( interp, 1, objv, "" );
        return TCL.TCL_ERROR;
      }

      /* Open a database. Then close it again. We need to do this so that
      ** we have a "closed database handle" to pass to various API functions.
      */
      rc = sqlite3_open( ":memory:", out db );
      if ( rc != SQLITE_OK )
      {
        zErrFunction = "sqlite3_open";
        goto error_out;
      }
      sqlite3_close( db );


      rc = sqlite3_errcode( db );
      if ( rc != SQLITE_MISUSE )
      {
        zErrFunction = "sqlite3_errcode";
        goto error_out;
      }

      pStmt = new sqlite3_stmt();
      pStmt.pc = 1234;
      rc = sqlite3_prepare( db, (StringBuilder)null, 0, ref pStmt, 0 );
      if ( rc != SQLITE_MISUSE )
      {
        zErrFunction = "sqlite3_prepare";
        goto error_out;
      }
      Debug.Assert( pStmt == null ); /* Verify that pStmt is zeroed even on a MISUSE error */


      pStmt = new sqlite3_stmt();
      pStmt.pc = 1234;
      rc = sqlite3_prepare_v2( db, null, 0, ref pStmt, 0 );
      if ( rc != SQLITE_MISUSE )
      {
        zErrFunction = "sqlite3_prepare_v2";
        goto error_out;
      }
      Debug.Assert( pStmt == null );

#if !SQLITE_OMIT_UTF16
pStmt = (sqlite3_stmt)1234;
rc = sqlite3_prepare16( db, null, 0, ref pStmt, 0 );
if( rc!=SQLITE_MISUSE ){
zErrFunction = "sqlite3_prepare16";
goto error_out;
}
Debug.Assert( pStmt==0 );
pStmt = (sqlite3_stmt)1234;
rc = sqlite3_prepare16_v2( db, null, 0, ref pStmt, 0 );
if( rc!=SQLITE_MISUSE ){
zErrFunction = "sqlite3_prepare16_v2";
goto error_out;
}
Debug.Assert( pStmt==0 );
#endif

      return TCL.TCL_OK;

error_out:
      TCL.Tcl_ResetResult( interp );
      TCL.Tcl_AppendResult( interp, "Error testing function: ", zErrFunction );
      return TCL.TCL_ERROR;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:85,代码来源:test9_c.cs

示例13: Sqlitetest9_Init

    /*
    ** Register commands with the TCL interpreter.
    */
    static public int Sqlitetest9_Init( Tcl_Interp interp )
    {
      //static struct {
      //   string zName;
      //   Tcl_ObjCmdProc *xProc;
      //   void *object;
      //}
      _aObjCmd[] aObjCmd = new _aObjCmd[]  {
new _aObjCmd( "c_misuse_test",    c_misuse_test, 0 ),
new _aObjCmd( "c_realloc_test",   c_realloc_test, 0 ),
new _aObjCmd( "c_collation_test", c_collation_test, 0 ),
};
      int i;
      for ( i = 0; i < aObjCmd.Length; i++ )
      {//sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
        TCL.Tcl_CreateObjCommand( interp, aObjCmd[i].zName,
        aObjCmd[i].xProc, aObjCmd[i].clientData, null );
      }
      return TCL.TCL_OK;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:23,代码来源:test9_c.cs

示例14: Sqlitetestintarray_Init

   /*
   ** Register commands with the TCL interpreter.
   */
   static public int Sqlitetestintarray_Init( Tcl_Interp interp )
   {
     //static struct {
     //   char *zName;
     //   Tcl_ObjCmdProc *xProc;
     //   void *clientData;
     //} 
     _aObjCmd[] aObjCmd = new _aObjCmd[] {
    new _aObjCmd( "sqlite3_intarray_create", test_intarray_create, 0 ),
    new _aObjCmd(  "sqlite3_intarray_bind", test_intarray_bind, 0 ),
 };
     int i;
     for ( i = 0; i < aObjCmd.Length; i++ )//sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++)
     {
       TCL.Tcl_CreateObjCommand( interp, aObjCmd[i].zName,
           aObjCmd[i].xProc, aObjCmd[i].clientData, null );
     }
     return TCL.TCL_OK;
   }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:22,代码来源:test_intarray_c.cs

示例15: test_intarray_bind

    /*
    **    sqlite3_intarray_bind  INTARRAY  ?VALUE ...?
    **
    ** Invoke the sqlite3_intarray_bind interface on the given array of integers.
    */
    static int test_intarray_bind(
      ClientData clientData, /* Not used */
      Tcl_Interp interp,     /* The TCL interpreter that invoked this command */
      int objc,              /* Number of arguments */
      Tcl_Obj[] objv         /* Command arguments */
    )
    {
      sqlite3_intarray pArray;
      int rc = SQLITE_OK;
      int i, n;
      sqlite3_int64[] a;

      if ( objc < 2 )
      {
        TCL.Tcl_WrongNumArgs( interp, 1, objv, "INTARRAY" );
        return TCL.TCL_ERROR;
      }
      pArray = (sqlite3_intarray)sqlite3TestTextToPtr( interp, TCL.Tcl_GetString( objv[1] ) );
      n = objc - 2;
#if !SQLITE_OMIT_VIRTUALTABLE
      a = new sqlite3_int64[n];//sqlite3_malloc( sizeof(a[0])*n );
      //if( a==0 ){
      //  Tcl_AppendResult(interp, "SQLITE_NOMEM", (char*)0);
      //  return TCL_ERROR;
      //}
      for ( i = 0; i < n; i++ )
      {
        //a[i] = 0;
        TCL.Tcl_GetWideIntFromObj( null, objv[i + 2], out a[i] );
      }
      rc = sqlite3_intarray_bind( pArray, n, a, sqlite3_free );
      if ( rc != SQLITE_OK )
      {
        TCL.Tcl_AppendResult( interp, sqlite3TestErrorName( rc ), null );
        return TCL.TCL_ERROR;
      }
#endif
      return TCL.TCL_OK;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:44,代码来源:test_intarray_c.cs


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