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


C# ILuaState.RawGetI方法代码示例

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


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

示例1: TBL_Concat

		private static int TBL_Concat( ILuaState lua )
		{
			string sep = lua.L_OptString( 2, "" );
			lua.L_CheckType( 1, LuaType.LUA_TTABLE );
			int i = lua.L_OptInt( 3, 1 );
			int last = lua.L_Opt( lua.L_CheckInteger, 4, lua.L_Len(1) );

			StringBuilder sb = new StringBuilder();
			for( ; i<last; ++i )
			{
				lua.RawGetI( 1, i );
				if( !lua.IsString(-1) )
					lua.L_Error(
						"invalid value ({0}) at index {1} in table for 'concat'",
						lua.L_TypeName(-1), i );
				sb.Append( lua.ToString(-1) );
				sb.Append( sep );
				lua.Pop( 1 );
			}
			if( i == last ) // add last value (if interval was not empty)
			{
				lua.RawGetI( 1, i );
				if( !lua.IsString(-1) )
					lua.L_Error(
						"invalid value ({0}) at index {1} in table for 'concat'",
						lua.L_TypeName(-1), i );
				sb.Append( lua.ToString(-1) );
				lua.Pop( 1 );
			}
			lua.PushString( sb.ToString() );
			return 1;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:32,代码来源:LuaTableLib.cs

示例2: IpairsAux

 private static int IpairsAux( ILuaState lua )
 {
     int i = lua.ToInteger( 2 );
     i++; // next value
     lua.PushInteger( i );
     lua.RawGetI( 1, i );
     return lua.IsNil( -1 ) ? 1 : 2;
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:8,代码来源:LuaBaseLib.cs

示例3: GetMethodAux

 private static int GetMethodAux( ILuaState lua, BindingFlags flags )
 {
     var t = (Type)lua.ToUserData(1);
     var mname = lua.ToString(2);
     var n = lua.RawLen(3);
     var types = new Type[n];
     for( int i=0; i<n; ++i )
     {
         lua.RawGetI( 3, i+1 );
         types[i] = (Type)lua.ToUserData(-1);
         lua.Pop(1);
     }
     var minfo = t.GetMethod( mname,
         flags,
         null,
         CallingConventions.Any,
         types,
         null
         );
     if( minfo == null )
     {
         return 0;
     }
     else
     {
         var ffiMethod = new FFIMethodInfo(minfo);
         lua.PushLightUserData( ffiMethod );
         return 1;
     }
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:30,代码来源:LuaFFILib.cs

示例4: FFI_GetConstructor

        private static int FFI_GetConstructor( ILuaState lua )
        {
            var t = (Type)lua.ToUserData(1);
            var n = lua.RawLen(2);
            var types = new Type[n];
            for( int i=0; i<n; ++i )
            {
                lua.RawGetI( 2, i+1 );
                types[i] = (Type)lua.ToUserData(-1);
                lua.Pop( 1 );
            }

            var cinfo = t.GetConstructor( types );
            var ffiMethod = new FFIConstructorInfo(cinfo);
            lua.PushLightUserData( ffiMethod );
            return 1;
        }
开发者ID:matthewyang,项目名称:UniLua,代码行数:17,代码来源:LuaFFILib.cs

示例5: TBL_Insert

		private static int TBL_Insert( ILuaState lua )
		{
			int e = AuxGetN(lua, 1) + 1; // first empty element
			int pos; // where to insert new element
			switch( lua.GetTop() )
			{
				case 2: // called with only 2 arguments
				{
					pos = e; // insert new element at the end
					break;
				}
				case 3:
				{
					pos = lua.L_CheckInteger(2); // 2nd argument is the position
					if( pos > e ) e = pos; // `grow' array if necessary
					for( int i=e; i>pos; --i ) // move up elements
					{
						lua.RawGetI( 1, i-1 );
						lua.RawSetI( 1, i ); // t[i] = t[i-1]
					}
					break;
				}
				default:
				{
					return lua.L_Error( "wrong number of arguments to 'insert'" );
				}
			}
			lua.RawSetI( 1, pos ); // t[pos] = v
			return 0;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:30,代码来源:LuaTableLib.cs

示例6: AuxSort

		private static void AuxSort( ILuaState lua, int l, int u )
		{
			while( l < u ) // for tail recursion
			{
				// sort elements a[l], a[(l+u)/2] and a[u]
				lua.RawGetI( 1, l );
				lua.RawGetI( 1, u );
				if( SortComp( lua, -1, -2 ) ) // a[u] < a[l]?
					Set2( lua, l, u );
				else
					lua.Pop( 2 );
				if( u-l == 1 ) break; // only 2 elements
				int i = (l+u) / 2;
				lua.RawGetI( 1, i );
				lua.RawGetI( 1, l );
				if( SortComp( lua, -2, -1 ) ) // a[i] < a[l]?
					Set2( lua, i, l );
				else
				{
					lua.Pop( 1 ); // remove a[l]
					lua.RawGetI( 1, u );
					if( SortComp( lua, -1, -2 ) ) // a[u] < a[i]?
						Set2( lua, i, u );
					else
						lua.Pop( 2 );
				}
				if( u-l == 2 ) break; // only 3 arguments
				lua.RawGetI( 1, i ); // Pivot
				lua.PushValue( -1 );
				lua.RawGetI( 1, u-1 );
				Set2(lua, i, u-1);
				/* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
				i = l;
				int j = u-1;
				for (;;) {  /* invariant: a[l..i] <= P <= a[j..u] */
					/* repeat ++i until a[i] >= P */
					lua.RawGetI( 1, ++i );
					while( SortComp(lua, -1, -2) )
					{
						if (i>=u) lua.L_Error( "invalid order function for sorting" );
						lua.Pop(1);  /* remove a[i] */
						lua.RawGetI( 1, ++i );
					}
					/* repeat --j until a[j] <= P */
					lua.RawGetI( 1, --j );
					while ( SortComp(lua, -3, -1) ) {
						if (j<=l) lua.L_Error( "invalid order function for sorting" );
						lua.Pop(1);  /* remove a[j] */
						lua.RawGetI( 1, --j );
					}
					if (j<i) {
						lua.Pop(3);  /* pop pivot, a[i], a[j] */
						break;
					}
					Set2(lua, i, j);
				}
				lua.RawGetI( 1, u-1 );
				lua.RawGetI( 1, i );
				Set2(lua, u-1, i);  /* swap pivot (a[u-1]) with a[i] */
				/* a[l..i-1] <= a[i] == P <= a[i+1..u] */
				/* adjust so that smaller half is in [j..i] and larger one in [l..u] */
				if (i-l < u-i) {
					j=l; i=i-1; l=i+2;
				}
				else {
					j=i+1; i=u; u=j-2;
				}
				AuxSort(lua, j, i);  /* call recursively the smaller one */
			}  /* repeat the routine for the larger one */
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:70,代码来源:LuaTableLib.cs

示例7: TBL_Remove

		private static int TBL_Remove( ILuaState lua )
		{
			int e = AuxGetN(lua, 1);
			int pos = lua.L_OptInt( 2, e );
			if( !(1 <= pos && pos <= e) ) // position is outside bounds?
				return 0; // nothing to remove
			lua.RawGetI(1, pos); /* result = t[pos] */
			for( ; pos<e; ++pos )
			{
				lua.RawGetI( 1, pos+1 );
				lua.RawSetI( 1, pos ); // t[pos] = t[pos+1]
			}
			lua.PushNil();
			lua.RawSetI( 1, e ); // t[2] = nil
			return 1;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:16,代码来源:LuaTableLib.cs

示例8: TBL_Unpack

		private static int TBL_Unpack( ILuaState lua )
		{
			lua.L_CheckType( 1, LuaType.LUA_TTABLE );
			int i = lua.L_OptInt( 2, 1 );
			int e = lua.L_OptInt( 3, lua.L_Len(1) );
			if( i > e ) return 0; // empty range
			int n = e - i + 1; // number of elements
			if( n <= 0 || !lua.CheckStack(n) ) // n <= 0 means arith. overflow
				return lua.L_Error( "too many results to unpack" );
			lua.RawGetI( 1, i ); // push arg[i] (avoiding overflow problems
			while( i++ < e ) // push arg[i + 1...e]
				lua.RawGetI( 1, i );
			return n;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:14,代码来源:LuaTableLib.cs

示例9: FindLoader

		private static void FindLoader( ILuaState lua, string name )
		{
			// will be at index 3
			lua.GetField( lua.UpvalueIndex(1), "searchers" );
			if( ! lua.IsTable(3) )
				lua.L_Error("'package.searchers' must be a table");

			var sb = new StringBuilder();
			// iterator over available searchers to find a loader
			for( int i=1; ; ++i )
			{
				lua.RawGetI( 3, i ); // get a searcher
				if( lua.IsNil( -1 ) ) // no more searchers?
				{
					lua.Pop( 1 ); // remove nil
					lua.PushString( sb.ToString() );
					lua.L_Error( "module '{0}' not found:{1}",
						name, lua.ToString(-1));
					return;
				}

				lua.PushString( name );
				lua.Call( 1, 2 ); // call it
				if( lua.IsFunction(-2) ) // did it find a loader
					return; // module loader found
				else if( lua.IsString(-2) ) // searcher returned error message?
				{
					lua.Pop( 1 ); // return extra return
					sb.Append( lua.ToString(-1) );
				}
				else
					lua.Pop( 2 ); // remove both returns
			}
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:34,代码来源:LuaPkgLib.cs

示例10: pushLightUserData

 public void pushLightUserData(ILuaState luaState,ILuaUserData userData)
 {
     if (userData == null || userData.getRef() == 0)
     {
         luaState.PushNil();
     }
     else
     {
         luaState.RawGetI(LuaDef.LUA_REGISTRYINDEX, userData.getRef());
     }
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:11,代码来源:InterpreterManager.cs

示例11: pushEffect

 public void pushEffect(ILuaState luaState,ISkillEffect effect)
 {
     if ( effect == null || effect.getRef() == 0 )
     {
         luaState.PushNil();
     }
     else
     {
         luaState.RawGetI(LuaDef.LUA_REGISTRYINDEX, effect.getRef());
     }
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:11,代码来源:InterpreterManager.cs

示例12: PushThis

 public static void PushThis(ILuaState lua)
 {
     if (m_luaIndex != 0)
     {
         lua.RawGetI(LuaDef.LUA_REGISTRYINDEX, m_luaIndex);
     }
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:7,代码来源:AudioManager.cs

示例13: pushargs

 /*
 ** Push on the stack the contents of table 'arg' from 1 to #arg
 */
 static int pushargs(ILuaState L)
 {
     int i, n;
     if (L.GetGlobal("arg") != LuaType.Table)
         L.Error("'arg' is not a table");
     n = L.LLen(-1);
     L.CheckStack(n + 3, "too many arguments to script");
     for (i = 1; i <= n; i++)
         L.RawGetI(-i, i);
     L.Remove(-i);  /* remove table from the stack */
     return n;
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:15,代码来源:Program.cs


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