本文整理汇总了C#中ILuaState.CheckStack方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.CheckStack方法的具体用法?C# ILuaState.CheckStack怎么用?C# ILuaState.CheckStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.CheckStack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: FinishPCall
private static int FinishPCall( ILuaState lua, bool status )
{
// no space for extra boolean?
if(!lua.CheckStack(1)) {
lua.SetTop(0); // create space for return values
lua.PushBoolean(false);
lua.PushString("stack overflow");
return 2;
}
lua.PushBoolean( status );
lua.Replace( 1 );
return lua.GetTop();
}
示例3: 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;
}
示例4: 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;
}
示例5: l_print
/*
** Prints (calling the Lua 'print' function) any values on the stack
*/
static void l_print(ILuaState L)
{
int n = L.GetTop();
if (n > 0)
{ /* any result to be printed? */
L.CheckStack(L.MinStack, "too many results to print");
L.GetGlobal("print");
L.Insert(1);
if (L.PCall(n, 0, 0) != LuaStatus.OK)
l_message(L, progname, L.PushFString("error calling 'print' (%s)", L.ToString(-1)));
}
}