本文整理汇总了C#中ILuaState.UpvalueIndex方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.UpvalueIndex方法的具体用法?C# ILuaState.UpvalueIndex怎么用?C# ILuaState.UpvalueIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.UpvalueIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: GmatchAux
private static int GmatchAux( ILuaState lua )
{
MatchState ms = new MatchState();
string src = lua.ToString( lua.UpvalueIndex(1) );
string pattern = lua.ToString( lua.UpvalueIndex(2) );
ms.Lua = lua;
ms.Src = src;
ms.SrcInit = 0;
ms.SrcEnd = src.Length;
ms.Pattern = pattern;
ms.PatternEnd = pattern.Length;
for( int s = lua.ToInteger( lua.UpvalueIndex(3) )
; s <= ms.SrcEnd
; s++ )
{
ms.Level = 0;
int e = Match( ms, s, 0 );
if( e != -1 )
{
int newStart = (e == 0) ? e+1: e;
lua.PushInteger( newStart );
lua.Replace( lua.UpvalueIndex(3) );
return PushCaptures(lua, ms, s, e);
}
}
return 0; // not found
}
示例3: 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
}
}
示例4: FindFile
private static string FindFile( ILuaState lua,
string name, string pname, string dirsep )
{
lua.GetField( lua.UpvalueIndex(1), pname );
string path = lua.ToString( -1 );
if( path == null )
lua.L_Error( "'package.{0}' must be a string", pname );
return SearchPath( lua, name, path, ".", dirsep );
}