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


C# ILuaState.GetTop方法代码示例

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


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

示例1: AuxResume

		private static int AuxResume( ILuaState lua, ILuaState co, int narg )
		{
			if(!co.CheckStack(narg)) {
				lua.PushString("too many arguments to resume");
				return -1; // error flag
			}
			if( co.Status == ThreadStatus.LUA_OK && co.GetTop() == 0 )
			{
				lua.PushString( "cannot resume dead coroutine" );
				return -1; // error flag
			}
			lua.XMove( co, narg );
			ThreadStatus status = co.Resume( lua, narg );
			if( status == ThreadStatus.LUA_OK || status == ThreadStatus.LUA_YIELD )
			{
				int nres = co.GetTop();
				if(!lua.CheckStack(nres+1)) {
					co.Pop(nres); // remove results anyway;
					lua.PushString("too many results to resume");
					return -1; // error flag
				}
				co.XMove( lua, nres ); // move yielded values
				return nres;
			}
			else
			{
				co.XMove( lua, 1 ); // move error message
				return -1;
			}
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:30,代码来源:LuaCoroLib.cs

示例2: AuxResume

 private static int AuxResume( ILuaState lua, ILuaState co, int narg )
 {
     if( co.Status == ThreadStatus.LUA_OK && co.GetTop() == 0 )
     {
         lua.PushString( "cannot resume dead coroutine" );
         return -1; // error flag
     }
     lua.XMove( co, narg );
     ThreadStatus status = co.Resume( lua, narg );
     if( status == ThreadStatus.LUA_OK || status == ThreadStatus.LUA_YIELD )
     {
         int nres = co.GetTop();
         co.XMove( lua, nres ); // move yielded values
         return nres;
     }
     else
     {
         co.XMove( lua, 1 ); // move error message
         return -1;
     }
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:21,代码来源:LuaCoroLib.cs

示例3: CO_AuxWrap

 private static int CO_AuxWrap( ILuaState lua )
 {
     ILuaState co = lua.ToThread( lua.UpvalueIndex(1) );
     int r = AuxResume( lua, co, lua.GetTop() );
     if( r < 0 )
     {
         if( lua.IsString( -1 ) ) // error object is a string?
         {
             lua.L_Where( 1 ); // add extra info
             lua.Insert( -2 );
             lua.Concat( 2 );
         }
         lua.Error();
     }
     return r;
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:16,代码来源:LuaCoroLib.cs

示例4: CO_Resume

 private static int CO_Resume( ILuaState lua )
 {
     ILuaState co = lua.ToThread( 1 );
     lua.L_ArgCheck( co != null, 1, "coroutine expected" );
     int r = AuxResume( lua, co, lua.GetTop() - 1 );
     if( r < 0 )
     {
         lua.PushBoolean( false );
         lua.Insert( -2 );
         return 2; // return false + error message
     }
     else
     {
         lua.PushBoolean( true );
         lua.Insert( -(r+1) );
         return r+1; // return true + `resume' returns
     }
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:18,代码来源:LuaCoroLib.cs

示例5: Math_Min

		private static int Math_Min( ILuaState lua )
		{
			int n = lua.GetTop();
			double dmin = lua.L_CheckNumber(1);
			for( int i=2; i<=n; ++i )
			{
				double d = lua.L_CheckNumber(i);
				if( d < dmin )
					dmin = d;
			}
			lua.PushNumber(dmin);
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:13,代码来源:LuaMathLib.cs

示例6: Lua_ImportProperty

 /////////////////////////////////////////////////////////////
 int Lua_ImportProperty(ILuaState lua)
 {
     if (lua.Type(2) != LuaType.LUA_TTABLE)
     {
         Debug.LogWarning("LuaExport:ImportProperty param1 is not table...");
         return 0;
     }
     Debug.Log("Lua_ImportProperty:"+lua.GetTop()+":"+lua.Type(-1));
     ImportProperty(2);
     Debug.Log("Lua_ImportProperty:"+lua.GetTop()+":"+lua.Type(-1));
     return 0;
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:13,代码来源:LuaExport.cs

示例7: Str_Char

		private static int Str_Char( ILuaState lua )
		{
			int n = lua.GetTop();
			StringBuilder sb = new StringBuilder();
			for( int i=1; i<=n; ++i )
			{
				int c = lua.L_CheckInteger(i);
				lua.L_ArgCheck( (char)c == c, i, "value out of range" );
				sb.Append( (char)c );
			}
			lua.PushString( sb.ToString() );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:13,代码来源:LuaStrLib.cs

示例8: B_XPCall

 public static int B_XPCall( ILuaState lua )
 {
     int n = lua.GetTop();
     lua.L_ArgCheck( n>=2, 2, "value expected" );
     lua.PushValue( 1 ); // exchange function...
     lua.Copy( 2, 1); // ...and error handler
     lua.Replace( 2 );
     ThreadStatus status = lua.PCallK( n-2, LuaDef.LUA_MULTRET,
         1, 0, PCallContinuation );
     return FinishPCall( lua, status == ThreadStatus.LUA_OK );
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:11,代码来源:LuaBaseLib.cs

示例9: FinishPCall

 private static int FinishPCall( ILuaState lua, bool status )
 {
     lua.PushBoolean( status );
     lua.Replace( 1 );
     return lua.GetTop();
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:6,代码来源:LuaBaseLib.cs

示例10: B_PCall

        public static int B_PCall( ILuaState lua )
        {
            lua.L_CheckAny( 1 );
            lua.PushNil();
            lua.Insert( 1 ); // create space for status result

            ThreadStatus status = lua.PCallK( lua.GetTop() - 2,
                LuaDef.LUA_MULTRET, 0, 0, PCallContinuation );

            return FinishPCall( lua, status == ThreadStatus.LUA_OK );
        }
开发者ID:matthewyang,项目名称:UniLua,代码行数:11,代码来源:LuaBaseLib.cs

示例11: B_Assert

 public static int B_Assert( ILuaState lua )
 {
     if( !lua.ToBoolean( 1 ) )
         return lua.L_Error( "{0}", lua.L_OptString( 2, "assertion failed!" ) );
     return lua.GetTop();
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:6,代码来源:LuaBaseLib.cs

示例12: SerializeTable

 /// <summary>
 /// 将Table序列化成为字符串写入文件
 /// </summary>
 public string SerializeTable(ILuaState _fileLua, int index)
 {
     //获取LibCore中_SerializeTable函数,然后串行化table, 以后要重写,从而不依赖LibCore(因为有在非运行状态下获取内容)
     if (_fileLua.Type(index) != LuaType.LUA_TTABLE)
     {
         Debug.LogWarning("LuaExport:SerializeTable param must a table.. please check");
         return "";
     }
     int dwStackIndex = _fileLua.GetTop();
     _fileLua.PushValue(index);
     _fileLua.GetGlobal("_SerializeTable");
     _fileLua.Insert(-2);
     _fileLua.PushBoolean(false);
     if (_fileLua.PCall(2, 1, 0) != 0)
     {
         Debug.LogWarning(_fileLua.ToString(-1) + " in SerializeTable");
         _fileLua.Pop(-1);
         return "";
     }
     string szResult = _fileLua.ToString(-1);
     //Debug.Log(m_szResult);
     _fileLua.Pop(1);
     if (dwStackIndex != _fileLua.GetTop())
         Debug.LogWarning("LuaExport:SerializeTable stack Exception:start=" + dwStackIndex + " end=" + _fileLua.GetTop());
     return szResult;
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:29,代码来源:StoryShotCtrl.cs

示例13: CO_Yield

 private static int CO_Yield( ILuaState lua )
 {
     return lua.Yield( lua.GetTop() );
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:4,代码来源:LuaCoroLib.cs

示例14: TBL_Pack

		private static int TBL_Pack( ILuaState lua )
		{
			int n = lua.GetTop(); // number of elements to pack
			lua.CreateTable( n, 1 ); // create result table
			lua.PushInteger( n );
			lua.SetField( -2, "n" ); // t.n = number of elements
			if( n > 0 ) // at least one element?
			{
				lua.PushValue( 1 );
				lua.RawSetI( -2, 1 ); // insert first element
				lua.Replace( 1 ); // move table into index 1
				for( int i=n; i>=2; --i ) // assign other elements
					lua.RawSetI( 1, i );
			}
			return 1; // return table
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:16,代码来源:LuaTableLib.cs

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


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